OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ | 5 #ifndef COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ |
6 #define COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ | 6 #define COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 18 matching lines...) Expand all Loading... |
29 class ArcBridgeService; | 29 class ArcBridgeService; |
30 | 30 |
31 class ArcBluetoothBridge | 31 class ArcBluetoothBridge |
32 : public ArcService, | 32 : public ArcService, |
33 public ArcBridgeService::Observer, | 33 public ArcBridgeService::Observer, |
34 public device::BluetoothAdapter::Observer, | 34 public device::BluetoothAdapter::Observer, |
35 public device::BluetoothAdapterFactory::AdapterCallback, | 35 public device::BluetoothAdapterFactory::AdapterCallback, |
36 public mojom::BluetoothHost { | 36 public mojom::BluetoothHost { |
37 public: | 37 public: |
38 explicit ArcBluetoothBridge(ArcBridgeService* bridge_service); | 38 explicit ArcBluetoothBridge(ArcBridgeService* bridge_service); |
39 ArcBluetoothBridge(ArcBridgeService* bridge_service, bool test_flag); | |
40 ~ArcBluetoothBridge() override; | 39 ~ArcBluetoothBridge() override; |
41 | 40 |
42 // Overridden from ArcBridgeService::Observer: | 41 // Overridden from ArcBridgeService::Observer: |
43 void OnBluetoothInstanceReady() override; | 42 void OnBluetoothInstanceReady() override; |
44 | 43 |
45 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter); | 44 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter); |
46 | 45 |
47 // Overridden from device::BluetoothAdadpter::Observer | 46 // Overridden from device::BluetoothAdadpter::Observer |
48 void AdapterPresentChanged(device::BluetoothAdapter* adapter, | 47 void AdapterPresentChanged(device::BluetoothAdapter* adapter, |
49 bool present) override; | 48 bool present) override; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 void OnGattNotifyStartDone( | 244 void OnGattNotifyStartDone( |
246 const RegisterForGattNotificationCallback& callback, | 245 const RegisterForGattNotificationCallback& callback, |
247 const std::string char_string_id, | 246 const std::string char_string_id, |
248 std::unique_ptr<device::BluetoothGattNotifySession> notify_session); | 247 std::unique_ptr<device::BluetoothGattNotifySession> notify_session); |
249 void OnGattNotifyStartError( | 248 void OnGattNotifyStartError( |
250 const RegisterForGattNotificationCallback& callback, | 249 const RegisterForGattNotificationCallback& callback, |
251 device::BluetoothGattService::GattErrorCode error_code) const; | 250 device::BluetoothGattService::GattErrorCode error_code) const; |
252 void OnGattNotifyStopDone( | 251 void OnGattNotifyStopDone( |
253 const DeregisterForGattNotificationCallback& callback) const; | 252 const DeregisterForGattNotificationCallback& callback) const; |
254 | 253 |
255 // Exposed for testing. | |
256 void SetAdapterForTest(device::BluetoothAdapter* adapter) { | |
257 bluetooth_adapter_ = adapter; | |
258 } | |
259 | |
260 void SetBluetoothInstanceForTest( | |
261 mojom::BluetoothInstance* bluetooth_instance) { | |
262 bluetooth_instance_ = base::WrapUnique(bluetooth_instance); | |
263 } | |
264 | |
265 void SetBluetoothVersionForTest(int32_t bluetooth_version) { | |
266 bluetooth_version_ = bluetooth_version; | |
267 } | |
268 | |
269 private: | 254 private: |
270 mojo::Array<mojom::BluetoothPropertyPtr> GetDeviceProperties( | 255 mojo::Array<mojom::BluetoothPropertyPtr> GetDeviceProperties( |
271 mojom::BluetoothPropertyType type, | 256 mojom::BluetoothPropertyType type, |
272 device::BluetoothDevice* device) const; | 257 device::BluetoothDevice* device) const; |
273 mojo::Array<mojom::BluetoothPropertyPtr> GetAdapterProperties( | 258 mojo::Array<mojom::BluetoothPropertyPtr> GetAdapterProperties( |
274 mojom::BluetoothPropertyType type) const; | 259 mojom::BluetoothPropertyType type) const; |
275 mojo::Array<mojom::BluetoothAdvertisingDataPtr> GetAdvertisingData( | 260 mojo::Array<mojom::BluetoothAdvertisingDataPtr> GetAdvertisingData( |
276 device::BluetoothDevice* device) const; | 261 device::BluetoothDevice* device) const; |
277 | 262 |
278 void SendCachedDevicesFound() const; | 263 void SendCachedDevicesFound() const; |
(...skipping 12 matching lines...) Expand all Loading... |
291 mojom::BluetoothGattServiceIDPtr service_id, | 276 mojom::BluetoothGattServiceIDPtr service_id, |
292 mojom::BluetoothGattIDPtr char_id, | 277 mojom::BluetoothGattIDPtr char_id, |
293 mojom::BluetoothGattIDPtr desc_id) const; | 278 mojom::BluetoothGattIDPtr desc_id) const; |
294 | 279 |
295 // Propagates the list of paired device to Android. | 280 // Propagates the list of paired device to Android. |
296 void SendCachedPairedDevices() const; | 281 void SendCachedPairedDevices() const; |
297 | 282 |
298 mojo::Binding<mojom::BluetoothHost> binding_; | 283 mojo::Binding<mojom::BluetoothHost> binding_; |
299 | 284 |
300 scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_; | 285 scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_; |
301 std::unique_ptr<mojom::BluetoothInstance> bluetooth_instance_; | |
302 int32_t bluetooth_version_; | |
303 scoped_refptr<device::BluetoothAdvertisement> advertisment_; | 286 scoped_refptr<device::BluetoothAdvertisement> advertisment_; |
304 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_; | 287 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_; |
305 std::map<std::string, std::unique_ptr<device::BluetoothGattNotifySession>> | 288 std::map<std::string, std::unique_ptr<device::BluetoothGattNotifySession>> |
306 notification_session_; | 289 notification_session_; |
307 | 290 |
308 // WeakPtrFactory to use for callbacks. | 291 // WeakPtrFactory to use for callbacks. |
309 base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_; | 292 base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_; |
310 | 293 |
311 DISALLOW_COPY_AND_ASSIGN(ArcBluetoothBridge); | 294 DISALLOW_COPY_AND_ASSIGN(ArcBluetoothBridge); |
312 }; | 295 }; |
313 | 296 |
314 } // namespace arc | 297 } // namespace arc |
315 | 298 |
316 #endif // COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ | 299 #endif // COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ |
OLD | NEW |