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

Side by Side Diff: device/bluetooth/bluetooth_device.cc

Issue 1341103004: Handle change of BLE address after pairing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ***ADDED BY MISTAKE, OMMIT *** Created 5 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
« no previous file with comments | « device/bluetooth/bluetooth_device.h ('k') | device/bluetooth/bluetooth_device_chromeos.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "device/bluetooth/bluetooth_device.h" 5 #include "device/bluetooth/bluetooth_device.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 196
197 bool BluetoothDevice::IsTrustable() const { 197 bool BluetoothDevice::IsTrustable() const {
198 // Sony PlayStation Dualshock3 198 // Sony PlayStation Dualshock3
199 if ((GetVendorID() == 0x054c && GetProductID() == 0x0268 && 199 if ((GetVendorID() == 0x054c && GetProductID() == 0x0268 &&
200 GetDeviceName() == "PLAYSTATION(R)3 Controller")) 200 GetDeviceName() == "PLAYSTATION(R)3 Controller"))
201 return true; 201 return true;
202 202
203 return false; 203 return false;
204 } 204 }
205 205
206 void BluetoothDevice::CreateGattConnection( 206 scoped_ptr<device::BluetoothGattConnection>
207 BluetoothDevice::CreateGattConnection(
207 const GattConnectionCallback& callback, 208 const GattConnectionCallback& callback,
208 const ConnectErrorCallback& error_callback) { 209 const ConnectErrorCallback& error_callback) {
209 create_gatt_connection_success_callbacks_.push_back(callback); 210 create_gatt_connection_success_callbacks_.push_back(callback);
210 create_gatt_connection_error_callbacks_.push_back(error_callback); 211 create_gatt_connection_error_callbacks_.push_back(error_callback);
211 212
212 if (IsGattConnected()) 213 if (IsGattConnected()) {
213 return DidConnectGatt(); 214 DidConnectGatt();
215 return ExistingGattConnection().Pass();
216 }
214 217
215 CreateGattConnectionImpl(); 218 return CreateGattConnectionImpl().Pass();
216 } 219 }
217 220
218 std::vector<BluetoothGattService*> 221 std::vector<BluetoothGattService*>
219 BluetoothDevice::GetGattServices() const { 222 BluetoothDevice::GetGattServices() const {
220 std::vector<BluetoothGattService*> services; 223 std::vector<BluetoothGattService*> services;
221 for (GattServiceMap::const_iterator iter = gatt_services_.begin(); 224 for (GattServiceMap::const_iterator iter = gatt_services_.begin();
222 iter != gatt_services_.end(); ++iter) 225 iter != gatt_services_.end(); ++iter)
223 services.push_back(iter->second); 226 services.push_back(iter->second);
224 return services; 227 return services;
225 } 228 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 base::DictionaryValue::Iterator iter(*services_data_); 285 base::DictionaryValue::Iterator iter(*services_data_);
283 while (!iter.IsAtEnd()) { 286 while (!iter.IsAtEnd()) {
284 BluetoothUUID uuid(iter.key()); 287 BluetoothUUID uuid(iter.key());
285 uuids.push_back(uuid); 288 uuids.push_back(uuid);
286 iter.Advance(); 289 iter.Advance();
287 } 290 }
288 return uuids; 291 return uuids;
289 } 292 }
290 293
291 void BluetoothDevice::DidConnectGatt() { 294 void BluetoothDevice::DidConnectGatt() {
295 VLOG(1) << "BluetoothDevice::DidConnectGatt";
292 for (const auto& callback : create_gatt_connection_success_callbacks_) { 296 for (const auto& callback : create_gatt_connection_success_callbacks_) {
293 callback.Run( 297 callback.Run();
294 make_scoped_ptr(new BluetoothGattConnection(adapter_, GetAddress())));
295 } 298 }
296 create_gatt_connection_success_callbacks_.clear(); 299 create_gatt_connection_success_callbacks_.clear();
297 create_gatt_connection_error_callbacks_.clear(); 300 create_gatt_connection_error_callbacks_.clear();
298 } 301 }
299 302
300 void BluetoothDevice::DidFailToConnectGatt(ConnectErrorCode error) { 303 void BluetoothDevice::DidFailToConnectGatt(ConnectErrorCode error) {
301 for (const auto& error_callback : create_gatt_connection_error_callbacks_) 304 for (const auto& error_callback : create_gatt_connection_error_callbacks_)
302 error_callback.Run(error); 305 error_callback.Run(error);
303 create_gatt_connection_success_callbacks_.clear(); 306 create_gatt_connection_success_callbacks_.clear();
304 create_gatt_connection_error_callbacks_.clear(); 307 create_gatt_connection_error_callbacks_.clear();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 base::BinaryValue::CreateWithCopiedBuffer(buffer, size)); 345 base::BinaryValue::CreateWithCopiedBuffer(buffer, size));
343 } 346 }
344 347
345 void BluetoothDevice::Pair(PairingDelegate* pairing_delegate, 348 void BluetoothDevice::Pair(PairingDelegate* pairing_delegate,
346 const base::Closure& callback, 349 const base::Closure& callback,
347 const ConnectErrorCallback& error_callback) { 350 const ConnectErrorCallback& error_callback) {
348 NOTREACHED(); 351 NOTREACHED();
349 } 352 }
350 353
351 } // namespace device 354 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_device.h ('k') | device/bluetooth/bluetooth_device_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698