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. | |
125 Disconnect(); | 123 Disconnect(); |
126 return; | 124 return; |
127 } | 125 } |
128 | 126 |
129 adapter_ = adapter; | 127 adapter_ = adapter; |
130 adapter_->AddObserver(this); | 128 adapter_->AddObserver(this); |
131 | 129 |
132 base::WeakPtr<BluetoothConnection> weak_this = weak_ptr_factory_.GetWeakPtr(); | 130 base::WeakPtr<BluetoothConnection> weak_this = weak_ptr_factory_.GetWeakPtr(); |
133 ConnectToService( | 131 ConnectToService( |
134 bluetooth_device, | 132 bluetooth_device, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 192 |
195 // Post a task to delay the read until the socket is available, as | 193 // Post a task to delay the read until the socket is available, as |
196 // calling StartReceive at this point would error with ERR_IO_PENDING. | 194 // calling StartReceive at this point would error with ERR_IO_PENDING. |
197 base::MessageLoop::current()->PostTask( | 195 base::MessageLoop::current()->PostTask( |
198 FROM_HERE, | 196 FROM_HERE, |
199 base::Bind(&BluetoothConnection::StartReceive, | 197 base::Bind(&BluetoothConnection::StartReceive, |
200 weak_ptr_factory_.GetWeakPtr())); | 198 weak_ptr_factory_.GetWeakPtr())); |
201 } | 199 } |
202 | 200 |
203 } // namespace proximity_auth | 201 } // namespace proximity_auth |
OLD | NEW |