| 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/public/browser/browser_message_filter.h" | 10 #include "content/public/browser/browser_message_filter.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 void SetBluetoothAdapterForTesting( | 44 void SetBluetoothAdapterForTesting( |
| 45 scoped_refptr<device::BluetoothAdapter> mock_adapter); | 45 scoped_refptr<device::BluetoothAdapter> mock_adapter); |
| 46 | 46 |
| 47 protected: | 47 protected: |
| 48 ~BluetoothDispatcherHost() override; | 48 ~BluetoothDispatcherHost() override; |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 friend class base::DeleteHelper<BluetoothDispatcherHost>; | 51 friend class base::DeleteHelper<BluetoothDispatcherHost>; |
| 52 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; | 52 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; |
| 53 | 53 |
| 54 struct DiscoverySessionOptions; | 54 struct RequestDeviceSession; |
| 55 | 55 |
| 56 // Set |adapter_| to a BluetoothAdapter instance and register observers, | 56 // Set |adapter_| to a BluetoothAdapter instance and register observers, |
| 57 // releasing references to previous |adapter_|. | 57 // releasing references to previous |adapter_|. |
| 58 void set_adapter(scoped_refptr<device::BluetoothAdapter> adapter); | 58 void set_adapter(scoped_refptr<device::BluetoothAdapter> adapter); |
| 59 | 59 |
| 60 // IPC Handlers, see definitions in bluetooth_messages.h. | 60 // IPC Handlers, see definitions in bluetooth_messages.h. |
| 61 void OnRequestDevice( | 61 void OnRequestDevice( |
| 62 int thread_id, | 62 int thread_id, |
| 63 int request_id, | 63 int request_id, |
| 64 const std::vector<content::BluetoothScanFilter>& filters, | 64 const std::vector<content::BluetoothScanFilter>& filters, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 78 const std::string& characteristic_instance_id); | 78 const std::string& characteristic_instance_id); |
| 79 void OnWriteValue(int thread_id, | 79 void OnWriteValue(int thread_id, |
| 80 int request_id, | 80 int request_id, |
| 81 const std::string& characteristic_instance_id, | 81 const std::string& characteristic_instance_id, |
| 82 const std::vector<uint8_t>& value); | 82 const std::vector<uint8_t>& value); |
| 83 | 83 |
| 84 // Callbacks for BluetoothAdapter::StartDiscoverySession. | 84 // Callbacks for BluetoothAdapter::StartDiscoverySession. |
| 85 void OnDiscoverySessionStarted( | 85 void OnDiscoverySessionStarted( |
| 86 int thread_id, | 86 int thread_id, |
| 87 int request_id, | 87 int request_id, |
| 88 scoped_ptr<DiscoverySessionOptions> options, | |
| 89 scoped_ptr<device::BluetoothDiscoverySession> discovery_session); | 88 scoped_ptr<device::BluetoothDiscoverySession> discovery_session); |
| 90 void OnDiscoverySessionStartedError(int thread_id, int request_id); | 89 void OnDiscoverySessionStartedError(int thread_id, int request_id); |
| 91 | 90 |
| 92 // Stop in progress discovery session. | 91 // Stop in progress discovery session. |
| 93 void StopDiscoverySession( | 92 void StopDiscoverySession( |
| 94 int thread_id, | 93 int thread_id, |
| 95 int request_id, | 94 int request_id, |
| 96 scoped_ptr<DiscoverySessionOptions> options, | |
| 97 scoped_ptr<device::BluetoothDiscoverySession> discovery_session); | 95 scoped_ptr<device::BluetoothDiscoverySession> discovery_session); |
| 98 | 96 |
| 99 // Callbacks for BluetoothDiscoverySession::Stop. | 97 // Callbacks for BluetoothDiscoverySession::Stop. |
| 100 void OnDiscoverySessionStopped(int thread_id, | 98 void OnDiscoverySessionStopped(int thread_id, int request_id); |
| 101 int request_id, | |
| 102 scoped_ptr<DiscoverySessionOptions> options); | |
| 103 void OnDiscoverySessionStoppedError(int thread_id, int request_id); | 99 void OnDiscoverySessionStoppedError(int thread_id, int request_id); |
| 104 | 100 |
| 105 // Callbacks for BluetoothDevice::CreateGattConnection. | 101 // Callbacks for BluetoothDevice::CreateGattConnection. |
| 106 void OnGATTConnectionCreated( | 102 void OnGATTConnectionCreated( |
| 107 int thread_id, | 103 int thread_id, |
| 108 int request_id, | 104 int request_id, |
| 109 const std::string& device_instance_id, | 105 const std::string& device_instance_id, |
| 110 scoped_ptr<device::BluetoothGattConnection> connection); | 106 scoped_ptr<device::BluetoothGattConnection> connection); |
| 111 void OnCreateGATTConnectionError( | 107 void OnCreateGATTConnectionError( |
| 112 int thread_id, | 108 int thread_id, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 130 int thread_id, | 126 int thread_id, |
| 131 int request_id, | 127 int request_id, |
| 132 device::BluetoothGattService::GattErrorCode); | 128 device::BluetoothGattService::GattErrorCode); |
| 133 | 129 |
| 134 // Callbacks for BluetoothGattCharacteristic::WriteRemoteCharacteristic. | 130 // Callbacks for BluetoothGattCharacteristic::WriteRemoteCharacteristic. |
| 135 void OnWriteValueSuccess(int thread_id, int request_id); | 131 void OnWriteValueSuccess(int thread_id, int request_id); |
| 136 void OnWriteValueFailed(int thread_id, | 132 void OnWriteValueFailed(int thread_id, |
| 137 int request_id, | 133 int request_id, |
| 138 device::BluetoothGattService::GattErrorCode); | 134 device::BluetoothGattService::GattErrorCode); |
| 139 | 135 |
| 136 // Maps a (thread_id,request_id) to information about its requestDevice call, |
| 137 // including the chooser dialog. |
| 138 // An entry is added to this map in OnRequestDevice, and should be removed |
| 139 // again everywhere a requestDevice() reply is sent. |
| 140 std::map<std::pair<int, int>, RequestDeviceSession> request_device_sessions_; |
| 141 |
| 140 // Maps to get the object's parent based on it's instanceID | 142 // Maps to get the object's parent based on it's instanceID |
| 141 // Map of service_instance_id to device_instance_id. | 143 // Map of service_instance_id to device_instance_id. |
| 142 std::map<std::string, std::string> service_to_device_; | 144 std::map<std::string, std::string> service_to_device_; |
| 143 // Map of characteristic_instance_id to service_instance_id. | 145 // Map of characteristic_instance_id to service_instance_id. |
| 144 std::map<std::string, std::string> characteristic_to_service_; | 146 std::map<std::string, std::string> characteristic_to_service_; |
| 145 | 147 |
| 146 // Defines how long to scan for and how long to discover services for. | 148 // Defines how long to scan for and how long to discover services for. |
| 147 int current_delay_time_; | 149 int current_delay_time_; |
| 148 | 150 |
| 149 // A BluetoothAdapter instance representing an adapter of the system. | 151 // A BluetoothAdapter instance representing an adapter of the system. |
| 150 scoped_refptr<device::BluetoothAdapter> adapter_; | 152 scoped_refptr<device::BluetoothAdapter> adapter_; |
| 151 | 153 |
| 152 // Must be last member, see base/memory/weak_ptr.h documentation | 154 // Must be last member, see base/memory/weak_ptr.h documentation |
| 153 base::WeakPtrFactory<BluetoothDispatcherHost> weak_ptr_factory_; | 155 base::WeakPtrFactory<BluetoothDispatcherHost> weak_ptr_factory_; |
| 154 | 156 |
| 155 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcherHost); | 157 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcherHost); |
| 156 }; | 158 }; |
| 157 | 159 |
| 158 } // namespace content | 160 } // namespace content |
| 159 | 161 |
| 160 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ | 162 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ |
| OLD | NEW |