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

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

Issue 10916331: Revert 156348 (caused http://crbug.com/149828) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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
55 // Override from chromeos::BluetoothAdapter::Observer 50 // Override from chromeos::BluetoothAdapter::Observer
56 virtual void AdapterPresentChanged(chromeos::BluetoothAdapter* adapter, 51 virtual void AdapterPresentChanged(chromeos::BluetoothAdapter* adapter,
57 bool present) OVERRIDE; 52 bool present) OVERRIDE;
58 virtual void AdapterPoweredChanged(chromeos::BluetoothAdapter* adapter, 53 virtual void AdapterPoweredChanged(chromeos::BluetoothAdapter* adapter,
59 bool has_power) OVERRIDE; 54 bool has_power) OVERRIDE;
60 virtual void AdapterDiscoveringChanged(chromeos::BluetoothAdapter* adapter, 55 virtual void AdapterDiscoveringChanged(chromeos::BluetoothAdapter* adapter,
61 bool discovering) OVERRIDE; 56 bool discovering) OVERRIDE;
62 virtual void DeviceAdded(chromeos::BluetoothAdapter* adapter, 57 virtual void DeviceAdded(chromeos::BluetoothAdapter* adapter,
63 chromeos::BluetoothDevice* device) OVERRIDE; 58 chromeos::BluetoothDevice* device) OVERRIDE;
64 59
65 // Exposed for testing. 60 // Exposed for testing.
66 void SetAdapterForTest(chromeos::BluetoothAdapter* adapter) { 61 void SetAdapterForTest(chromeos::BluetoothAdapter* adapter) {
67 adapter_ = adapter; 62 adapter_ = adapter;
68 } 63 }
69 private: 64 private:
70 void DispatchBooleanValueEvent(const char* event_name, bool value); 65 void DispatchBooleanValueEvent(const char* event_name, bool value);
66 void DispatchDeviceEvent(
67 const extensions::api::experimental_bluetooth::Device& device);
71 68
72 bool send_discovery_events_; 69 bool send_discovery_events_;
73 bool responsible_for_discovery_; 70 bool responsible_for_discovery_;
74 71
75 Profile* profile_; 72 Profile* profile_;
76 scoped_refptr<chromeos::BluetoothAdapter> adapter_; 73 scoped_refptr<chromeos::BluetoothAdapter> adapter_;
77 74
78 // The next id to use for referring to a BluetoothSocket. We avoid using 75 // The next id to use for referring to a BluetoothSocket. We avoid using
79 // the fd of the socket because we don't want to leak that information to 76 // the fd of the socket because we don't want to leak that information to
80 // the extension javascript. 77 // the extension javascript.
81 int next_socket_id_; 78 int next_socket_id_;
82 79
83 typedef std::map<int, scoped_refptr<BluetoothSocket> > SocketMap; 80 typedef std::map<int, scoped_refptr<BluetoothSocket> > SocketMap;
84 SocketMap socket_map_; 81 SocketMap socket_map_;
85 82
86 typedef ScopedVector<extensions::api::experimental_bluetooth::Device> 83 typedef ScopedVector<extensions::api::experimental_bluetooth::Device>
87 DeviceList; 84 DeviceList;
88 DeviceList discovered_devices_; 85 DeviceList discovered_devices_;
89 86
90 DISALLOW_COPY_AND_ASSIGN(ExtensionBluetoothEventRouter); 87 DISALLOW_COPY_AND_ASSIGN(ExtensionBluetoothEventRouter);
91 }; 88 };
92 89
93 } // namespace chromeos 90 } // namespace chromeos
94 91
95 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_BLUETOOTH_EVENT_ROUTER_H_ 92 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_BLUETOOTH_EVENT_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698