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

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

Issue 227493006: Revert 262175 "* Replace "read" method with onReceiveXxx events." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 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: trunk/src/chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h
===================================================================
--- trunk/src/chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h (revision 262179)
+++ trunk/src/chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h (working copy)
@@ -49,6 +49,17 @@
void GetAdapter(
const device::BluetoothAdapterFactory::AdapterCallback& callback);
+ // Register the BluetoothSocket |socket| for use by the extensions system.
+ // This class will hold onto the socket for its lifetime until
+ // ReleaseSocket is called for the socket, or until the extension associated
+ // with the socket is disabled/ reloaded. Returns an id for the socket.
+ int RegisterSocket(const std::string& extension_id,
+ scoped_refptr<device::BluetoothSocket> socket);
+
+ // Release the BluetoothSocket corresponding to |id|. Returns true if
+ // 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 until RemoveProfile is
// called for the profile, or until the extension that added the profile
@@ -88,6 +99,16 @@
// if the BluetoothProfile with |uuid| does not exist.
device::BluetoothProfile* GetProfile(const device::BluetoothUUID& uuid) const;
+ // Get the BluetoothSocket corresponding to |id|.
+ scoped_refptr<device::BluetoothSocket> GetSocket(int id);
+
+ // 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 device::BluetoothUUID& uuid,
+ const device::BluetoothDevice* device,
+ scoped_refptr<device::BluetoothSocket> socket);
+
// Called when a bluetooth event listener is added.
void OnListenerAdded();
@@ -157,6 +178,14 @@
int num_event_listeners_;
+ // The next id to use for referring to a BluetoothSocket. We avoid using
+ // the fd of the socket because we don't want to leak that information to
+ // the extension javascript.
+ int next_socket_id_;
+
+ typedef std::map<int, ExtensionBluetoothSocketRecord> SocketMap;
+ SocketMap socket_map_;
+
// Maps uuids to a struct containing a Bluetooth profile and its
// associated extension id.
typedef std::map<device::BluetoothUUID, ExtensionBluetoothProfileRecord>

Powered by Google App Engine
This is Rietveld 408576698