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