Chromium Code Reviews| Index: chrome/browser/ui/webui/bluetooth_internals/services/bluetooth_adapter_service.h |
| diff --git a/chrome/browser/ui/webui/bluetooth_internals/services/bluetooth_adapter_service.h b/chrome/browser/ui/webui/bluetooth_internals/services/bluetooth_adapter_service.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..470ccb5e9b640a3292065fc1090d25021c11dc97 |
| --- /dev/null |
| +++ b/chrome/browser/ui/webui/bluetooth_internals/services/bluetooth_adapter_service.h |
| @@ -0,0 +1,59 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_UI_WEBUI_BLUETOOTH_INTERNALS_SERVICES_BLUETOOTH_ADAPTER_SERVICE_H_ |
| +#define CHROME_BROWSER_UI_WEBUI_BLUETOOTH_INTERNALS_SERVICES_BLUETOOTH_ADAPTER_SERVICE_H_ |
| + |
| +#include <set> |
| +#include <string> |
| + |
| +#include "base/macros.h" |
| +#include "base/strings/utf_string_conversions.h" |
| +#include "chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals.mojom.h" |
| +#include "chrome/browser/ui/webui/mojo_web_ui_handler.h" |
| +#include "device/bluetooth/bluetooth_adapter.h" |
| +#include "device/bluetooth/bluetooth_adapter_factory.h" |
| +#include "mojo/public/cpp/bindings/binding.h" |
| + |
| +// Implementation of Mojo BluetoothAdapter located in |
|
ortuno
2016/09/26 01:57:56
Should this be under the bluetooth: namespace?
scheib
2016/09/26 18:00:37
I think yes, and the bluetooth service implementat
mbrunson
2016/09/28 02:18:22
I've renamed and moved this to device/bluetooth.
|
| +// device/bluetooth/public/interfaces/bluetooth.mojom. |
| +// It handles requests for Bluetooth adapter capabilities |
| +// and devices coming from the chrome://bluetooth-internals |
| +// page and uses the platform abstraction of device/bluetooth. |
| +// This class is instantiated on-demand via the GetAdapterService |
| +// function in BluetoothInternalsUI which creates a strong Mojo |
| +// binding that manages the lifetime of an instance of this class. |
| +class BluetoothAdapterService : public bluetooth::mojom::Adapter, |
| + public device::BluetoothAdapter::Observer { |
| + public: |
| + explicit BluetoothAdapterService(bluetooth::mojom::AdapterClientPtr client); |
| + ~BluetoothAdapterService() override; |
| + |
| + // bluetooth::mojom::AdapterService overrides: |
| + void GetDevices(const GetDevicesCallback& callback) override; |
| + |
| + // device::BluetoothAdapter::Observer overrides: |
| + void DeviceAdded(device::BluetoothAdapter* adapter, |
| + device::BluetoothDevice* device) override; |
| + |
| + void DeviceRemoved(device::BluetoothAdapter* adapter, |
| + device::BluetoothDevice* device) override; |
| + |
| + private: |
| + bluetooth::mojom::DeviceInfoPtr ConstructDeviceInfoStruct( |
|
ortuno
2016/09/26 01:57:56
The order of declaration should match the order of
mbrunson
2016/09/28 02:18:22
Done.
|
| + device::BluetoothDevice* device); |
| + scoped_refptr<device::BluetoothAdapter> GetAdapter(); |
| + void GetDevicesImpl(const GetDevicesCallback& callback, |
| + scoped_refptr<device::BluetoothAdapter> adapter); |
| + void OnGetAdapter(scoped_refptr<device::BluetoothAdapter> adapter); |
| + |
| + scoped_refptr<device::BluetoothAdapter> adapter_; |
|
ortuno
2016/09/26 01:57:56
nit: Could you add comments for these?
mbrunson
2016/09/28 02:18:22
Done.
|
| + std::set<std::string> addresses_; |
|
ortuno
2016/09/26 01:57:56
q: Why do you keep track of the devices? In other
mbrunson
2016/09/28 02:18:22
I have removed this and simplified the adapter ser
|
| + bluetooth::mojom::AdapterClientPtr client_; |
| + base::WeakPtrFactory<BluetoothAdapterService> weak_ptr_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterService); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_UI_WEBUI_BLUETOOTH_INTERNALS_SERVICES_BLUETOOTH_ADAPTER_SERVICE_H_ |