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

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

Issue 1958393002: Reset BluetoothHostPairingController in an earlier stage for normal user login flow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
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/shark_connection_listener.h" 5 #include "components/pairing/shark_connection_listener.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
11 #include "components/pairing/bluetooth_host_pairing_controller.h" 11 #include "components/pairing/bluetooth_host_pairing_controller.h"
12 12
13 namespace pairing_chromeos { 13 namespace pairing_chromeos {
14 14
15 SharkConnectionListener::SharkConnectionListener( 15 SharkConnectionListener::SharkConnectionListener(
16 const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner, 16 const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner,
17 OnConnectedCallback callback) 17 OnConnectedCallback callback)
18 : callback_(callback) { 18 : callback_(callback) {
19 controller_.reset(new BluetoothHostPairingController(file_task_runner)); 19 controller_.reset(new BluetoothHostPairingController(file_task_runner));
20 controller_->AddObserver(this); 20 controller_->AddObserver(this);
21 controller_->StartPairing(); 21 controller_->StartPairing();
22 } 22 }
23 23
24 SharkConnectionListener::~SharkConnectionListener() { 24 SharkConnectionListener::~SharkConnectionListener() {
25 if (controller_) 25 if (controller_)
26 controller_->RemoveObserver(this); 26 controller_->RemoveObserver(this);
27 } 27 }
28 28
29 void SharkConnectionListener::ResetHostPairingController() {
30 if (controller_.get()) {
31 controller_->Reset();
32 controller_->RemoveObserver(this);
33 }
34 }
35
29 void SharkConnectionListener::PairingStageChanged(Stage new_stage) { 36 void SharkConnectionListener::PairingStageChanged(Stage new_stage) {
30 if (new_stage == HostPairingController::STAGE_WAITING_FOR_CODE_CONFIRMATION 37 if (new_stage == HostPairingController::STAGE_WAITING_FOR_CODE_CONFIRMATION
31 // Code confirmation stage can be skipped if devices were paired before. 38 // Code confirmation stage can be skipped if devices were paired before.
32 || new_stage == HostPairingController::STAGE_SETUP_BASIC_CONFIGURATION) { 39 || new_stage == HostPairingController::STAGE_SETUP_BASIC_CONFIGURATION) {
33 controller_->RemoveObserver(this); 40 controller_->RemoveObserver(this);
34 callback_.Run(std::move(controller_)); 41 callback_.Run(std::move(controller_));
35 callback_.Reset(); 42 callback_.Reset();
36 } else if (new_stage != HostPairingController::STAGE_WAITING_FOR_CONTROLLER) { 43 } else if (new_stage != HostPairingController::STAGE_WAITING_FOR_CONTROLLER) {
37 LOG(ERROR) << "Unexpected stage " << new_stage; 44 LOG(ERROR) << "Unexpected stage " << new_stage;
38 } 45 }
39 } 46 }
40 47
41 } // namespace pairing_chromeos 48 } // namespace pairing_chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698