| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
| 14 #include "components/proximity_auth/bluetooth_connection.h" | 14 #include "components/proximity_auth/bluetooth_connection.h" |
| 15 #include "components/proximity_auth/logging/logging.h" | 15 #include "components/proximity_auth/logging/logging.h" |
| 16 #include "device/bluetooth/bluetooth_adapter_factory.h" | 16 #include "device/bluetooth/bluetooth_adapter_factory.h" |
| 17 | 17 |
| 18 using device::BluetoothAdapter; | 18 using device::BluetoothAdapter; |
| 19 | 19 |
| 20 namespace proximity_auth { | 20 namespace proximity_auth { |
| 21 | 21 |
| 22 BluetoothConnectionFinder::BluetoothConnectionFinder( | 22 BluetoothConnectionFinder::BluetoothConnectionFinder( |
| 23 const RemoteDevice& remote_device, | 23 const cryptauth::RemoteDevice& remote_device, |
| 24 const device::BluetoothUUID& uuid, | 24 const device::BluetoothUUID& uuid, |
| 25 const base::TimeDelta& polling_interval) | 25 const base::TimeDelta& polling_interval) |
| 26 : remote_device_(remote_device), | 26 : remote_device_(remote_device), |
| 27 uuid_(uuid), | 27 uuid_(uuid), |
| 28 polling_interval_(polling_interval), | 28 polling_interval_(polling_interval), |
| 29 has_delayed_poll_scheduled_(false), | 29 has_delayed_poll_scheduled_(false), |
| 30 weak_ptr_factory_(this) { | 30 weak_ptr_factory_(this) {} |
| 31 } | |
| 32 | 31 |
| 33 BluetoothConnectionFinder::~BluetoothConnectionFinder() { | 32 BluetoothConnectionFinder::~BluetoothConnectionFinder() { |
| 34 UnregisterAsObserver(); | 33 UnregisterAsObserver(); |
| 35 } | 34 } |
| 36 | 35 |
| 37 void BluetoothConnectionFinder::Find( | 36 void BluetoothConnectionFinder::Find( |
| 38 const ConnectionCallback& connection_callback) { | 37 const ConnectionCallback& connection_callback) { |
| 39 if (!device::BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) { | 38 if (!device::BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) { |
| 40 PA_LOG(WARNING) << "Bluetooth is unsupported on this platform. Aborting."; | 39 PA_LOG(WARNING) << "Bluetooth is unsupported on this platform. Aborting."; |
| 41 return; | 40 return; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 << "Connection failed! Scheduling another polling iteration."; | 197 << "Connection failed! Scheduling another polling iteration."; |
| 199 PostDelayedPoll(); | 198 PostDelayedPoll(); |
| 200 } | 199 } |
| 201 } | 200 } |
| 202 | 201 |
| 203 void BluetoothConnectionFinder::InvokeCallbackAsync() { | 202 void BluetoothConnectionFinder::InvokeCallbackAsync() { |
| 204 connection_callback_.Run(std::move(connection_)); | 203 connection_callback_.Run(std::move(connection_)); |
| 205 } | 204 } |
| 206 | 205 |
| 207 } // namespace proximity_auth | 206 } // namespace proximity_auth |
| OLD | NEW |