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/shark_connection_listener.h" | 5 #include "components/pairing/shark_connection_listener.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/logging.h" | 9 #include "base/logging.h" |
8 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
9 #include "components/pairing/bluetooth_host_pairing_controller.h" | 11 #include "components/pairing/bluetooth_host_pairing_controller.h" |
10 | 12 |
11 namespace pairing_chromeos { | 13 namespace pairing_chromeos { |
12 | 14 |
13 SharkConnectionListener::SharkConnectionListener(OnConnectedCallback callback) | 15 SharkConnectionListener::SharkConnectionListener(OnConnectedCallback callback) |
14 : callback_(callback) { | 16 : callback_(callback) { |
15 controller_.reset(new BluetoothHostPairingController()); | 17 controller_.reset(new BluetoothHostPairingController()); |
16 controller_->AddObserver(this); | 18 controller_->AddObserver(this); |
17 controller_->StartPairing(); | 19 controller_->StartPairing(); |
18 } | 20 } |
19 | 21 |
20 SharkConnectionListener::~SharkConnectionListener() { | 22 SharkConnectionListener::~SharkConnectionListener() { |
21 if (controller_) | 23 if (controller_) |
22 controller_->RemoveObserver(this); | 24 controller_->RemoveObserver(this); |
23 } | 25 } |
24 | 26 |
25 void SharkConnectionListener::PairingStageChanged(Stage new_stage) { | 27 void SharkConnectionListener::PairingStageChanged(Stage new_stage) { |
26 if (new_stage == HostPairingController::STAGE_WAITING_FOR_CODE_CONFIRMATION) { | 28 if (new_stage == HostPairingController::STAGE_WAITING_FOR_CODE_CONFIRMATION) { |
27 controller_->RemoveObserver(this); | 29 controller_->RemoveObserver(this); |
28 callback_.Run(controller_.Pass()); | 30 callback_.Run(std::move(controller_)); |
29 callback_.Reset(); | 31 callback_.Reset(); |
30 } | 32 } |
31 } | 33 } |
32 | 34 |
33 } // namespace pairing_chromeos | 35 } // namespace pairing_chromeos |
OLD | NEW |