| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/numerics/safe_conversions.h" | 9 #include "base/numerics/safe_conversions.h" |
| 10 #include "components/proximity_auth/bluetooth_util.h" | 10 #include "components/proximity_auth/bluetooth_util.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 base::Bind(&BluetoothConnection::OnReceiveError, weak_this)); | 113 base::Bind(&BluetoothConnection::OnReceiveError, weak_this)); |
| 114 } | 114 } |
| 115 | 115 |
| 116 void BluetoothConnection::OnAdapterInitialized( | 116 void BluetoothConnection::OnAdapterInitialized( |
| 117 scoped_refptr<device::BluetoothAdapter> adapter) { | 117 scoped_refptr<device::BluetoothAdapter> adapter) { |
| 118 const std::string address = remote_device().bluetooth_address; | 118 const std::string address = remote_device().bluetooth_address; |
| 119 device::BluetoothDevice* bluetooth_device = adapter->GetDevice(address); | 119 device::BluetoothDevice* bluetooth_device = adapter->GetDevice(address); |
| 120 if (!bluetooth_device) { | 120 if (!bluetooth_device) { |
| 121 VLOG(1) << "[BC] Device with address " << address | 121 VLOG(1) << "[BC] Device with address " << address |
| 122 << " is not known to the system Bluetooth daemon."; | 122 << " is not known to the system Bluetooth daemon."; |
| 123 // TOOD(isherman): Optimistically attempt to seek the device and connect |
| 124 // anyway, as was previously implemented in BluetoothConnectionFinder. |
| 123 Disconnect(); | 125 Disconnect(); |
| 124 return; | 126 return; |
| 125 } | 127 } |
| 126 | 128 |
| 127 adapter_ = adapter; | 129 adapter_ = adapter; |
| 128 adapter_->AddObserver(this); | 130 adapter_->AddObserver(this); |
| 129 | 131 |
| 130 base::WeakPtr<BluetoothConnection> weak_this = weak_ptr_factory_.GetWeakPtr(); | 132 base::WeakPtr<BluetoothConnection> weak_this = weak_ptr_factory_.GetWeakPtr(); |
| 131 ConnectToService( | 133 ConnectToService( |
| 132 bluetooth_device, | 134 bluetooth_device, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 194 |
| 193 // Post a task to delay the read until the socket is available, as | 195 // Post a task to delay the read until the socket is available, as |
| 194 // calling StartReceive at this point would error with ERR_IO_PENDING. | 196 // calling StartReceive at this point would error with ERR_IO_PENDING. |
| 195 base::MessageLoop::current()->PostTask( | 197 base::MessageLoop::current()->PostTask( |
| 196 FROM_HERE, | 198 FROM_HERE, |
| 197 base::Bind(&BluetoothConnection::StartReceive, | 199 base::Bind(&BluetoothConnection::StartReceive, |
| 198 weak_ptr_factory_.GetWeakPtr())); | 200 weak_ptr_factory_.GetWeakPtr())); |
| 199 } | 201 } |
| 200 | 202 |
| 201 } // namespace proximity_auth | 203 } // namespace proximity_auth |
| OLD | NEW |