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

Unified Diff: chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h

Issue 14487002: Bluetooth: Profile support for Chrome OS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Transfer out ownership of fd. Fix socket code Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h
diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h b/chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h
index d8f8024264b5103b3d452e2d7a008206ab85ecb6..3225c76e112386fd064b04a53b14acb4afd63d3d 100644
--- a/chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h
+++ b/chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h
@@ -17,6 +17,13 @@
class Profile;
+namespace device {
+
+class BluetoothDevice;
+class BluetoothProfile;
+
+} // namespace device
+
namespace extensions {
class ExtensionBluetoothEventRouter
@@ -47,6 +54,20 @@ class ExtensionBluetoothEventRouter
// the socket was found and released, false otherwise.
bool ReleaseSocket(int id);
+ // Add the BluetoothProfile |bluetooth_profile| for use by the extension
+ // system. This class will hold onto the profile for its lifetime, or until
+ // RemoveProfile is called for the profile.
+ void AddProfile(const std::string& uuid,
+ device::BluetoothProfile* bluetooth_profile);
+
+ // Unregister the BluetoothProfile corersponding to |uuid| and release the
+ // object from this class.
+ void RemoveProfile(const std::string& uuid);
+
+ // Returns true if the BluetoothProfile corresponding to |uuid| is already
+ // registered.
+ bool HasProfile(const std::string& uuid) const;
+
// Get the BluetoothSocket corresponding to |id|.
scoped_refptr<device::BluetoothSocket> GetSocket(int id);
@@ -63,6 +84,13 @@ class ExtensionBluetoothEventRouter
const char* event_name,
const extensions::api::bluetooth::Device& device);
+ // Dispatch an event that takes a connection socket as a parameter to the
+ // extension that registered the profile that the socket has connected to.
+ void DispatchConnectionEvent(const std::string& extension_id,
+ const std::string& uuid,
+ const device::BluetoothDevice* device,
+ scoped_refptr<device::BluetoothSocket> socket);
+
// Override from device::BluetoothAdapter::Observer
virtual void AdapterPresentChanged(device::BluetoothAdapter* adapter,
bool present) OVERRIDE;
@@ -103,6 +131,10 @@ class ExtensionBluetoothEventRouter
DeviceList;
DeviceList discovered_devices_;
+ // A map that maps uuids to the BluetoothProfile objects.
+ typedef std::map<std::string, device::BluetoothProfile*> BluetoothProfileMap;
+ BluetoothProfileMap bluetooth_profile_map_;
+
base::WeakPtrFactory<ExtensionBluetoothEventRouter> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(ExtensionBluetoothEventRouter);

Powered by Google App Engine
This is Rietveld 408576698