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

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

Issue 2357383002: bluetooth: Add device list retrieval for chrome://bluetooth-internals (Closed)
Patch Set: Mojo interface and implementation fixes 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
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.
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(bluetooth::mojom::AdapterClientPtr client);
31 ~BluetoothAdapterService() override;
32
33 // bluetooth::mojom::AdapterService overrides:
34 void GetDevices(const GetDevicesCallback& callback) override;
35
36 // device::BluetoothAdapter::Observer overrides:
37 void DeviceAdded(device::BluetoothAdapter* adapter,
38 device::BluetoothDevice* device) override;
39
40 void DeviceRemoved(device::BluetoothAdapter* adapter,
41 device::BluetoothDevice* device) override;
42
43 private:
44 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.
45 device::BluetoothDevice* device);
46 scoped_refptr<device::BluetoothAdapter> GetAdapter();
47 void GetDevicesImpl(const GetDevicesCallback& callback,
48 scoped_refptr<device::BluetoothAdapter> adapter);
49 void OnGetAdapter(scoped_refptr<device::BluetoothAdapter> adapter);
50
51 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.
52 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
53 bluetooth::mojom::AdapterClientPtr client_;
54 base::WeakPtrFactory<BluetoothAdapterService> weak_ptr_factory_;
55
56 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterService);
57 };
58
59 #endif // CHROME_BROWSER_UI_WEBUI_BLUETOOTH_INTERNALS_SERVICES_BLUETOOTH_ADAPTE R_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698