Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ | 5 #ifndef CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ |
| 6 #define CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ | 6 #define CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "content/common/bluetooth/bluetooth_error.h" | 10 #include "content/common/bluetooth/bluetooth_error.h" |
| 11 #include "content/public/browser/browser_message_filter.h" | 11 #include "content/public/browser/browser_message_filter.h" |
| 12 #include "device/bluetooth/bluetooth_adapter.h" | 12 #include "device/bluetooth/bluetooth_adapter.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 | 15 |
| 16 // Dispatches and sends bluetooth related messages sent to/from a child | 16 // Dispatches and sends bluetooth related messages sent to/from a child |
| 17 // process BluetoothDispatcher from/to the main browser process. | 17 // process BluetoothDispatcher from/to the main browser process. |
| 18 // | 18 // |
| 19 // Intended to be instantiated by the RenderProcessHost and installed as | 19 // Intended to be instantiated by the RenderProcessHost and installed as |
| 20 // a filter on the channel. BrowserMessageFilter is refcounted and typically | 20 // a filter on the channel. BrowserMessageFilter is refcounted and typically |
| 21 // lives as long as it is installed on a channel. | 21 // lives as long as it is installed on a channel. |
| 22 // | 22 // |
| 23 // UI Thread Note: | 23 // UI Thread Note: |
| 24 // BluetoothDispatcherHost is constructed, operates, and destroyed on the UI | 24 // BluetoothDispatcherHost is constructed, operates, and destroyed on the UI |
| 25 // thread because BluetoothAdapter and related objects live there. | 25 // thread because BluetoothAdapter and related objects live there. |
| 26 class BluetoothDispatcherHost final | 26 class CONTENT_EXPORT BluetoothDispatcherHost final |
| 27 : public BrowserMessageFilter, | 27 : public BrowserMessageFilter, |
| 28 public device::BluetoothAdapter::Observer { | 28 public device::BluetoothAdapter::Observer { |
| 29 public: | 29 public: |
| 30 BluetoothDispatcherHost(); | 30 BluetoothDispatcherHost(); |
| 31 // BrowserMessageFilter: | 31 // BrowserMessageFilter: |
| 32 void OnDestruct() const override; | 32 void OnDestruct() const override; |
| 33 void OverrideThreadForMessage(const IPC::Message& message, | 33 void OverrideThreadForMessage(const IPC::Message& message, |
| 34 BrowserThread::ID* thread) override; | 34 BrowserThread::ID* thread) override; |
| 35 bool OnMessageReceived(const IPC::Message& message) override; | 35 bool OnMessageReceived(const IPC::Message& message) override; |
| 36 | 36 |
| 37 void SetBluetoothAdapterForTesting(const std::string& name); | |
|
scheib
2015/05/16 01:00:35
Make this match the signature you'll use in https:
scheib
2015/05/18 16:43:30
Sorry, my miss-reading here. Fine to have this sig
| |
| 38 | |
| 37 protected: | 39 protected: |
| 38 ~BluetoothDispatcherHost() override; | 40 ~BluetoothDispatcherHost() override; |
| 39 | 41 |
| 40 private: | 42 private: |
| 41 friend class base::DeleteHelper<BluetoothDispatcherHost>; | 43 friend class base::DeleteHelper<BluetoothDispatcherHost>; |
| 42 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; | 44 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; |
| 43 | 45 |
| 44 // Set |adapter_| to a BluetoothAdapter instance and register observers, | 46 // Set |adapter_| to a BluetoothAdapter instance and register observers, |
| 45 // releasing references to previous |adapter_|. | 47 // releasing references to previous |adapter_|. |
| 46 void set_adapter(scoped_refptr<device::BluetoothAdapter> adapter); | 48 void set_adapter(scoped_refptr<device::BluetoothAdapter> adapter); |
| 47 | 49 |
| 48 // IPC Handlers, see definitions in bluetooth_messages.h. | 50 // IPC Handlers, see definitions in bluetooth_messages.h. |
| 49 void OnRequestDevice(int thread_id, int request_id); | 51 void OnRequestDevice(int thread_id, int request_id); |
| 50 void OnConnectGATT(int thread_id, int request_id, | 52 void OnConnectGATT(int thread_id, int request_id, |
| 51 const std::string& device_instance_id); | 53 const std::string& device_instance_id); |
| 52 void OnSetBluetoothMockDataSetForTesting(const std::string& name); | |
| 53 | 54 |
| 54 // Callbacks for BluetoothAdapter::StartDiscoverySession. | 55 // Callbacks for BluetoothAdapter::StartDiscoverySession. |
| 55 void OnDiscoverySessionStarted( | 56 void OnDiscoverySessionStarted( |
| 56 int thread_id, | 57 int thread_id, |
| 57 int request_id, | 58 int request_id, |
| 58 scoped_ptr<device::BluetoothDiscoverySession> discovery_session); | 59 scoped_ptr<device::BluetoothDiscoverySession> discovery_session); |
| 59 void OnDiscoverySessionStartedError(int thread_id, int request_id); | 60 void OnDiscoverySessionStartedError(int thread_id, int request_id); |
| 60 | 61 |
| 61 // Stop in progress discovery session. | 62 // Stop in progress discovery session. |
| 62 void StopDiscoverySession( | 63 void StopDiscoverySession( |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 77 | 78 |
| 78 // Must be last member, see base/memory/weak_ptr.h documentation | 79 // Must be last member, see base/memory/weak_ptr.h documentation |
| 79 base::WeakPtrFactory<BluetoothDispatcherHost> weak_ptr_factory_; | 80 base::WeakPtrFactory<BluetoothDispatcherHost> weak_ptr_factory_; |
| 80 | 81 |
| 81 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcherHost); | 82 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcherHost); |
| 82 }; | 83 }; |
| 83 | 84 |
| 84 } // namespace content | 85 } // namespace content |
| 85 | 86 |
| 86 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ | 87 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ |
| OLD | NEW |