Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: chrome/browser/chromeos/extensions/bluetooth_event_router.h

Issue 10915148: Change getDevices to use a DeviceCallback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test breakage Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_BLUETOOTH_EVENT_ROUTER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_BLUETOOTH_EVENT_ROUTER_H_
6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_BLUETOOTH_EVENT_ROUTER_H_ 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_BLUETOOTH_EVENT_ROUTER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 29 matching lines...) Expand all
40 scoped_refptr<BluetoothSocket> GetSocket(int id); 40 scoped_refptr<BluetoothSocket> GetSocket(int id);
41 41
42 // Sets whether this Profile is responsible for the discovering state of the 42 // Sets whether this Profile is responsible for the discovering state of the
43 // adapter. 43 // adapter.
44 void SetResponsibleForDiscovery(bool responsible); 44 void SetResponsibleForDiscovery(bool responsible);
45 bool IsResponsibleForDiscovery() const; 45 bool IsResponsibleForDiscovery() const;
46 46
47 // Sets whether or not DeviceAdded events will be dispatched to extensions. 47 // Sets whether or not DeviceAdded events will be dispatched to extensions.
48 void SetSendDiscoveryEvents(bool should_send); 48 void SetSendDiscoveryEvents(bool should_send);
49 49
50 // Dispatch an event that takes a device as a parameter to all renderers.
51 void DispatchDeviceEvent(
52 const char* event_name,
53 const extensions::api::experimental_bluetooth::Device& device);
54
50 // Override from chromeos::BluetoothAdapter::Observer 55 // Override from chromeos::BluetoothAdapter::Observer
51 virtual void AdapterPresentChanged(chromeos::BluetoothAdapter* adapter, 56 virtual void AdapterPresentChanged(chromeos::BluetoothAdapter* adapter,
52 bool present) OVERRIDE; 57 bool present) OVERRIDE;
53 virtual void AdapterPoweredChanged(chromeos::BluetoothAdapter* adapter, 58 virtual void AdapterPoweredChanged(chromeos::BluetoothAdapter* adapter,
54 bool has_power) OVERRIDE; 59 bool has_power) OVERRIDE;
55 virtual void AdapterDiscoveringChanged(chromeos::BluetoothAdapter* adapter, 60 virtual void AdapterDiscoveringChanged(chromeos::BluetoothAdapter* adapter,
56 bool discovering) OVERRIDE; 61 bool discovering) OVERRIDE;
57 virtual void DeviceAdded(chromeos::BluetoothAdapter* adapter, 62 virtual void DeviceAdded(chromeos::BluetoothAdapter* adapter,
58 chromeos::BluetoothDevice* device) OVERRIDE; 63 chromeos::BluetoothDevice* device) OVERRIDE;
59 64
60 // Exposed for testing. 65 // Exposed for testing.
61 void SetAdapterForTest(chromeos::BluetoothAdapter* adapter) { 66 void SetAdapterForTest(chromeos::BluetoothAdapter* adapter) {
62 adapter_ = adapter; 67 adapter_ = adapter;
63 } 68 }
64 private: 69 private:
65 void DispatchBooleanValueEvent(const char* event_name, bool value); 70 void DispatchBooleanValueEvent(const char* event_name, bool value);
66 void DispatchDeviceEvent(
67 const extensions::api::experimental_bluetooth::Device& device);
68 71
69 bool send_discovery_events_; 72 bool send_discovery_events_;
70 bool responsible_for_discovery_; 73 bool responsible_for_discovery_;
71 74
72 Profile* profile_; 75 Profile* profile_;
73 scoped_refptr<chromeos::BluetoothAdapter> adapter_; 76 scoped_refptr<chromeos::BluetoothAdapter> adapter_;
74 77
75 // The next id to use for referring to a BluetoothSocket. We avoid using 78 // The next id to use for referring to a BluetoothSocket. We avoid using
76 // the fd of the socket because we don't want to leak that information to 79 // the fd of the socket because we don't want to leak that information to
77 // the extension javascript. 80 // the extension javascript.
78 int next_socket_id_; 81 int next_socket_id_;
79 82
80 typedef std::map<int, scoped_refptr<BluetoothSocket> > SocketMap; 83 typedef std::map<int, scoped_refptr<BluetoothSocket> > SocketMap;
81 SocketMap socket_map_; 84 SocketMap socket_map_;
82 85
83 typedef ScopedVector<extensions::api::experimental_bluetooth::Device> 86 typedef ScopedVector<extensions::api::experimental_bluetooth::Device>
84 DeviceList; 87 DeviceList;
85 DeviceList discovered_devices_; 88 DeviceList discovered_devices_;
86 89
87 DISALLOW_COPY_AND_ASSIGN(ExtensionBluetoothEventRouter); 90 DISALLOW_COPY_AND_ASSIGN(ExtensionBluetoothEventRouter);
88 }; 91 };
89 92
90 } // namespace chromeos 93 } // namespace chromeos
91 94
92 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_BLUETOOTH_EVENT_ROUTER_H_ 95 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_BLUETOOTH_EVENT_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698