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

Side by Side Diff: components/proximity_auth/ble/bluetooth_low_energy_connection_finder.cc

Issue 1102473003: Unlock Chrome when a phone with Smart Lock service is found. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_screen_lock
Patch Set: Prepare for review Created 5 years, 7 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/ble/bluetooth_low_energy_connection_finder.h " 5 #include "components/proximity_auth/ble/bluetooth_low_energy_connection_finder.h "
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 if (remote_service_uuid_ == *iter) { 147 if (remote_service_uuid_ == *iter) {
148 return true; 148 return true;
149 } 149 }
150 } 150 }
151 } 151 }
152 return false; 152 return false;
153 } 153 }
154 154
155 void BluetoothLowEnergyConnectionFinder::OnCreateConnectionError( 155 void BluetoothLowEnergyConnectionFinder::OnCreateConnectionError(
156 BluetoothDevice::ConnectErrorCode error_code) { 156 BluetoothDevice::ConnectErrorCode error_code) {
157 VLOG(1) << "Error creating connection"; 157 VLOG(1) << "Error creating connection: " << error_code;
158 } 158 }
159 159
160 void BluetoothLowEnergyConnectionFinder::OnConnectionCreated( 160 void BluetoothLowEnergyConnectionFinder::OnConnectionCreated(
161 scoped_ptr<BluetoothGattConnection> connection) { 161 scoped_ptr<BluetoothGattConnection> connection) {
162 VLOG(1) << "Connection created"; 162 VLOG(1) << "Connection created";
163 connected_ = true; 163 connected_ = true;
164 StopDiscoverySession(); 164 StopDiscoverySession();
165 connection_callback_.Run(connection.Pass()); 165 if (!connection_callback_.is_null()) {
166 connection_callback_.Run(connection.Pass());
167 connection_callback_.Reset();
168 }
166 } 169 }
167 170
168 void BluetoothLowEnergyConnectionFinder::CreateConnection( 171 void BluetoothLowEnergyConnectionFinder::CreateConnection(
169 device::BluetoothDevice* remote_device) { 172 device::BluetoothDevice* remote_device) {
170 VLOG(1) << "SmartLock service found (" 173 VLOG(1) << "SmartLock service found ("
171 << remote_service_uuid_.canonical_value() << ")\n" 174 << remote_service_uuid_.canonical_value() << ")\n"
172 << "device = " << remote_device->GetAddress() 175 << "device = " << remote_device->GetAddress()
173 << ", name = " << remote_device->GetName(); 176 << ", name = " << remote_device->GetName();
174 remote_device->CreateGattConnection( 177 remote_device->CreateGattConnection(
175 base::Bind(&BluetoothLowEnergyConnectionFinder::OnConnectionCreated, 178 base::Bind(&BluetoothLowEnergyConnectionFinder::OnConnectionCreated,
176 weak_ptr_factory_.GetWeakPtr()), 179 weak_ptr_factory_.GetWeakPtr()),
177 base::Bind(&BluetoothLowEnergyConnectionFinder::OnCreateConnectionError, 180 base::Bind(&BluetoothLowEnergyConnectionFinder::OnCreateConnectionError,
178 weak_ptr_factory_.GetWeakPtr())); 181 weak_ptr_factory_.GetWeakPtr()));
179 } 182 }
180 183
181 } // namespace proximity_auth 184 } // namespace proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698