| 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/proximity_auth/bluetooth_connection_finder.h" | 5 #include "components/proximity_auth/bluetooth_connection_finder.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/single_thread_task_runner.h" |
| 11 #include "base/thread_task_runner_handle.h" |
| 11 #include "components/proximity_auth/bluetooth_connection.h" | 12 #include "components/proximity_auth/bluetooth_connection.h" |
| 12 #include "device/bluetooth/bluetooth_adapter_factory.h" | 13 #include "device/bluetooth/bluetooth_adapter_factory.h" |
| 13 | 14 |
| 14 using device::BluetoothAdapter; | 15 using device::BluetoothAdapter; |
| 15 | 16 |
| 16 namespace proximity_auth { | 17 namespace proximity_auth { |
| 17 | 18 |
| 18 BluetoothConnectionFinder::BluetoothConnectionFinder( | 19 BluetoothConnectionFinder::BluetoothConnectionFinder( |
| 19 const RemoteDevice& remote_device, | 20 const RemoteDevice& remote_device, |
| 20 const device::BluetoothUUID& uuid, | 21 const device::BluetoothUUID& uuid, |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 if (connection_->IsConnected()) { | 128 if (connection_->IsConnected()) { |
| 128 base::TimeDelta elapsed = base::TimeTicks::Now() - start_time_; | 129 base::TimeDelta elapsed = base::TimeTicks::Now() - start_time_; |
| 129 VLOG(1) << "[BCF] Connection found! Elapsed Time: " | 130 VLOG(1) << "[BCF] Connection found! Elapsed Time: " |
| 130 << elapsed.InMilliseconds() << "ms."; | 131 << elapsed.InMilliseconds() << "ms."; |
| 131 UnregisterAsObserver(); | 132 UnregisterAsObserver(); |
| 132 connection_callback_.Run(connection_.Pass()); | 133 connection_callback_.Run(connection_.Pass()); |
| 133 } else if (old_status == Connection::IN_PROGRESS) { | 134 } else if (old_status == Connection::IN_PROGRESS) { |
| 134 VLOG(1) << "[BCF] Connection failed! Scheduling another polling iteration."; | 135 VLOG(1) << "[BCF] Connection failed! Scheduling another polling iteration."; |
| 135 connection_.reset(); | 136 connection_.reset(); |
| 136 has_delayed_poll_scheduled_ = true; | 137 has_delayed_poll_scheduled_ = true; |
| 137 base::MessageLoopProxy::current()->PostDelayedTask( | 138 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 138 FROM_HERE, | 139 FROM_HERE, base::Bind(&BluetoothConnectionFinder::DelayedPollIfReady, |
| 139 base::Bind(&BluetoothConnectionFinder::DelayedPollIfReady, | 140 weak_ptr_factory_.GetWeakPtr()), |
| 140 weak_ptr_factory_.GetWeakPtr()), | |
| 141 polling_interval_); | 141 polling_interval_); |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 | 144 |
| 145 } // namespace proximity_auth | 145 } // namespace proximity_auth |
| OLD | NEW |