OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_experimental_chromeos.h" | 5 #include "device/bluetooth/bluetooth_device_experimental_chromeos.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "chromeos/dbus/dbus_thread_manager.h" | 11 #include "chromeos/dbus/dbus_thread_manager.h" |
12 #include "chromeos/dbus/experimental_bluetooth_adapter_client.h" | 12 #include "chromeos/dbus/experimental_bluetooth_adapter_client.h" |
13 #include "chromeos/dbus/experimental_bluetooth_agent_manager_client.h" | 13 #include "chromeos/dbus/experimental_bluetooth_agent_manager_client.h" |
14 #include "chromeos/dbus/experimental_bluetooth_agent_service_provider.h" | 14 #include "chromeos/dbus/experimental_bluetooth_agent_service_provider.h" |
15 #include "chromeos/dbus/experimental_bluetooth_device_client.h" | 15 #include "chromeos/dbus/experimental_bluetooth_device_client.h" |
16 #include "chromeos/dbus/experimental_bluetooth_input_client.h" | 16 #include "chromeos/dbus/experimental_bluetooth_input_client.h" |
17 #include "dbus/bus.h" | 17 #include "dbus/bus.h" |
18 #include "device/bluetooth/bluetooth_adapter_experimental_chromeos.h" | 18 #include "device/bluetooth/bluetooth_adapter_experimental_chromeos.h" |
| 19 #include "device/bluetooth/bluetooth_profile_experimental_chromeos.h" |
19 #include "device/bluetooth/bluetooth_socket.h" | 20 #include "device/bluetooth/bluetooth_socket.h" |
20 #include "third_party/cros_system_api/dbus/service_constants.h" | 21 #include "third_party/cros_system_api/dbus/service_constants.h" |
21 | 22 |
22 using device::BluetoothDevice; | 23 using device::BluetoothDevice; |
23 | 24 |
24 namespace { | 25 namespace { |
25 | 26 |
26 // The agent path is relatively meaningless since BlueZ only supports one | 27 // The agent path is relatively meaningless since BlueZ only supports one |
27 // at time and will fail in an attempt to register another with "Already Exists" | 28 // at time and will fail in an attempt to register another with "Already Exists" |
28 // (which we fail in OnRegisterAgentError with ERROR_INPROGRESS). | 29 // (which we fail in OnRegisterAgentError with ERROR_INPROGRESS). |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 const std::string& service_uuid, | 386 const std::string& service_uuid, |
386 const SocketCallback& callback) { | 387 const SocketCallback& callback) { |
387 // TODO(keybuk): implement | 388 // TODO(keybuk): implement |
388 callback.Run(scoped_refptr<device::BluetoothSocket>()); | 389 callback.Run(scoped_refptr<device::BluetoothSocket>()); |
389 } | 390 } |
390 | 391 |
391 void BluetoothDeviceExperimentalChromeOS::ConnectToProfile( | 392 void BluetoothDeviceExperimentalChromeOS::ConnectToProfile( |
392 device::BluetoothProfile* profile, | 393 device::BluetoothProfile* profile, |
393 const base::Closure& callback, | 394 const base::Closure& callback, |
394 const ErrorCallback& error_callback) { | 395 const ErrorCallback& error_callback) { |
395 // TODO(keybuk): implement | 396 BluetoothProfileExperimentalChromeOS* profile_chromeos = |
396 error_callback.Run(); | 397 static_cast<BluetoothProfileExperimentalChromeOS*>(profile); |
| 398 VLOG(1) << object_path_.value() << ": Connecting profile: " |
| 399 << profile_chromeos->uuid(); |
| 400 DBusThreadManager::Get()->GetExperimentalBluetoothDeviceClient()-> |
| 401 ConnectProfile( |
| 402 object_path_, |
| 403 profile_chromeos->uuid(), |
| 404 base::Bind( |
| 405 &BluetoothDeviceExperimentalChromeOS::OnConnectProfile, |
| 406 weak_ptr_factory_.GetWeakPtr(), |
| 407 profile, |
| 408 callback), |
| 409 base::Bind( |
| 410 &BluetoothDeviceExperimentalChromeOS::OnConnectProfileError, |
| 411 weak_ptr_factory_.GetWeakPtr(), |
| 412 profile, |
| 413 error_callback)); |
397 } | 414 } |
398 | 415 |
399 void BluetoothDeviceExperimentalChromeOS::SetOutOfBandPairingData( | 416 void BluetoothDeviceExperimentalChromeOS::SetOutOfBandPairingData( |
400 const device::BluetoothOutOfBandPairingData& data, | 417 const device::BluetoothOutOfBandPairingData& data, |
401 const base::Closure& callback, | 418 const base::Closure& callback, |
402 const ErrorCallback& error_callback) { | 419 const ErrorCallback& error_callback) { |
403 // TODO(keybuk): implement | 420 // TODO(keybuk): implement |
404 error_callback.Run(); | 421 error_callback.Run(); |
405 } | 422 } |
406 | 423 |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 | 814 |
798 if (!confirmation_callback_.is_null()) { | 815 if (!confirmation_callback_.is_null()) { |
799 confirmation_callback_.Run(status); | 816 confirmation_callback_.Run(status); |
800 confirmation_callback_.Reset(); | 817 confirmation_callback_.Reset(); |
801 callback_run = true; | 818 callback_run = true; |
802 } | 819 } |
803 | 820 |
804 return callback_run; | 821 return callback_run; |
805 } | 822 } |
806 | 823 |
| 824 void BluetoothDeviceExperimentalChromeOS::OnConnectProfile( |
| 825 device::BluetoothProfile* profile, |
| 826 const base::Closure& callback) { |
| 827 BluetoothProfileExperimentalChromeOS* profile_chromeos = |
| 828 static_cast<BluetoothProfileExperimentalChromeOS*>(profile); |
| 829 VLOG(1) << object_path_.value() << ": Profile connected: " |
| 830 << profile_chromeos->uuid(); |
| 831 callback.Run(); |
| 832 } |
| 833 |
| 834 void BluetoothDeviceExperimentalChromeOS::OnConnectProfileError( |
| 835 device::BluetoothProfile* profile, |
| 836 const ErrorCallback& error_callback, |
| 837 const std::string& error_name, |
| 838 const std::string& error_message) { |
| 839 BluetoothProfileExperimentalChromeOS* profile_chromeos = |
| 840 static_cast<BluetoothProfileExperimentalChromeOS*>(profile); |
| 841 VLOG(1) << object_path_.value() << ": Profile connection failed: " |
| 842 << profile_chromeos->uuid() << ": " |
| 843 << error_name << ": " << error_message; |
| 844 error_callback.Run(); |
| 845 } |
| 846 |
807 } // namespace chromeos | 847 } // namespace chromeos |
OLD | NEW |