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

Side by Side Diff: device/bluetooth/adapter.h

Issue 2448713002: bluetooth: Add Device connection logic and accompanying user interface. (Closed)
Patch Set: Remove binding variable in Device.Create Created 4 years, 1 month 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
« no previous file with comments | « device/bluetooth/BUILD.gn ('k') | device/bluetooth/adapter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory>
8 #include <string> 9 #include <string>
9 10
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
12 #include "device/bluetooth/bluetooth_adapter.h" 13 #include "device/bluetooth/bluetooth_adapter.h"
14 #include "device/bluetooth/bluetooth_gatt_connection.h"
13 #include "device/bluetooth/public/interfaces/adapter.mojom.h" 15 #include "device/bluetooth/public/interfaces/adapter.mojom.h"
14 #include "device/bluetooth/public/interfaces/device.mojom.h" 16 #include "device/bluetooth/public/interfaces/device.mojom.h"
15 17
16 namespace bluetooth { 18 namespace bluetooth {
17 19
18 // Implementation of Mojo Adapter located in 20 // Implementation of Mojo Adapter located in
19 // device/bluetooth/public/interfaces/adapter.mojom. 21 // device/bluetooth/public/interfaces/adapter.mojom.
20 // It handles requests for Bluetooth adapter capabilities 22 // It handles requests for Bluetooth adapter capabilities
21 // and devices and uses the platform abstraction of device/bluetooth. 23 // and devices and uses the platform abstraction of device/bluetooth.
22 class Adapter : public mojom::Adapter, 24 class Adapter : public mojom::Adapter,
23 public device::BluetoothAdapter::Observer { 25 public device::BluetoothAdapter::Observer {
24 public: 26 public:
25 explicit Adapter(scoped_refptr<device::BluetoothAdapter> adapter); 27 explicit Adapter(scoped_refptr<device::BluetoothAdapter> adapter);
26 ~Adapter() override; 28 ~Adapter() override;
27 29
28 // mojom::Adapter overrides: 30 // mojom::Adapter overrides:
29 void GetInfo(const GetInfoCallback& callback) override; 31 void GetInfo(const GetInfoCallback& callback) override;
30 void GetDevice(const std::string& address, 32 void ConnectToDevice(const std::string& address,
31 const GetDeviceCallback& callback) override; 33 const ConnectToDeviceCallback& callback) override;
32 void GetDevices(const GetDevicesCallback& callback) override; 34 void GetDevices(const GetDevicesCallback& callback) override;
33 void SetClient(mojom::AdapterClientPtr client) override; 35 void SetClient(mojom::AdapterClientPtr client) override;
34 36
35 // device::BluetoothAdapter::Observer overrides: 37 // device::BluetoothAdapter::Observer overrides:
36 void DeviceAdded(device::BluetoothAdapter* adapter, 38 void DeviceAdded(device::BluetoothAdapter* adapter,
37 device::BluetoothDevice* device) override; 39 device::BluetoothDevice* device) override;
38 void DeviceRemoved(device::BluetoothAdapter* adapter, 40 void DeviceRemoved(device::BluetoothAdapter* adapter,
39 device::BluetoothDevice* device) override; 41 device::BluetoothDevice* device) override;
40 void DeviceChanged(device::BluetoothAdapter* adapter, 42 void DeviceChanged(device::BluetoothAdapter* adapter,
41 device::BluetoothDevice* device) override; 43 device::BluetoothDevice* device) override;
42 44
43 private: 45 private:
46 void OnGattConnected(
47 const ConnectToDeviceCallback& callback,
48 std::unique_ptr<device::BluetoothGattConnection> connection);
49
50 void OnConnectError(const ConnectToDeviceCallback& callback,
51 device::BluetoothDevice::ConnectErrorCode error_code);
52
44 // The current Bluetooth adapter. 53 // The current Bluetooth adapter.
45 scoped_refptr<device::BluetoothAdapter> adapter_; 54 scoped_refptr<device::BluetoothAdapter> adapter_;
46 55
47 // The adapter client that listens to this service. 56 // The adapter client that listens to this service.
48 mojom::AdapterClientPtr client_; 57 mojom::AdapterClientPtr client_;
49 58
50 base::WeakPtrFactory<Adapter> weak_ptr_factory_; 59 base::WeakPtrFactory<Adapter> weak_ptr_factory_;
51 60
52 DISALLOW_COPY_AND_ASSIGN(Adapter); 61 DISALLOW_COPY_AND_ASSIGN(Adapter);
53 }; 62 };
54 63
55 } // namespace bluetooth 64 } // namespace bluetooth
56 65
57 #endif // DEVICE_BLUETOOTH_ADAPTER_H_ 66 #endif // DEVICE_BLUETOOTH_ADAPTER_H_
OLDNEW
« no previous file with comments | « device/bluetooth/BUILD.gn ('k') | device/bluetooth/adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698