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> |
11 #include <memory> | 11 #include <memory> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/callback.h" | 15 #include "base/callback.h" |
16 #include "components/arc/arc_bridge_service.h" | 16 #include "components/arc/arc_bridge_service.h" |
17 #include "components/arc/arc_service.h" | 17 #include "components/arc/arc_service.h" |
18 #include "components/arc/common/bluetooth.mojom.h" | 18 #include "components/arc/common/bluetooth.mojom.h" |
| 19 #include "components/arc/instance_holder.h" |
19 #include "device/bluetooth/bluetooth_adapter.h" | 20 #include "device/bluetooth/bluetooth_adapter.h" |
20 #include "device/bluetooth/bluetooth_adapter_factory.h" | 21 #include "device/bluetooth/bluetooth_adapter_factory.h" |
21 #include "device/bluetooth/bluetooth_device.h" | 22 #include "device/bluetooth/bluetooth_device.h" |
22 #include "device/bluetooth/bluetooth_discovery_session.h" | 23 #include "device/bluetooth/bluetooth_discovery_session.h" |
23 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" | 24 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" |
24 #include "device/bluetooth/bluetooth_remote_gatt_descriptor.h" | 25 #include "device/bluetooth/bluetooth_remote_gatt_descriptor.h" |
25 #include "device/bluetooth/bluetooth_remote_gatt_service.h" | 26 #include "device/bluetooth/bluetooth_remote_gatt_service.h" |
26 #include "device/bluetooth/bluez/bluetooth_adapter_bluez.h" | 27 #include "device/bluetooth/bluez/bluetooth_adapter_bluez.h" |
27 #include "mojo/public/cpp/bindings/binding.h" | 28 #include "mojo/public/cpp/bindings/binding.h" |
28 | 29 |
29 namespace arc { | 30 namespace arc { |
30 | 31 |
31 class ArcBridgeService; | 32 class ArcBridgeService; |
32 | 33 |
33 class ArcBluetoothBridge | 34 class ArcBluetoothBridge |
34 : public ArcService, | 35 : public ArcService, |
35 public ArcBridgeService::Observer, | 36 public InstanceHolder<mojom::BluetoothInstance>::Observer, |
36 public device::BluetoothAdapter::Observer, | 37 public device::BluetoothAdapter::Observer, |
37 public device::BluetoothAdapterFactory::AdapterCallback, | 38 public device::BluetoothAdapterFactory::AdapterCallback, |
38 public mojom::BluetoothHost { | 39 public mojom::BluetoothHost { |
39 public: | 40 public: |
40 explicit ArcBluetoothBridge(ArcBridgeService* bridge_service); | 41 explicit ArcBluetoothBridge(ArcBridgeService* bridge_service); |
41 ~ArcBluetoothBridge() override; | 42 ~ArcBluetoothBridge() override; |
42 | 43 |
43 // Overridden from ArcBridgeService::Observer: | 44 // Overridden from |
44 void OnBluetoothInstanceReady() override; | 45 // InstanceHolder<mojom::BluetoothInstance>::Observer: |
| 46 void OnInstanceReady() override; |
45 | 47 |
46 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter); | 48 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter); |
47 | 49 |
48 // Overridden from device::BluetoothAdadpter::Observer | 50 // Overridden from device::BluetoothAdadpter::Observer |
49 void AdapterPresentChanged(device::BluetoothAdapter* adapter, | 51 void AdapterPresentChanged(device::BluetoothAdapter* adapter, |
50 bool present) override; | 52 bool present) override; |
51 | 53 |
52 void AdapterPoweredChanged(device::BluetoothAdapter* adapter, | 54 void AdapterPoweredChanged(device::BluetoothAdapter* adapter, |
53 bool powered) override; | 55 bool powered) override; |
54 | 56 |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 mojo::Array<mojom::BluetoothPropertyPtr> GetDeviceProperties( | 259 mojo::Array<mojom::BluetoothPropertyPtr> GetDeviceProperties( |
258 mojom::BluetoothPropertyType type, | 260 mojom::BluetoothPropertyType type, |
259 device::BluetoothDevice* device) const; | 261 device::BluetoothDevice* device) const; |
260 mojo::Array<mojom::BluetoothPropertyPtr> GetAdapterProperties( | 262 mojo::Array<mojom::BluetoothPropertyPtr> GetAdapterProperties( |
261 mojom::BluetoothPropertyType type) const; | 263 mojom::BluetoothPropertyType type) const; |
262 mojo::Array<mojom::BluetoothAdvertisingDataPtr> GetAdvertisingData( | 264 mojo::Array<mojom::BluetoothAdvertisingDataPtr> GetAdvertisingData( |
263 device::BluetoothDevice* device) const; | 265 device::BluetoothDevice* device) const; |
264 | 266 |
265 void SendCachedDevicesFound() const; | 267 void SendCachedDevicesFound() const; |
266 bool HasBluetoothInstance() const; | 268 bool HasBluetoothInstance() const; |
267 bool CheckBluetoothInstanceVersion(int32_t version_need) const; | 269 bool CheckBluetoothInstanceVersion(uint32_t version_need) const; |
268 | 270 |
269 template <class T> | 271 template <class T> |
270 T* FindGattObjectFromUuid(const std::vector<T*> objs, | 272 T* FindGattObjectFromUuid(const std::vector<T*> objs, |
271 const device::BluetoothUUID uuid) const; | 273 const device::BluetoothUUID uuid) const; |
272 device::BluetoothRemoteGattCharacteristic* FindGattCharacteristic( | 274 device::BluetoothRemoteGattCharacteristic* FindGattCharacteristic( |
273 mojom::BluetoothAddressPtr remote_addr, | 275 mojom::BluetoothAddressPtr remote_addr, |
274 mojom::BluetoothGattServiceIDPtr service_id, | 276 mojom::BluetoothGattServiceIDPtr service_id, |
275 mojom::BluetoothGattIDPtr char_id) const; | 277 mojom::BluetoothGattIDPtr char_id) const; |
276 | 278 |
277 device::BluetoothRemoteGattDescriptor* FindGattDescriptor( | 279 device::BluetoothRemoteGattDescriptor* FindGattDescriptor( |
(...skipping 15 matching lines...) Expand all Loading... |
293 | 295 |
294 // WeakPtrFactory to use for callbacks. | 296 // WeakPtrFactory to use for callbacks. |
295 base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_; | 297 base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_; |
296 | 298 |
297 DISALLOW_COPY_AND_ASSIGN(ArcBluetoothBridge); | 299 DISALLOW_COPY_AND_ASSIGN(ArcBluetoothBridge); |
298 }; | 300 }; |
299 | 301 |
300 } // namespace arc | 302 } // namespace arc |
301 | 303 |
302 #endif // COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ | 304 #endif // COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ |
OLD | NEW |