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

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

Issue 681903002: Clear the bluetooth discoverable bit when OOBE is finished on Remora. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 | « no previous file | no next file » | 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 #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
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 Reset();
achuithb 2014/10/27 21:32:34 This also calls ChangeStage, which calls the obser
69 adapter_->RemoveObserver(this);
70 } 69 }
71 70
72 void BluetoothHostPairingController::ChangeStage(Stage new_stage) { 71 void BluetoothHostPairingController::ChangeStage(Stage new_stage) {
73 if (current_stage_ == new_stage) 72 if (current_stage_ == new_stage)
74 return; 73 return;
75 VLOG(1) << "ChangeStage " << new_stage; 74 VLOG(1) << "ChangeStage " << new_stage;
76 current_stage_ = new_stage; 75 current_stage_ = new_stage;
77 FOR_EACH_OBSERVER(Observer, observers_, PairingStageChanged(new_stage)); 76 FOR_EACH_OBSERVER(Observer, observers_, PairingStageChanged(new_stage));
78 } 77 }
79 78
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 void BluetoothHostPairingController::Reset() { 133 void BluetoothHostPairingController::Reset() {
135 if (controller_socket_.get()) { 134 if (controller_socket_.get()) {
136 controller_socket_->Close(); 135 controller_socket_->Close();
137 controller_socket_ = NULL; 136 controller_socket_ = NULL;
138 } 137 }
139 138
140 if (service_socket_.get()) { 139 if (service_socket_.get()) {
141 service_socket_->Close(); 140 service_socket_->Close();
142 service_socket_ = NULL; 141 service_socket_ = NULL;
143 } 142 }
143
144 if (adapter_.get()) {
145 if (adapter_->IsDiscoverable()) {
146 adapter_->SetDiscoverable(false, base::Closure(), base::Closure());
147 }
148 adapter_->RemoveObserver(this);
149 adapter_ = NULL;
150 }
151
144 ChangeStage(STAGE_NONE); 152 ChangeStage(STAGE_NONE);
achuithb 2014/10/27 21:32:34 Should we get rid of this?
145 } 153 }
146 154
147 void BluetoothHostPairingController::OnGetAdapter( 155 void BluetoothHostPairingController::OnGetAdapter(
148 scoped_refptr<device::BluetoothAdapter> adapter) { 156 scoped_refptr<device::BluetoothAdapter> adapter) {
149 DCHECK(thread_checker_.CalledOnValidThread()); 157 DCHECK(thread_checker_.CalledOnValidThread());
150 DCHECK(!adapter_.get()); 158 DCHECK(!adapter_.get());
151 adapter_ = adapter; 159 adapter_ = adapter;
152 160
153 if (adapter_->IsPresent()) { 161 if (adapter_->IsPresent()) {
154 SetName(); 162 SetName();
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 } 283 }
276 284
277 void BluetoothHostPairingController::OnSetError() { 285 void BluetoothHostPairingController::OnSetError() {
278 adapter_->RemovePairingDelegate(this); 286 adapter_->RemovePairingDelegate(this);
279 ChangeStage(STAGE_INITIALIZATION_ERROR); 287 ChangeStage(STAGE_INITIALIZATION_ERROR);
280 } 288 }
281 289
282 void BluetoothHostPairingController::OnAcceptError( 290 void BluetoothHostPairingController::OnAcceptError(
283 const std::string& error_message) { 291 const std::string& error_message) {
284 LOG(ERROR) << error_message; 292 LOG(ERROR) << error_message;
285 Reset();
286 } 293 }
287 294
288 void BluetoothHostPairingController::OnSendError( 295 void BluetoothHostPairingController::OnSendError(
289 const std::string& error_message) { 296 const std::string& error_message) {
290 LOG(ERROR) << error_message; 297 LOG(ERROR) << error_message;
291 } 298 }
292 299
293 void BluetoothHostPairingController::OnReceiveError( 300 void BluetoothHostPairingController::OnReceiveError(
294 device::BluetoothSocket::ErrorReason reason, 301 device::BluetoothSocket::ErrorReason reason,
295 const std::string& error_message) { 302 const std::string& error_message) {
296 LOG(ERROR) << reason << ", " << error_message; 303 LOG(ERROR) << reason << ", " << error_message;
297 Reset();
298 } 304 }
299 305
300 void BluetoothHostPairingController::OnHostStatusMessage( 306 void BluetoothHostPairingController::OnHostStatusMessage(
301 const pairing_api::HostStatus& message) { 307 const pairing_api::HostStatus& message) {
302 NOTREACHED(); 308 NOTREACHED();
303 } 309 }
304 310
305 void BluetoothHostPairingController::OnConfigureHostMessage( 311 void BluetoothHostPairingController::OnConfigureHostMessage(
306 const pairing_api::ConfigureHost& message) { 312 const pairing_api::ConfigureHost& message) {
307 FOR_EACH_OBSERVER(Observer, observers_, 313 FOR_EACH_OBSERVER(Observer, observers_,
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 ChangeStage(STAGE_WAITING_FOR_CODE_CONFIRMATION); 461 ChangeStage(STAGE_WAITING_FOR_CODE_CONFIRMATION);
456 } 462 }
457 463
458 void BluetoothHostPairingController::AuthorizePairing( 464 void BluetoothHostPairingController::AuthorizePairing(
459 device::BluetoothDevice* device) { 465 device::BluetoothDevice* device) {
460 // Disallow unknown device. 466 // Disallow unknown device.
461 device->RejectPairing(); 467 device->RejectPairing();
462 } 468 }
463 469
464 } // namespace pairing_chromeos 470 } // namespace pairing_chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698