| 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 "content/common/bluetooth/bluetooth_error.h" | 9 #include "content/common/bluetooth/bluetooth_error.h" |
| 10 #include "content/public/browser/browser_message_filter.h" | 10 #include "content/public/browser/browser_message_filter.h" |
| 11 #include "device/bluetooth/bluetooth_adapter.h" |
| 11 | 12 |
| 12 namespace content { | 13 namespace content { |
| 13 | 14 |
| 14 // Dispatches and sends bluetooth related messages sent to/from a child | 15 // Dispatches and sends bluetooth related messages sent to/from a child |
| 15 // process BluetoothDispatcher from/to the main browser process. | 16 // process BluetoothDispatcher from/to the main browser process. |
| 16 // Constructed on the main (UI) thread and receives IPC on the IO thread. | 17 // Constructed on the main (UI) thread and receives IPC on the IO thread. |
| 17 // Intended to be instantiated by the RenderProcessHost and installed as | 18 // Intended to be instantiated by the RenderProcessHost and installed as |
| 18 // a filter on the channel. BrowserMessageFilter is refcounted and typically | 19 // a filter on the channel. BrowserMessageFilter is refcounted and typically |
| 19 // lives as long as it is installed on a channel. | 20 // lives as long as it is installed on a channel. |
| 20 class BluetoothDispatcherHost : public BrowserMessageFilter { | 21 class BluetoothDispatcherHost : public BrowserMessageFilter, |
| 22 public device::BluetoothAdapter::Observer { |
| 21 public: | 23 public: |
| 22 BluetoothDispatcherHost(); | 24 // Creates a BluetoothDispatcherHost. |
| 25 static scoped_refptr<BluetoothDispatcherHost> Create(); |
| 23 | 26 |
| 24 // BrowserMessageFilter: | 27 // BrowserMessageFilter: |
| 25 bool OnMessageReceived(const IPC::Message& message) override; | 28 bool OnMessageReceived(const IPC::Message& message) override; |
| 26 | 29 |
| 27 protected: | 30 protected: |
| 31 BluetoothDispatcherHost(); |
| 28 ~BluetoothDispatcherHost() override; | 32 ~BluetoothDispatcherHost() override; |
| 29 | 33 |
| 30 private: | 34 private: |
| 35 // Set |adapter_| to a BluetoothAdapter instance and register observers, |
| 36 // releasing references to previous |adapter_|. |
| 37 void set_adapter(scoped_refptr<device::BluetoothAdapter> adapter); |
| 38 |
| 31 // IPC Handlers, see definitions in bluetooth_messages.h. | 39 // IPC Handlers, see definitions in bluetooth_messages.h. |
| 32 void OnRequestDevice(int thread_id, int request_id); | 40 void OnRequestDevice(int thread_id, int request_id); |
| 33 void OnSetBluetoothMockDataSetForTesting(const std::string& name); | 41 void OnSetBluetoothMockDataSetForTesting(const std::string& name); |
| 34 | 42 |
| 43 // A BluetoothAdapter instance representing an adapter of the system. |
| 44 scoped_refptr<device::BluetoothAdapter> adapter_; |
| 45 |
| 35 enum class MockData { NOT_MOCKING, REJECT, RESOLVE }; | 46 enum class MockData { NOT_MOCKING, REJECT, RESOLVE }; |
| 36 MockData bluetooth_mock_data_set_; | 47 MockData bluetooth_mock_data_set_; |
| 37 BluetoothError bluetooth_request_device_reject_type_; | 48 BluetoothError bluetooth_request_device_reject_type_; |
| 38 | 49 |
| 39 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcherHost); | 50 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcherHost); |
| 40 }; | 51 }; |
| 41 | 52 |
| 42 } // namespace content | 53 } // namespace content |
| 43 | 54 |
| 44 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ | 55 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ |
| OLD | NEW |