Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: chrome/browser/ui/webui/bluetooth_internals/services/bluetooth_adapter_service.h

Issue 2372433002: POC for adapter service (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_WEBUI_BLUETOOTH_INTERNALS_SERVICES_BLUETOOTH_ADAPTER_S ERVICE_H_
6 #define CHROME_BROWSER_UI_WEBUI_BLUETOOTH_INTERNALS_SERVICES_BLUETOOTH_ADAPTER_S ERVICE_H_
7
8 #include <set>
9 #include <string>
10
11 #include "base/macros.h"
12 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals.mojom. h"
14 #include "chrome/browser/ui/webui/mojo_web_ui_handler.h"
15 #include "device/bluetooth/bluetooth_adapter.h"
16 #include "device/bluetooth/bluetooth_adapter_factory.h"
17 #include "mojo/public/cpp/bindings/binding.h"
18
19 // Implementation of Mojo BluetoothAdapter located in
20 // device/bluetooth/public/interfaces/bluetooth.mojom.
21 // It handles requests for Bluetooth adapter capabilities
22 // and devices coming from the chrome://bluetooth-internals
23 // page and uses the platform abstraction of device/bluetooth.
24 // This class is instantiated on-demand via the GetAdapterService
25 // function in BluetoothInternalsUI which creates a strong Mojo
26 // binding that manages the lifetime of an instance of this class.
27 class BluetoothAdapterService : public bluetooth::mojom::Adapter,
28 public device::BluetoothAdapter::Observer {
29 public:
30 explicit BluetoothAdapterService();
31 ~BluetoothAdapterService() override;
32
33 static void Create(bluetooth::mojom::AdapterRequest request);
34
35 void SetClient(bluetooth::mojom::AdapterClientPtr client_) override;
36
37 // bluetooth::mojom::AdapterService overrides:
38 void GetDevices(const GetDevicesCallback& callback) override;
39
40 // device::BluetoothAdapter::Observer overrides:
41 void DeviceAdded(device::BluetoothAdapter* adapter,
42 device::BluetoothDevice* device) override;
43
44 void DeviceRemoved(device::BluetoothAdapter* adapter,
45 device::BluetoothDevice* device) override;
46
47 private:
48 bluetooth::mojom::DeviceInfoPtr ConstructDeviceInfoStruct(
49 device::BluetoothDevice* device);
50 scoped_refptr<device::BluetoothAdapter> GetAdapter();
51 void GetDevicesImpl(const GetDevicesCallback& callback,
52 scoped_refptr<device::BluetoothAdapter> adapter);
53 void OnGetAdapter(scoped_refptr<device::BluetoothAdapter> adapter);
54
55 scoped_refptr<device::BluetoothAdapter> adapter_;
56 std::set<std::string> addresses_;
57 bluetooth::mojom::AdapterClientPtr client_;
58 base::WeakPtrFactory<BluetoothAdapterService> weak_ptr_factory_;
59
60 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterService);
61 };
62
63 #endif // CHROME_BROWSER_UI_WEBUI_BLUETOOTH_INTERNALS_SERVICES_BLUETOOTH_ADAPTE R_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698