| 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 #include "device/bluetooth/bluetooth_gatt_connection.h" | 13 #include "device/bluetooth/bluetooth_gatt_connection.h" |
| 14 #include "device/bluetooth/bluetooth_gatt_service.h" | 14 #include "device/bluetooth/bluetooth_gatt_service.h" |
| 15 | 15 |
| 16 namespace device { |
| 17 class BluetoothUUID; |
| 18 } |
| 19 |
| 16 namespace content { | 20 namespace content { |
| 17 | 21 |
| 22 struct BluetoothScanFilter; |
| 23 |
| 18 // Dispatches and sends bluetooth related messages sent to/from a child | 24 // Dispatches and sends bluetooth related messages sent to/from a child |
| 19 // process BluetoothDispatcher from/to the main browser process. | 25 // process BluetoothDispatcher from/to the main browser process. |
| 20 // | 26 // |
| 21 // Intended to be instantiated by the RenderProcessHost and installed as | 27 // Intended to be instantiated by the RenderProcessHost and installed as |
| 22 // a filter on the channel. BrowserMessageFilter is refcounted and typically | 28 // a filter on the channel. BrowserMessageFilter is refcounted and typically |
| 23 // lives as long as it is installed on a channel. | 29 // lives as long as it is installed on a channel. |
| 24 // | 30 // |
| 25 // UI Thread Note: | 31 // UI Thread Note: |
| 26 // BluetoothDispatcherHost is constructed, operates, and destroyed on the UI | 32 // BluetoothDispatcherHost is constructed, operates, and destroyed on the UI |
| 27 // thread because BluetoothAdapter and related objects live there. | 33 // thread because BluetoothAdapter and related objects live there. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 39 void SetBluetoothAdapterForTesting( | 45 void SetBluetoothAdapterForTesting( |
| 40 scoped_refptr<device::BluetoothAdapter> mock_adapter); | 46 scoped_refptr<device::BluetoothAdapter> mock_adapter); |
| 41 | 47 |
| 42 protected: | 48 protected: |
| 43 ~BluetoothDispatcherHost() override; | 49 ~BluetoothDispatcherHost() override; |
| 44 | 50 |
| 45 private: | 51 private: |
| 46 friend class base::DeleteHelper<BluetoothDispatcherHost>; | 52 friend class base::DeleteHelper<BluetoothDispatcherHost>; |
| 47 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; | 53 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; |
| 48 | 54 |
| 55 struct DiscoverySessionOptions; |
| 56 |
| 49 // Set |adapter_| to a BluetoothAdapter instance and register observers, | 57 // Set |adapter_| to a BluetoothAdapter instance and register observers, |
| 50 // releasing references to previous |adapter_|. | 58 // releasing references to previous |adapter_|. |
| 51 void set_adapter(scoped_refptr<device::BluetoothAdapter> adapter); | 59 void set_adapter(scoped_refptr<device::BluetoothAdapter> adapter); |
| 52 | 60 |
| 53 // IPC Handlers, see definitions in bluetooth_messages.h. | 61 // IPC Handlers, see definitions in bluetooth_messages.h. |
| 54 void OnRequestDevice(int thread_id, int request_id); | 62 void OnRequestDevice( |
| 63 int thread_id, |
| 64 int request_id, |
| 65 const std::vector<content::BluetoothScanFilter>& filters, |
| 66 const std::vector<device::BluetoothUUID>& optional_services); |
| 55 void OnConnectGATT(int thread_id, int request_id, | 67 void OnConnectGATT(int thread_id, int request_id, |
| 56 const std::string& device_instance_id); | 68 const std::string& device_instance_id); |
| 57 void OnGetPrimaryService(int thread_id, | 69 void OnGetPrimaryService(int thread_id, |
| 58 int request_id, | 70 int request_id, |
| 59 const std::string& device_instance_id, | 71 const std::string& device_instance_id, |
| 60 const std::string& service_uuid); | 72 const std::string& service_uuid); |
| 61 void OnGetCharacteristic(int thread_id, | 73 void OnGetCharacteristic(int thread_id, |
| 62 int request_id, | 74 int request_id, |
| 63 const std::string& service_instance_id, | 75 const std::string& service_instance_id, |
| 64 const std::string& characteristic_uuid); | 76 const std::string& characteristic_uuid); |
| 65 void OnReadValue(int thread_id, | 77 void OnReadValue(int thread_id, |
| 66 int request_id, | 78 int request_id, |
| 67 const std::string& characteristic_instance_id); | 79 const std::string& characteristic_instance_id); |
| 68 | 80 |
| 69 // Callbacks for BluetoothAdapter::StartDiscoverySession. | 81 // Callbacks for BluetoothAdapter::StartDiscoverySession. |
| 70 void OnDiscoverySessionStarted( | 82 void OnDiscoverySessionStarted( |
| 71 int thread_id, | 83 int thread_id, |
| 72 int request_id, | 84 int request_id, |
| 85 scoped_ptr<DiscoverySessionOptions> options, |
| 73 scoped_ptr<device::BluetoothDiscoverySession> discovery_session); | 86 scoped_ptr<device::BluetoothDiscoverySession> discovery_session); |
| 74 void OnDiscoverySessionStartedError(int thread_id, int request_id); | 87 void OnDiscoverySessionStartedError(int thread_id, int request_id); |
| 75 | 88 |
| 76 // Stop in progress discovery session. | 89 // Stop in progress discovery session. |
| 77 void StopDiscoverySession( | 90 void StopDiscoverySession( |
| 78 int thread_id, | 91 int thread_id, |
| 79 int request_id, | 92 int request_id, |
| 93 scoped_ptr<DiscoverySessionOptions> options, |
| 80 scoped_ptr<device::BluetoothDiscoverySession> discovery_session); | 94 scoped_ptr<device::BluetoothDiscoverySession> discovery_session); |
| 81 | 95 |
| 82 // Callbacks for BluetoothDiscoverySession::Stop. | 96 // Callbacks for BluetoothDiscoverySession::Stop. |
| 83 void OnDiscoverySessionStopped(int thread_id, int request_id); | 97 void OnDiscoverySessionStopped(int thread_id, |
| 98 int request_id, |
| 99 scoped_ptr<DiscoverySessionOptions> options); |
| 84 void OnDiscoverySessionStoppedError(int thread_id, int request_id); | 100 void OnDiscoverySessionStoppedError(int thread_id, int request_id); |
| 85 | 101 |
| 86 // Callbacks for BluetoothDevice::CreateGattConnection. | 102 // Callbacks for BluetoothDevice::CreateGattConnection. |
| 87 void OnGATTConnectionCreated( | 103 void OnGATTConnectionCreated( |
| 88 int thread_id, | 104 int thread_id, |
| 89 int request_id, | 105 int request_id, |
| 90 const std::string& device_instance_id, | 106 const std::string& device_instance_id, |
| 91 scoped_ptr<device::BluetoothGattConnection> connection); | 107 scoped_ptr<device::BluetoothGattConnection> connection); |
| 92 void OnCreateGATTConnectionError( | 108 void OnCreateGATTConnectionError( |
| 93 int thread_id, | 109 int thread_id, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 142 |
| 127 // Must be last member, see base/memory/weak_ptr.h documentation | 143 // Must be last member, see base/memory/weak_ptr.h documentation |
| 128 base::WeakPtrFactory<BluetoothDispatcherHost> weak_ptr_factory_; | 144 base::WeakPtrFactory<BluetoothDispatcherHost> weak_ptr_factory_; |
| 129 | 145 |
| 130 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcherHost); | 146 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcherHost); |
| 131 }; | 147 }; |
| 132 | 148 |
| 133 } // namespace content | 149 } // namespace content |
| 134 | 150 |
| 135 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ | 151 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ |
| OLD | NEW |