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 #include "components/pairing/bluetooth_host_pairing_controller.h" | 5 #include "components/pairing/bluetooth_host_pairing_controller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/hash.h" | 8 #include "base/hash.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 BluetoothHostPairingController::BluetoothHostPairingController() | 58 BluetoothHostPairingController::BluetoothHostPairingController() |
59 : current_stage_(STAGE_NONE), | 59 : current_stage_(STAGE_NONE), |
60 update_status_(UPDATE_STATUS_UNKNOWN), | 60 update_status_(UPDATE_STATUS_UNKNOWN), |
61 enrollment_status_(ENROLLMENT_STATUS_UNKNOWN), | 61 enrollment_status_(ENROLLMENT_STATUS_UNKNOWN), |
62 device_(NULL), | 62 device_(NULL), |
63 proto_decoder_(new ProtoDecoder(this)), | 63 proto_decoder_(new ProtoDecoder(this)), |
64 ptr_factory_(this) { | 64 ptr_factory_(this) { |
65 } | 65 } |
66 | 66 |
67 BluetoothHostPairingController::~BluetoothHostPairingController() { | 67 BluetoothHostPairingController::~BluetoothHostPairingController() { |
68 if (adapter_.get()) | 68 if (adapter_.get()) { |
69 if (adapter_->IsDiscoverable()) { | |
70 adapter_->SetDiscoverable(false, base::Closure(), base::Closure()); | |
71 } | |
69 adapter_->RemoveObserver(this); | 72 adapter_->RemoveObserver(this); |
73 adapter_ = NULL; | |
achuithb
2014/10/27 21:47:32
nit: this is not necessary since this object's dat
Zachary Kuznia
2014/10/28 00:01:41
Acknowledged.
| |
74 } | |
70 } | 75 } |
71 | 76 |
72 void BluetoothHostPairingController::ChangeStage(Stage new_stage) { | 77 void BluetoothHostPairingController::ChangeStage(Stage new_stage) { |
73 if (current_stage_ == new_stage) | 78 if (current_stage_ == new_stage) |
74 return; | 79 return; |
75 VLOG(1) << "ChangeStage " << new_stage; | 80 VLOG(1) << "ChangeStage " << new_stage; |
76 current_stage_ = new_stage; | 81 current_stage_ = new_stage; |
77 FOR_EACH_OBSERVER(Observer, observers_, PairingStageChanged(new_stage)); | 82 FOR_EACH_OBSERVER(Observer, observers_, PairingStageChanged(new_stage)); |
78 } | 83 } |
79 | 84 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 } | 280 } |
276 | 281 |
277 void BluetoothHostPairingController::OnSetError() { | 282 void BluetoothHostPairingController::OnSetError() { |
278 adapter_->RemovePairingDelegate(this); | 283 adapter_->RemovePairingDelegate(this); |
279 ChangeStage(STAGE_INITIALIZATION_ERROR); | 284 ChangeStage(STAGE_INITIALIZATION_ERROR); |
280 } | 285 } |
281 | 286 |
282 void BluetoothHostPairingController::OnAcceptError( | 287 void BluetoothHostPairingController::OnAcceptError( |
283 const std::string& error_message) { | 288 const std::string& error_message) { |
284 LOG(ERROR) << error_message; | 289 LOG(ERROR) << error_message; |
285 Reset(); | |
286 } | 290 } |
287 | 291 |
288 void BluetoothHostPairingController::OnSendError( | 292 void BluetoothHostPairingController::OnSendError( |
289 const std::string& error_message) { | 293 const std::string& error_message) { |
290 LOG(ERROR) << error_message; | 294 LOG(ERROR) << error_message; |
291 } | 295 } |
292 | 296 |
293 void BluetoothHostPairingController::OnReceiveError( | 297 void BluetoothHostPairingController::OnReceiveError( |
294 device::BluetoothSocket::ErrorReason reason, | 298 device::BluetoothSocket::ErrorReason reason, |
295 const std::string& error_message) { | 299 const std::string& error_message) { |
296 LOG(ERROR) << reason << ", " << error_message; | 300 LOG(ERROR) << reason << ", " << error_message; |
297 Reset(); | |
298 } | 301 } |
299 | 302 |
300 void BluetoothHostPairingController::OnHostStatusMessage( | 303 void BluetoothHostPairingController::OnHostStatusMessage( |
301 const pairing_api::HostStatus& message) { | 304 const pairing_api::HostStatus& message) { |
302 NOTREACHED(); | 305 NOTREACHED(); |
303 } | 306 } |
304 | 307 |
305 void BluetoothHostPairingController::OnConfigureHostMessage( | 308 void BluetoothHostPairingController::OnConfigureHostMessage( |
306 const pairing_api::ConfigureHost& message) { | 309 const pairing_api::ConfigureHost& message) { |
307 FOR_EACH_OBSERVER(Observer, observers_, | 310 FOR_EACH_OBSERVER(Observer, observers_, |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
455 ChangeStage(STAGE_WAITING_FOR_CODE_CONFIRMATION); | 458 ChangeStage(STAGE_WAITING_FOR_CODE_CONFIRMATION); |
456 } | 459 } |
457 | 460 |
458 void BluetoothHostPairingController::AuthorizePairing( | 461 void BluetoothHostPairingController::AuthorizePairing( |
459 device::BluetoothDevice* device) { | 462 device::BluetoothDevice* device) { |
460 // Disallow unknown device. | 463 // Disallow unknown device. |
461 device->RejectPairing(); | 464 device->RejectPairing(); |
462 } | 465 } |
463 | 466 |
464 } // namespace pairing_chromeos | 467 } // namespace pairing_chromeos |
OLD | NEW |