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 DEVICE_BLUETOOTH_ADAPTER_H_ | 5 #ifndef DEVICE_BLUETOOTH_ADAPTER_H_ |
6 #define DEVICE_BLUETOOTH_ADAPTER_H_ | 6 #define DEVICE_BLUETOOTH_ADAPTER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "device/bluetooth/bluetooth_adapter.h" | 9 #include "device/bluetooth/bluetooth_adapter.h" |
10 #include "device/bluetooth/bluetooth_adapter_factory.h" | 10 #include "device/bluetooth/bluetooth_adapter_factory.h" |
11 #include "device/bluetooth/public/interfaces/adapter.mojom.h" | 11 #include "device/bluetooth/public/interfaces/adapter.mojom.h" |
12 | 12 |
13 namespace bluetooth { | 13 namespace bluetooth { |
14 | 14 |
15 // Implementation of Mojo Adapter located in | 15 // Implementation of Mojo Adapter located in |
16 // device/bluetooth/public/interfaces/adapter.mojom. | 16 // device/bluetooth/public/interfaces/adapter.mojom. |
17 // It handles requests for Bluetooth adapter capabilities | 17 // It handles requests for Bluetooth adapter capabilities |
18 // and devices and uses the platform abstraction of device/bluetooth. | 18 // and devices and uses the platform abstraction of device/bluetooth. |
19 class Adapter : public mojom::Adapter, | 19 class Adapter : public mojom::Adapter, |
20 public device::BluetoothAdapter::Observer { | 20 public device::BluetoothAdapter::Observer { |
21 public: | 21 public: |
22 explicit Adapter(scoped_refptr<device::BluetoothAdapter> adapter); | 22 explicit Adapter(scoped_refptr<device::BluetoothAdapter> adapter); |
23 ~Adapter() override; | 23 ~Adapter() override; |
24 | 24 |
25 // mojom::Adapter overrides: | 25 // mojom::Adapter overrides: |
| 26 void GetInfo(const GetInfoCallback& callback) override; |
26 void GetDevices(const GetDevicesCallback& callback) override; | 27 void GetDevices(const GetDevicesCallback& callback) override; |
27 void SetClient(mojom::AdapterClientPtr client) override; | 28 void SetClient(mojom::AdapterClientPtr client) override; |
28 | 29 |
29 // device::BluetoothAdapter::Observer overrides: | 30 // device::BluetoothAdapter::Observer overrides: |
30 void DeviceAdded(device::BluetoothAdapter* adapter, | 31 void DeviceAdded(device::BluetoothAdapter* adapter, |
31 device::BluetoothDevice* device) override; | 32 device::BluetoothDevice* device) override; |
32 void DeviceRemoved(device::BluetoothAdapter* adapter, | 33 void DeviceRemoved(device::BluetoothAdapter* adapter, |
33 device::BluetoothDevice* device) override; | 34 device::BluetoothDevice* device) override; |
34 | 35 |
35 private: | 36 private: |
36 // Creates a mojom::DeviceInfo using info from the given |device|. | 37 // Creates a mojom::DeviceInfo using info from the given |device|. |
37 static mojom::DeviceInfoPtr ConstructDeviceInfoStruct( | 38 static mojom::DeviceInfoPtr ConstructDeviceInfoStruct( |
38 const device::BluetoothDevice* device); | 39 const device::BluetoothDevice* device); |
39 | 40 |
40 // The current Bluetooth adapter. | 41 // The current Bluetooth adapter. |
41 scoped_refptr<device::BluetoothAdapter> adapter_; | 42 scoped_refptr<device::BluetoothAdapter> adapter_; |
42 | 43 |
43 // The adapter client that listens to this service. | 44 // The adapter client that listens to this service. |
44 mojom::AdapterClientPtr client_; | 45 mojom::AdapterClientPtr client_; |
45 | 46 |
46 base::WeakPtrFactory<Adapter> weak_ptr_factory_; | 47 base::WeakPtrFactory<Adapter> weak_ptr_factory_; |
47 | 48 |
48 DISALLOW_COPY_AND_ASSIGN(Adapter); | 49 DISALLOW_COPY_AND_ASSIGN(Adapter); |
49 }; | 50 }; |
50 | 51 |
51 } // namespace bluetooth | 52 } // namespace bluetooth |
52 | 53 |
53 #endif // DEVICE_BLUETOOTH_ADAPTER_H_ | 54 #endif // DEVICE_BLUETOOTH_ADAPTER_H_ |
OLD | NEW |