Chromium Code Reviews| 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. |
|
asargent_no_longer_on_chrome
2012/05/12 16:36:05
Questions to think about for possible future work
bryeung
2012/05/14 17:20:28
Is there a "canonical" (or just known good) exampl
asargent_no_longer_on_chrome
2012/05/15 16:01:18
One common pattern is to have the class which hold
|
| + 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); |
| }; |