| 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.h" | 5 #include "components/proximity_auth/bluetooth_connection.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" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 Disconnect(); | 35 Disconnect(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void BluetoothConnection::Connect() { | 38 void BluetoothConnection::Connect() { |
| 39 if (status() != DISCONNECTED) { | 39 if (status() != DISCONNECTED) { |
| 40 PA_LOG(WARNING) | 40 PA_LOG(WARNING) |
| 41 << "Ignoring attempt to connect a non-disconnected connection."; | 41 << "Ignoring attempt to connect a non-disconnected connection."; |
| 42 return; | 42 return; |
| 43 } | 43 } |
| 44 | 44 |
| 45 if (!device::BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) { | 45 if (!device::BluetoothAdapterFactory::IsBluetoothSupported()) { |
| 46 PA_LOG(WARNING) | 46 PA_LOG(WARNING) |
| 47 << "Connection failed: Bluetooth is unsupported on this platform."; | 47 << "Connection failed: Bluetooth is unsupported on this platform."; |
| 48 return; | 48 return; |
| 49 } | 49 } |
| 50 | 50 |
| 51 SetStatus(IN_PROGRESS); | 51 SetStatus(IN_PROGRESS); |
| 52 device::BluetoothAdapterFactory::GetAdapter( | 52 device::BluetoothAdapterFactory::GetAdapter( |
| 53 base::Bind(&BluetoothConnection::OnAdapterInitialized, | 53 base::Bind(&BluetoothConnection::OnAdapterInitialized, |
| 54 weak_ptr_factory_.GetWeakPtr())); | 54 weak_ptr_factory_.GetWeakPtr())); |
| 55 } | 55 } |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 PA_LOG(WARNING) << "Error receiving bytes: " << error_message; | 200 PA_LOG(WARNING) << "Error receiving bytes: " << error_message; |
| 201 | 201 |
| 202 // Post a task to delay the read until the socket is available, as | 202 // Post a task to delay the read until the socket is available, as |
| 203 // calling StartReceive at this point would error with ERR_IO_PENDING. | 203 // calling StartReceive at this point would error with ERR_IO_PENDING. |
| 204 base::ThreadTaskRunnerHandle::Get()->PostTask( | 204 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 205 FROM_HERE, base::Bind(&BluetoothConnection::StartReceive, | 205 FROM_HERE, base::Bind(&BluetoothConnection::StartReceive, |
| 206 weak_ptr_factory_.GetWeakPtr())); | 206 weak_ptr_factory_.GetWeakPtr())); |
| 207 } | 207 } |
| 208 | 208 |
| 209 } // namespace proximity_auth | 209 } // namespace proximity_auth |
| OLD | NEW |