Chromium Code Reviews| 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); | |
| 39 ~ArcBluetoothBridge() override; | 40 ~ArcBluetoothBridge() override; |
| 40 | 41 |
| 41 // Overridden from ArcBridgeService::Observer: | 42 // Overridden from ArcBridgeService::Observer: |
| 42 void OnBluetoothInstanceReady() override; | 43 void OnBluetoothInstanceReady() override; |
| 43 | 44 |
| 44 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter); | 45 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter); |
| 45 | 46 |
| 46 // Overridden from device::BluetoothAdadpter::Observer | 47 // Overridden from device::BluetoothAdadpter::Observer |
| 47 void AdapterPresentChanged(device::BluetoothAdapter* adapter, | 48 void AdapterPresentChanged(device::BluetoothAdapter* adapter, |
| 48 bool present) override; | 49 bool present) override; |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 void OnGattNotifyStartDone( | 245 void OnGattNotifyStartDone( |
| 245 const RegisterForGattNotificationCallback& callback, | 246 const RegisterForGattNotificationCallback& callback, |
| 246 const std::string char_string_id, | 247 const std::string char_string_id, |
| 247 std::unique_ptr<device::BluetoothGattNotifySession> notify_session); | 248 std::unique_ptr<device::BluetoothGattNotifySession> notify_session); |
| 248 void OnGattNotifyStartError( | 249 void OnGattNotifyStartError( |
| 249 const RegisterForGattNotificationCallback& callback, | 250 const RegisterForGattNotificationCallback& callback, |
| 250 device::BluetoothGattService::GattErrorCode error_code) const; | 251 device::BluetoothGattService::GattErrorCode error_code) const; |
| 251 void OnGattNotifyStopDone( | 252 void OnGattNotifyStopDone( |
| 252 const DeregisterForGattNotificationCallback& callback) const; | 253 const DeregisterForGattNotificationCallback& callback) const; |
| 253 | 254 |
| 255 // Exposed for testing. | |
| 256 void SetAdapterForTest(device::BluetoothAdapter* adapter) { | |
|
rkc
2016/06/19 18:45:43
None of these are required.
Adding "SetXXXForTesti
| |
| 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 | |
| 254 private: | 269 private: |
| 255 mojo::Array<mojom::BluetoothPropertyPtr> GetDeviceProperties( | 270 mojo::Array<mojom::BluetoothPropertyPtr> GetDeviceProperties( |
| 256 mojom::BluetoothPropertyType type, | 271 mojom::BluetoothPropertyType type, |
| 257 device::BluetoothDevice* device) const; | 272 device::BluetoothDevice* device) const; |
| 258 mojo::Array<mojom::BluetoothPropertyPtr> GetAdapterProperties( | 273 mojo::Array<mojom::BluetoothPropertyPtr> GetAdapterProperties( |
| 259 mojom::BluetoothPropertyType type) const; | 274 mojom::BluetoothPropertyType type) const; |
| 260 mojo::Array<mojom::BluetoothAdvertisingDataPtr> GetAdvertisingData( | 275 mojo::Array<mojom::BluetoothAdvertisingDataPtr> GetAdvertisingData( |
| 261 device::BluetoothDevice* device) const; | 276 device::BluetoothDevice* device) const; |
| 262 | 277 |
| 263 void SendCachedDevicesFound() const; | 278 void SendCachedDevicesFound() const; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 276 mojom::BluetoothGattServiceIDPtr service_id, | 291 mojom::BluetoothGattServiceIDPtr service_id, |
| 277 mojom::BluetoothGattIDPtr char_id, | 292 mojom::BluetoothGattIDPtr char_id, |
| 278 mojom::BluetoothGattIDPtr desc_id) const; | 293 mojom::BluetoothGattIDPtr desc_id) const; |
| 279 | 294 |
| 280 // Propagates the list of paired device to Android. | 295 // Propagates the list of paired device to Android. |
| 281 void SendCachedPairedDevices() const; | 296 void SendCachedPairedDevices() const; |
| 282 | 297 |
| 283 mojo::Binding<mojom::BluetoothHost> binding_; | 298 mojo::Binding<mojom::BluetoothHost> binding_; |
| 284 | 299 |
| 285 scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_; | 300 scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_; |
| 301 std::unique_ptr<mojom::BluetoothInstance> bluetooth_instance_; | |
| 302 int32_t bluetooth_version_; | |
| 286 scoped_refptr<device::BluetoothAdvertisement> advertisment_; | 303 scoped_refptr<device::BluetoothAdvertisement> advertisment_; |
| 287 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_; | 304 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_; |
| 288 std::map<std::string, std::unique_ptr<device::BluetoothGattNotifySession>> | 305 std::map<std::string, std::unique_ptr<device::BluetoothGattNotifySession>> |
| 289 notification_session_; | 306 notification_session_; |
| 290 | 307 |
| 291 // WeakPtrFactory to use for callbacks. | 308 // WeakPtrFactory to use for callbacks. |
| 292 base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_; | 309 base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_; |
| 293 | 310 |
| 294 DISALLOW_COPY_AND_ASSIGN(ArcBluetoothBridge); | 311 DISALLOW_COPY_AND_ASSIGN(ArcBluetoothBridge); |
| 295 }; | 312 }; |
| 296 | 313 |
| 297 } // namespace arc | 314 } // namespace arc |
| 298 | 315 |
| 299 #endif // COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ | 316 #endif // COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ |
| OLD | NEW |