OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_chromeos.h" | 5 #include "device/bluetooth/bluetooth_device_chromeos.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 bool BluetoothDeviceChromeOS::IsConnecting() const { | 212 bool BluetoothDeviceChromeOS::IsConnecting() const { |
213 return num_connecting_calls_ > 0; | 213 return num_connecting_calls_ > 0; |
214 } | 214 } |
215 | 215 |
216 BluetoothDeviceChromeOS::UUIDList BluetoothDeviceChromeOS::GetUUIDs() const { | 216 BluetoothDeviceChromeOS::UUIDList BluetoothDeviceChromeOS::GetUUIDs() const { |
217 BluetoothDeviceClient::Properties* properties = | 217 BluetoothDeviceClient::Properties* properties = |
218 DBusThreadManager::Get()->GetBluetoothDeviceClient()-> | 218 DBusThreadManager::Get()->GetBluetoothDeviceClient()-> |
219 GetProperties(object_path_); | 219 GetProperties(object_path_); |
220 DCHECK(properties); | 220 DCHECK(properties); |
221 | 221 |
222 return properties->uuids.value(); | 222 std::vector<device::BluetoothUUID> uuids; |
| 223 const std::vector<std::string> &dbus_uuids = properties->uuids.value(); |
| 224 for (std::vector<std::string>::const_iterator iter = dbus_uuids.begin(); |
| 225 iter != dbus_uuids.end(); ++iter) { |
| 226 device::BluetoothUUID uuid(*iter); |
| 227 DCHECK(uuid.IsValid()); |
| 228 uuids.push_back(uuid); |
| 229 } |
| 230 return uuids; |
223 } | 231 } |
224 | 232 |
225 bool BluetoothDeviceChromeOS::ExpectingPinCode() const { | 233 bool BluetoothDeviceChromeOS::ExpectingPinCode() const { |
226 return pairing_.get() && pairing_->ExpectingPinCode(); | 234 return pairing_.get() && pairing_->ExpectingPinCode(); |
227 } | 235 } |
228 | 236 |
229 bool BluetoothDeviceChromeOS::ExpectingPasskey() const { | 237 bool BluetoothDeviceChromeOS::ExpectingPasskey() const { |
230 return pairing_.get() && pairing_->ExpectingPasskey(); | 238 return pairing_.get() && pairing_->ExpectingPasskey(); |
231 } | 239 } |
232 | 240 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 RemoveDevice( | 345 RemoveDevice( |
338 adapter_->object_path_, | 346 adapter_->object_path_, |
339 object_path_, | 347 object_path_, |
340 base::Bind(&base::DoNothing), | 348 base::Bind(&base::DoNothing), |
341 base::Bind(&BluetoothDeviceChromeOS::OnForgetError, | 349 base::Bind(&BluetoothDeviceChromeOS::OnForgetError, |
342 weak_ptr_factory_.GetWeakPtr(), | 350 weak_ptr_factory_.GetWeakPtr(), |
343 error_callback)); | 351 error_callback)); |
344 } | 352 } |
345 | 353 |
346 void BluetoothDeviceChromeOS::ConnectToService( | 354 void BluetoothDeviceChromeOS::ConnectToService( |
347 const std::string& service_uuid, | 355 const device::BluetoothUUID& service_uuid, |
348 const SocketCallback& callback) { | 356 const SocketCallback& callback) { |
349 // TODO(keybuk): implement | 357 // TODO(keybuk): implement |
350 callback.Run(scoped_refptr<device::BluetoothSocket>()); | 358 callback.Run(scoped_refptr<device::BluetoothSocket>()); |
351 } | 359 } |
352 | 360 |
353 void BluetoothDeviceChromeOS::ConnectToProfile( | 361 void BluetoothDeviceChromeOS::ConnectToProfile( |
354 device::BluetoothProfile* profile, | 362 device::BluetoothProfile* profile, |
355 const base::Closure& callback, | 363 const base::Closure& callback, |
356 const ErrorCallback& error_callback) { | 364 const ErrorCallback& error_callback) { |
357 BluetoothProfileChromeOS* profile_chromeos = | 365 BluetoothProfileChromeOS* profile_chromeos = |
358 static_cast<BluetoothProfileChromeOS*>(profile); | 366 static_cast<BluetoothProfileChromeOS*>(profile); |
359 VLOG(1) << object_path_.value() << ": Connecting profile: " | 367 VLOG(1) << object_path_.value() << ": Connecting profile: " |
360 << profile_chromeos->uuid(); | 368 << profile_chromeos->uuid().canonical_value(); |
361 DBusThreadManager::Get()->GetBluetoothDeviceClient()-> | 369 DBusThreadManager::Get()->GetBluetoothDeviceClient()-> |
362 ConnectProfile( | 370 ConnectProfile( |
363 object_path_, | 371 object_path_, |
364 profile_chromeos->uuid(), | 372 profile_chromeos->uuid().canonical_value(), |
365 base::Bind( | 373 base::Bind( |
366 &BluetoothDeviceChromeOS::OnConnectProfile, | 374 &BluetoothDeviceChromeOS::OnConnectProfile, |
367 weak_ptr_factory_.GetWeakPtr(), | 375 weak_ptr_factory_.GetWeakPtr(), |
368 profile, | 376 profile, |
369 callback), | 377 callback), |
370 base::Bind( | 378 base::Bind( |
371 &BluetoothDeviceChromeOS::OnConnectProfileError, | 379 &BluetoothDeviceChromeOS::OnConnectProfileError, |
372 weak_ptr_factory_.GetWeakPtr(), | 380 weak_ptr_factory_.GetWeakPtr(), |
373 profile, | 381 profile, |
374 error_callback)); | 382 error_callback)); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 << error_name << ": " << error_message; | 568 << error_name << ": " << error_message; |
561 error_callback.Run(); | 569 error_callback.Run(); |
562 } | 570 } |
563 | 571 |
564 void BluetoothDeviceChromeOS::OnConnectProfile( | 572 void BluetoothDeviceChromeOS::OnConnectProfile( |
565 device::BluetoothProfile* profile, | 573 device::BluetoothProfile* profile, |
566 const base::Closure& callback) { | 574 const base::Closure& callback) { |
567 BluetoothProfileChromeOS* profile_chromeos = | 575 BluetoothProfileChromeOS* profile_chromeos = |
568 static_cast<BluetoothProfileChromeOS*>(profile); | 576 static_cast<BluetoothProfileChromeOS*>(profile); |
569 VLOG(1) << object_path_.value() << ": Profile connected: " | 577 VLOG(1) << object_path_.value() << ": Profile connected: " |
570 << profile_chromeos->uuid(); | 578 << profile_chromeos->uuid().canonical_value(); |
571 callback.Run(); | 579 callback.Run(); |
572 } | 580 } |
573 | 581 |
574 void BluetoothDeviceChromeOS::OnConnectProfileError( | 582 void BluetoothDeviceChromeOS::OnConnectProfileError( |
575 device::BluetoothProfile* profile, | 583 device::BluetoothProfile* profile, |
576 const ErrorCallback& error_callback, | 584 const ErrorCallback& error_callback, |
577 const std::string& error_name, | 585 const std::string& error_name, |
578 const std::string& error_message) { | 586 const std::string& error_message) { |
579 BluetoothProfileChromeOS* profile_chromeos = | 587 BluetoothProfileChromeOS* profile_chromeos = |
580 static_cast<BluetoothProfileChromeOS*>(profile); | 588 static_cast<BluetoothProfileChromeOS*>(profile); |
581 VLOG(1) << object_path_.value() << ": Profile connection failed: " | 589 VLOG(1) << object_path_.value() << ": Profile connection failed: " |
582 << profile_chromeos->uuid() << ": " | 590 << profile_chromeos->uuid().canonical_value() << ": " |
583 << error_name << ": " << error_message; | 591 << error_name << ": " << error_message; |
584 error_callback.Run(); | 592 error_callback.Run(); |
585 } | 593 } |
586 | 594 |
587 } // namespace chromeos | 595 } // namespace chromeos |
OLD | NEW |