OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_PAIRING_BLUETOOTH_HOST_PAIRING_CONTROLLER_H_ | 5 #ifndef COMPONENTS_PAIRING_BLUETOOTH_HOST_PAIRING_CONTROLLER_H_ |
6 #define COMPONENTS_PAIRING_BLUETOOTH_HOST_PAIRING_CONTROLLER_H_ | 6 #define COMPONENTS_PAIRING_BLUETOOTH_HOST_PAIRING_CONTROLLER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
16 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
17 #include "components/pairing/host_pairing_controller.h" | 17 #include "components/pairing/host_pairing_controller.h" |
18 #include "components/pairing/proto_decoder.h" | 18 #include "components/pairing/proto_decoder.h" |
19 #include "device/bluetooth/bluetooth_adapter.h" | 19 #include "device/bluetooth/bluetooth_adapter.h" |
20 #include "device/bluetooth/bluetooth_device.h" | 20 #include "device/bluetooth/bluetooth_device.h" |
21 #include "device/bluetooth/bluetooth_socket.h" | 21 #include "device/bluetooth/bluetooth_socket.h" |
22 #include "device/hid/input_service_linux.h" | |
22 | 23 |
23 namespace device { | 24 namespace device { |
24 class BluetoothAdapter; | 25 class BluetoothAdapter; |
25 } | 26 } |
26 | 27 |
27 namespace net { | 28 namespace net { |
28 class IOBuffer; | 29 class IOBuffer; |
29 } | 30 } |
30 | 31 |
31 namespace pairing_chromeos { | 32 namespace pairing_chromeos { |
32 | 33 |
33 class BluetoothHostPairingController | 34 class BluetoothHostPairingController |
34 : public HostPairingController, | 35 : public HostPairingController, |
35 public ProtoDecoder::Observer, | 36 public ProtoDecoder::Observer, |
36 public device::BluetoothAdapter::Observer, | 37 public device::BluetoothAdapter::Observer, |
37 public device::BluetoothDevice::PairingDelegate { | 38 public device::BluetoothDevice::PairingDelegate { |
38 public: | 39 public: |
39 typedef HostPairingController::Observer Observer; | 40 typedef HostPairingController::Observer Observer; |
41 typedef device::InputServiceLinux::InputDeviceInfo InputDeviceInfo; | |
achuithb
2016/05/02 23:02:40
We prefer using, please switch this and HostingPai
| |
40 | 42 |
41 BluetoothHostPairingController(); | 43 BluetoothHostPairingController(); |
42 ~BluetoothHostPairingController() override; | 44 ~BluetoothHostPairingController() override; |
43 | 45 |
44 private: | 46 private: |
45 void ChangeStage(Stage new_stage); | 47 void ChangeStage(Stage new_stage); |
46 void SendHostStatus(); | 48 void SendHostStatus(); |
47 void Reset(); | 49 void Reset(); |
48 | 50 |
49 void OnGetAdapter(scoped_refptr<device::BluetoothAdapter> adapter); | 51 void OnGetAdapter(scoped_refptr<device::BluetoothAdapter> adapter); |
50 void SetName(); | 52 void SetName(); |
51 void OnSetName(); | 53 void OnSetName(); |
52 void OnSetPowered(); | 54 void OnSetPowered(); |
53 void OnCreateService(scoped_refptr<device::BluetoothSocket> socket); | 55 void OnCreateService(scoped_refptr<device::BluetoothSocket> socket); |
54 void OnSetDiscoverable(bool change_stage); | 56 void OnSetDiscoverable(bool change_stage); |
55 void OnAccept(const device::BluetoothDevice* device, | 57 void OnAccept(const device::BluetoothDevice* device, |
56 scoped_refptr<device::BluetoothSocket> socket); | 58 scoped_refptr<device::BluetoothSocket> socket); |
57 void OnSendComplete(int bytes_sent); | 59 void OnSendComplete(int bytes_sent); |
58 void OnReceiveComplete(int bytes, scoped_refptr<net::IOBuffer> io_buffer); | 60 void OnReceiveComplete(int bytes, scoped_refptr<net::IOBuffer> io_buffer); |
59 | 61 |
60 void OnCreateServiceError(const std::string& message); | 62 void OnCreateServiceError(const std::string& message); |
61 void OnSetError(); | 63 void OnSetError(); |
62 void OnAcceptError(const std::string& error_message); | 64 void OnAcceptError(const std::string& error_message); |
63 void OnSendError(const std::string& error_message); | 65 void OnSendError(const std::string& error_message); |
64 void OnReceiveError(device::BluetoothSocket::ErrorReason reason, | 66 void OnReceiveError(device::BluetoothSocket::ErrorReason reason, |
65 const std::string& error_message); | 67 const std::string& error_message); |
68 void PowerOffAdapterIfApplicable(const std::vector<InputDeviceInfo>& devices); | |
66 | 69 |
67 // HostPairingController: | 70 // HostPairingController: |
68 void AddObserver(Observer* observer) override; | 71 void AddObserver(Observer* observer) override; |
69 void RemoveObserver(Observer* observer) override; | 72 void RemoveObserver(Observer* observer) override; |
70 Stage GetCurrentStage() override; | 73 Stage GetCurrentStage() override; |
71 void StartPairing() override; | 74 void StartPairing() override; |
72 std::string GetDeviceName() override; | 75 std::string GetDeviceName() override; |
73 std::string GetConfirmationCode() override; | 76 std::string GetConfirmationCode() override; |
74 std::string GetEnrollmentDomain() override; | 77 std::string GetEnrollmentDomain() override; |
75 void OnNetworkConnectivityChanged(Connectivity connectivity_status) override; | 78 void OnNetworkConnectivityChanged(Connectivity connectivity_status) override; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 base::ThreadChecker thread_checker_; | 124 base::ThreadChecker thread_checker_; |
122 base::ObserverList<Observer> observers_; | 125 base::ObserverList<Observer> observers_; |
123 base::WeakPtrFactory<BluetoothHostPairingController> ptr_factory_; | 126 base::WeakPtrFactory<BluetoothHostPairingController> ptr_factory_; |
124 | 127 |
125 DISALLOW_COPY_AND_ASSIGN(BluetoothHostPairingController); | 128 DISALLOW_COPY_AND_ASSIGN(BluetoothHostPairingController); |
126 }; | 129 }; |
127 | 130 |
128 } // namespace pairing_chromeos | 131 } // namespace pairing_chromeos |
129 | 132 |
130 #endif // COMPONENTS_PAIRING_BLUETOOTH_HOST_PAIRING_CONTROLLER_H_ | 133 #endif // COMPONENTS_PAIRING_BLUETOOTH_HOST_PAIRING_CONTROLLER_H_ |
OLD | NEW |