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

Unified Diff: chrome/browser/chromeos/extensions/bluetooth_event_router.h

Issue 10381120: Implement chrome.experimental.bluetooth.connect (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/extensions/bluetooth_event_router.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/extensions/bluetooth_event_router.h
diff --git a/chrome/browser/chromeos/extensions/bluetooth_event_router.h b/chrome/browser/chromeos/extensions/bluetooth_event_router.h
index 73b73364e939e1db245454eab0f5e0d59a9cd9f3..f8056612fc93770e856433d136a499b8964ce422 100644
--- a/chrome/browser/chromeos/extensions/bluetooth_event_router.h
+++ b/chrome/browser/chromeos/extensions/bluetooth_event_router.h
@@ -6,8 +6,12 @@
#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_BLUETOOTH_EVENT_ROUTER_H_
#pragma once
+#include <map>
+
+#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/chromeos/bluetooth/bluetooth_adapter.h"
+#include "chrome/browser/chromeos/bluetooth/bluetooth_socket.h"
#include "chrome/browser/profiles/profile.h"
namespace chromeos {
@@ -21,6 +25,18 @@ class ExtensionBluetoothEventRouter
const chromeos::BluetoothAdapter* adapter() const { return adapter_.get(); }
chromeos::BluetoothAdapter* GetMutableAdapter() { return adapter_.get(); }
+ // Register the BluetoothSocket |socket| for use by the extensions system.
+ // This class will hold onto the socket for its lifetime, or until
+ // ReleaseSocket is called for the socket. Returns an id for the socket.
+ int RegisterSocket(scoped_refptr<BluetoothSocket> socket);
+
+ // Release the BluetoothSocket corresponding to |id|. Returns true if
+ // the socket was found and released, false otherwise.
+ bool ReleaseSocket(int id);
+
+ // Get the BluetoothSocket corresponding to |id|.
+ scoped_refptr<BluetoothSocket> GetSocket(int id);
+
// Override from chromeos::BluetoothAdapter::Observer
virtual void AdapterPresentChanged(
chromeos::BluetoothAdapter* adapter, bool present) OVERRIDE;
@@ -31,6 +47,15 @@ class ExtensionBluetoothEventRouter
Profile* profile_;
scoped_ptr<chromeos::BluetoothAdapter> adapter_;
+
+ // 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, scoped_refptr<BluetoothSocket> > SocketMap;
+ SocketMap socket_map_;
+
DISALLOW_COPY_AND_ASSIGN(ExtensionBluetoothEventRouter);
};
« no previous file with comments | « no previous file | chrome/browser/chromeos/extensions/bluetooth_event_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698