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" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "chromeos/dbus/bluetooth_adapter_client.h" | 13 #include "chromeos/dbus/bluetooth_adapter_client.h" |
14 #include "chromeos/dbus/bluetooth_device_client.h" | 14 #include "chromeos/dbus/bluetooth_device_client.h" |
15 #include "chromeos/dbus/bluetooth_input_client.h" | 15 #include "chromeos/dbus/bluetooth_input_client.h" |
16 #include "chromeos/dbus/dbus_thread_manager.h" | 16 #include "chromeos/dbus/dbus_thread_manager.h" |
17 #include "dbus/bus.h" | 17 #include "dbus/bus.h" |
18 #include "device/bluetooth/bluetooth_adapter_chromeos.h" | 18 #include "device/bluetooth/bluetooth_adapter_chromeos.h" |
19 #include "device/bluetooth/bluetooth_pairing_chromeos.h" | 19 #include "device/bluetooth/bluetooth_pairing_chromeos.h" |
20 #include "device/bluetooth/bluetooth_profile_chromeos.h" | 20 #include "device/bluetooth/bluetooth_profile_chromeos.h" |
21 #include "device/bluetooth/bluetooth_socket.h" | 21 #include "device/bluetooth/bluetooth_socket.h" |
22 #include "third_party/cros_system_api/dbus/service_constants.h" | 22 #include "third_party/cros_system_api/dbus/service_constants.h" |
23 | 23 |
24 using device::BluetoothDevice; | 24 using device::BluetoothDevice; |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 const char kNotImplemented[] = "Function not yet implemented"; | |
29 | |
28 // Histogram enumerations for pairing results. | 30 // Histogram enumerations for pairing results. |
29 enum UMAPairingResult { | 31 enum UMAPairingResult { |
30 UMA_PAIRING_RESULT_SUCCESS, | 32 UMA_PAIRING_RESULT_SUCCESS, |
31 UMA_PAIRING_RESULT_INPROGRESS, | 33 UMA_PAIRING_RESULT_INPROGRESS, |
32 UMA_PAIRING_RESULT_FAILED, | 34 UMA_PAIRING_RESULT_FAILED, |
33 UMA_PAIRING_RESULT_AUTH_FAILED, | 35 UMA_PAIRING_RESULT_AUTH_FAILED, |
34 UMA_PAIRING_RESULT_AUTH_CANCELED, | 36 UMA_PAIRING_RESULT_AUTH_CANCELED, |
35 UMA_PAIRING_RESULT_AUTH_REJECTED, | 37 UMA_PAIRING_RESULT_AUTH_REJECTED, |
36 UMA_PAIRING_RESULT_AUTH_TIMEOUT, | 38 UMA_PAIRING_RESULT_AUTH_TIMEOUT, |
37 UMA_PAIRING_RESULT_UNSUPPORTED_DEVICE, | 39 UMA_PAIRING_RESULT_UNSUPPORTED_DEVICE, |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 GetProperties(object_path_); | 222 GetProperties(object_path_); |
221 DCHECK(properties); | 223 DCHECK(properties); |
222 | 224 |
223 return properties->uuids.value(); | 225 return properties->uuids.value(); |
224 } | 226 } |
225 | 227 |
226 void BluetoothDeviceChromeOS::GetServiceRecords( | 228 void BluetoothDeviceChromeOS::GetServiceRecords( |
227 const ServiceRecordsCallback& callback, | 229 const ServiceRecordsCallback& callback, |
228 const ErrorCallback& error_callback) { | 230 const ErrorCallback& error_callback) { |
229 // TODO(keybuk): not implemented; remove | 231 // TODO(keybuk): not implemented; remove |
230 error_callback.Run(); | 232 error_callback.Run(kNotImplemented); |
keybuk
2014/03/27 20:20:07
Drop this change, this is using ErrorCallback not
rpaquay
2014/03/27 22:00:01
Actually, this method has disappeared after rebasi
| |
231 } | 233 } |
232 | 234 |
233 void BluetoothDeviceChromeOS::ProvidesServiceWithName( | 235 void BluetoothDeviceChromeOS::ProvidesServiceWithName( |
234 const std::string& name, | 236 const std::string& name, |
235 const ProvidesServiceCallback& callback) { | 237 const ProvidesServiceCallback& callback) { |
236 // TODO(keybuk): not implemented; remove | 238 // TODO(keybuk): not implemented; remove |
237 callback.Run(false); | 239 callback.Run(false); |
238 } | 240 } |
239 | 241 |
240 bool BluetoothDeviceChromeOS::ExpectingPinCode() const { | 242 bool BluetoothDeviceChromeOS::ExpectingPinCode() const { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
361 void BluetoothDeviceChromeOS::ConnectToService( | 363 void BluetoothDeviceChromeOS::ConnectToService( |
362 const std::string& service_uuid, | 364 const std::string& service_uuid, |
363 const SocketCallback& callback) { | 365 const SocketCallback& callback) { |
364 // TODO(keybuk): implement | 366 // TODO(keybuk): implement |
365 callback.Run(scoped_refptr<device::BluetoothSocket>()); | 367 callback.Run(scoped_refptr<device::BluetoothSocket>()); |
366 } | 368 } |
367 | 369 |
368 void BluetoothDeviceChromeOS::ConnectToProfile( | 370 void BluetoothDeviceChromeOS::ConnectToProfile( |
369 device::BluetoothProfile* profile, | 371 device::BluetoothProfile* profile, |
370 const base::Closure& callback, | 372 const base::Closure& callback, |
371 const ErrorCallback& error_callback) { | 373 const ConnectToProfileErrorCallback& error_callback) { |
372 BluetoothProfileChromeOS* profile_chromeos = | 374 BluetoothProfileChromeOS* profile_chromeos = |
373 static_cast<BluetoothProfileChromeOS*>(profile); | 375 static_cast<BluetoothProfileChromeOS*>(profile); |
374 VLOG(1) << object_path_.value() << ": Connecting profile: " | 376 VLOG(1) << object_path_.value() << ": Connecting profile: " |
375 << profile_chromeos->uuid(); | 377 << profile_chromeos->uuid(); |
376 DBusThreadManager::Get()->GetBluetoothDeviceClient()-> | 378 DBusThreadManager::Get()->GetBluetoothDeviceClient()-> |
377 ConnectProfile( | 379 ConnectProfile( |
378 object_path_, | 380 object_path_, |
379 profile_chromeos->uuid(), | 381 profile_chromeos->uuid(), |
380 base::Bind( | 382 base::Bind( |
381 &BluetoothDeviceChromeOS::OnConnectProfile, | 383 &BluetoothDeviceChromeOS::OnConnectProfile, |
382 weak_ptr_factory_.GetWeakPtr(), | 384 weak_ptr_factory_.GetWeakPtr(), |
383 profile, | 385 profile, |
384 callback), | 386 callback), |
385 base::Bind( | 387 base::Bind( |
386 &BluetoothDeviceChromeOS::OnConnectProfileError, | 388 &BluetoothDeviceChromeOS::OnConnectProfileError, |
387 weak_ptr_factory_.GetWeakPtr(), | 389 weak_ptr_factory_.GetWeakPtr(), |
388 profile, | 390 profile, |
389 error_callback)); | 391 error_callback)); |
390 } | 392 } |
391 | 393 |
392 void BluetoothDeviceChromeOS::SetOutOfBandPairingData( | 394 void BluetoothDeviceChromeOS::SetOutOfBandPairingData( |
393 const device::BluetoothOutOfBandPairingData& data, | 395 const device::BluetoothOutOfBandPairingData& data, |
394 const base::Closure& callback, | 396 const base::Closure& callback, |
395 const ErrorCallback& error_callback) { | 397 const ErrorCallback& error_callback) { |
396 // TODO(keybuk): implement | 398 // TODO(keybuk): implement |
397 error_callback.Run(); | 399 error_callback.Run(kNotImplemented); |
keybuk
2014/03/27 20:20:07
as above
rpaquay
2014/03/27 22:00:01
Done.
| |
398 } | 400 } |
399 | 401 |
400 void BluetoothDeviceChromeOS::ClearOutOfBandPairingData( | 402 void BluetoothDeviceChromeOS::ClearOutOfBandPairingData( |
401 const base::Closure& callback, | 403 const base::Closure& callback, |
402 const ErrorCallback& error_callback) { | 404 const ErrorCallback& error_callback) { |
403 // TODO(keybuk): implement | 405 // TODO(keybuk): implement |
404 error_callback.Run(); | 406 error_callback.Run(kNotImplemented); |
keybuk
2014/03/27 20:20:07
as above
rpaquay
2014/03/27 22:00:01
Done.
| |
405 } | 407 } |
406 | 408 |
407 BluetoothPairingChromeOS* BluetoothDeviceChromeOS::BeginPairing( | 409 BluetoothPairingChromeOS* BluetoothDeviceChromeOS::BeginPairing( |
408 BluetoothDevice::PairingDelegate* pairing_delegate) { | 410 BluetoothDevice::PairingDelegate* pairing_delegate) { |
409 pairing_.reset(new BluetoothPairingChromeOS(this, pairing_delegate)); | 411 pairing_.reset(new BluetoothPairingChromeOS(this, pairing_delegate)); |
410 return pairing_.get(); | 412 return pairing_.get(); |
411 } | 413 } |
412 | 414 |
413 void BluetoothDeviceChromeOS::EndPairing() { | 415 void BluetoothDeviceChromeOS::EndPairing() { |
414 pairing_.reset(); | 416 pairing_.reset(); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
557 VLOG(1) << object_path_.value() << ": Disconnected"; | 559 VLOG(1) << object_path_.value() << ": Disconnected"; |
558 callback.Run(); | 560 callback.Run(); |
559 } | 561 } |
560 | 562 |
561 void BluetoothDeviceChromeOS::OnDisconnectError( | 563 void BluetoothDeviceChromeOS::OnDisconnectError( |
562 const ErrorCallback& error_callback, | 564 const ErrorCallback& error_callback, |
563 const std::string& error_name, | 565 const std::string& error_name, |
564 const std::string& error_message) { | 566 const std::string& error_message) { |
565 LOG(WARNING) << object_path_.value() << ": Failed to disconnect device: " | 567 LOG(WARNING) << object_path_.value() << ": Failed to disconnect device: " |
566 << error_name << ": " << error_message; | 568 << error_name << ": " << error_message; |
567 error_callback.Run(); | 569 error_callback.Run(error_message); |
keybuk
2014/03/27 20:20:07
as above
rpaquay
2014/03/27 22:00:01
Done.
| |
568 } | 570 } |
569 | 571 |
570 void BluetoothDeviceChromeOS::OnForgetError( | 572 void BluetoothDeviceChromeOS::OnForgetError( |
571 const ErrorCallback& error_callback, | 573 const ErrorCallback& error_callback, |
572 const std::string& error_name, | 574 const std::string& error_name, |
573 const std::string& error_message) { | 575 const std::string& error_message) { |
574 LOG(WARNING) << object_path_.value() << ": Failed to remove device: " | 576 LOG(WARNING) << object_path_.value() << ": Failed to remove device: " |
575 << error_name << ": " << error_message; | 577 << error_name << ": " << error_message; |
576 error_callback.Run(); | 578 error_callback.Run(error_message); |
keybuk
2014/03/27 20:20:07
as above
rpaquay
2014/03/27 22:00:01
Done.
| |
577 } | 579 } |
578 | 580 |
579 void BluetoothDeviceChromeOS::OnConnectProfile( | 581 void BluetoothDeviceChromeOS::OnConnectProfile( |
580 device::BluetoothProfile* profile, | 582 device::BluetoothProfile* profile, |
581 const base::Closure& callback) { | 583 const base::Closure& callback) { |
582 BluetoothProfileChromeOS* profile_chromeos = | 584 BluetoothProfileChromeOS* profile_chromeos = |
583 static_cast<BluetoothProfileChromeOS*>(profile); | 585 static_cast<BluetoothProfileChromeOS*>(profile); |
584 VLOG(1) << object_path_.value() << ": Profile connected: " | 586 VLOG(1) << object_path_.value() << ": Profile connected: " |
585 << profile_chromeos->uuid(); | 587 << profile_chromeos->uuid(); |
586 callback.Run(); | 588 callback.Run(); |
587 } | 589 } |
588 | 590 |
589 void BluetoothDeviceChromeOS::OnConnectProfileError( | 591 void BluetoothDeviceChromeOS::OnConnectProfileError( |
590 device::BluetoothProfile* profile, | 592 device::BluetoothProfile* profile, |
591 const ErrorCallback& error_callback, | 593 const ErrorCallback& error_callback, |
592 const std::string& error_name, | 594 const std::string& error_name, |
593 const std::string& error_message) { | 595 const std::string& error_message) { |
594 BluetoothProfileChromeOS* profile_chromeos = | 596 BluetoothProfileChromeOS* profile_chromeos = |
595 static_cast<BluetoothProfileChromeOS*>(profile); | 597 static_cast<BluetoothProfileChromeOS*>(profile); |
596 VLOG(1) << object_path_.value() << ": Profile connection failed: " | 598 VLOG(1) << object_path_.value() << ": Profile connection failed: " |
597 << profile_chromeos->uuid() << ": " | 599 << profile_chromeos->uuid() << ": " |
598 << error_name << ": " << error_message; | 600 << error_name << ": " << error_message; |
599 error_callback.Run(); | 601 error_callback.Run(error_message); |
600 } | 602 } |
601 | 603 |
602 } // namespace chromeos | 604 } // namespace chromeos |
OLD | NEW |