Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: components/proximity_auth/bluetooth_connection.cc

Issue 633253002: [Easy Unlock] Port the BluetoothConnectionFinder class to native code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a missing #include Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « components/proximity_auth/BUILD.gn ('k') | components/proximity_auth/bluetooth_connection_finder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698