| 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..16a695b12ca9cb556ddedb9c8e29079a80242c3a
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/webui/bluetooth_internals/services/bluetooth_adapter_service.h
|
| @@ -0,0 +1,63 @@
|
| +// 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
|
| +// 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();
|
| + ~BluetoothAdapterService() override;
|
| +
|
| + static void Create(bluetooth::mojom::AdapterRequest request);
|
| +
|
| + void SetClient(bluetooth::mojom::AdapterClientPtr client_) 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(
|
| + 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_;
|
| + std::set<std::string> addresses_;
|
| + 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_
|
|
|