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

Side by Side Diff: components/pairing/bluetooth_host_pairing_controller.h

Issue 1957953003: [Merge to M50] [Chrome OS Bootstrapping]: Do not always power off the Bluetooth adapter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: Created 4 years, 7 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
« no previous file with comments | « components/pairing/DEPS ('k') | components/pairing/bluetooth_host_pairing_controller.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 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 "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "base/threading/thread_checker.h" 14 #include "base/threading/thread_checker.h"
15 #include "components/pairing/host_pairing_controller.h" 15 #include "components/pairing/host_pairing_controller.h"
16 #include "components/pairing/proto_decoder.h" 16 #include "components/pairing/proto_decoder.h"
17 #include "device/bluetooth/bluetooth_adapter.h" 17 #include "device/bluetooth/bluetooth_adapter.h"
18 #include "device/bluetooth/bluetooth_device.h" 18 #include "device/bluetooth/bluetooth_device.h"
19 #include "device/bluetooth/bluetooth_socket.h" 19 #include "device/bluetooth/bluetooth_socket.h"
20 #include "device/hid/input_service_linux.h"
20 21
21 namespace device { 22 namespace device {
22 class BluetoothAdapter; 23 class BluetoothAdapter;
23 } 24 }
24 25
25 namespace net { 26 namespace net {
26 class IOBuffer; 27 class IOBuffer;
27 } 28 }
28 29
29 namespace pairing_chromeos { 30 namespace pairing_chromeos {
30 31
31 class BluetoothHostPairingController 32 class BluetoothHostPairingController
32 : public HostPairingController, 33 : public HostPairingController,
33 public ProtoDecoder::Observer, 34 public ProtoDecoder::Observer,
34 public device::BluetoothAdapter::Observer, 35 public device::BluetoothAdapter::Observer,
35 public device::BluetoothDevice::PairingDelegate { 36 public device::BluetoothDevice::PairingDelegate {
36 public: 37 public:
37 typedef HostPairingController::Observer Observer; 38 using Observer = HostPairingController::Observer;
39 using InputDeviceInfo = device::InputServiceLinux::InputDeviceInfo;
38 40
39 BluetoothHostPairingController(); 41 explicit BluetoothHostPairingController(
42 const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner);
40 ~BluetoothHostPairingController() override; 43 ~BluetoothHostPairingController() override;
41 44
42 private: 45 private:
43 void ChangeStage(Stage new_stage); 46 void ChangeStage(Stage new_stage);
44 void SendHostStatus(); 47 void SendHostStatus();
45 void Reset(); 48 void Reset();
46 49
47 void OnGetAdapter(scoped_refptr<device::BluetoothAdapter> adapter); 50 void OnGetAdapter(scoped_refptr<device::BluetoothAdapter> adapter);
48 void SetName(); 51 void SetName();
49 void OnSetName(); 52 void OnSetName();
50 void OnSetPowered(); 53 void OnSetPowered();
51 void OnCreateService(scoped_refptr<device::BluetoothSocket> socket); 54 void OnCreateService(scoped_refptr<device::BluetoothSocket> socket);
52 void OnSetDiscoverable(bool change_stage); 55 void OnSetDiscoverable(bool change_stage);
53 void OnAccept(const device::BluetoothDevice* device, 56 void OnAccept(const device::BluetoothDevice* device,
54 scoped_refptr<device::BluetoothSocket> socket); 57 scoped_refptr<device::BluetoothSocket> socket);
55 void OnSendComplete(int bytes_sent); 58 void OnSendComplete(int bytes_sent);
56 void OnReceiveComplete(int bytes, scoped_refptr<net::IOBuffer> io_buffer); 59 void OnReceiveComplete(int bytes, scoped_refptr<net::IOBuffer> io_buffer);
57 60
58 void OnCreateServiceError(const std::string& message); 61 void OnCreateServiceError(const std::string& message);
59 void OnSetError(); 62 void OnSetError();
60 void OnAcceptError(const std::string& error_message); 63 void OnAcceptError(const std::string& error_message);
61 void OnSendError(const std::string& error_message); 64 void OnSendError(const std::string& error_message);
62 void OnReceiveError(device::BluetoothSocket::ErrorReason reason, 65 void OnReceiveError(device::BluetoothSocket::ErrorReason reason,
63 const std::string& error_message); 66 const std::string& error_message);
67 void PowerOffAdapterIfApplicable(const std::vector<InputDeviceInfo>& devices);
64 68
65 // HostPairingController: 69 // HostPairingController:
66 void AddObserver(Observer* observer) override; 70 void AddObserver(Observer* observer) override;
67 void RemoveObserver(Observer* observer) override; 71 void RemoveObserver(Observer* observer) override;
68 Stage GetCurrentStage() override; 72 Stage GetCurrentStage() override;
69 void StartPairing() override; 73 void StartPairing() override;
70 std::string GetDeviceName() override; 74 std::string GetDeviceName() override;
71 std::string GetConfirmationCode() override; 75 std::string GetConfirmationCode() override;
72 std::string GetEnrollmentDomain() override; 76 std::string GetEnrollmentDomain() override;
73 void OnNetworkConnectivityChanged(Connectivity connectivity_status) override; 77 void OnNetworkConnectivityChanged(Connectivity connectivity_status) override;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 UpdateStatus update_status_; 113 UpdateStatus update_status_;
110 EnrollmentStatus enrollment_status_; 114 EnrollmentStatus enrollment_status_;
111 std::string permanent_id_; 115 std::string permanent_id_;
112 bool was_powered_ = false; 116 bool was_powered_ = false;
113 117
114 scoped_refptr<device::BluetoothAdapter> adapter_; 118 scoped_refptr<device::BluetoothAdapter> adapter_;
115 scoped_refptr<device::BluetoothSocket> service_socket_; 119 scoped_refptr<device::BluetoothSocket> service_socket_;
116 scoped_refptr<device::BluetoothSocket> controller_socket_; 120 scoped_refptr<device::BluetoothSocket> controller_socket_;
117 scoped_ptr<ProtoDecoder> proto_decoder_; 121 scoped_ptr<ProtoDecoder> proto_decoder_;
118 122
123 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
119 base::ThreadChecker thread_checker_; 124 base::ThreadChecker thread_checker_;
120 base::ObserverList<Observer> observers_; 125 base::ObserverList<Observer> observers_;
121 base::WeakPtrFactory<BluetoothHostPairingController> ptr_factory_; 126 base::WeakPtrFactory<BluetoothHostPairingController> ptr_factory_;
122 127
123 DISALLOW_COPY_AND_ASSIGN(BluetoothHostPairingController); 128 DISALLOW_COPY_AND_ASSIGN(BluetoothHostPairingController);
124 }; 129 };
125 130
126 } // namespace pairing_chromeos 131 } // namespace pairing_chromeos
127 132
128 #endif // COMPONENTS_PAIRING_BLUETOOTH_HOST_PAIRING_CONTROLLER_H_ 133 #endif // COMPONENTS_PAIRING_BLUETOOTH_HOST_PAIRING_CONTROLLER_H_
OLDNEW
« no previous file with comments | « components/pairing/DEPS ('k') | components/pairing/bluetooth_host_pairing_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698