| 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/containers/scoped_ptr_map.h" | 9 #include "base/containers/scoped_ptr_map.h" |
| 10 #include "base/id_map.h" | 10 #include "base/id_map.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 void SetBluetoothAdapterForTesting( | 49 void SetBluetoothAdapterForTesting( |
| 50 scoped_refptr<device::BluetoothAdapter> mock_adapter); | 50 scoped_refptr<device::BluetoothAdapter> mock_adapter); |
| 51 | 51 |
| 52 protected: | 52 protected: |
| 53 ~BluetoothDispatcherHost() override; | 53 ~BluetoothDispatcherHost() override; |
| 54 | 54 |
| 55 private: | 55 private: |
| 56 friend class base::DeleteHelper<BluetoothDispatcherHost>; | 56 friend class base::DeleteHelper<BluetoothDispatcherHost>; |
| 57 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; | 57 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; |
| 58 | 58 |
| 59 struct CacheQueryResult; |
| 59 struct RequestDeviceSession; | 60 struct RequestDeviceSession; |
| 60 | 61 |
| 61 // Set |adapter_| to a BluetoothAdapter instance and register observers, | 62 // Set |adapter_| to a BluetoothAdapter instance and register observers, |
| 62 // releasing references to previous |adapter_|. | 63 // releasing references to previous |adapter_|. |
| 63 void set_adapter(scoped_refptr<device::BluetoothAdapter> adapter); | 64 void set_adapter(scoped_refptr<device::BluetoothAdapter> adapter); |
| 64 | 65 |
| 65 // Makes sure a BluetoothDiscoverySession is active for |session|, and resets | 66 // Makes sure a BluetoothDiscoverySession is active for |session|, and resets |
| 66 // its timeout. | 67 // its timeout. |
| 67 void StartDeviceDiscovery(RequestDeviceSession* session, int chooser_id); | 68 void StartDeviceDiscovery(RequestDeviceSession* session, int chooser_id); |
| 68 | 69 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 void OnStartNotifySessionFailed( | 189 void OnStartNotifySessionFailed( |
| 189 int thread_id, | 190 int thread_id, |
| 190 int request_id, | 191 int request_id, |
| 191 device::BluetoothGattService::GattErrorCode error_code); | 192 device::BluetoothGattService::GattErrorCode error_code); |
| 192 | 193 |
| 193 // Callback for BluetoothGattNotifySession::Stop. | 194 // Callback for BluetoothGattNotifySession::Stop. |
| 194 void OnStopNotifySession(int thread_id, | 195 void OnStopNotifySession(int thread_id, |
| 195 int request_id, | 196 int request_id, |
| 196 const std::string& characteristic_instance_id); | 197 const std::string& characteristic_instance_id); |
| 197 | 198 |
| 199 // Functions to query the platform cache for the bluetooth object. |
| 200 // result.outcome == CacheQueryOutcome::SUCCESS if the object was found in the |
| 201 // cache. Otherwise result.outcome that can used to record the outcome and |
| 202 // result.error will contain the error that should be send to the renderer. |
| 203 |
| 204 // Queries the platform cache for a Device with |device_instance_id|. If |
| 205 // successful the device will be in result.device |
| 206 void QueryCacheForDevice(const std::string& device_instance_id, |
| 207 CacheQueryResult& result); |
| 208 // Queries the platform cache for a Service with |service_instance_id|. |
| 209 // Returns true if we made the renderer crash due to a bad message. If |
| 210 // successfull the service will be in result.service. |
| 211 bool QueryCacheForService(const std::string& service_instance_id, |
| 212 CacheQueryResult& result); |
| 213 // Queries the platform cache for a characteristic with |
| 214 // |characteristic_instance_id|. Returns true if we made the renderer crash |
| 215 // due to a bad message. If successfull the characteristic will be in |
| 216 // result.characteristic. |
| 217 bool QueryCacheForCharacteristic( |
| 218 const std::string& characteristic_instance_id, |
| 219 CacheQueryResult& result); |
| 220 |
| 198 // Show help pages from the chooser dialog. | 221 // Show help pages from the chooser dialog. |
| 199 void ShowBluetoothOverviewLink(); | 222 void ShowBluetoothOverviewLink(); |
| 200 void ShowBluetoothPairingLink(); | 223 void ShowBluetoothPairingLink(); |
| 201 void ShowBluetoothAdapterOffLink(); | 224 void ShowBluetoothAdapterOffLink(); |
| 202 | 225 |
| 203 int render_process_id_; | 226 int render_process_id_; |
| 204 | 227 |
| 205 // Maps a (thread_id,request_id) to information about its requestDevice call, | 228 // Maps a (thread_id,request_id) to information about its requestDevice call, |
| 206 // including the chooser dialog. | 229 // including the chooser dialog. |
| 207 // An entry is added to this map in OnRequestDevice, and should be removed | 230 // An entry is added to this map in OnRequestDevice, and should be removed |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 // copies verify they are also used on the UI thread. | 271 // copies verify they are also used on the UI thread. |
| 249 base::WeakPtr<BluetoothDispatcherHost> weak_ptr_on_ui_thread_; | 272 base::WeakPtr<BluetoothDispatcherHost> weak_ptr_on_ui_thread_; |
| 250 base::WeakPtrFactory<BluetoothDispatcherHost> weak_ptr_factory_; | 273 base::WeakPtrFactory<BluetoothDispatcherHost> weak_ptr_factory_; |
| 251 | 274 |
| 252 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcherHost); | 275 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcherHost); |
| 253 }; | 276 }; |
| 254 | 277 |
| 255 } // namespace content | 278 } // namespace content |
| 256 | 279 |
| 257 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ | 280 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ |
| OLD | NEW |