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> |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 67 |
68 // These functions should be only used in tests. | 68 // These functions should be only used in tests. |
69 void SetDelegateForTesting(TestDelegate* delegate); | 69 void SetDelegateForTesting(TestDelegate* delegate); |
70 scoped_refptr<device::BluetoothAdapter> GetAdapterForTesting(); | 70 scoped_refptr<device::BluetoothAdapter> GetAdapterForTesting(); |
71 | 71 |
72 private: | 72 private: |
73 friend class chromeos::BluetoothHostPairingNoInputTest; | 73 friend class chromeos::BluetoothHostPairingNoInputTest; |
74 | 74 |
75 void ChangeStage(Stage new_stage); | 75 void ChangeStage(Stage new_stage); |
76 void SendHostStatus(); | 76 void SendHostStatus(); |
| 77 void SendErrorCodeAndMessage(); |
77 | 78 |
78 void OnGetAdapter(scoped_refptr<device::BluetoothAdapter> adapter); | 79 void OnGetAdapter(scoped_refptr<device::BluetoothAdapter> adapter); |
79 void SetPowered(); | 80 void SetPowered(); |
80 void OnSetPowered(); | 81 void OnSetPowered(); |
81 void OnCreateService(scoped_refptr<device::BluetoothSocket> socket); | 82 void OnCreateService(scoped_refptr<device::BluetoothSocket> socket); |
82 void OnSetDiscoverable(bool change_stage); | 83 void OnSetDiscoverable(bool change_stage); |
83 void OnAccept(const device::BluetoothDevice* device, | 84 void OnAccept(const device::BluetoothDevice* device, |
84 scoped_refptr<device::BluetoothSocket> socket); | 85 scoped_refptr<device::BluetoothSocket> socket); |
85 void OnSendComplete(int bytes_sent); | 86 void OnSendComplete(int bytes_sent); |
86 void OnReceiveComplete(int bytes, scoped_refptr<net::IOBuffer> io_buffer); | 87 void OnReceiveComplete(int bytes, scoped_refptr<net::IOBuffer> io_buffer); |
(...skipping 15 matching lines...) Expand all Loading... |
102 void RemoveObserver(Observer* observer) override; | 103 void RemoveObserver(Observer* observer) override; |
103 Stage GetCurrentStage() override; | 104 Stage GetCurrentStage() override; |
104 void StartPairing() override; | 105 void StartPairing() override; |
105 std::string GetDeviceName() override; | 106 std::string GetDeviceName() override; |
106 std::string GetConfirmationCode() override; | 107 std::string GetConfirmationCode() override; |
107 std::string GetEnrollmentDomain() override; | 108 std::string GetEnrollmentDomain() override; |
108 void OnNetworkConnectivityChanged(Connectivity connectivity_status) override; | 109 void OnNetworkConnectivityChanged(Connectivity connectivity_status) override; |
109 void OnUpdateStatusChanged(UpdateStatus update_status) override; | 110 void OnUpdateStatusChanged(UpdateStatus update_status) override; |
110 void OnEnrollmentStatusChanged(EnrollmentStatus enrollment_status) override; | 111 void OnEnrollmentStatusChanged(EnrollmentStatus enrollment_status) override; |
111 void SetPermanentId(const std::string& permanent_id) override; | 112 void SetPermanentId(const std::string& permanent_id) override; |
| 113 void SetErrorCodeAndMessage(int error_code, |
| 114 const std::string& error_message) override; |
112 void Reset() override; | 115 void Reset() override; |
113 | 116 |
114 // ProtoDecoder::Observer: | 117 // ProtoDecoder::Observer: |
115 void OnHostStatusMessage(const pairing_api::HostStatus& message) override; | 118 void OnHostStatusMessage(const pairing_api::HostStatus& message) override; |
116 void OnConfigureHostMessage( | 119 void OnConfigureHostMessage( |
117 const pairing_api::ConfigureHost& message) override; | 120 const pairing_api::ConfigureHost& message) override; |
118 void OnPairDevicesMessage(const pairing_api::PairDevices& message) override; | 121 void OnPairDevicesMessage(const pairing_api::PairDevices& message) override; |
119 void OnCompleteSetupMessage( | 122 void OnCompleteSetupMessage( |
120 const pairing_api::CompleteSetup& message) override; | 123 const pairing_api::CompleteSetup& message) override; |
121 void OnErrorMessage(const pairing_api::Error& message) override; | 124 void OnErrorMessage(const pairing_api::Error& message) override; |
(...skipping 19 matching lines...) Expand all Loading... |
141 Stage current_stage_; | 144 Stage current_stage_; |
142 std::string confirmation_code_; | 145 std::string confirmation_code_; |
143 std::string enrollment_domain_; | 146 std::string enrollment_domain_; |
144 Connectivity connectivity_status_; | 147 Connectivity connectivity_status_; |
145 UpdateStatus update_status_; | 148 UpdateStatus update_status_; |
146 EnrollmentStatus enrollment_status_; | 149 EnrollmentStatus enrollment_status_; |
147 std::string permanent_id_; | 150 std::string permanent_id_; |
148 std::string controller_device_address_; | 151 std::string controller_device_address_; |
149 bool was_powered_ = false; | 152 bool was_powered_ = false; |
150 | 153 |
| 154 // The format of the |error_code_| is: |
| 155 // [0, "no error"] |
| 156 // [1*, "network error"] |
| 157 // [2*, "authentication error"], e.g., [21, "Service unavailable"], ... |
| 158 // [3*, "enrollment error"], e.g., [31, "DMserver registration error"], ... |
| 159 // [4*, "other error"] |
| 160 // The |error_code_| and |error_message_| will pass over to the master device |
| 161 // to assist error diagnosis. |
| 162 int error_code_ = 0; |
| 163 std::string error_message_; |
| 164 |
151 scoped_refptr<device::BluetoothAdapter> adapter_; | 165 scoped_refptr<device::BluetoothAdapter> adapter_; |
152 scoped_refptr<device::BluetoothSocket> service_socket_; | 166 scoped_refptr<device::BluetoothSocket> service_socket_; |
153 scoped_refptr<device::BluetoothSocket> controller_socket_; | 167 scoped_refptr<device::BluetoothSocket> controller_socket_; |
154 std::unique_ptr<ProtoDecoder> proto_decoder_; | 168 std::unique_ptr<ProtoDecoder> proto_decoder_; |
155 TestDelegate* delegate_ = nullptr; | 169 TestDelegate* delegate_ = nullptr; |
156 | 170 |
157 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; | 171 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; |
158 base::ThreadChecker thread_checker_; | 172 base::ThreadChecker thread_checker_; |
159 base::ObserverList<Observer> observers_; | 173 base::ObserverList<Observer> observers_; |
160 base::WeakPtrFactory<BluetoothHostPairingController> ptr_factory_; | 174 base::WeakPtrFactory<BluetoothHostPairingController> ptr_factory_; |
161 | 175 |
162 DISALLOW_COPY_AND_ASSIGN(BluetoothHostPairingController); | 176 DISALLOW_COPY_AND_ASSIGN(BluetoothHostPairingController); |
163 }; | 177 }; |
164 | 178 |
165 } // namespace pairing_chromeos | 179 } // namespace pairing_chromeos |
166 | 180 |
167 #endif // COMPONENTS_PAIRING_BLUETOOTH_HOST_PAIRING_CONTROLLER_H_ | 181 #endif // COMPONENTS_PAIRING_BLUETOOTH_HOST_PAIRING_CONTROLLER_H_ |
OLD | NEW |