diff options
author | rkc <rkc@chromium.org> | 2015-09-28 19:24:14 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-09-29 02:25:40 +0000 |
commit | 17fcdab015a073437404f35e7e63c1464280d36b (patch) | |
tree | ff11fdb0bfeeebbfd58cdb50f9f90e336c702424 /device | |
parent | d02508f8c010b1415f5f1521a6f4cee260d1f8a9 (diff) | |
download | chromium_src-17fcdab015a073437404f35e7e63c1464280d36b.zip chromium_src-17fcdab015a073437404f35e7e63c1464280d36b.tar.gz chromium_src-17fcdab015a073437404f35e7e63c1464280d36b.tar.bz2 |
Add Linux support for the Bluetooth API.
This refactors all the code in //device/bluetooth to be non-ChromeOS specific
and adds code to enable all of it to run on Linux through the linux specific
DBusThreadManager that is added.
This CL depends on https://codereview.chromium.org/1347193004/
Owners reviews requested,
//device - armansito@
//extensions - rockot@
//chrome/browser/chrome_browser_main_linux.* - jhawkins@
R=armansito@chromium.org, jhawkins@chromium.org, rockot@chromium.org
BUG=522633
Review URL: https://codereview.chromium.org/1367663002
Cr-Commit-Position: refs/heads/master@{#351237}
Diffstat (limited to 'device')
76 files changed, 1952 insertions, 1948 deletions
diff --git a/device/BUILD.gn b/device/BUILD.gn index 4961292..c81e8dc3 100644 --- a/device/BUILD.gn +++ b/device/BUILD.gn @@ -30,20 +30,14 @@ test("device_unittests") { "battery/battery_status_manager_win_unittest.cc", "battery/battery_status_service_unittest.cc", "bluetooth/bluetooth_adapter_mac_unittest.mm", - "bluetooth/bluetooth_adapter_profile_chromeos_unittest.cc", "bluetooth/bluetooth_adapter_unittest.cc", "bluetooth/bluetooth_adapter_win_unittest.cc", - "bluetooth/bluetooth_advertisement_chromeos_unittest.cc", "bluetooth/bluetooth_advertisement_unittest.cc", - "bluetooth/bluetooth_audio_sink_chromeos_unittest.cc", - "bluetooth/bluetooth_chromeos_unittest.cc", "bluetooth/bluetooth_device_unittest.cc", "bluetooth/bluetooth_device_win_unittest.cc", "bluetooth/bluetooth_discovery_filter_unittest.cc", - "bluetooth/bluetooth_gatt_chromeos_unittest.cc", "bluetooth/bluetooth_low_energy_win_unittest.cc", "bluetooth/bluetooth_service_record_win_unittest.cc", - "bluetooth/bluetooth_socket_chromeos_unittest.cc", "bluetooth/bluetooth_task_manager_win_unittest.cc", "bluetooth/bluetooth_uuid_unittest.cc", "bluetooth/test/bluetooth_test.cc", @@ -141,16 +135,28 @@ test("device_unittests") { } if (is_chromeos) { - configs += [ "//build/config/linux:dbus" ] - deps += [ "//chromeos", "//chromeos:test_support", "//chromeos:test_support_without_gmock", - "//dbus", ] } + if (is_chromeos || is_linux) { + configs += [ "//build/config/linux:dbus" ] + + sources += [ + "bluetooth/bluetooth_adapter_profile_bluez_unittest.cc", + "bluetooth/bluetooth_advertisement_bluez_unittest.cc", + "bluetooth/bluetooth_audio_sink_bluez_unittest.cc", + "bluetooth/bluetooth_bluez_unittest.cc", + "bluetooth/bluetooth_gatt_bluez_unittest.cc", + "bluetooth/bluetooth_socket_bluez_unittest.cc", + ] + + deps += [ "//dbus" ] + } + if (is_posix && !is_android && !is_mac) { libs = [ "rt" ] } diff --git a/device/bluetooth/BUILD.gn b/device/bluetooth/BUILD.gn index 69da108..b7bd5f8 100644 --- a/device/bluetooth/BUILD.gn +++ b/device/bluetooth/BUILD.gn @@ -29,24 +29,16 @@ component("bluetooth") { "bluetooth_adapter.h", "bluetooth_adapter_android.cc", "bluetooth_adapter_android.h", - "bluetooth_adapter_chromeos.cc", - "bluetooth_adapter_chromeos.h", "bluetooth_adapter_factory.cc", "bluetooth_adapter_factory.h", "bluetooth_adapter_mac.h", "bluetooth_adapter_mac.mm", - "bluetooth_adapter_profile_chromeos.cc", - "bluetooth_adapter_profile_chromeos.h", "bluetooth_adapter_win.cc", "bluetooth_adapter_win.h", "bluetooth_advertisement.cc", "bluetooth_advertisement.h", - "bluetooth_advertisement_chromeos.cc", - "bluetooth_advertisement_chromeos.h", "bluetooth_audio_sink.cc", "bluetooth_audio_sink.h", - "bluetooth_audio_sink_chromeos.cc", - "bluetooth_audio_sink_chromeos.h", "bluetooth_channel_mac.h", "bluetooth_channel_mac.mm", "bluetooth_classic_device_mac.h", @@ -55,8 +47,6 @@ component("bluetooth") { "bluetooth_device.h", "bluetooth_device_android.cc", "bluetooth_device_android.h", - "bluetooth_device_chromeos.cc", - "bluetooth_device_chromeos.h", "bluetooth_device_mac.h", "bluetooth_device_mac.mm", "bluetooth_device_win.cc", @@ -72,14 +62,10 @@ component("bluetooth") { "bluetooth_gatt_characteristic.h", "bluetooth_gatt_connection.cc", "bluetooth_gatt_connection.h", - "bluetooth_gatt_connection_chromeos.cc", - "bluetooth_gatt_connection_chromeos.h", "bluetooth_gatt_descriptor.cc", "bluetooth_gatt_descriptor.h", "bluetooth_gatt_notify_session.cc", "bluetooth_gatt_notify_session.h", - "bluetooth_gatt_notify_session_chromeos.cc", - "bluetooth_gatt_notify_session_chromeos.h", "bluetooth_gatt_service.cc", "bluetooth_gatt_service.h", "bluetooth_init_win.cc", @@ -96,22 +82,12 @@ component("bluetooth") { "bluetooth_low_energy_discovery_manager_mac.mm", "bluetooth_low_energy_win.cc", "bluetooth_low_energy_win.h", - "bluetooth_pairing_chromeos.cc", - "bluetooth_pairing_chromeos.h", - "bluetooth_remote_gatt_characteristic_chromeos.cc", - "bluetooth_remote_gatt_characteristic_chromeos.h", - "bluetooth_remote_gatt_descriptor_chromeos.cc", - "bluetooth_remote_gatt_descriptor_chromeos.h", - "bluetooth_remote_gatt_service_chromeos.cc", - "bluetooth_remote_gatt_service_chromeos.h", "bluetooth_rfcomm_channel_mac.h", "bluetooth_rfcomm_channel_mac.mm", "bluetooth_service_record_win.cc", "bluetooth_service_record_win.h", "bluetooth_socket.cc", "bluetooth_socket.h", - "bluetooth_socket_chromeos.cc", - "bluetooth_socket_chromeos.h", "bluetooth_socket_mac.h", "bluetooth_socket_mac.mm", "bluetooth_socket_net.cc", @@ -144,10 +120,11 @@ component("bluetooth") { } if (is_chromeos) { - deps += [ - "//chromeos", - "//dbus", - ] + deps += [ "//chromeos" ] + } + + if (is_chromeos || is_linux) { + deps += [ "//dbus" ] } if (is_mac) { @@ -158,11 +135,32 @@ component("bluetooth") { libs = [ "setupapi.lib" ] } - # This block will also build for Linux once we write the linux - # implementation of BluezDbusManager. - if (is_chromeos) { - defines += [ "DEVICE_BLUETOOTH_IMPLEMENTATION" ] + if (is_chromeos || is_linux) { sources += [ + "bluetooth_adapter_bluez.cc", + "bluetooth_adapter_bluez.h", + "bluetooth_adapter_profile_bluez.cc", + "bluetooth_adapter_profile_bluez.h", + "bluetooth_advertisement_bluez.cc", + "bluetooth_advertisement_bluez.h", + "bluetooth_audio_sink_bluez.cc", + "bluetooth_audio_sink_bluez.h", + "bluetooth_device_bluez.cc", + "bluetooth_device_bluez.h", + "bluetooth_gatt_connection_bluez.cc", + "bluetooth_gatt_connection_bluez.h", + "bluetooth_gatt_notify_session_bluez.cc", + "bluetooth_gatt_notify_session_bluez.h", + "bluetooth_pairing_bluez.cc", + "bluetooth_pairing_bluez.h", + "bluetooth_remote_gatt_characteristic_bluez.cc", + "bluetooth_remote_gatt_characteristic_bluez.h", + "bluetooth_remote_gatt_descriptor_bluez.cc", + "bluetooth_remote_gatt_descriptor_bluez.h", + "bluetooth_remote_gatt_service_bluez.cc", + "bluetooth_remote_gatt_service_bluez.h", + "bluetooth_socket_bluez.cc", + "bluetooth_socket_bluez.h", "dbus/bluetooth_adapter_client.cc", "dbus/bluetooth_adapter_client.h", "dbus/bluetooth_agent_manager_client.cc", @@ -206,6 +204,8 @@ component("bluetooth") { "dbus/bluez_dbus_client.h", "dbus/bluez_dbus_manager.cc", "dbus/bluez_dbus_manager.h", + "dbus/dbus_thread_manager_linux.cc", + "dbus/dbus_thread_manager_linux.h", "dbus/fake_bluetooth_adapter_client.cc", "dbus/fake_bluetooth_adapter_client.h", "dbus/fake_bluetooth_agent_manager_client.cc", diff --git a/device/bluetooth/bluetooth.gyp b/device/bluetooth/bluetooth.gyp index 5e4e821..df88000 100644 --- a/device/bluetooth/bluetooth.gyp +++ b/device/bluetooth/bluetooth.gyp @@ -32,24 +32,16 @@ 'bluetooth_adapter.h', 'bluetooth_adapter_android.cc', 'bluetooth_adapter_android.h', - 'bluetooth_adapter_chromeos.cc', - 'bluetooth_adapter_chromeos.h', 'bluetooth_adapter_factory.cc', 'bluetooth_adapter_factory.h', 'bluetooth_adapter_mac.h', 'bluetooth_adapter_mac.mm', - "bluetooth_adapter_profile_chromeos.cc", - "bluetooth_adapter_profile_chromeos.h", 'bluetooth_adapter_win.cc', 'bluetooth_adapter_win.h', 'bluetooth_advertisement.cc', 'bluetooth_advertisement.h', - 'bluetooth_advertisement_chromeos.cc', - 'bluetooth_advertisement_chromeos.h', 'bluetooth_audio_sink.cc', 'bluetooth_audio_sink.h', - 'bluetooth_audio_sink_chromeos.cc', - 'bluetooth_audio_sink_chromeos.h', 'bluetooth_channel_mac.mm', 'bluetooth_channel_mac.h', 'bluetooth_classic_device_mac.mm', @@ -58,8 +50,6 @@ 'bluetooth_device.h', 'bluetooth_device_android.h', 'bluetooth_device_android.cc', - 'bluetooth_device_chromeos.cc', - 'bluetooth_device_chromeos.h', 'bluetooth_device_mac.mm', 'bluetooth_device_mac.h', 'bluetooth_device_win.cc', @@ -75,14 +65,10 @@ 'bluetooth_gatt_characteristic.h', 'bluetooth_gatt_connection.cc', 'bluetooth_gatt_connection.h', - 'bluetooth_gatt_connection_chromeos.cc', - 'bluetooth_gatt_connection_chromeos.h', 'bluetooth_gatt_descriptor.cc', 'bluetooth_gatt_descriptor.h', 'bluetooth_gatt_notify_session.cc', 'bluetooth_gatt_notify_session.h', - 'bluetooth_gatt_notify_session_chromeos.cc', - 'bluetooth_gatt_notify_session_chromeos.h', 'bluetooth_gatt_service.cc', 'bluetooth_gatt_service.h', 'bluetooth_init_win.cc', @@ -99,22 +85,12 @@ 'bluetooth_low_energy_discovery_manager_mac.mm', 'bluetooth_low_energy_win.cc', 'bluetooth_low_energy_win.h', - 'bluetooth_pairing_chromeos.cc', - 'bluetooth_pairing_chromeos.h', - 'bluetooth_remote_gatt_characteristic_chromeos.cc', - 'bluetooth_remote_gatt_characteristic_chromeos.h', - 'bluetooth_remote_gatt_descriptor_chromeos.cc', - 'bluetooth_remote_gatt_descriptor_chromeos.h', - 'bluetooth_remote_gatt_service_chromeos.cc', - 'bluetooth_remote_gatt_service_chromeos.h', 'bluetooth_rfcomm_channel_mac.mm', 'bluetooth_rfcomm_channel_mac.h', 'bluetooth_service_record_win.cc', 'bluetooth_service_record_win.h', 'bluetooth_socket.cc', 'bluetooth_socket.h', - 'bluetooth_socket_chromeos.cc', - 'bluetooth_socket_chromeos.h', 'bluetooth_socket_mac.h', 'bluetooth_socket_mac.mm', 'bluetooth_socket_net.cc', @@ -131,11 +107,35 @@ 'conditions': [ # This block will also build for Linux once we write the linux # implementation of BluezDbusManager. - ['chromeos==1', { + ['chromeos==1 or OS=="linux"', { 'defines': [ 'DEVICE_BLUETOOTH_IMPLEMENTATION', ], 'sources': [ + 'bluetooth_adapter_bluez.cc', + 'bluetooth_adapter_bluez.h', + 'bluetooth_adapter_profile_bluez.cc', + 'bluetooth_adapter_profile_bluez.h', + 'bluetooth_advertisement_bluez.cc', + 'bluetooth_advertisement_bluez.h', + 'bluetooth_audio_sink_bluez.cc', + 'bluetooth_audio_sink_bluez.h', + 'bluetooth_device_bluez.cc', + 'bluetooth_device_bluez.h', + 'bluetooth_gatt_connection_bluez.cc', + 'bluetooth_gatt_connection_bluez.h', + 'bluetooth_gatt_notify_session_bluez.cc', + 'bluetooth_gatt_notify_session_bluez.h', + 'bluetooth_pairing_bluez.cc', + 'bluetooth_pairing_bluez.h', + 'bluetooth_remote_gatt_characteristic_bluez.cc', + 'bluetooth_remote_gatt_characteristic_bluez.h', + 'bluetooth_remote_gatt_descriptor_bluez.cc', + 'bluetooth_remote_gatt_descriptor_bluez.h', + 'bluetooth_remote_gatt_service_bluez.cc', + 'bluetooth_remote_gatt_service_bluez.h', + 'bluetooth_socket_bluez.cc', + 'bluetooth_socket_bluez.h', 'dbus/bluetooth_adapter_client.cc', 'dbus/bluetooth_adapter_client.h', 'dbus/bluetooth_le_advertising_manager_client.cc', @@ -179,6 +179,8 @@ 'dbus/bluez_dbus_client.h', 'dbus/bluez_dbus_manager.cc', 'dbus/bluez_dbus_manager.h', + 'dbus/dbus_thread_manager_linux.cc', + 'dbus/dbus_thread_manager_linux.h', 'dbus/fake_bluetooth_adapter_client.cc', 'dbus/fake_bluetooth_adapter_client.h', 'dbus/fake_bluetooth_le_advertising_manager_client.cc', @@ -218,17 +220,19 @@ 'dbus/fake_bluetooth_profile_service_provider.cc', 'dbus/fake_bluetooth_profile_service_provider.h', ], - }], - ['chromeos==1', { 'dependencies': [ '../../build/linux/system.gyp:dbus', - '../../chromeos/chromeos.gyp:chromeos', '../../dbus/dbus.gyp:dbus', ], 'export_dependent_settings': [ '../../build/linux/system.gyp:dbus' ] }], + ['chromeos==1', { + 'dependencies': [ + '../../chromeos/chromeos.gyp:chromeos', + ], + }], ['OS == "android"', { 'dependencies': [ 'device_bluetooth_java', diff --git a/device/bluetooth/bluetooth_adapter.cc b/device/bluetooth/bluetooth_adapter.cc index f3d15bf..0cb190c 100644 --- a/device/bluetooth/bluetooth_adapter.cc +++ b/device/bluetooth/bluetooth_adapter.cc @@ -19,7 +19,7 @@ BluetoothAdapter::ServiceOptions::~ServiceOptions() { } #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) && !defined(OS_MACOSX) && \ - !defined(OS_WIN) + !defined(OS_WIN) && !defined(OS_LINUX) // static base::WeakPtr<BluetoothAdapter> BluetoothAdapter::CreateAdapter( const InitCallback& init_callback) { @@ -31,7 +31,7 @@ base::WeakPtr<BluetoothAdapter> BluetoothAdapter::GetWeakPtrForTesting() { return weak_ptr_factory_.GetWeakPtr(); } -#if defined(OS_CHROMEOS) +#if defined(OS_CHROMEOS) || defined(OS_LINUX) void BluetoothAdapter::Shutdown() { NOTIMPLEMENTED(); } diff --git a/device/bluetooth/bluetooth_adapter.h b/device/bluetooth/bluetooth_adapter.h index 801a1fd..0479527 100644 --- a/device/bluetooth/bluetooth_adapter.h +++ b/device/bluetooth/bluetooth_adapter.h @@ -216,7 +216,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapter // Returns a weak pointer to an existing adapter for testing purposes only. base::WeakPtr<BluetoothAdapter> GetWeakPtrForTesting(); -#if defined(OS_CHROMEOS) +#if defined(OS_CHROMEOS) || defined(OS_LINUX) // Shutdown the adapter: tear down and clean up all objects owned by // BluetoothAdapter. After this call, the BluetoothAdapter will behave as if // no Bluetooth controller exists in the local system. |IsPresent| will return diff --git a/device/bluetooth/bluetooth_adapter_chromeos.cc b/device/bluetooth/bluetooth_adapter_bluez.cc index 15f30bf..3175f8f 100644 --- a/device/bluetooth/bluetooth_adapter_chromeos.cc +++ b/device/bluetooth/bluetooth_adapter_bluez.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "device/bluetooth/bluetooth_adapter_chromeos.h" +#include "device/bluetooth/bluetooth_adapter_bluez.h" #include <string> @@ -13,18 +13,17 @@ #include "base/sequenced_task_runner.h" #include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" -#include "chromeos/system/devicetype.h" -#include "device/bluetooth/bluetooth_adapter_profile_chromeos.h" -#include "device/bluetooth/bluetooth_advertisement_chromeos.h" -#include "device/bluetooth/bluetooth_audio_sink_chromeos.h" +#include "device/bluetooth/bluetooth_adapter_profile_bluez.h" +#include "device/bluetooth/bluetooth_advertisement_bluez.h" +#include "device/bluetooth/bluetooth_audio_sink_bluez.h" #include "device/bluetooth/bluetooth_device.h" -#include "device/bluetooth/bluetooth_device_chromeos.h" +#include "device/bluetooth/bluetooth_device_bluez.h" #include "device/bluetooth/bluetooth_discovery_session_outcome.h" -#include "device/bluetooth/bluetooth_pairing_chromeos.h" -#include "device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h" -#include "device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.h" -#include "device/bluetooth/bluetooth_remote_gatt_service_chromeos.h" -#include "device/bluetooth/bluetooth_socket_chromeos.h" +#include "device/bluetooth/bluetooth_pairing_bluez.h" +#include "device/bluetooth/bluetooth_remote_gatt_characteristic_bluez.h" +#include "device/bluetooth/bluetooth_remote_gatt_descriptor_bluez.h" +#include "device/bluetooth/bluetooth_remote_gatt_service_bluez.h" +#include "device/bluetooth/bluetooth_socket_bluez.h" #include "device/bluetooth/bluetooth_socket_thread.h" #include "device/bluetooth/bluetooth_uuid.h" #include "device/bluetooth/dbus/bluetooth_adapter_client.h" @@ -35,6 +34,10 @@ #include "device/bluetooth/dbus/bluez_dbus_manager.h" #include "third_party/cros_system_api/dbus/service_constants.h" +#if defined(OS_CHROMEOS) +#include "chromeos/system/devicetype.h" +#endif + using device::BluetoothAdapter; using device::BluetoothAudioSink; using device::BluetoothDevice; @@ -55,20 +58,20 @@ void OnUnregisterAgentError(const std::string& error_name, if (error_name == bluetooth_agent_manager::kErrorDoesNotExist) return; - LOG(WARNING) << "Failed to unregister pairing agent: " - << error_name << ": " << error_message; + LOG(WARNING) << "Failed to unregister pairing agent: " << error_name << ": " + << error_message; } UMABluetoothDiscoverySessionOutcome TranslateDiscoveryErrorToUMA( const std::string& error_name) { if (error_name == bluez::BluetoothAdapterClient::kUnknownAdapterError) { - return UMABluetoothDiscoverySessionOutcome::CHROMEOS_DBUS_UNKNOWN_ADAPTER; + return UMABluetoothDiscoverySessionOutcome::BLUEZ_DBUS_UNKNOWN_ADAPTER; } else if (error_name == bluez::BluetoothAdapterClient::kNoResponseError) { - return UMABluetoothDiscoverySessionOutcome::CHROMEOS_DBUS_NO_RESPONSE; + return UMABluetoothDiscoverySessionOutcome::BLUEZ_DBUS_NO_RESPONSE; } else if (error_name == bluetooth_device::kErrorInProgress) { - return UMABluetoothDiscoverySessionOutcome::CHROMEOS_DBUS_IN_PROGRESS; + return UMABluetoothDiscoverySessionOutcome::BLUEZ_DBUS_IN_PROGRESS; } else if (error_name == bluetooth_device::kErrorNotReady) { - return UMABluetoothDiscoverySessionOutcome::CHROMEOS_DBUS_NOT_READY; + return UMABluetoothDiscoverySessionOutcome::BLUEZ_DBUS_NOT_READY; } else if (error_name == bluetooth_device::kErrorFailed) { return UMABluetoothDiscoverySessionOutcome::FAILED; } else { @@ -84,20 +87,20 @@ namespace device { // static base::WeakPtr<BluetoothAdapter> BluetoothAdapter::CreateAdapter( const InitCallback& init_callback) { - return chromeos::BluetoothAdapterChromeOS::CreateAdapter(); + return bluez::BluetoothAdapterBlueZ::CreateAdapter(); } } // namespace device -namespace chromeos { +namespace bluez { // static -base::WeakPtr<BluetoothAdapter> BluetoothAdapterChromeOS::CreateAdapter() { - BluetoothAdapterChromeOS* adapter = new BluetoothAdapterChromeOS(); +base::WeakPtr<BluetoothAdapter> BluetoothAdapterBlueZ::CreateAdapter() { + BluetoothAdapterBlueZ* adapter = new BluetoothAdapterBlueZ(); return adapter->weak_ptr_factory_.GetWeakPtr(); } -void BluetoothAdapterChromeOS::Shutdown() { +void BluetoothAdapterBlueZ::Shutdown() { if (dbus_is_shutdown_) return; DCHECK(bluez::BluezDBusManager::IsInitialized()) @@ -133,7 +136,7 @@ void BluetoothAdapterChromeOS::Shutdown() { dbus_is_shutdown_ = true; } -BluetoothAdapterChromeOS::BluetoothAdapterChromeOS() +BluetoothAdapterBlueZ::BluetoothAdapterBlueZ() : dbus_is_shutdown_(false), num_discovery_sessions_(0), discovery_request_pending_(false), @@ -162,11 +165,11 @@ BluetoothAdapterChromeOS::BluetoothAdapterChromeOS() } } -BluetoothAdapterChromeOS::~BluetoothAdapterChromeOS() { +BluetoothAdapterBlueZ::~BluetoothAdapterBlueZ() { Shutdown(); } -std::string BluetoothAdapterChromeOS::GetAddress() const { +std::string BluetoothAdapterBlueZ::GetAddress() const { if (!IsPresent()) return std::string(); @@ -179,7 +182,7 @@ std::string BluetoothAdapterChromeOS::GetAddress() const { return BluetoothDevice::CanonicalizeAddress(properties->address.value()); } -std::string BluetoothAdapterChromeOS::GetName() const { +std::string BluetoothAdapterBlueZ::GetName() const { if (!IsPresent()) return std::string(); @@ -192,9 +195,9 @@ std::string BluetoothAdapterChromeOS::GetName() const { return properties->alias.value(); } -void BluetoothAdapterChromeOS::SetName(const std::string& name, - const base::Closure& callback, - const ErrorCallback& error_callback) { +void BluetoothAdapterBlueZ::SetName(const std::string& name, + const base::Closure& callback, + const ErrorCallback& error_callback) { if (!IsPresent()) { error_callback.Run(); return; @@ -205,19 +208,19 @@ void BluetoothAdapterChromeOS::SetName(const std::string& name, ->GetProperties(object_path_) ->alias.Set( name, - base::Bind(&BluetoothAdapterChromeOS::OnPropertyChangeCompleted, + base::Bind(&BluetoothAdapterBlueZ::OnPropertyChangeCompleted, weak_ptr_factory_.GetWeakPtr(), callback, error_callback)); } -bool BluetoothAdapterChromeOS::IsInitialized() const { +bool BluetoothAdapterBlueZ::IsInitialized() const { return true; } -bool BluetoothAdapterChromeOS::IsPresent() const { +bool BluetoothAdapterBlueZ::IsPresent() const { return !dbus_is_shutdown_ && !object_path_.value().empty(); } -bool BluetoothAdapterChromeOS::IsPowered() const { +bool BluetoothAdapterBlueZ::IsPowered() const { if (!IsPresent()) return false; @@ -229,10 +232,9 @@ bool BluetoothAdapterChromeOS::IsPowered() const { return properties->powered.value(); } -void BluetoothAdapterChromeOS::SetPowered( - bool powered, - const base::Closure& callback, - const ErrorCallback& error_callback) { +void BluetoothAdapterBlueZ::SetPowered(bool powered, + const base::Closure& callback, + const ErrorCallback& error_callback) { if (!IsPresent()) { error_callback.Run(); return; @@ -243,11 +245,11 @@ void BluetoothAdapterChromeOS::SetPowered( ->GetProperties(object_path_) ->powered.Set( powered, - base::Bind(&BluetoothAdapterChromeOS::OnPropertyChangeCompleted, + base::Bind(&BluetoothAdapterBlueZ::OnPropertyChangeCompleted, weak_ptr_factory_.GetWeakPtr(), callback, error_callback)); } -bool BluetoothAdapterChromeOS::IsDiscoverable() const { +bool BluetoothAdapterBlueZ::IsDiscoverable() const { if (!IsPresent()) return false; @@ -259,7 +261,7 @@ bool BluetoothAdapterChromeOS::IsDiscoverable() const { return properties->discoverable.value(); } -void BluetoothAdapterChromeOS::SetDiscoverable( +void BluetoothAdapterBlueZ::SetDiscoverable( bool discoverable, const base::Closure& callback, const ErrorCallback& error_callback) { @@ -273,11 +275,11 @@ void BluetoothAdapterChromeOS::SetDiscoverable( ->GetProperties(object_path_) ->discoverable.Set( discoverable, - base::Bind(&BluetoothAdapterChromeOS::OnSetDiscoverable, + base::Bind(&BluetoothAdapterBlueZ::OnSetDiscoverable, weak_ptr_factory_.GetWeakPtr(), callback, error_callback)); } -bool BluetoothAdapterChromeOS::IsDiscovering() const { +bool BluetoothAdapterBlueZ::IsDiscovering() const { if (!IsPresent()) return false; @@ -289,45 +291,37 @@ bool BluetoothAdapterChromeOS::IsDiscovering() const { return properties->discovering.value(); } -void BluetoothAdapterChromeOS::CreateRfcommService( +void BluetoothAdapterBlueZ::CreateRfcommService( const BluetoothUUID& uuid, const ServiceOptions& options, const CreateServiceCallback& callback, const CreateServiceErrorCallback& error_callback) { DCHECK(!dbus_is_shutdown_); - VLOG(1) << object_path_.value() << ": Creating RFCOMM service: " - << uuid.canonical_value(); - scoped_refptr<BluetoothSocketChromeOS> socket = - BluetoothSocketChromeOS::CreateBluetoothSocket( - ui_task_runner_, socket_thread_); - socket->Listen(this, - BluetoothSocketChromeOS::kRfcomm, - uuid, - options, - base::Bind(callback, socket), - error_callback); -} - -void BluetoothAdapterChromeOS::CreateL2capService( + VLOG(1) << object_path_.value() + << ": Creating RFCOMM service: " << uuid.canonical_value(); + scoped_refptr<BluetoothSocketBlueZ> socket = + BluetoothSocketBlueZ::CreateBluetoothSocket(ui_task_runner_, + socket_thread_); + socket->Listen(this, BluetoothSocketBlueZ::kRfcomm, uuid, options, + base::Bind(callback, socket), error_callback); +} + +void BluetoothAdapterBlueZ::CreateL2capService( const BluetoothUUID& uuid, const ServiceOptions& options, const CreateServiceCallback& callback, const CreateServiceErrorCallback& error_callback) { DCHECK(!dbus_is_shutdown_); - VLOG(1) << object_path_.value() << ": Creating L2CAP service: " - << uuid.canonical_value(); - scoped_refptr<BluetoothSocketChromeOS> socket = - BluetoothSocketChromeOS::CreateBluetoothSocket( - ui_task_runner_, socket_thread_); - socket->Listen(this, - BluetoothSocketChromeOS::kL2cap, - uuid, - options, - base::Bind(callback, socket), - error_callback); -} - -void BluetoothAdapterChromeOS::RegisterAudioSink( + VLOG(1) << object_path_.value() + << ": Creating L2CAP service: " << uuid.canonical_value(); + scoped_refptr<BluetoothSocketBlueZ> socket = + BluetoothSocketBlueZ::CreateBluetoothSocket(ui_task_runner_, + socket_thread_); + socket->Listen(this, BluetoothSocketBlueZ::kL2cap, uuid, options, + base::Bind(callback, socket), error_callback); +} + +void BluetoothAdapterBlueZ::RegisterAudioSink( const BluetoothAudioSink::Options& options, const device::BluetoothAdapter::AcquiredCallback& callback, const BluetoothAudioSink::ErrorCallback& error_callback) { @@ -336,53 +330,52 @@ void BluetoothAdapterChromeOS::RegisterAudioSink( error_callback.Run(BluetoothAudioSink::ERROR_INVALID_ADAPTER); return; } - scoped_refptr<BluetoothAudioSinkChromeOS> audio_sink( - new BluetoothAudioSinkChromeOS(this)); - audio_sink->Register( - options, base::Bind(&BluetoothAdapterChromeOS::OnRegisterAudioSink, - weak_ptr_factory_.GetWeakPtr(), callback, - error_callback, audio_sink), - error_callback); + scoped_refptr<BluetoothAudioSinkBlueZ> audio_sink( + new BluetoothAudioSinkBlueZ(this)); + audio_sink->Register(options, + base::Bind(&BluetoothAdapterBlueZ::OnRegisterAudioSink, + weak_ptr_factory_.GetWeakPtr(), callback, + error_callback, audio_sink), + error_callback); } -void BluetoothAdapterChromeOS::RegisterAdvertisement( +void BluetoothAdapterBlueZ::RegisterAdvertisement( scoped_ptr<device::BluetoothAdvertisement::Data> advertisement_data, const CreateAdvertisementCallback& callback, const CreateAdvertisementErrorCallback& error_callback) { - scoped_refptr<BluetoothAdvertisementChromeOS> advertisement( - new BluetoothAdvertisementChromeOS(advertisement_data.Pass(), this)); + scoped_refptr<BluetoothAdvertisementBlueZ> advertisement( + new BluetoothAdvertisementBlueZ(advertisement_data.Pass(), this)); advertisement->Register(base::Bind(callback, advertisement), error_callback); } -void BluetoothAdapterChromeOS::RemovePairingDelegateInternal( +void BluetoothAdapterBlueZ::RemovePairingDelegateInternal( BluetoothDevice::PairingDelegate* pairing_delegate) { // Check if any device is using the pairing delegate. // If so, clear the pairing context which will make any responses no-ops. - for (DevicesMap::iterator iter = devices_.begin(); - iter != devices_.end(); ++iter) { - BluetoothDeviceChromeOS* device_chromeos = - static_cast<BluetoothDeviceChromeOS*>(iter->second); + for (DevicesMap::iterator iter = devices_.begin(); iter != devices_.end(); + ++iter) { + BluetoothDeviceBlueZ* device_bluez = + static_cast<BluetoothDeviceBlueZ*>(iter->second); - BluetoothPairingChromeOS* pairing = device_chromeos->GetPairing(); + BluetoothPairingBlueZ* pairing = device_bluez->GetPairing(); if (pairing && pairing->GetPairingDelegate() == pairing_delegate) - device_chromeos->EndPairing(); + device_bluez->EndPairing(); } } -void BluetoothAdapterChromeOS::AdapterAdded( - const dbus::ObjectPath& object_path) { +void BluetoothAdapterBlueZ::AdapterAdded(const dbus::ObjectPath& object_path) { // Set the adapter to the newly added adapter only if no adapter is present. if (!IsPresent()) SetAdapter(object_path); } -void BluetoothAdapterChromeOS::AdapterRemoved( +void BluetoothAdapterBlueZ::AdapterRemoved( const dbus::ObjectPath& object_path) { if (object_path == object_path_) RemoveAdapter(); } -void BluetoothAdapterChromeOS::AdapterPropertyChanged( +void BluetoothAdapterBlueZ::AdapterPropertyChanged( const dbus::ObjectPath& object_path, const std::string& property_name) { if (object_path != object_path_) @@ -403,8 +396,7 @@ void BluetoothAdapterChromeOS::AdapterPropertyChanged( } } -void BluetoothAdapterChromeOS::DeviceAdded( - const dbus::ObjectPath& object_path) { +void BluetoothAdapterBlueZ::DeviceAdded(const dbus::ObjectPath& object_path) { DCHECK(bluez::BluezDBusManager::Get()); bluez::BluetoothDeviceClient::Properties* properties = bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( @@ -413,41 +405,37 @@ void BluetoothAdapterChromeOS::DeviceAdded( return; DCHECK(IsPresent()); - BluetoothDeviceChromeOS* device_chromeos = - new BluetoothDeviceChromeOS(this, - object_path, - ui_task_runner_, - socket_thread_); - DCHECK(devices_.find(device_chromeos->GetAddress()) == devices_.end()); + BluetoothDeviceBlueZ* device_bluez = new BluetoothDeviceBlueZ( + this, object_path, ui_task_runner_, socket_thread_); + DCHECK(devices_.find(device_bluez->GetAddress()) == devices_.end()); - devices_[device_chromeos->GetAddress()] = device_chromeos; + devices_[device_bluez->GetAddress()] = device_bluez; FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, - DeviceAdded(this, device_chromeos)); + DeviceAdded(this, device_bluez)); } -void BluetoothAdapterChromeOS::DeviceRemoved( - const dbus::ObjectPath& object_path) { - for (DevicesMap::iterator iter = devices_.begin(); - iter != devices_.end(); ++iter) { - BluetoothDeviceChromeOS* device_chromeos = - static_cast<BluetoothDeviceChromeOS*>(iter->second); - if (device_chromeos->object_path() == object_path) { +void BluetoothAdapterBlueZ::DeviceRemoved(const dbus::ObjectPath& object_path) { + for (DevicesMap::iterator iter = devices_.begin(); iter != devices_.end(); + ++iter) { + BluetoothDeviceBlueZ* device_bluez = + static_cast<BluetoothDeviceBlueZ*>(iter->second); + if (device_bluez->object_path() == object_path) { devices_.erase(iter); FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, - DeviceRemoved(this, device_chromeos)); - delete device_chromeos; + DeviceRemoved(this, device_bluez)); + delete device_bluez; return; } } } -void BluetoothAdapterChromeOS::DevicePropertyChanged( +void BluetoothAdapterBlueZ::DevicePropertyChanged( const dbus::ObjectPath& object_path, const std::string& property_name) { - BluetoothDeviceChromeOS* device_chromeos = GetDeviceWithPath(object_path); - if (!device_chromeos) + BluetoothDeviceBlueZ* device_bluez = GetDeviceWithPath(object_path); + if (!device_bluez) return; bluez::BluetoothDeviceClient::Properties* properties = @@ -456,15 +444,15 @@ void BluetoothAdapterChromeOS::DevicePropertyChanged( if (property_name == properties->address.name()) { for (auto iter = devices_.begin(); iter != devices_.end(); ++iter) { - if (iter->second->GetAddress() == device_chromeos->GetAddress()) { + if (iter->second->GetAddress() == device_bluez->GetAddress()) { std::string old_address = iter->first; VLOG(1) << "Device changed address, old: " << old_address - << " new: " << device_chromeos->GetAddress(); + << " new: " << device_bluez->GetAddress(); devices_.erase(iter); - DCHECK(devices_.find(device_chromeos->GetAddress()) == devices_.end()); - devices_[device_chromeos->GetAddress()] = device_chromeos; - NotifyDeviceAddressChanged(device_chromeos, old_address); + DCHECK(devices_.find(device_bluez->GetAddress()) == devices_.end()); + devices_[device_bluez->GetAddress()] = device_bluez; + NotifyDeviceAddressChanged(device_bluez, old_address); break; } } @@ -479,14 +467,14 @@ void BluetoothAdapterChromeOS::DevicePropertyChanged( property_name == properties->uuids.name() || property_name == properties->rssi.name() || property_name == properties->tx_power.name()) { - NotifyDeviceChanged(device_chromeos); + NotifyDeviceChanged(device_bluez); } // When a device becomes paired, mark it as trusted so that the user does // not need to approve every incoming connection if (property_name == properties->paired.name() && properties->paired.value() && !properties->trusted.value()) { - device_chromeos->SetTrusted(); + device_bluez->SetTrusted(); } // UMA connection counting @@ -494,14 +482,14 @@ void BluetoothAdapterChromeOS::DevicePropertyChanged( // PlayStation joystick tries to reconnect after disconnection from USB. // If it is still not trusted, set it, so it becomes available on the // list of known devices. - if (properties->connected.value() && device_chromeos->IsTrustable() && + if (properties->connected.value() && device_bluez->IsTrustable() && !properties->trusted.value()) - device_chromeos->SetTrusted(); + device_bluez->SetTrusted(); int count = 0; - for (DevicesMap::iterator iter = devices_.begin(); - iter != devices_.end(); ++iter) { + for (DevicesMap::iterator iter = devices_.begin(); iter != devices_.end(); + ++iter) { if (iter->second->IsPaired() && iter->second->IsConnected()) ++count; } @@ -510,11 +498,11 @@ void BluetoothAdapterChromeOS::DevicePropertyChanged( } } -void BluetoothAdapterChromeOS::InputPropertyChanged( +void BluetoothAdapterBlueZ::InputPropertyChanged( const dbus::ObjectPath& object_path, const std::string& property_name) { - BluetoothDeviceChromeOS* device_chromeos = GetDeviceWithPath(object_path); - if (!device_chromeos) + BluetoothDeviceBlueZ* device_bluez = GetDeviceWithPath(object_path); + if (!device_bluez) return; bluez::BluetoothInputClient::Properties* properties = @@ -525,11 +513,11 @@ void BluetoothAdapterChromeOS::InputPropertyChanged( // BluetoothDevice::IsConnectable() property, as does a change in the // actual reconnect_mode property. if (!properties || property_name == properties->reconnect_mode.name()) { - NotifyDeviceChanged(device_chromeos); + NotifyDeviceChanged(device_bluez); } } -void BluetoothAdapterChromeOS::Released() { +void BluetoothAdapterBlueZ::Released() { VLOG(1) << "Release"; if (!IsPresent()) return; @@ -539,14 +527,13 @@ void BluetoothAdapterChromeOS::Released() { // capabilities. Nothing much to be done right now. } -void BluetoothAdapterChromeOS::RequestPinCode( - const dbus::ObjectPath& device_path, - const PinCodeCallback& callback) { +void BluetoothAdapterBlueZ::RequestPinCode(const dbus::ObjectPath& device_path, + const PinCodeCallback& callback) { DCHECK(IsPresent()); DCHECK(agent_.get()); VLOG(1) << device_path.value() << ": RequestPinCode"; - BluetoothPairingChromeOS* pairing = GetPairing(device_path); + BluetoothPairingBlueZ* pairing = GetPairing(device_path); if (!pairing) { callback.Run(REJECTED, ""); return; @@ -555,28 +542,26 @@ void BluetoothAdapterChromeOS::RequestPinCode( pairing->RequestPinCode(callback); } -void BluetoothAdapterChromeOS::DisplayPinCode( - const dbus::ObjectPath& device_path, - const std::string& pincode) { +void BluetoothAdapterBlueZ::DisplayPinCode(const dbus::ObjectPath& device_path, + const std::string& pincode) { DCHECK(IsPresent()); DCHECK(agent_.get()); VLOG(1) << device_path.value() << ": DisplayPinCode: " << pincode; - BluetoothPairingChromeOS* pairing = GetPairing(device_path); + BluetoothPairingBlueZ* pairing = GetPairing(device_path); if (!pairing) return; pairing->DisplayPinCode(pincode); } -void BluetoothAdapterChromeOS::RequestPasskey( - const dbus::ObjectPath& device_path, - const PasskeyCallback& callback) { +void BluetoothAdapterBlueZ::RequestPasskey(const dbus::ObjectPath& device_path, + const PasskeyCallback& callback) { DCHECK(IsPresent()); DCHECK(agent_.get()); VLOG(1) << device_path.value() << ": RequestPasskey"; - BluetoothPairingChromeOS* pairing = GetPairing(device_path); + BluetoothPairingBlueZ* pairing = GetPairing(device_path); if (!pairing) { callback.Run(REJECTED, 0); return; @@ -585,16 +570,15 @@ void BluetoothAdapterChromeOS::RequestPasskey( pairing->RequestPasskey(callback); } -void BluetoothAdapterChromeOS::DisplayPasskey( - const dbus::ObjectPath& device_path, - uint32 passkey, - uint16 entered) { +void BluetoothAdapterBlueZ::DisplayPasskey(const dbus::ObjectPath& device_path, + uint32 passkey, + uint16 entered) { DCHECK(IsPresent()); DCHECK(agent_.get()); - VLOG(1) << device_path.value() << ": DisplayPasskey: " << passkey - << " (" << entered << " entered)"; + VLOG(1) << device_path.value() << ": DisplayPasskey: " << passkey << " (" + << entered << " entered)"; - BluetoothPairingChromeOS* pairing = GetPairing(device_path); + BluetoothPairingBlueZ* pairing = GetPairing(device_path); if (!pairing) return; @@ -604,7 +588,7 @@ void BluetoothAdapterChromeOS::DisplayPasskey( pairing->KeysEntered(entered); } -void BluetoothAdapterChromeOS::RequestConfirmation( +void BluetoothAdapterBlueZ::RequestConfirmation( const dbus::ObjectPath& device_path, uint32 passkey, const ConfirmationCallback& callback) { @@ -612,7 +596,7 @@ void BluetoothAdapterChromeOS::RequestConfirmation( DCHECK(agent_.get()); VLOG(1) << device_path.value() << ": RequestConfirmation: " << passkey; - BluetoothPairingChromeOS* pairing = GetPairing(device_path); + BluetoothPairingBlueZ* pairing = GetPairing(device_path); if (!pairing) { callback.Run(REJECTED); return; @@ -621,14 +605,14 @@ void BluetoothAdapterChromeOS::RequestConfirmation( pairing->RequestConfirmation(passkey, callback); } -void BluetoothAdapterChromeOS::RequestAuthorization( +void BluetoothAdapterBlueZ::RequestAuthorization( const dbus::ObjectPath& device_path, const ConfirmationCallback& callback) { DCHECK(IsPresent()); DCHECK(agent_.get()); VLOG(1) << device_path.value() << ": RequestAuthorization"; - BluetoothPairingChromeOS* pairing = GetPairing(device_path); + BluetoothPairingBlueZ* pairing = GetPairing(device_path); if (!pairing) { callback.Run(REJECTED); return; @@ -637,7 +621,7 @@ void BluetoothAdapterChromeOS::RequestAuthorization( pairing->RequestAuthorization(callback); } -void BluetoothAdapterChromeOS::AuthorizeService( +void BluetoothAdapterBlueZ::AuthorizeService( const dbus::ObjectPath& device_path, const std::string& uuid, const ConfirmationCallback& callback) { @@ -645,8 +629,8 @@ void BluetoothAdapterChromeOS::AuthorizeService( DCHECK(agent_.get()); VLOG(1) << device_path.value() << ": AuthorizeService: " << uuid; - BluetoothDeviceChromeOS* device_chromeos = GetDeviceWithPath(device_path); - if (!device_chromeos) { + BluetoothDeviceBlueZ* device_bluez = GetDeviceWithPath(device_path); + if (!device_bluez) { callback.Run(CANCELLED); return; } @@ -655,7 +639,7 @@ void BluetoothAdapterChromeOS::AuthorizeService( // method call would ever be called is in the case of a race condition where // our "Set('Trusted', true)" method call is still pending in the Bluetooth // daemon because it's busy handling the incoming connection. - if (device_chromeos->IsPaired()) { + if (device_bluez->IsPaired()) { callback.Run(SUCCESS); return; } @@ -663,52 +647,52 @@ void BluetoothAdapterChromeOS::AuthorizeService( // TODO(keybuk): reject service authorizations when not paired, determine // whether this is acceptable long-term. LOG(WARNING) << "Rejecting service connection from unpaired device " - << device_chromeos->GetAddress() << " for UUID " << uuid; + << device_bluez->GetAddress() << " for UUID " << uuid; callback.Run(REJECTED); } -void BluetoothAdapterChromeOS::Cancel() { +void BluetoothAdapterBlueZ::Cancel() { DCHECK(IsPresent()); DCHECK(agent_.get()); VLOG(1) << "Cancel"; } -void BluetoothAdapterChromeOS::OnRegisterAgent() { +void BluetoothAdapterBlueZ::OnRegisterAgent() { VLOG(1) << "Pairing agent registered, requesting to be made default"; bluez::BluezDBusManager::Get() ->GetBluetoothAgentManagerClient() ->RequestDefaultAgent( dbus::ObjectPath(kAgentPath), - base::Bind(&BluetoothAdapterChromeOS::OnRequestDefaultAgent, + base::Bind(&BluetoothAdapterBlueZ::OnRequestDefaultAgent, weak_ptr_factory_.GetWeakPtr()), - base::Bind(&BluetoothAdapterChromeOS::OnRequestDefaultAgentError, + base::Bind(&BluetoothAdapterBlueZ::OnRequestDefaultAgentError, weak_ptr_factory_.GetWeakPtr())); } -void BluetoothAdapterChromeOS::OnRegisterAgentError( +void BluetoothAdapterBlueZ::OnRegisterAgentError( const std::string& error_name, const std::string& error_message) { // Our agent being already registered isn't an error. if (error_name == bluetooth_agent_manager::kErrorAlreadyExists) return; - LOG(WARNING) << ": Failed to register pairing agent: " - << error_name << ": " << error_message; + LOG(WARNING) << ": Failed to register pairing agent: " << error_name << ": " + << error_message; } -void BluetoothAdapterChromeOS::OnRequestDefaultAgent() { +void BluetoothAdapterBlueZ::OnRequestDefaultAgent() { VLOG(1) << "Pairing agent now default"; } -void BluetoothAdapterChromeOS::OnRequestDefaultAgentError( +void BluetoothAdapterBlueZ::OnRequestDefaultAgentError( const std::string& error_name, const std::string& error_message) { - LOG(WARNING) << ": Failed to make pairing agent default: " - << error_name << ": " << error_message; + LOG(WARNING) << ": Failed to make pairing agent default: " << error_name + << ": " << error_message; } -void BluetoothAdapterChromeOS::OnRegisterAudioSink( +void BluetoothAdapterBlueZ::OnRegisterAudioSink( const device::BluetoothAdapter::AcquiredCallback& callback, const device::BluetoothAudioSink::ErrorCallback& error_callback, scoped_refptr<BluetoothAudioSink> audio_sink) { @@ -721,34 +705,33 @@ void BluetoothAdapterChromeOS::OnRegisterAudioSink( callback.Run(audio_sink); } -BluetoothDeviceChromeOS* -BluetoothAdapterChromeOS::GetDeviceWithPath( +BluetoothDeviceBlueZ* BluetoothAdapterBlueZ::GetDeviceWithPath( const dbus::ObjectPath& object_path) { if (!IsPresent()) return nullptr; for (DevicesMap::iterator iter = devices_.begin(); iter != devices_.end(); ++iter) { - BluetoothDeviceChromeOS* device_chromeos = - static_cast<BluetoothDeviceChromeOS*>(iter->second); - if (device_chromeos->object_path() == object_path) - return device_chromeos; + BluetoothDeviceBlueZ* device_bluez = + static_cast<BluetoothDeviceBlueZ*>(iter->second); + if (device_bluez->object_path() == object_path) + return device_bluez; } return nullptr; } -BluetoothPairingChromeOS* BluetoothAdapterChromeOS::GetPairing( +BluetoothPairingBlueZ* BluetoothAdapterBlueZ::GetPairing( const dbus::ObjectPath& object_path) { DCHECK(IsPresent()); - BluetoothDeviceChromeOS* device_chromeos = GetDeviceWithPath(object_path); - if (!device_chromeos) { + BluetoothDeviceBlueZ* device_bluez = GetDeviceWithPath(object_path); + if (!device_bluez) { LOG(WARNING) << "Pairing Agent request for unknown device: " << object_path.value(); return nullptr; } - BluetoothPairingChromeOS* pairing = device_chromeos->GetPairing(); + BluetoothPairingBlueZ* pairing = device_bluez->GetPairing(); if (pairing) return pairing; @@ -758,10 +741,10 @@ BluetoothPairingChromeOS* BluetoothAdapterChromeOS::GetPairing( if (!pairing_delegate) return nullptr; - return device_chromeos->BeginPairing(pairing_delegate); + return device_bluez->BeginPairing(pairing_delegate); } -void BluetoothAdapterChromeOS::SetAdapter(const dbus::ObjectPath& object_path) { +void BluetoothAdapterBlueZ::SetAdapter(const dbus::ObjectPath& object_path) { DCHECK(!IsPresent()); DCHECK(!dbus_is_shutdown_); object_path_ = object_path; @@ -771,13 +754,12 @@ void BluetoothAdapterChromeOS::SetAdapter(const dbus::ObjectPath& object_path) { VLOG(1) << "Registering pairing agent"; bluez::BluezDBusManager::Get() ->GetBluetoothAgentManagerClient() - ->RegisterAgent( - dbus::ObjectPath(kAgentPath), - bluetooth_agent_manager::kKeyboardDisplayCapability, - base::Bind(&BluetoothAdapterChromeOS::OnRegisterAgent, - weak_ptr_factory_.GetWeakPtr()), - base::Bind(&BluetoothAdapterChromeOS::OnRegisterAgentError, - weak_ptr_factory_.GetWeakPtr())); + ->RegisterAgent(dbus::ObjectPath(kAgentPath), + bluetooth_agent_manager::kKeyboardDisplayCapability, + base::Bind(&BluetoothAdapterBlueZ::OnRegisterAgent, + weak_ptr_factory_.GetWeakPtr()), + base::Bind(&BluetoothAdapterBlueZ::OnRegisterAgentError, + weak_ptr_factory_.GetWeakPtr())); SetDefaultAdapterName(); @@ -806,32 +788,36 @@ void BluetoothAdapterChromeOS::SetAdapter(const dbus::ObjectPath& object_path) { } } -void BluetoothAdapterChromeOS::SetDefaultAdapterName() { +void BluetoothAdapterBlueZ::SetDefaultAdapterName() { DCHECK(IsPresent()); std::string alias; +#if defined(OS_CHROMEOS) switch (chromeos::GetDeviceType()) { - case DeviceType::kChromebase: + case chromeos::DeviceType::kChromebase: alias = "Chromebase"; break; - case DeviceType::kChromebit: + case chromeos::DeviceType::kChromebit: alias = "Chromebit"; break; - case DeviceType::kChromebook: + case chromeos::DeviceType::kChromebook: alias = "Chromebook"; break; - case DeviceType::kChromebox: + case chromeos::DeviceType::kChromebox: alias = "Chromebox"; break; - case DeviceType::kUnknown: + case chromeos::DeviceType::kUnknown: alias = "Chromebook"; break; } +#elif defined(OS_LINUX) + alias = "ChromeLinux"; +#endif SetName(alias, base::Bind(&base::DoNothing), base::Bind(&base::DoNothing)); } -void BluetoothAdapterChromeOS::RemoveAdapter() { +void BluetoothAdapterBlueZ::RemoveAdapter() { DCHECK(IsPresent()); VLOG(1) << object_path_.value() << ": adapter removed."; @@ -854,8 +840,8 @@ void BluetoothAdapterChromeOS::RemoveAdapter() { DevicesMap devices = devices_; devices_.clear(); - for (DevicesMap::iterator iter = devices.begin(); - iter != devices.end(); ++iter) { + for (DevicesMap::iterator iter = devices.begin(); iter != devices.end(); + ++iter) { FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, DeviceRemoved(this, iter->second)); delete iter->second; @@ -864,18 +850,17 @@ void BluetoothAdapterChromeOS::RemoveAdapter() { PresentChanged(false); } -void BluetoothAdapterChromeOS::PoweredChanged(bool powered) { +void BluetoothAdapterBlueZ::PoweredChanged(bool powered) { FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, AdapterPoweredChanged(this, powered)); } -void BluetoothAdapterChromeOS::DiscoverableChanged(bool discoverable) { +void BluetoothAdapterBlueZ::DiscoverableChanged(bool discoverable) { FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, AdapterDiscoverableChanged(this, discoverable)); } -void BluetoothAdapterChromeOS::DiscoveringChanged( - bool discovering) { +void BluetoothAdapterBlueZ::DiscoveringChanged(bool discovering) { // If the adapter stopped discovery due to a reason other than a request by // us, reset the count to 0. VLOG(1) << "Discovering changed: " << discovering; @@ -889,13 +874,12 @@ void BluetoothAdapterChromeOS::DiscoveringChanged( AdapterDiscoveringChanged(this, discovering)); } -void BluetoothAdapterChromeOS::PresentChanged(bool present) { +void BluetoothAdapterBlueZ::PresentChanged(bool present) { FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, AdapterPresentChanged(this, present)); } -void BluetoothAdapterChromeOS::NotifyDeviceChanged( - BluetoothDeviceChromeOS* device) { +void BluetoothAdapterBlueZ::NotifyDeviceChanged(BluetoothDeviceBlueZ* device) { DCHECK(device); DCHECK(device->adapter_ == this); @@ -903,8 +887,8 @@ void BluetoothAdapterChromeOS::NotifyDeviceChanged( DeviceChanged(this, device)); } -void BluetoothAdapterChromeOS::NotifyDeviceAddressChanged( - BluetoothDeviceChromeOS* device, +void BluetoothAdapterBlueZ::NotifyDeviceAddressChanged( + BluetoothDeviceBlueZ* device, const std::string& old_address) { DCHECK(device->adapter_ == this); @@ -912,118 +896,112 @@ void BluetoothAdapterChromeOS::NotifyDeviceAddressChanged( DeviceAddressChanged(this, device, old_address)); } -void BluetoothAdapterChromeOS::NotifyGattServiceAdded( - BluetoothRemoteGattServiceChromeOS* service) { +void BluetoothAdapterBlueZ::NotifyGattServiceAdded( + BluetoothRemoteGattServiceBlueZ* service) { DCHECK_EQ(service->GetAdapter(), this); - DCHECK_EQ( - static_cast<BluetoothDeviceChromeOS*>(service->GetDevice())->adapter_, - this); + DCHECK_EQ(static_cast<BluetoothDeviceBlueZ*>(service->GetDevice())->adapter_, + this); - FOR_EACH_OBSERVER(BluetoothAdapter::Observer, - observers_, + FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, GattServiceAdded(this, service->GetDevice(), service)); } -void BluetoothAdapterChromeOS::NotifyGattServiceRemoved( - BluetoothRemoteGattServiceChromeOS* service) { +void BluetoothAdapterBlueZ::NotifyGattServiceRemoved( + BluetoothRemoteGattServiceBlueZ* service) { DCHECK_EQ(service->GetAdapter(), this); - DCHECK_EQ( - static_cast<BluetoothDeviceChromeOS*>(service->GetDevice())->adapter_, - this); + DCHECK_EQ(static_cast<BluetoothDeviceBlueZ*>(service->GetDevice())->adapter_, + this); - FOR_EACH_OBSERVER(BluetoothAdapter::Observer, - observers_, + FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, GattServiceRemoved(this, service->GetDevice(), service)); } -void BluetoothAdapterChromeOS::NotifyGattServiceChanged( - BluetoothRemoteGattServiceChromeOS* service) { +void BluetoothAdapterBlueZ::NotifyGattServiceChanged( + BluetoothRemoteGattServiceBlueZ* service) { DCHECK_EQ(service->GetAdapter(), this); - FOR_EACH_OBSERVER(BluetoothAdapter::Observer, - observers_, + FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, GattServiceChanged(this, service)); } -void BluetoothAdapterChromeOS::NotifyGattDiscoveryComplete( - BluetoothRemoteGattServiceChromeOS* service) { +void BluetoothAdapterBlueZ::NotifyGattDiscoveryComplete( + BluetoothRemoteGattServiceBlueZ* service) { DCHECK_EQ(service->GetAdapter(), this); - FOR_EACH_OBSERVER(BluetoothAdapter::Observer, - observers_, + FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, GattDiscoveryCompleteForService(this, service)); } -void BluetoothAdapterChromeOS::NotifyGattCharacteristicAdded( - BluetoothRemoteGattCharacteristicChromeOS* characteristic) { - DCHECK_EQ(static_cast<BluetoothRemoteGattServiceChromeOS*>( - characteristic->GetService())->GetAdapter(), +void BluetoothAdapterBlueZ::NotifyGattCharacteristicAdded( + BluetoothRemoteGattCharacteristicBlueZ* characteristic) { + DCHECK_EQ(static_cast<BluetoothRemoteGattServiceBlueZ*>( + characteristic->GetService()) + ->GetAdapter(), this); - FOR_EACH_OBSERVER(BluetoothAdapter::Observer, - observers_, + FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, GattCharacteristicAdded(this, characteristic)); } -void BluetoothAdapterChromeOS::NotifyGattCharacteristicRemoved( - BluetoothRemoteGattCharacteristicChromeOS* characteristic) { - DCHECK_EQ(static_cast<BluetoothRemoteGattServiceChromeOS*>( - characteristic->GetService())->GetAdapter(), +void BluetoothAdapterBlueZ::NotifyGattCharacteristicRemoved( + BluetoothRemoteGattCharacteristicBlueZ* characteristic) { + DCHECK_EQ(static_cast<BluetoothRemoteGattServiceBlueZ*>( + characteristic->GetService()) + ->GetAdapter(), this); - FOR_EACH_OBSERVER(BluetoothAdapter::Observer, - observers_, + FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, GattCharacteristicRemoved(this, characteristic)); } -void BluetoothAdapterChromeOS::NotifyGattDescriptorAdded( - BluetoothRemoteGattDescriptorChromeOS* descriptor) { - DCHECK_EQ(static_cast<BluetoothRemoteGattServiceChromeOS*>( - descriptor->GetCharacteristic()->GetService())->GetAdapter(), +void BluetoothAdapterBlueZ::NotifyGattDescriptorAdded( + BluetoothRemoteGattDescriptorBlueZ* descriptor) { + DCHECK_EQ(static_cast<BluetoothRemoteGattServiceBlueZ*>( + descriptor->GetCharacteristic()->GetService()) + ->GetAdapter(), this); - FOR_EACH_OBSERVER(BluetoothAdapter::Observer, - observers_, + FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, GattDescriptorAdded(this, descriptor)); } -void BluetoothAdapterChromeOS::NotifyGattDescriptorRemoved( - BluetoothRemoteGattDescriptorChromeOS* descriptor) { - DCHECK_EQ(static_cast<BluetoothRemoteGattServiceChromeOS*>( - descriptor->GetCharacteristic()->GetService())->GetAdapter(), +void BluetoothAdapterBlueZ::NotifyGattDescriptorRemoved( + BluetoothRemoteGattDescriptorBlueZ* descriptor) { + DCHECK_EQ(static_cast<BluetoothRemoteGattServiceBlueZ*>( + descriptor->GetCharacteristic()->GetService()) + ->GetAdapter(), this); - FOR_EACH_OBSERVER(BluetoothAdapter::Observer, - observers_, + FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, GattDescriptorRemoved(this, descriptor)); } -void BluetoothAdapterChromeOS::NotifyGattCharacteristicValueChanged( - BluetoothRemoteGattCharacteristicChromeOS* characteristic, +void BluetoothAdapterBlueZ::NotifyGattCharacteristicValueChanged( + BluetoothRemoteGattCharacteristicBlueZ* characteristic, const std::vector<uint8>& value) { - DCHECK_EQ(static_cast<BluetoothRemoteGattServiceChromeOS*>( - characteristic->GetService())->GetAdapter(), + DCHECK_EQ(static_cast<BluetoothRemoteGattServiceBlueZ*>( + characteristic->GetService()) + ->GetAdapter(), this); FOR_EACH_OBSERVER( - BluetoothAdapter::Observer, - observers_, + BluetoothAdapter::Observer, observers_, GattCharacteristicValueChanged(this, characteristic, value)); } -void BluetoothAdapterChromeOS::NotifyGattDescriptorValueChanged( - BluetoothRemoteGattDescriptorChromeOS* descriptor, +void BluetoothAdapterBlueZ::NotifyGattDescriptorValueChanged( + BluetoothRemoteGattDescriptorBlueZ* descriptor, const std::vector<uint8>& value) { - DCHECK_EQ(static_cast<BluetoothRemoteGattServiceChromeOS*>( - descriptor->GetCharacteristic()->GetService())->GetAdapter(), + DCHECK_EQ(static_cast<BluetoothRemoteGattServiceBlueZ*>( + descriptor->GetCharacteristic()->GetService()) + ->GetAdapter(), this); - FOR_EACH_OBSERVER(BluetoothAdapter::Observer, - observers_, + FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, GattDescriptorValueChanged(this, descriptor, value)); } -void BluetoothAdapterChromeOS::UseProfile( +void BluetoothAdapterBlueZ::UseProfile( const BluetoothUUID& uuid, const dbus::ObjectPath& device_path, const bluez::BluetoothProfileManagerClient::Options& options, @@ -1047,32 +1025,31 @@ void BluetoothAdapterChromeOS::UseProfile( } if (profile_queues_.find(uuid) == profile_queues_.end()) { - BluetoothAdapterProfileChromeOS::Register( + BluetoothAdapterProfileBlueZ::Register( uuid, options, - base::Bind(&BluetoothAdapterChromeOS::OnRegisterProfile, this, uuid), - base::Bind(&BluetoothAdapterChromeOS::OnRegisterProfileError, this, - uuid)); + base::Bind(&BluetoothAdapterBlueZ::OnRegisterProfile, this, uuid), + base::Bind(&BluetoothAdapterBlueZ::OnRegisterProfileError, this, uuid)); profile_queues_[uuid] = new std::vector<RegisterProfileCompletionPair>(); } profile_queues_[uuid]->push_back(std::make_pair( - base::Bind(&BluetoothAdapterChromeOS::SetProfileDelegate, this, uuid, + base::Bind(&BluetoothAdapterBlueZ::SetProfileDelegate, this, uuid, device_path, delegate, success_callback, error_callback), error_callback)); } -void BluetoothAdapterChromeOS::ReleaseProfile( +void BluetoothAdapterBlueZ::ReleaseProfile( const dbus::ObjectPath& device_path, - BluetoothAdapterProfileChromeOS* profile) { + BluetoothAdapterProfileBlueZ* profile) { VLOG(2) << "Releasing Profile: " << profile->uuid().canonical_value() << " from " << device_path.value(); profile->RemoveDelegate( - device_path, base::Bind(&BluetoothAdapterChromeOS::RemoveProfile, + device_path, base::Bind(&BluetoothAdapterBlueZ::RemoveProfile, weak_ptr_factory_.GetWeakPtr(), profile->uuid())); } -void BluetoothAdapterChromeOS::RemoveProfile(const BluetoothUUID& uuid) { +void BluetoothAdapterBlueZ::RemoveProfile(const BluetoothUUID& uuid) { VLOG(2) << "Remove Profile: " << uuid.canonical_value(); if (profiles_.find(uuid) != profiles_.end()) { @@ -1081,9 +1058,9 @@ void BluetoothAdapterChromeOS::RemoveProfile(const BluetoothUUID& uuid) { } } -void BluetoothAdapterChromeOS::OnRegisterProfile( +void BluetoothAdapterBlueZ::OnRegisterProfile( const BluetoothUUID& uuid, - scoped_ptr<BluetoothAdapterProfileChromeOS> profile) { + scoped_ptr<BluetoothAdapterProfileBlueZ> profile) { profiles_[uuid] = profile.release(); if (profile_queues_.find(uuid) == profile_queues_.end()) @@ -1095,7 +1072,7 @@ void BluetoothAdapterChromeOS::OnRegisterProfile( profile_queues_.erase(uuid); } -void BluetoothAdapterChromeOS::SetProfileDelegate( +void BluetoothAdapterBlueZ::SetProfileDelegate( const BluetoothUUID& uuid, const dbus::ObjectPath& device_path, bluez::BluetoothProfileServiceProvider::Delegate* delegate, @@ -1114,12 +1091,13 @@ void BluetoothAdapterChromeOS::SetProfileDelegate( error_callback.Run(bluetooth_agent_manager::kErrorAlreadyExists); } -void BluetoothAdapterChromeOS::OnRegisterProfileError( +void BluetoothAdapterBlueZ::OnRegisterProfileError( const BluetoothUUID& uuid, const std::string& error_name, const std::string& error_message) { - VLOG(2) << object_path_.value() << ": Failed to register profile: " - << error_name << ": " << error_message; + VLOG(2) << object_path_.value() + << ": Failed to register profile: " << error_name << ": " + << error_message; if (profile_queues_.find(uuid) == profile_queues_.end()) return; @@ -1130,7 +1108,7 @@ void BluetoothAdapterChromeOS::OnRegisterProfileError( profile_queues_.erase(uuid); } -void BluetoothAdapterChromeOS::OnSetDiscoverable( +void BluetoothAdapterBlueZ::OnSetDiscoverable( const base::Closure& callback, const ErrorCallback& error_callback, bool success) { @@ -1146,11 +1124,11 @@ void BluetoothAdapterChromeOS::OnSetDiscoverable( ->GetProperties(object_path_) ->discoverable_timeout.Set( 0, - base::Bind(&BluetoothAdapterChromeOS::OnPropertyChangeCompleted, + base::Bind(&BluetoothAdapterBlueZ::OnPropertyChangeCompleted, weak_ptr_factory_.GetWeakPtr(), callback, error_callback)); } -void BluetoothAdapterChromeOS::OnPropertyChangeCompleted( +void BluetoothAdapterBlueZ::OnPropertyChangeCompleted( const base::Closure& callback, const ErrorCallback& error_callback, bool success) { @@ -1161,7 +1139,7 @@ void BluetoothAdapterChromeOS::OnPropertyChangeCompleted( } } -void BluetoothAdapterChromeOS::AddDiscoverySession( +void BluetoothAdapterBlueZ::AddDiscoverySession( BluetoothDiscoveryFilter* discovery_filter, const base::Closure& callback, const DiscoverySessionErrorCallback& error_callback) { @@ -1204,9 +1182,9 @@ void BluetoothAdapterChromeOS::AddDiscoverySession( df->CopyFrom(*discovery_filter); SetDiscoveryFilter( df.Pass(), - base::Bind(&BluetoothAdapterChromeOS::OnPreSetDiscoveryFilter, + base::Bind(&BluetoothAdapterBlueZ::OnPreSetDiscoveryFilter, weak_ptr_factory_.GetWeakPtr(), callback, error_callback), - base::Bind(&BluetoothAdapterChromeOS::OnPreSetDiscoveryFilterError, + base::Bind(&BluetoothAdapterBlueZ::OnPreSetDiscoveryFilterError, weak_ptr_factory_.GetWeakPtr(), callback, error_callback)); return; } else { @@ -1217,13 +1195,13 @@ void BluetoothAdapterChromeOS::AddDiscoverySession( discovery_request_pending_ = true; bluez::BluezDBusManager::Get()->GetBluetoothAdapterClient()->StartDiscovery( object_path_, - base::Bind(&BluetoothAdapterChromeOS::OnStartDiscovery, + base::Bind(&BluetoothAdapterBlueZ::OnStartDiscovery, weak_ptr_factory_.GetWeakPtr(), callback, error_callback), - base::Bind(&BluetoothAdapterChromeOS::OnStartDiscoveryError, + base::Bind(&BluetoothAdapterBlueZ::OnStartDiscoveryError, weak_ptr_factory_.GetWeakPtr(), callback, error_callback)); } -void BluetoothAdapterChromeOS::RemoveDiscoverySession( +void BluetoothAdapterBlueZ::RemoveDiscoverySession( BluetoothDiscoveryFilter* discovery_filter, const base::Closure& callback, const DiscoverySessionErrorCallback& error_callback) { @@ -1270,13 +1248,13 @@ void BluetoothAdapterChromeOS::RemoveDiscoverySession( DCHECK_EQ(num_discovery_sessions_, 1); discovery_request_pending_ = true; bluez::BluezDBusManager::Get()->GetBluetoothAdapterClient()->StopDiscovery( - object_path_, base::Bind(&BluetoothAdapterChromeOS::OnStopDiscovery, + object_path_, base::Bind(&BluetoothAdapterBlueZ::OnStopDiscovery, weak_ptr_factory_.GetWeakPtr(), callback), - base::Bind(&BluetoothAdapterChromeOS::OnStopDiscoveryError, + base::Bind(&BluetoothAdapterBlueZ::OnStopDiscoveryError, weak_ptr_factory_.GetWeakPtr(), error_callback)); } -void BluetoothAdapterChromeOS::SetDiscoveryFilter( +void BluetoothAdapterBlueZ::SetDiscoveryFilter( scoped_ptr<BluetoothDiscoveryFilter> discovery_filter, const base::Closure& callback, const DiscoverySessionErrorCallback& error_callback) { @@ -1341,13 +1319,13 @@ void BluetoothAdapterChromeOS::SetDiscoveryFilter( ->GetBluetoothAdapterClient() ->SetDiscoveryFilter( object_path_, dbus_discovery_filter, - base::Bind(&BluetoothAdapterChromeOS::OnSetDiscoveryFilter, + base::Bind(&BluetoothAdapterBlueZ::OnSetDiscoveryFilter, weak_ptr_factory_.GetWeakPtr(), callback, error_callback), - base::Bind(&BluetoothAdapterChromeOS::OnSetDiscoveryFilterError, + base::Bind(&BluetoothAdapterBlueZ::OnSetDiscoveryFilterError, weak_ptr_factory_.GetWeakPtr(), callback, error_callback)); } -void BluetoothAdapterChromeOS::OnStartDiscovery( +void BluetoothAdapterBlueZ::OnStartDiscovery( const base::Closure& callback, const DiscoverySessionErrorCallback& error_callback) { // Report success on the original request and increment the count. @@ -1366,13 +1344,14 @@ void BluetoothAdapterChromeOS::OnStartDiscovery( ProcessQueuedDiscoveryRequests(); } -void BluetoothAdapterChromeOS::OnStartDiscoveryError( +void BluetoothAdapterBlueZ::OnStartDiscoveryError( const base::Closure& callback, const DiscoverySessionErrorCallback& error_callback, const std::string& error_name, const std::string& error_message) { - LOG(WARNING) << object_path_.value() << ": Failed to start discovery: " - << error_name << ": " << error_message; + LOG(WARNING) << object_path_.value() + << ": Failed to start discovery: " << error_name << ": " + << error_message; // Failed to start discovery. This can only happen if the count is at 0. DCHECK_EQ(num_discovery_sessions_, 0); @@ -1395,7 +1374,7 @@ void BluetoothAdapterChromeOS::OnStartDiscoveryError( ProcessQueuedDiscoveryRequests(); } -void BluetoothAdapterChromeOS::OnStopDiscovery(const base::Closure& callback) { +void BluetoothAdapterBlueZ::OnStopDiscovery(const base::Closure& callback) { // Report success on the original request and decrement the count. VLOG(1) << __func__; DCHECK(discovery_request_pending_); @@ -1410,12 +1389,13 @@ void BluetoothAdapterChromeOS::OnStopDiscovery(const base::Closure& callback) { ProcessQueuedDiscoveryRequests(); } -void BluetoothAdapterChromeOS::OnStopDiscoveryError( +void BluetoothAdapterBlueZ::OnStopDiscoveryError( const DiscoverySessionErrorCallback& error_callback, const std::string& error_name, const std::string& error_message) { - LOG(WARNING) << object_path_.value() << ": Failed to stop discovery: " - << error_name << ": " << error_message; + LOG(WARNING) << object_path_.value() + << ": Failed to stop discovery: " << error_name << ": " + << error_message; // Failed to stop discovery. This can only happen if the count is at 1. DCHECK(discovery_request_pending_); @@ -1427,7 +1407,7 @@ void BluetoothAdapterChromeOS::OnStopDiscoveryError( ProcessQueuedDiscoveryRequests(); } -void BluetoothAdapterChromeOS::OnPreSetDiscoveryFilter( +void BluetoothAdapterBlueZ::OnPreSetDiscoveryFilter( const base::Closure& callback, const DiscoverySessionErrorCallback& error_callback) { // This is the first request to start device discovery. @@ -1436,13 +1416,13 @@ void BluetoothAdapterChromeOS::OnPreSetDiscoveryFilter( bluez::BluezDBusManager::Get()->GetBluetoothAdapterClient()->StartDiscovery( object_path_, - base::Bind(&BluetoothAdapterChromeOS::OnStartDiscovery, + base::Bind(&BluetoothAdapterBlueZ::OnStartDiscovery, weak_ptr_factory_.GetWeakPtr(), callback, error_callback), - base::Bind(&BluetoothAdapterChromeOS::OnStartDiscoveryError, + base::Bind(&BluetoothAdapterBlueZ::OnStartDiscoveryError, weak_ptr_factory_.GetWeakPtr(), callback, error_callback)); } -void BluetoothAdapterChromeOS::OnPreSetDiscoveryFilterError( +void BluetoothAdapterBlueZ::OnPreSetDiscoveryFilterError( const base::Closure& callback, const DiscoverySessionErrorCallback& error_callback, UMABluetoothDiscoverySessionOutcome outcome) { @@ -1460,7 +1440,7 @@ void BluetoothAdapterChromeOS::OnPreSetDiscoveryFilterError( ProcessQueuedDiscoveryRequests(); } -void BluetoothAdapterChromeOS::OnSetDiscoveryFilter( +void BluetoothAdapterBlueZ::OnSetDiscoveryFilter( const base::Closure& callback, const DiscoverySessionErrorCallback& error_callback) { // Report success on the original request and increment the count. @@ -1472,7 +1452,7 @@ void BluetoothAdapterChromeOS::OnSetDiscoveryFilter( } } -void BluetoothAdapterChromeOS::OnSetDiscoveryFilterError( +void BluetoothAdapterBlueZ::OnSetDiscoveryFilterError( const base::Closure& callback, const DiscoverySessionErrorCallback& error_callback, const std::string& error_name, @@ -1488,7 +1468,7 @@ void BluetoothAdapterChromeOS::OnSetDiscoveryFilterError( // SetDiscoveryFilter when the controller doesn't support the requested // transport. outcome = UMABluetoothDiscoverySessionOutcome:: - CHROMEOS_DBUS_FAILED_MAYBE_UNSUPPORTED_TRANSPORT; + BLUEZ_DBUS_FAILED_MAYBE_UNSUPPORTED_TRANSPORT; } error_callback.Run(outcome); @@ -1496,7 +1476,7 @@ void BluetoothAdapterChromeOS::OnSetDiscoveryFilterError( ProcessQueuedDiscoveryRequests(); } -void BluetoothAdapterChromeOS::ProcessQueuedDiscoveryRequests() { +void BluetoothAdapterBlueZ::ProcessQueuedDiscoveryRequests() { while (!discovery_request_queue_.empty()) { VLOG(1) << "Process queued discovery request."; DiscoveryParamTuple params = discovery_request_queue_.front(); @@ -1512,4 +1492,4 @@ void BluetoothAdapterChromeOS::ProcessQueuedDiscoveryRequests() { } } -} // namespace chromeos +} // namespace bluez diff --git a/device/bluetooth/bluetooth_adapter_chromeos.h b/device/bluetooth/bluetooth_adapter_bluez.h index b51e603..a4d66a9 100644 --- a/device/bluetooth/bluetooth_adapter_chromeos.h +++ b/device/bluetooth/bluetooth_adapter_bluez.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_CHROMEOS_H_ -#define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_CHROMEOS_H_ +#ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_BLUEZ_H_ +#define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_BLUEZ_H_ #include <map> #include <queue> @@ -33,17 +33,17 @@ namespace device { class BluetoothSocketThread; } // namespace device -namespace chromeos { +namespace bluez { -class BluetoothChromeOSTest; -class BluetoothAdapterProfileChromeOS; -class BluetoothDeviceChromeOS; -class BluetoothPairingChromeOS; -class BluetoothRemoteGattCharacteristicChromeOS; -class BluetoothRemoteGattDescriptorChromeOS; -class BluetoothRemoteGattServiceChromeOS; +class BluetoothBlueZTest; +class BluetoothAdapterProfileBlueZ; +class BluetoothDeviceBlueZ; +class BluetoothPairingBlueZ; +class BluetoothRemoteGattCharacteristicBlueZ; +class BluetoothRemoteGattDescriptorBlueZ; +class BluetoothRemoteGattServiceBlueZ; -// The BluetoothAdapterChromeOS class implements BluetoothAdapter for the +// The BluetoothAdapterBlueZ class implements BluetoothAdapter for the // Chrome OS platform. // // All methods are called from the dbus origin / UI thread and are generally @@ -52,13 +52,13 @@ class BluetoothRemoteGattServiceChromeOS; // This class interacts with sockets using the BluetoothSocketThread to ensure // single-threaded calls, and posts tasks to the UI thread. // -// Methods tolerate a shutdown scenario where BluetoothAdapterChromeOS::Shutdown +// Methods tolerate a shutdown scenario where BluetoothAdapterBlueZ::Shutdown // causes IsPresent to return false just before the dbus system is shutdown but -// while references to the BluetoothAdapterChromeOS object still exists. +// while references to the BluetoothAdapterBlueZ object still exists. // // When adding methods to this class verify shutdown behavior in -// BluetoothChromeOSTest, Shutdown. -class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterChromeOS +// BluetoothBlueZTest, Shutdown. +class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterBlueZ : public device::BluetoothAdapter, public bluez::BluetoothAdapterClient::Observer, public bluez::BluetoothDeviceClient::Observer, @@ -67,7 +67,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterChromeOS public: typedef base::Callback<void(const std::string& error_message)> ErrorCompletionCallback; - typedef base::Callback<void(BluetoothAdapterProfileChromeOS* profile)> + typedef base::Callback<void(BluetoothAdapterProfileBlueZ* profile)> ProfileRegisteredCallback; static base::WeakPtr<BluetoothAdapter> CreateAdapter(); @@ -112,36 +112,35 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterChromeOS // Locates the device object by object path (the devices map and // BluetoothDevice methods are by address). - BluetoothDeviceChromeOS* GetDeviceWithPath( - const dbus::ObjectPath& object_path); + BluetoothDeviceBlueZ* GetDeviceWithPath(const dbus::ObjectPath& object_path); // Announces to observers a change in device state that is not reflected by // its D-Bus properties. |device| is owned by the caller and cannot be NULL. - void NotifyDeviceChanged(BluetoothDeviceChromeOS* device); + void NotifyDeviceChanged(BluetoothDeviceBlueZ* device); // Announce to observers a device address change. - void NotifyDeviceAddressChanged(BluetoothDeviceChromeOS* device, + void NotifyDeviceAddressChanged(BluetoothDeviceBlueZ* device, const std::string& old_address); // The following methods are used to send various GATT observer events to // observers. - void NotifyGattServiceAdded(BluetoothRemoteGattServiceChromeOS* service); - void NotifyGattServiceRemoved(BluetoothRemoteGattServiceChromeOS* service); - void NotifyGattServiceChanged(BluetoothRemoteGattServiceChromeOS* service); - void NotifyGattDiscoveryComplete(BluetoothRemoteGattServiceChromeOS* service); + void NotifyGattServiceAdded(BluetoothRemoteGattServiceBlueZ* service); + void NotifyGattServiceRemoved(BluetoothRemoteGattServiceBlueZ* service); + void NotifyGattServiceChanged(BluetoothRemoteGattServiceBlueZ* service); + void NotifyGattDiscoveryComplete(BluetoothRemoteGattServiceBlueZ* service); void NotifyGattCharacteristicAdded( - BluetoothRemoteGattCharacteristicChromeOS* characteristic); + BluetoothRemoteGattCharacteristicBlueZ* characteristic); void NotifyGattCharacteristicRemoved( - BluetoothRemoteGattCharacteristicChromeOS* characteristic); + BluetoothRemoteGattCharacteristicBlueZ* characteristic); void NotifyGattDescriptorAdded( - BluetoothRemoteGattDescriptorChromeOS* descriptor); + BluetoothRemoteGattDescriptorBlueZ* descriptor); void NotifyGattDescriptorRemoved( - BluetoothRemoteGattDescriptorChromeOS* descriptor); + BluetoothRemoteGattDescriptorBlueZ* descriptor); void NotifyGattCharacteristicValueChanged( - BluetoothRemoteGattCharacteristicChromeOS* characteristic, + BluetoothRemoteGattCharacteristicBlueZ* characteristic, const std::vector<uint8>& value); void NotifyGattDescriptorValueChanged( - BluetoothRemoteGattDescriptorChromeOS* descriptor, + BluetoothRemoteGattDescriptorBlueZ* descriptor, const std::vector<uint8>& value); // Returns the object path of the adapter. @@ -152,7 +151,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterChromeOS // If |device_path| is the empty string, incoming connections will be // assigned to |delegate|. When the profile is // successfully registered, |success_callback| will be called with a pointer - // to the profile which is managed by BluetoothAdapterChromeOS. On failure, + // to the profile which is managed by BluetoothAdapterBlueZ. On failure, // |error_callback| will be called. void UseProfile(const device::BluetoothUUID& uuid, const dbus::ObjectPath& device_path, @@ -163,7 +162,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterChromeOS // Release use of a profile by a device. void ReleaseProfile(const dbus::ObjectPath& device_path, - BluetoothAdapterProfileChromeOS* profile); + BluetoothAdapterProfileBlueZ* profile); protected: // BluetoothAdapter: @@ -171,12 +170,12 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterChromeOS device::BluetoothDevice::PairingDelegate* pairing_delegate) override; private: - friend class BluetoothChromeOSTest; - friend class BluetoothChromeOSTest_Shutdown_Test; - friend class BluetoothChromeOSTest_Shutdown_OnStartDiscovery_Test; - friend class BluetoothChromeOSTest_Shutdown_OnStartDiscoveryError_Test; - friend class BluetoothChromeOSTest_Shutdown_OnStopDiscovery_Test; - friend class BluetoothChromeOSTest_Shutdown_OnStopDiscoveryError_Test; + friend class BluetoothBlueZTest; + friend class BluetoothBlueZTest_Shutdown_Test; + friend class BluetoothBlueZTest_Shutdown_OnStartDiscovery_Test; + friend class BluetoothBlueZTest_Shutdown_OnStartDiscoveryError_Test; + friend class BluetoothBlueZTest_Shutdown_OnStopDiscovery_Test; + friend class BluetoothBlueZTest_Shutdown_OnStopDiscoveryError_Test; // typedef for callback parameters that are passed to AddDiscoverySession // and RemoveDiscoverySession. This is used to queue incoming requests while @@ -190,8 +189,8 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterChromeOS typedef std::pair<base::Closure, ErrorCompletionCallback> RegisterProfileCompletionPair; - BluetoothAdapterChromeOS(); - ~BluetoothAdapterChromeOS() override; + BluetoothAdapterBlueZ(); + ~BluetoothAdapterBlueZ() override; // bluez::BluetoothAdapterClient::Observer override. void AdapterAdded(const dbus::ObjectPath& object_path) override; @@ -242,19 +241,19 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterChromeOS void OnRequestDefaultAgentError(const std::string& error_name, const std::string& error_message); - // Called by BluetoothAudioSinkChromeOS on completion of registering an audio + // Called by BluetoothAudioSinkBlueZ on completion of registering an audio // sink. void OnRegisterAudioSink( const device::BluetoothAdapter::AcquiredCallback& callback, const device::BluetoothAudioSink::ErrorCallback& error_callback, scoped_refptr<device::BluetoothAudioSink> audio_sink); - // Internal method to obtain a BluetoothPairingChromeOS object for the device + // Internal method to obtain a BluetoothPairingBlueZ object for the device // with path |object_path|. Returns the existing pairing object if the device // already has one (usually an outgoing connection in progress) or a new // pairing object with the default pairing delegate if not. If no default // pairing object exists, NULL will be returned. - BluetoothPairingChromeOS* GetPairing(const dbus::ObjectPath& object_path); + BluetoothPairingBlueZ* GetPairing(const dbus::ObjectPath& object_path); // Set the tracked adapter to the one in |object_path|, this object will // subsequently operate on that adapter until it is removed. @@ -330,7 +329,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterChromeOS // Called by dbus:: on completion of the D-Bus method to register a profile. void OnRegisterProfile(const device::BluetoothUUID& uuid, - scoped_ptr<BluetoothAdapterProfileChromeOS> profile); + scoped_ptr<BluetoothAdapterProfileBlueZ> profile); void SetProfileDelegate( const device::BluetoothUUID& uuid, @@ -342,7 +341,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterChromeOS const std::string& error_name, const std::string& error_message); - // Called by BluetoothAdapterProfileChromeOS when no users of a profile + // Called by BluetoothAdapterProfileBlueZ when no users of a profile // remain. void RemoveProfile(const device::BluetoothUUID& uuid); @@ -384,7 +383,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterChromeOS scoped_refptr<device::BluetoothSocketThread> socket_thread_; // The profiles we have registered with the bluetooth daemon. - std::map<device::BluetoothUUID, BluetoothAdapterProfileChromeOS*> profiles_; + std::map<device::BluetoothUUID, BluetoothAdapterProfileBlueZ*> profiles_; // Queue of delegates waiting for a profile to register. std::map<device::BluetoothUUID, std::vector<RegisterProfileCompletionPair>*> @@ -394,11 +393,11 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterChromeOS // Note: This should remain the last member so it'll be destroyed and // invalidate its weak pointers before any other members are destroyed. - base::WeakPtrFactory<BluetoothAdapterChromeOS> weak_ptr_factory_; + base::WeakPtrFactory<BluetoothAdapterBlueZ> weak_ptr_factory_; - DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterChromeOS); + DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterBlueZ); }; -} // namespace chromeos +} // namespace bluez -#endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_CHROMEOS_H_ +#endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_BLUEZ_H_ diff --git a/device/bluetooth/bluetooth_adapter_factory.cc b/device/bluetooth/bluetooth_adapter_factory.cc index c3e6d5c..9771439 100644 --- a/device/bluetooth/bluetooth_adapter_factory.cc +++ b/device/bluetooth/bluetooth_adapter_factory.cc @@ -12,8 +12,8 @@ #include "base/memory/weak_ptr.h" #include "device/bluetooth/bluetooth_adapter.h" -#if defined(OS_CHROMEOS) -#include "device/bluetooth/bluetooth_adapter_chromeos.h" +#if defined(OS_CHROMEOS) || defined(OS_LINUX) +#include "device/bluetooth/bluetooth_adapter_bluez.h" #endif #if defined(OS_MACOSX) @@ -62,6 +62,8 @@ bool BluetoothAdapterFactory::IsBluetoothAdapterAvailable() { // instance even on platforms that would otherwise not support it. if (default_adapter.Get()) return true; +// Even though the adapter is available on Linux, we only want to use it for +// the Chrome API, which is why defines(OS_LINUX) is missing from here. #if defined(OS_ANDROID) || defined(OS_CHROMEOS) || defined(OS_WIN) return true; #elif defined(OS_MACOSX) @@ -73,7 +75,12 @@ bool BluetoothAdapterFactory::IsBluetoothAdapterAvailable() { // static void BluetoothAdapterFactory::GetAdapter(const AdapterCallback& callback) { +// TODO(rkc): This is a very slight hack to allow us to be able to create +// an adapter on Linux, 'without' exposing the adapter to all Bluetooth +// services within the browser. +#if !defined(OS_LINUX) DCHECK(IsBluetoothAdapterAvailable()); +#endif #if defined(OS_WIN) if (!default_adapter.Get()) { @@ -98,7 +105,7 @@ void BluetoothAdapterFactory::GetAdapter(const AdapterCallback& callback) { } -#if defined(OS_CHROMEOS) +#if defined(OS_CHROMEOS) || defined(OS_LINUX) // static void BluetoothAdapterFactory::Shutdown() { if (default_adapter.Get()) diff --git a/device/bluetooth/bluetooth_adapter_factory.h b/device/bluetooth/bluetooth_adapter_factory.h index 3b11685..05e1d3d 100644 --- a/device/bluetooth/bluetooth_adapter_factory.h +++ b/device/bluetooth/bluetooth_adapter_factory.h @@ -29,7 +29,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterFactory { // use. static void GetAdapter(const AdapterCallback& callback); -#if defined(OS_CHROMEOS) +#if defined(OS_CHROMEOS) || defined(OS_LINUX) // Calls |BluetoothAdapter::Shutdown| on the adapter if // present. static void Shutdown(); diff --git a/device/bluetooth/bluetooth_adapter_profile_chromeos.cc b/device/bluetooth/bluetooth_adapter_profile_bluez.cc index 27779f2..845002b 100644 --- a/device/bluetooth/bluetooth_adapter_profile_chromeos.cc +++ b/device/bluetooth/bluetooth_adapter_profile_bluez.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "device/bluetooth/bluetooth_adapter_profile_chromeos.h" +#include "device/bluetooth/bluetooth_adapter_profile_bluez.h" #include <string> @@ -11,21 +11,21 @@ #include "base/strings/string_util.h" #include "dbus/bus.h" #include "dbus/object_path.h" -#include "device/bluetooth/bluetooth_adapter_chromeos.h" +#include "device/bluetooth/bluetooth_adapter_bluez.h" #include "device/bluetooth/bluetooth_uuid.h" #include "device/bluetooth/dbus/bluetooth_profile_service_provider.h" #include "device/bluetooth/dbus/bluez_dbus_manager.h" -namespace chromeos { +namespace bluez { // static -void BluetoothAdapterProfileChromeOS::Register( +void BluetoothAdapterProfileBlueZ::Register( const device::BluetoothUUID& uuid, const bluez::BluetoothProfileManagerClient::Options& options, const ProfileRegisteredCallback& success_callback, const bluez::BluetoothProfileManagerClient::ErrorCallback& error_callback) { - scoped_ptr<BluetoothAdapterProfileChromeOS> profile( - new BluetoothAdapterProfileChromeOS(uuid)); + scoped_ptr<BluetoothAdapterProfileBlueZ> profile( + new BluetoothAdapterProfileBlueZ(uuid)); VLOG(1) << "Registering profile: " << profile->object_path().value(); const dbus::ObjectPath& object_path = profile->object_path(); @@ -36,7 +36,7 @@ void BluetoothAdapterProfileChromeOS::Register( error_callback); } -BluetoothAdapterProfileChromeOS::BluetoothAdapterProfileChromeOS( +BluetoothAdapterProfileBlueZ::BluetoothAdapterProfileBlueZ( const device::BluetoothUUID& uuid) : uuid_(uuid), weak_ptr_factory_(this) { std::string uuid_path; @@ -50,10 +50,9 @@ BluetoothAdapterProfileChromeOS::BluetoothAdapterProfileChromeOS( DCHECK(profile_.get()); } -BluetoothAdapterProfileChromeOS::~BluetoothAdapterProfileChromeOS() { -} +BluetoothAdapterProfileBlueZ::~BluetoothAdapterProfileBlueZ() {} -bool BluetoothAdapterProfileChromeOS::SetDelegate( +bool BluetoothAdapterProfileBlueZ::SetDelegate( const dbus::ObjectPath& device_path, bluez::BluetoothProfileServiceProvider::Delegate* delegate) { DCHECK(delegate); @@ -68,7 +67,7 @@ bool BluetoothAdapterProfileChromeOS::SetDelegate( return true; } -void BluetoothAdapterProfileChromeOS::RemoveDelegate( +void BluetoothAdapterProfileBlueZ::RemoveDelegate( const dbus::ObjectPath& device_path, const base::Closure& unregistered_callback) { VLOG(1) << object_path_.value() << " dev " << device_path.value() @@ -89,11 +88,11 @@ void BluetoothAdapterProfileChromeOS::RemoveDelegate( ->GetBluetoothProfileManagerClient() ->UnregisterProfile( object_path_, unregistered_callback, - base::Bind(&BluetoothAdapterProfileChromeOS::OnUnregisterProfileError, + base::Bind(&BluetoothAdapterProfileBlueZ::OnUnregisterProfileError, weak_ptr_factory_.GetWeakPtr(), unregistered_callback)); } -void BluetoothAdapterProfileChromeOS::OnUnregisterProfileError( +void BluetoothAdapterProfileBlueZ::OnUnregisterProfileError( const base::Closure& unregistered_callback, const std::string& error_name, const std::string& error_message) { @@ -105,11 +104,11 @@ void BluetoothAdapterProfileChromeOS::OnUnregisterProfileError( } // bluez::BluetoothProfileServiceProvider::Delegate: -void BluetoothAdapterProfileChromeOS::Released() { +void BluetoothAdapterProfileBlueZ::Released() { VLOG(1) << object_path_.value() << ": Release"; } -void BluetoothAdapterProfileChromeOS::NewConnection( +void BluetoothAdapterProfileBlueZ::NewConnection( const dbus::ObjectPath& device_path, scoped_ptr<dbus::FileDescriptor> fd, const bluez::BluetoothProfileServiceProvider::Delegate::Options& options, @@ -130,7 +129,7 @@ void BluetoothAdapterProfileChromeOS::NewConnection( options, callback); } -void BluetoothAdapterProfileChromeOS::RequestDisconnection( +void BluetoothAdapterProfileBlueZ::RequestDisconnection( const dbus::ObjectPath& device_path, const ConfirmationCallback& callback) { dbus::ObjectPath delegate_path = device_path; @@ -148,7 +147,7 @@ void BluetoothAdapterProfileChromeOS::RequestDisconnection( callback); } -void BluetoothAdapterProfileChromeOS::Cancel() { +void BluetoothAdapterProfileBlueZ::Cancel() { // Cancel() should only go to a delegate accepting connections. if (delegates_.find("") == delegates_.end()) { VLOG(1) << object_path_.value() << ": Cancel with no delegate!"; @@ -158,4 +157,4 @@ void BluetoothAdapterProfileChromeOS::Cancel() { delegates_[""]->Cancel(); } -} // namespace chromeos +} // namespace bluez diff --git a/device/bluetooth/bluetooth_adapter_profile_chromeos.h b/device/bluetooth/bluetooth_adapter_profile_bluez.h index 35971e8..b6e9eb4 100644 --- a/device/bluetooth/bluetooth_adapter_profile_chromeos.h +++ b/device/bluetooth/bluetooth_adapter_profile_bluez.h @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_PROFILE_CHROMEOS_H_ -#define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_PROFILE_CHROMEOS_H_ +#ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_PROFILE_BLUEZ_H_ +#define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_PROFILE_BLUEZ_H_ #include "base/memory/weak_ptr.h" -#include "device/bluetooth/bluetooth_adapter_chromeos.h" +#include "device/bluetooth/bluetooth_adapter_bluez.h" #include "device/bluetooth/bluetooth_export.h" #include "device/bluetooth/dbus/bluetooth_profile_manager_client.h" #include "device/bluetooth/dbus/bluetooth_profile_service_provider.h" @@ -15,9 +15,9 @@ namespace device { class BluetoothUUID; } // namespace device -namespace chromeos { +namespace bluez { -// The BluetoothAdapterProfileChromeOS class implements a multiplexing +// The BluetoothAdapterProfileBlueZ class implements a multiplexing // profile for custom Bluetooth services managed by a BluetoothAdapter. // Maintains a list of delegates which may serve the profile. // One delegate is allowed for each device. @@ -25,13 +25,13 @@ namespace chromeos { // This class is not thread-safe, but is only called from the dbus origin // thread. // -// BluetoothAdapterProfileChromeOS objects are owned by the -// BluetoothAdapterChromeOS and allocated through Register() -class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterProfileChromeOS +// BluetoothAdapterProfileBlueZ objects are owned by the +// BluetoothAdapterBlueZ and allocated through Register() +class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterProfileBlueZ : public bluez::BluetoothProfileServiceProvider::Delegate { public: - typedef base::Callback<void(scoped_ptr<BluetoothAdapterProfileChromeOS> - profile)> ProfileRegisteredCallback; + typedef base::Callback<void(scoped_ptr<BluetoothAdapterProfileBlueZ> profile)> + ProfileRegisteredCallback; // Registers a profile with the BlueZ server for |uuid| with the // options |options|. |success_callback| is provided with a newly @@ -44,7 +44,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterProfileChromeOS const bluez::BluetoothProfileManagerClient::ErrorCallback& error_callback); - ~BluetoothAdapterProfileChromeOS() override; + ~BluetoothAdapterProfileBlueZ() override; // The object path of the profile. const dbus::ObjectPath& object_path() const { return object_path_; } @@ -68,7 +68,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterProfileChromeOS size_t DelegateCount() const { return delegates_.size(); } private: - BluetoothAdapterProfileChromeOS(const device::BluetoothUUID& uuid); + BluetoothAdapterProfileBlueZ(const device::BluetoothUUID& uuid); // bluez::BluetoothProfileServiceProvider::Delegate: void Released() override; @@ -101,11 +101,11 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterProfileChromeOS // Note: This should remain the last member so it'll be destroyed and // invalidate its weak pointers before any other members are destroyed. - base::WeakPtrFactory<BluetoothAdapterProfileChromeOS> weak_ptr_factory_; + base::WeakPtrFactory<BluetoothAdapterProfileBlueZ> weak_ptr_factory_; - DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterProfileChromeOS); + DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterProfileBlueZ); }; -} // namespace chromeos +} // namespace bluez -#endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_PROFILE_CHROMEOS_H_ +#endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_PROFILE_BLUEZ_H_ diff --git a/device/bluetooth/bluetooth_adapter_profile_chromeos_unittest.cc b/device/bluetooth/bluetooth_adapter_profile_bluez_unittest.cc index be99901..f64359d 100644 --- a/device/bluetooth/bluetooth_adapter_profile_chromeos_unittest.cc +++ b/device/bluetooth/bluetooth_adapter_profile_bluez_unittest.cc @@ -5,9 +5,9 @@ #include "base/bind.h" #include "base/message_loop/message_loop.h" #include "device/bluetooth/bluetooth_adapter.h" -#include "device/bluetooth/bluetooth_adapter_chromeos.h" +#include "device/bluetooth/bluetooth_adapter_bluez.h" #include "device/bluetooth/bluetooth_adapter_factory.h" -#include "device/bluetooth/bluetooth_adapter_profile_chromeos.h" +#include "device/bluetooth/bluetooth_adapter_profile_bluez.h" #include "device/bluetooth/bluetooth_uuid.h" #include "device/bluetooth/dbus/bluetooth_profile_service_provider.h" #include "device/bluetooth/dbus/bluez_dbus_manager.h" @@ -20,11 +20,11 @@ using device::BluetoothAdapter; using device::BluetoothUUID; -namespace chromeos { +namespace bluez { -class BluetoothAdapterProfileChromeOSTest : public testing::Test { +class BluetoothAdapterProfileBlueZTest : public testing::Test { public: - BluetoothAdapterProfileChromeOSTest() + BluetoothAdapterProfileBlueZTest() : success_callback_count_(0), error_callback_count_(0), fake_delegate_paired_( @@ -53,7 +53,7 @@ class BluetoothAdapterProfileChromeOSTest : public testing::Test { // Grab a pointer to the adapter. device::BluetoothAdapterFactory::GetAdapter( - base::Bind(&BluetoothAdapterProfileChromeOSTest::AdapterCallback, + base::Bind(&BluetoothAdapterProfileBlueZTest::AdapterCallback, base::Unretained(this))); ASSERT_TRUE(adapter_.get() != nullptr); ASSERT_TRUE(adapter_->IsInitialized()); @@ -115,17 +115,17 @@ class BluetoothAdapterProfileChromeOSTest : public testing::Test { }; void ProfileSuccessCallback( - scoped_ptr<BluetoothAdapterProfileChromeOS> profile) { + scoped_ptr<BluetoothAdapterProfileBlueZ> profile) { profile_.swap(profile); ++success_callback_count_; } - void ProfileUserSuccessCallback(BluetoothAdapterProfileChromeOS* profile) { + void ProfileUserSuccessCallback(BluetoothAdapterProfileBlueZ* profile) { profile_user_ptr_ = profile; ++success_callback_count_; } - void MatchedProfileCallback(BluetoothAdapterProfileChromeOS* profile) { + void MatchedProfileCallback(BluetoothAdapterProfileBlueZ* profile) { ASSERT_EQ(profile_user_ptr_, profile); ++success_callback_count_; } @@ -153,24 +153,24 @@ class BluetoothAdapterProfileChromeOSTest : public testing::Test { FakeDelegate fake_delegate_autopair_; FakeDelegate fake_delegate_listen_; - scoped_ptr<BluetoothAdapterProfileChromeOS> profile_; + scoped_ptr<BluetoothAdapterProfileBlueZ> profile_; // unowned pointer as expected to be used by clients of - // BluetoothAdapterChromeOS::UseProfile like BluetoothSocketChromeOS - BluetoothAdapterProfileChromeOS* profile_user_ptr_; + // BluetoothAdapterBlueZ::UseProfile like BluetoothSocketBlueZ + BluetoothAdapterProfileBlueZ* profile_user_ptr_; }; -TEST_F(BluetoothAdapterProfileChromeOSTest, DelegateCount) { +TEST_F(BluetoothAdapterProfileBlueZTest, DelegateCount) { BluetoothUUID uuid(bluez::FakeBluetoothProfileManagerClient::kRfcommUuid); bluez::BluetoothProfileManagerClient::Options options; options.require_authentication.reset(new bool(false)); - BluetoothAdapterProfileChromeOS::Register( + BluetoothAdapterProfileBlueZ::Register( uuid, options, - base::Bind(&BluetoothAdapterProfileChromeOSTest::ProfileSuccessCallback, + base::Bind(&BluetoothAdapterProfileBlueZTest::ProfileSuccessCallback, base::Unretained(this)), - base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, + base::Bind(&BluetoothAdapterProfileBlueZTest::DBusErrorCallback, base::Unretained(this))); message_loop_.RunUntilIdle(); @@ -197,17 +197,17 @@ TEST_F(BluetoothAdapterProfileChromeOSTest, DelegateCount) { EXPECT_EQ(0U, profile_->DelegateCount()); } -TEST_F(BluetoothAdapterProfileChromeOSTest, BlackHole) { +TEST_F(BluetoothAdapterProfileBlueZTest, BlackHole) { BluetoothUUID uuid(bluez::FakeBluetoothProfileManagerClient::kRfcommUuid); bluez::BluetoothProfileManagerClient::Options options; options.require_authentication.reset(new bool(false)); - BluetoothAdapterProfileChromeOS::Register( + BluetoothAdapterProfileBlueZ::Register( uuid, options, - base::Bind(&BluetoothAdapterProfileChromeOSTest::ProfileSuccessCallback, + base::Bind(&BluetoothAdapterProfileBlueZTest::ProfileSuccessCallback, base::Unretained(this)), - base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, + base::Bind(&BluetoothAdapterProfileBlueZTest::DBusErrorCallback, base::Unretained(this))); message_loop_.RunUntilIdle(); @@ -219,10 +219,9 @@ TEST_F(BluetoothAdapterProfileChromeOSTest, BlackHole) { bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->ConnectProfile( dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kPairedDevicePath), bluez::FakeBluetoothProfileManagerClient::kRfcommUuid, - base::Bind( - &BluetoothAdapterProfileChromeOSTest::DBusConnectSuccessCallback, - base::Unretained(this)), - base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, + base::Bind(&BluetoothAdapterProfileBlueZTest::DBusConnectSuccessCallback, + base::Unretained(this)), + base::Bind(&BluetoothAdapterProfileBlueZTest::DBusErrorCallback, base::Unretained(this))); message_loop_.RunUntilIdle(); @@ -233,17 +232,17 @@ TEST_F(BluetoothAdapterProfileChromeOSTest, BlackHole) { EXPECT_EQ(0U, fake_delegate_paired_.connections_); } -TEST_F(BluetoothAdapterProfileChromeOSTest, Routing) { +TEST_F(BluetoothAdapterProfileBlueZTest, Routing) { BluetoothUUID uuid(bluez::FakeBluetoothProfileManagerClient::kRfcommUuid); bluez::BluetoothProfileManagerClient::Options options; options.require_authentication.reset(new bool(false)); - BluetoothAdapterProfileChromeOS::Register( + BluetoothAdapterProfileBlueZ::Register( uuid, options, - base::Bind(&BluetoothAdapterProfileChromeOSTest::ProfileSuccessCallback, + base::Bind(&BluetoothAdapterProfileBlueZTest::ProfileSuccessCallback, base::Unretained(this)), - base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, + base::Bind(&BluetoothAdapterProfileBlueZTest::DBusErrorCallback, base::Unretained(this))); message_loop_.RunUntilIdle(); @@ -262,10 +261,9 @@ TEST_F(BluetoothAdapterProfileChromeOSTest, Routing) { bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->ConnectProfile( dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kPairedDevicePath), bluez::FakeBluetoothProfileManagerClient::kRfcommUuid, - base::Bind( - &BluetoothAdapterProfileChromeOSTest::DBusConnectSuccessCallback, - base::Unretained(this)), - base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, + base::Bind(&BluetoothAdapterProfileBlueZTest::DBusConnectSuccessCallback, + base::Unretained(this)), + base::Bind(&BluetoothAdapterProfileBlueZTest::DBusErrorCallback, base::Unretained(this))); message_loop_.RunUntilIdle(); @@ -278,10 +276,9 @@ TEST_F(BluetoothAdapterProfileChromeOSTest, Routing) { bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->ConnectProfile( dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLegacyAutopairPath), bluez::FakeBluetoothProfileManagerClient::kRfcommUuid, - base::Bind( - &BluetoothAdapterProfileChromeOSTest::DBusConnectSuccessCallback, - base::Unretained(this)), - base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, + base::Bind(&BluetoothAdapterProfileBlueZTest::DBusConnectSuccessCallback, + base::Unretained(this)), + base::Bind(&BluetoothAdapterProfileBlueZTest::DBusErrorCallback, base::Unretained(this))); message_loop_.RunUntilIdle(); @@ -295,10 +292,9 @@ TEST_F(BluetoothAdapterProfileChromeOSTest, Routing) { bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->ConnectProfile( dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kDisplayPinCodePath), bluez::FakeBluetoothProfileManagerClient::kRfcommUuid, - base::Bind( - &BluetoothAdapterProfileChromeOSTest::DBusConnectSuccessCallback, - base::Unretained(this)), - base::Bind(&BluetoothAdapterProfileChromeOSTest::DBusErrorCallback, + base::Bind(&BluetoothAdapterProfileBlueZTest::DBusConnectSuccessCallback, + base::Unretained(this)), + base::Bind(&BluetoothAdapterProfileBlueZTest::DBusErrorCallback, base::Unretained(this))); message_loop_.RunUntilIdle(); @@ -309,11 +305,11 @@ TEST_F(BluetoothAdapterProfileChromeOSTest, Routing) { EXPECT_EQ(1U, fake_delegate_listen_.connections_); } -TEST_F(BluetoothAdapterProfileChromeOSTest, SimultaneousRegister) { +TEST_F(BluetoothAdapterProfileBlueZTest, SimultaneousRegister) { BluetoothUUID uuid(bluez::FakeBluetoothProfileManagerClient::kRfcommUuid); bluez::BluetoothProfileManagerClient::Options options; - BluetoothAdapterChromeOS* adapter = - static_cast<BluetoothAdapterChromeOS*>(adapter_.get()); + BluetoothAdapterBlueZ* adapter = + static_cast<BluetoothAdapterBlueZ*>(adapter_.get()); options.require_authentication.reset(new bool(false)); @@ -322,18 +318,17 @@ TEST_F(BluetoothAdapterProfileChromeOSTest, SimultaneousRegister) { adapter->UseProfile( uuid, fake_delegate_paired_.device_path_, options, &fake_delegate_paired_, - base::Bind( - &BluetoothAdapterProfileChromeOSTest::ProfileUserSuccessCallback, - base::Unretained(this)), - base::Bind(&BluetoothAdapterProfileChromeOSTest::BasicErrorCallback, + base::Bind(&BluetoothAdapterProfileBlueZTest::ProfileUserSuccessCallback, + base::Unretained(this)), + base::Bind(&BluetoothAdapterProfileBlueZTest::BasicErrorCallback, base::Unretained(this))); adapter->UseProfile( uuid, fake_delegate_autopair_.device_path_, options, &fake_delegate_autopair_, - base::Bind(&BluetoothAdapterProfileChromeOSTest::MatchedProfileCallback, + base::Bind(&BluetoothAdapterProfileBlueZTest::MatchedProfileCallback, base::Unretained(this)), - base::Bind(&BluetoothAdapterProfileChromeOSTest::BasicErrorCallback, + base::Bind(&BluetoothAdapterProfileBlueZTest::BasicErrorCallback, base::Unretained(this))); message_loop_.RunUntilIdle(); @@ -350,12 +345,12 @@ TEST_F(BluetoothAdapterProfileChromeOSTest, SimultaneousRegister) { message_loop_.RunUntilIdle(); } -TEST_F(BluetoothAdapterProfileChromeOSTest, SimultaneousRegisterFail) { +TEST_F(BluetoothAdapterProfileBlueZTest, SimultaneousRegisterFail) { BluetoothUUID uuid( bluez::FakeBluetoothProfileManagerClient::kUnregisterableUuid); bluez::BluetoothProfileManagerClient::Options options; - BluetoothAdapterChromeOS* adapter = - static_cast<BluetoothAdapterChromeOS*>(adapter_.get()); + BluetoothAdapterBlueZ* adapter = + static_cast<BluetoothAdapterBlueZ*>(adapter_.get()); options.require_authentication.reset(new bool(false)); @@ -364,18 +359,17 @@ TEST_F(BluetoothAdapterProfileChromeOSTest, SimultaneousRegisterFail) { adapter->UseProfile( uuid, fake_delegate_paired_.device_path_, options, &fake_delegate_paired_, - base::Bind( - &BluetoothAdapterProfileChromeOSTest::ProfileUserSuccessCallback, - base::Unretained(this)), - base::Bind(&BluetoothAdapterProfileChromeOSTest::BasicErrorCallback, + base::Bind(&BluetoothAdapterProfileBlueZTest::ProfileUserSuccessCallback, + base::Unretained(this)), + base::Bind(&BluetoothAdapterProfileBlueZTest::BasicErrorCallback, base::Unretained(this))); adapter->UseProfile( uuid, fake_delegate_autopair_.device_path_, options, &fake_delegate_autopair_, - base::Bind(&BluetoothAdapterProfileChromeOSTest::MatchedProfileCallback, + base::Bind(&BluetoothAdapterProfileBlueZTest::MatchedProfileCallback, base::Unretained(this)), - base::Bind(&BluetoothAdapterProfileChromeOSTest::BasicErrorCallback, + base::Bind(&BluetoothAdapterProfileBlueZTest::BasicErrorCallback, base::Unretained(this))); message_loop_.RunUntilIdle(); @@ -385,4 +379,4 @@ TEST_F(BluetoothAdapterProfileChromeOSTest, SimultaneousRegisterFail) { EXPECT_EQ(2U, error_callback_count_); } -} // namespace chromeos +} // namespace bluez diff --git a/device/bluetooth/bluetooth_advertisement_chromeos.cc b/device/bluetooth/bluetooth_advertisement_bluez.cc index 671977d..97b78da 100644 --- a/device/bluetooth/bluetooth_advertisement_chromeos.cc +++ b/device/bluetooth/bluetooth_advertisement_bluez.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "device/bluetooth/bluetooth_advertisement_chromeos.h" +#include "device/bluetooth/bluetooth_advertisement_bluez.h" #include <string> @@ -14,7 +14,7 @@ #include "base/strings/string_util.h" #include "dbus/bus.h" #include "dbus/object_path.h" -#include "device/bluetooth/bluetooth_adapter_chromeos.h" +#include "device/bluetooth/bluetooth_adapter_bluez.h" #include "device/bluetooth/dbus/bluetooth_le_advertising_manager_client.h" #include "device/bluetooth/dbus/bluez_dbus_manager.h" #include "third_party/cros_system_api/dbus/service_constants.h" @@ -23,7 +23,7 @@ namespace { void UnregisterFailure(device::BluetoothAdvertisement::ErrorCode error) { LOG(ERROR) - << "BluetoothAdvertisementChromeOS::Unregister failed with error code = " + << "BluetoothAdvertisementBlueZ::Unregister failed with error code = " << error; } @@ -68,11 +68,11 @@ void UnregisterErrorCallbackConnector( } // namespace -namespace chromeos { +namespace bluez { -BluetoothAdvertisementChromeOS::BluetoothAdvertisementChromeOS( +BluetoothAdvertisementBlueZ::BluetoothAdvertisementBlueZ( scoped_ptr<device::BluetoothAdvertisement::Data> data, - scoped_refptr<BluetoothAdapterChromeOS> adapter) + scoped_refptr<BluetoothAdapterBlueZ> adapter) : adapter_(adapter) { // Generate a new object path - make sure that we strip any -'s from the // generated GUID string since object paths can only contain alphanumeric @@ -93,7 +93,7 @@ BluetoothAdvertisementChromeOS::BluetoothAdvertisementChromeOS( data->solicit_uuids().Pass(), data->service_data().Pass()); } -void BluetoothAdvertisementChromeOS::Register( +void BluetoothAdvertisementBlueZ::Register( const base::Closure& success_callback, const device::BluetoothAdapter::CreateAdvertisementErrorCallback& error_callback) { @@ -105,11 +105,11 @@ void BluetoothAdvertisementChromeOS::Register( base::Bind(&RegisterErrorCallbackConnector, error_callback)); } -BluetoothAdvertisementChromeOS::~BluetoothAdvertisementChromeOS() { +BluetoothAdvertisementBlueZ::~BluetoothAdvertisementBlueZ() { Unregister(base::Bind(&base::DoNothing), base::Bind(&UnregisterFailure)); } -void BluetoothAdvertisementChromeOS::Unregister( +void BluetoothAdvertisementBlueZ::Unregister( const SuccessCallback& success_callback, const ErrorCallback& error_callback) { // If we don't have a provider, that means we have already been unregistered, @@ -129,11 +129,11 @@ void BluetoothAdvertisementChromeOS::Unregister( provider_.reset(); } -void BluetoothAdvertisementChromeOS::Released() { +void BluetoothAdvertisementBlueZ::Released() { LOG(WARNING) << "Advertisement released."; provider_.reset(); FOR_EACH_OBSERVER(BluetoothAdvertisement::Observer, observers_, AdvertisementReleased(this)); } -} // namespace chromeos +} // namespace bluez diff --git a/device/bluetooth/bluetooth_advertisement_chromeos.h b/device/bluetooth/bluetooth_advertisement_bluez.h index 44abec2..bde8cc8 100644 --- a/device/bluetooth/bluetooth_advertisement_chromeos.h +++ b/device/bluetooth/bluetooth_advertisement_bluez.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADVERTISEMENT_CHROMEOS_H_ -#define DEVICE_BLUETOOTH_BLUETOOTH_ADVERTISEMENT_CHROMEOS_H_ +#ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADVERTISEMENT_BLUEZ_H_ +#define DEVICE_BLUETOOTH_BLUETOOTH_ADVERTISEMENT_BLUEZ_H_ #include "base/macros.h" #include "device/bluetooth/bluetooth_adapter.h" @@ -15,19 +15,19 @@ namespace bluez { class BluetoothLEAdvertisementServiceProvider; } -namespace chromeos { +namespace bluez { -class BluetoothAdapterChromeOS; +class BluetoothAdapterBlueZ; -// The BluetoothAdvertisementChromeOS class implements BluetoothAdvertisement +// The BluetoothAdvertisementBlueZ class implements BluetoothAdvertisement // for the Chrome OS platform. -class DEVICE_BLUETOOTH_EXPORT BluetoothAdvertisementChromeOS +class DEVICE_BLUETOOTH_EXPORT BluetoothAdvertisementBlueZ : public device::BluetoothAdvertisement, public bluez::BluetoothLEAdvertisementServiceProvider::Delegate { public: - BluetoothAdvertisementChromeOS( + BluetoothAdvertisementBlueZ( scoped_ptr<device::BluetoothAdvertisement::Data> data, - scoped_refptr<BluetoothAdapterChromeOS> adapter); + scoped_refptr<BluetoothAdapterBlueZ> adapter); // BluetoothAdvertisement overrides: void Unregister(const SuccessCallback& success_callback, @@ -48,15 +48,15 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdvertisementChromeOS } private: - ~BluetoothAdvertisementChromeOS() override; + ~BluetoothAdvertisementBlueZ() override; // Adapter this advertisement is advertising on. - scoped_refptr<BluetoothAdapterChromeOS> adapter_; + scoped_refptr<BluetoothAdapterBlueZ> adapter_; scoped_ptr<bluez::BluetoothLEAdvertisementServiceProvider> provider_; - DISALLOW_COPY_AND_ASSIGN(BluetoothAdvertisementChromeOS); + DISALLOW_COPY_AND_ASSIGN(BluetoothAdvertisementBlueZ); }; -} // namespace chromeos +} // namespace bluez -#endif // DEVICE_BLUETOOTH_BLUETOOTH_ADVERTISEMENT_CHROMEOS_H_ +#endif // DEVICE_BLUETOOTH_BLUETOOTH_ADVERTISEMENT_BLUEZ_H_ diff --git a/device/bluetooth/bluetooth_advertisement_chromeos_unittest.cc b/device/bluetooth/bluetooth_advertisement_bluez_unittest.cc index 165dc8d..6ef7a63 100644 --- a/device/bluetooth/bluetooth_advertisement_chromeos_unittest.cc +++ b/device/bluetooth/bluetooth_advertisement_bluez_unittest.cc @@ -12,7 +12,7 @@ #include "device/bluetooth/bluetooth_adapter.h" #include "device/bluetooth/bluetooth_adapter_factory.h" #include "device/bluetooth/bluetooth_advertisement.h" -#include "device/bluetooth/bluetooth_advertisement_chromeos.h" +#include "device/bluetooth/bluetooth_advertisement_bluez.h" #include "device/bluetooth/dbus/bluez_dbus_manager.h" #include "device/bluetooth/dbus/fake_bluetooth_le_advertisement_service_provider.h" #include "testing/gtest/include/gtest/gtest.h" @@ -21,7 +21,7 @@ using device::BluetoothAdapter; using device::BluetoothAdapterFactory; using device::BluetoothAdvertisement; -namespace chromeos { +namespace bluez { class TestAdvertisementObserver : public BluetoothAdvertisement::Observer { public: @@ -49,7 +49,7 @@ class TestAdvertisementObserver : public BluetoothAdvertisement::Observer { DISALLOW_COPY_AND_ASSIGN(TestAdvertisementObserver); }; -class BluetoothAdvertisementChromeOSTest : public testing::Test { +class BluetoothAdvertisementBlueZTest : public testing::Test { public: void SetUp() override { bluez::BluezDBusManager::Initialize(NULL, true); @@ -76,7 +76,7 @@ class BluetoothAdvertisementChromeOSTest : public testing::Test { // Gets the existing Bluetooth adapter. void GetAdapter() { BluetoothAdapterFactory::GetAdapter( - base::Bind(&BluetoothAdvertisementChromeOSTest::GetAdapterCallback, + base::Bind(&BluetoothAdvertisementBlueZTest::GetAdapterCallback, base::Unretained(this))); } @@ -109,11 +109,10 @@ class BluetoothAdvertisementChromeOSTest : public testing::Test { adapter_->RegisterAdvertisement( CreateAdvertisementData().Pass(), - base::Bind(&BluetoothAdvertisementChromeOSTest::RegisterCallback, + base::Bind(&BluetoothAdvertisementBlueZTest::RegisterCallback, base::Unretained(this)), - base::Bind( - &BluetoothAdvertisementChromeOSTest::AdvertisementErrorCallback, - base::Unretained(this))); + base::Bind(&BluetoothAdvertisementBlueZTest::AdvertisementErrorCallback, + base::Unretained(this))); message_loop_.RunUntilIdle(); return advertisement_; @@ -122,18 +121,17 @@ class BluetoothAdvertisementChromeOSTest : public testing::Test { void UnregisterAdvertisement( scoped_refptr<BluetoothAdvertisement> advertisement) { advertisement->Unregister( - base::Bind(&BluetoothAdvertisementChromeOSTest::Callback, + base::Bind(&BluetoothAdvertisementBlueZTest::Callback, base::Unretained(this)), - base::Bind( - &BluetoothAdvertisementChromeOSTest::AdvertisementErrorCallback, - base::Unretained(this))); + base::Bind(&BluetoothAdvertisementBlueZTest::AdvertisementErrorCallback, + base::Unretained(this))); message_loop_.RunUntilIdle(); } void TriggerReleased(scoped_refptr<BluetoothAdvertisement> advertisement) { - BluetoothAdvertisementChromeOS* adv = - static_cast<BluetoothAdvertisementChromeOS*>(advertisement.get()); + BluetoothAdvertisementBlueZ* adv = + static_cast<BluetoothAdvertisementBlueZ*>(advertisement.get()); bluez::FakeBluetoothLEAdvertisementServiceProvider* provider = static_cast<bluez::FakeBluetoothLEAdvertisementServiceProvider*>( adv->provider()); @@ -190,7 +188,7 @@ class BluetoothAdvertisementChromeOSTest : public testing::Test { scoped_refptr<BluetoothAdvertisement> advertisement_; }; -TEST_F(BluetoothAdvertisementChromeOSTest, RegisterSucceeded) { +TEST_F(BluetoothAdvertisementBlueZTest, RegisterSucceeded) { scoped_refptr<BluetoothAdvertisement> advertisement = CreateAdvertisement(); ExpectSuccess(); EXPECT_NE(nullptr, advertisement); @@ -199,7 +197,7 @@ TEST_F(BluetoothAdvertisementChromeOSTest, RegisterSucceeded) { ExpectSuccess(); } -TEST_F(BluetoothAdvertisementChromeOSTest, DoubleRegisterFailed) { +TEST_F(BluetoothAdvertisementBlueZTest, DoubleRegisterFailed) { scoped_refptr<BluetoothAdvertisement> advertisement = CreateAdvertisement(); ExpectSuccess(); EXPECT_NE(nullptr, advertisement); @@ -210,7 +208,7 @@ TEST_F(BluetoothAdvertisementChromeOSTest, DoubleRegisterFailed) { EXPECT_EQ(nullptr, advertisement2); } -TEST_F(BluetoothAdvertisementChromeOSTest, DoubleUnregisterFailed) { +TEST_F(BluetoothAdvertisementBlueZTest, DoubleUnregisterFailed) { scoped_refptr<BluetoothAdvertisement> advertisement = CreateAdvertisement(); ExpectSuccess(); EXPECT_NE(nullptr, advertisement); @@ -224,7 +222,7 @@ TEST_F(BluetoothAdvertisementChromeOSTest, DoubleUnregisterFailed) { ExpectError(BluetoothAdvertisement::ERROR_ADVERTISEMENT_DOES_NOT_EXIST); } -TEST_F(BluetoothAdvertisementChromeOSTest, UnregisterAfterReleasedFailed) { +TEST_F(BluetoothAdvertisementBlueZTest, UnregisterAfterReleasedFailed) { scoped_refptr<BluetoothAdvertisement> advertisement = CreateAdvertisement(); ExpectSuccess(); EXPECT_NE(nullptr, advertisement); @@ -239,4 +237,4 @@ TEST_F(BluetoothAdvertisementChromeOSTest, UnregisterAfterReleasedFailed) { ExpectError(BluetoothAdvertisement::ERROR_ADVERTISEMENT_DOES_NOT_EXIST); } -} // namespace chromeos +} // namespace bluez diff --git a/device/bluetooth/bluetooth_audio_sink_chromeos.cc b/device/bluetooth/bluetooth_audio_sink_bluez.cc index 9bb4b60..fca894b 100644 --- a/device/bluetooth/bluetooth_audio_sink_chromeos.cc +++ b/device/bluetooth/bluetooth_audio_sink_bluez.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "device/bluetooth/bluetooth_audio_sink_chromeos.h" +#include "device/bluetooth/bluetooth_audio_sink_bluez.h" #include <unistd.h> @@ -15,7 +15,7 @@ #include "base/files/file_util.h" #include "base/logging.h" #include "dbus/message.h" -#include "device/bluetooth/bluetooth_adapter_chromeos.h" +#include "device/bluetooth/bluetooth_adapter_bluez.h" #include "device/bluetooth/dbus/bluez_dbus_manager.h" using dbus::ObjectPath; @@ -71,17 +71,16 @@ std::string ErrorCodeToString(const BluetoothAudioSink::ErrorCode& error_code) { } // A dummy error callback for calling Unregister() in destructor. -void UnregisterErrorCallback( - device::BluetoothAudioSink::ErrorCode error_code) { +void UnregisterErrorCallback(device::BluetoothAudioSink::ErrorCode error_code) { VLOG(1) << "UnregisterErrorCallback - " << ErrorCodeToString(error_code) << "(" << error_code << ")"; } } // namespace -namespace chromeos { +namespace bluez { -BluetoothAudioSinkChromeOS::BluetoothAudioSinkChromeOS( +BluetoothAudioSinkBlueZ::BluetoothAudioSinkBlueZ( scoped_refptr<device::BluetoothAdapter> adapter) : state_(BluetoothAudioSink::STATE_INVALID), volume_(BluetoothAudioSink::kInvalidVolume), @@ -90,7 +89,7 @@ BluetoothAudioSinkChromeOS::BluetoothAudioSinkChromeOS( read_has_failed_(false), adapter_(adapter), weak_ptr_factory_(this) { - VLOG(1) << "BluetoothAudioSinkChromeOS created"; + VLOG(1) << "BluetoothAudioSinkBlueZ created"; CHECK(adapter_.get()); CHECK(adapter_->IsPresent()); @@ -111,8 +110,8 @@ BluetoothAudioSinkChromeOS::BluetoothAudioSinkChromeOS( StateChanged(device::BluetoothAudioSink::STATE_DISCONNECTED); } -BluetoothAudioSinkChromeOS::~BluetoothAudioSinkChromeOS() { - VLOG(1) << "BluetoothAudioSinkChromeOS destroyed"; +BluetoothAudioSinkBlueZ::~BluetoothAudioSinkBlueZ() { + VLOG(1) << "BluetoothAudioSinkBlueZ destroyed"; DCHECK(adapter_.get()); @@ -134,7 +133,7 @@ BluetoothAudioSinkChromeOS::~BluetoothAudioSinkChromeOS() { transport->RemoveObserver(this); } -void BluetoothAudioSinkChromeOS::Unregister( +void BluetoothAudioSinkBlueZ::Unregister( const base::Closure& callback, const device::BluetoothAudioSink::ErrorCallback& error_callback) { VLOG(1) << "Unregister"; @@ -147,35 +146,34 @@ void BluetoothAudioSinkChromeOS::Unregister( CHECK(media); media->UnregisterEndpoint( - media_path_, - endpoint_path_, - base::Bind(&BluetoothAudioSinkChromeOS::OnUnregisterSucceeded, + media_path_, endpoint_path_, + base::Bind(&BluetoothAudioSinkBlueZ::OnUnregisterSucceeded, weak_ptr_factory_.GetWeakPtr(), callback), - base::Bind(&BluetoothAudioSinkChromeOS::OnUnregisterFailed, + base::Bind(&BluetoothAudioSinkBlueZ::OnUnregisterFailed, weak_ptr_factory_.GetWeakPtr(), error_callback)); } -void BluetoothAudioSinkChromeOS::AddObserver( +void BluetoothAudioSinkBlueZ::AddObserver( BluetoothAudioSink::Observer* observer) { CHECK(observer); observers_.AddObserver(observer); } -void BluetoothAudioSinkChromeOS::RemoveObserver( +void BluetoothAudioSinkBlueZ::RemoveObserver( BluetoothAudioSink::Observer* observer) { CHECK(observer); observers_.RemoveObserver(observer); } -BluetoothAudioSink::State BluetoothAudioSinkChromeOS::GetState() const { +BluetoothAudioSink::State BluetoothAudioSinkBlueZ::GetState() const { return state_; } -uint16_t BluetoothAudioSinkChromeOS::GetVolume() const { +uint16_t BluetoothAudioSinkBlueZ::GetVolume() const { return volume_; } -void BluetoothAudioSinkChromeOS::Register( +void BluetoothAudioSinkBlueZ::Register( const BluetoothAudioSink::Options& options, const base::Closure& callback, const BluetoothAudioSink::ErrorCallback& error_callback) { @@ -202,29 +200,28 @@ void BluetoothAudioSinkChromeOS::Register( endpoint_properties.codec = options_.codec; endpoint_properties.capabilities = options_.capabilities; - media_path_ = static_cast<BluetoothAdapterChromeOS*>( - adapter_.get())->object_path(); + media_path_ = + static_cast<BluetoothAdapterBlueZ*>(adapter_.get())->object_path(); bluez::BluetoothMediaClient* media = bluez::BluezDBusManager::Get()->GetBluetoothMediaClient(); CHECK(media); media->RegisterEndpoint( - media_path_, - endpoint_path_, - endpoint_properties, - base::Bind(&BluetoothAudioSinkChromeOS::OnRegisterSucceeded, + media_path_, endpoint_path_, endpoint_properties, + base::Bind(&BluetoothAudioSinkBlueZ::OnRegisterSucceeded, weak_ptr_factory_.GetWeakPtr(), callback), - base::Bind(&BluetoothAudioSinkChromeOS::OnRegisterFailed, + base::Bind(&BluetoothAudioSinkBlueZ::OnRegisterFailed, weak_ptr_factory_.GetWeakPtr(), error_callback)); } bluez::BluetoothMediaEndpointServiceProvider* -BluetoothAudioSinkChromeOS::GetEndpointServiceProvider() { +BluetoothAudioSinkBlueZ::GetEndpointServiceProvider() { return media_endpoint_.get(); } -void BluetoothAudioSinkChromeOS::AdapterPresentChanged( - device::BluetoothAdapter* adapter, bool present) { +void BluetoothAudioSinkBlueZ::AdapterPresentChanged( + device::BluetoothAdapter* adapter, + bool present) { VLOG(1) << "AdapterPresentChanged: " << present; if (adapter != adapter_.get()) @@ -238,8 +235,9 @@ void BluetoothAudioSinkChromeOS::AdapterPresentChanged( } } -void BluetoothAudioSinkChromeOS::AdapterPoweredChanged( - device::BluetoothAdapter* adapter, bool powered) { +void BluetoothAudioSinkBlueZ::AdapterPoweredChanged( + device::BluetoothAdapter* adapter, + bool powered) { VLOG(1) << "AdapterPoweredChanged: " << powered; if (adapter != adapter_.get()) @@ -253,14 +251,14 @@ void BluetoothAudioSinkChromeOS::AdapterPoweredChanged( StateChanged(BluetoothAudioSink::STATE_DISCONNECTED); } -void BluetoothAudioSinkChromeOS::MediaRemoved(const ObjectPath& object_path) { +void BluetoothAudioSinkBlueZ::MediaRemoved(const ObjectPath& object_path) { if (object_path == media_path_) { VLOG(1) << "MediaRemoved: " << object_path.value(); StateChanged(BluetoothAudioSink::STATE_INVALID); } } -void BluetoothAudioSinkChromeOS::MediaTransportRemoved( +void BluetoothAudioSinkBlueZ::MediaTransportRemoved( const ObjectPath& object_path) { // Whenever powered of |adapter_| turns false while present stays true, media // transport object should be removed accordingly, and the state should be @@ -271,7 +269,7 @@ void BluetoothAudioSinkChromeOS::MediaTransportRemoved( } } -void BluetoothAudioSinkChromeOS::MediaTransportPropertyChanged( +void BluetoothAudioSinkBlueZ::MediaTransportPropertyChanged( const ObjectPath& object_path, const std::string& property_name) { if (object_path != transport_path_) @@ -302,7 +300,7 @@ void BluetoothAudioSinkChromeOS::MediaTransportPropertyChanged( } } -void BluetoothAudioSinkChromeOS::SetConfiguration( +void BluetoothAudioSinkBlueZ::SetConfiguration( const ObjectPath& transport_path, const TransportProperties& properties) { VLOG(1) << "SetConfiguration"; @@ -322,14 +320,14 @@ void BluetoothAudioSinkChromeOS::SetConfiguration( StateChanged(BluetoothAudioSink::STATE_IDLE); } -void BluetoothAudioSinkChromeOS::SelectConfiguration( +void BluetoothAudioSinkBlueZ::SelectConfiguration( const std::vector<uint8_t>& capabilities, const SelectConfigurationCallback& callback) { VLOG(1) << "SelectConfiguration"; callback.Run(options_.capabilities); } -void BluetoothAudioSinkChromeOS::ClearConfiguration( +void BluetoothAudioSinkBlueZ::ClearConfiguration( const ObjectPath& transport_path) { if (transport_path != transport_path_) return; @@ -338,33 +336,32 @@ void BluetoothAudioSinkChromeOS::ClearConfiguration( StateChanged(BluetoothAudioSink::STATE_DISCONNECTED); } -void BluetoothAudioSinkChromeOS::Released() { +void BluetoothAudioSinkBlueZ::Released() { VLOG(1) << "Released"; StateChanged(BluetoothAudioSink::STATE_INVALID); } -void BluetoothAudioSinkChromeOS::OnFileCanReadWithoutBlocking(int fd) { +void BluetoothAudioSinkBlueZ::OnFileCanReadWithoutBlocking(int fd) { ReadFromFile(); } -void BluetoothAudioSinkChromeOS::OnFileCanWriteWithoutBlocking(int fd) { +void BluetoothAudioSinkBlueZ::OnFileCanWriteWithoutBlocking(int fd) { // Do nothing for now. } -void BluetoothAudioSinkChromeOS::AcquireFD() { +void BluetoothAudioSinkBlueZ::AcquireFD() { VLOG(1) << "AcquireFD - transport path: " << transport_path_.value(); read_has_failed_ = false; bluez::BluezDBusManager::Get()->GetBluetoothMediaTransportClient()->Acquire( - transport_path_, - base::Bind(&BluetoothAudioSinkChromeOS::OnAcquireSucceeded, - weak_ptr_factory_.GetWeakPtr()), - base::Bind(&BluetoothAudioSinkChromeOS::OnAcquireFailed, + transport_path_, base::Bind(&BluetoothAudioSinkBlueZ::OnAcquireSucceeded, + weak_ptr_factory_.GetWeakPtr()), + base::Bind(&BluetoothAudioSinkBlueZ::OnAcquireFailed, weak_ptr_factory_.GetWeakPtr())); } -void BluetoothAudioSinkChromeOS::WatchFD() { +void BluetoothAudioSinkBlueZ::WatchFD() { CHECK(file_.get() && file_->IsValid()); VLOG(1) << "WatchFD - file: " << file_->GetPlatformFile() @@ -375,7 +372,7 @@ void BluetoothAudioSinkChromeOS::WatchFD() { &fd_read_watcher_, this); } -void BluetoothAudioSinkChromeOS::StopWatchingFD() { +void BluetoothAudioSinkBlueZ::StopWatchingFD() { if (!file_.get()) { VLOG(1) << "StopWatchingFD - skip"; return; @@ -390,7 +387,7 @@ void BluetoothAudioSinkChromeOS::StopWatchingFD() { file_.reset(); // This will close the file descriptor. } -void BluetoothAudioSinkChromeOS::ReadFromFile() { +void BluetoothAudioSinkBlueZ::ReadFromFile() { DCHECK(file_.get() && file_->IsValid()); DCHECK(data_.get()); @@ -411,8 +408,7 @@ void BluetoothAudioSinkChromeOS::ReadFromFile() { BluetoothAudioSinkDataAvailable(this, data_.get(), size, read_mtu_)); } -void BluetoothAudioSinkChromeOS::StateChanged( - BluetoothAudioSink::State state) { +void BluetoothAudioSinkBlueZ::StateChanged(BluetoothAudioSink::State state) { if (state == state_) return; @@ -443,7 +439,7 @@ void BluetoothAudioSinkChromeOS::StateChanged( BluetoothAudioSinkStateChanged(this, state_)); } -void BluetoothAudioSinkChromeOS::VolumeChanged(uint16_t volume) { +void BluetoothAudioSinkBlueZ::VolumeChanged(uint16_t volume) { if (volume == volume_) return; @@ -454,7 +450,7 @@ void BluetoothAudioSinkChromeOS::VolumeChanged(uint16_t volume) { BluetoothAudioSinkVolumeChanged(this, volume_)); } -void BluetoothAudioSinkChromeOS::OnRegisterSucceeded( +void BluetoothAudioSinkBlueZ::OnRegisterSucceeded( const base::Closure& callback) { DCHECK(media_endpoint_.get()); VLOG(1) << "OnRegisterSucceeded"; @@ -463,7 +459,7 @@ void BluetoothAudioSinkChromeOS::OnRegisterSucceeded( callback.Run(); } -void BluetoothAudioSinkChromeOS::OnRegisterFailed( +void BluetoothAudioSinkBlueZ::OnRegisterFailed( const BluetoothAudioSink::ErrorCallback& error_callback, const std::string& error_name, const std::string& error_message) { @@ -474,7 +470,7 @@ void BluetoothAudioSinkChromeOS::OnRegisterFailed( error_callback.Run(BluetoothAudioSink::ERROR_NOT_REGISTERED); } -void BluetoothAudioSinkChromeOS::OnUnregisterSucceeded( +void BluetoothAudioSinkBlueZ::OnUnregisterSucceeded( const base::Closure& callback) { VLOG(1) << "Unregistered - endpoint: " << endpoint_path_.value(); @@ -484,7 +480,7 @@ void BluetoothAudioSinkChromeOS::OnUnregisterSucceeded( callback.Run(); } -void BluetoothAudioSinkChromeOS::OnUnregisterFailed( +void BluetoothAudioSinkBlueZ::OnUnregisterFailed( const device::BluetoothAudioSink::ErrorCallback& error_callback, const std::string& error_name, const std::string& error_message) { @@ -494,10 +490,9 @@ void BluetoothAudioSinkChromeOS::OnUnregisterFailed( error_callback.Run(BluetoothAudioSink::ERROR_NOT_UNREGISTERED); } -void BluetoothAudioSinkChromeOS::OnAcquireSucceeded( - dbus::FileDescriptor* fd, - const uint16_t read_mtu, - const uint16_t write_mtu) { +void BluetoothAudioSinkBlueZ::OnAcquireSucceeded(dbus::FileDescriptor* fd, + const uint16_t read_mtu, + const uint16_t write_mtu) { CHECK(fd); fd->CheckValidity(); CHECK(fd->is_valid() && fd->value() != kInvalidFd); @@ -526,31 +521,31 @@ void BluetoothAudioSinkChromeOS::OnAcquireSucceeded( << ", read MTU: " << read_mtu_ << ", write MTU: " << write_mtu_; } -void BluetoothAudioSinkChromeOS::OnAcquireFailed( +void BluetoothAudioSinkBlueZ::OnAcquireFailed( const std::string& error_name, const std::string& error_message) { VLOG(1) << "OnAcquireFailed - error name: " << error_name << ", error message: " << error_message; } -void BluetoothAudioSinkChromeOS::OnReleaseFDSucceeded() { +void BluetoothAudioSinkBlueZ::OnReleaseFDSucceeded() { VLOG(1) << "OnReleaseFDSucceeded"; } -void BluetoothAudioSinkChromeOS::OnReleaseFDFailed( +void BluetoothAudioSinkBlueZ::OnReleaseFDFailed( const std::string& error_name, const std::string& error_message) { VLOG(1) << "OnReleaseFDFailed - error name: " << error_name << ", error message: " << error_message; } -void BluetoothAudioSinkChromeOS::ResetMedia() { +void BluetoothAudioSinkBlueZ::ResetMedia() { VLOG(1) << "ResetMedia"; media_path_ = dbus::ObjectPath(""); } -void BluetoothAudioSinkChromeOS::ResetTransport() { +void BluetoothAudioSinkBlueZ::ResetTransport() { if (!transport_path_.IsValid()) { VLOG(1) << "ResetTransport - skip"; return; @@ -565,11 +560,11 @@ void BluetoothAudioSinkChromeOS::ResetTransport() { file_.reset(); } -void BluetoothAudioSinkChromeOS::ResetEndpoint() { +void BluetoothAudioSinkBlueZ::ResetEndpoint() { VLOG(1) << "ResetEndpoint"; endpoint_path_ = ObjectPath(""); media_endpoint_ = nullptr; } -} // namespace chromeos +} // namespace bluez diff --git a/device/bluetooth/bluetooth_audio_sink_chromeos.h b/device/bluetooth/bluetooth_audio_sink_bluez.h index 750b31d..e319aea 100644 --- a/device/bluetooth/bluetooth_audio_sink_chromeos.h +++ b/device/bluetooth/bluetooth_audio_sink_bluez.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_CHROMEOS_H_ -#define DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_CHROMEOS_H_ +#ifndef DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_BLUEZ_H_ +#define DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_BLUEZ_H_ #include <stdint.h> #include <string> @@ -23,11 +23,11 @@ #include "device/bluetooth/dbus/bluetooth_media_endpoint_service_provider.h" #include "device/bluetooth/dbus/bluetooth_media_transport_client.h" -namespace chromeos { +namespace bluez { -class BluetoothAudioSinkChromeOSTest; +class BluetoothAudioSinkBlueZTest; -class DEVICE_BLUETOOTH_EXPORT BluetoothAudioSinkChromeOS +class DEVICE_BLUETOOTH_EXPORT BluetoothAudioSinkBlueZ : public device::BluetoothAudioSink, public device::BluetoothAdapter::Observer, public bluez::BluetoothMediaClient::Observer, @@ -35,7 +35,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAudioSinkChromeOS public bluez::BluetoothMediaEndpointServiceProvider::Delegate, public base::MessageLoopForIO::Watcher { public: - explicit BluetoothAudioSinkChromeOS( + explicit BluetoothAudioSinkBlueZ( scoped_refptr<device::BluetoothAdapter> adapter); // device::BluetoothAudioSink overrides. @@ -53,7 +53,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAudioSinkChromeOS // Registers a BluetoothAudioSink. User applications can use |options| to // configure the audio sink. |callback| will be executed if the audio sink is // successfully registered, otherwise |error_callback| will be called. Called - // by BluetoothAdapterChromeOS. + // by BluetoothAdapterBlueZ. void Register( const device::BluetoothAudioSink::Options& options, const base::Closure& callback, @@ -64,7 +64,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAudioSinkChromeOS bluez::BluetoothMediaEndpointServiceProvider* GetEndpointServiceProvider(); private: - ~BluetoothAudioSinkChromeOS() override; + ~BluetoothAudioSinkBlueZ() override; // device::BluetoothAdapter::Observer overrides. void AdapterPresentChanged(device::BluetoothAdapter* adapter, @@ -157,7 +157,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAudioSinkChromeOS void ResetTransport(); void ResetEndpoint(); - // The connection state between the BluetoothAudioSinkChromeOS and the remote + // The connection state between the BluetoothAudioSinkBlueZ and the remote // device. device::BluetoothAudioSink::State state_; @@ -196,7 +196,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAudioSinkChromeOS dbus::ObjectPath endpoint_path_; // BT adapter which the audio sink binds to. |adapter_| should outlive - // a BluetoothAudioSinkChromeOS object. + // a BluetoothAudioSinkBlueZ object. scoped_refptr<device::BluetoothAdapter> adapter_; // Options used to initiate Media Endpoint and select configuration for the @@ -207,16 +207,16 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAudioSinkChromeOS scoped_ptr<bluez::BluetoothMediaEndpointServiceProvider> media_endpoint_; // List of observers interested in event notifications from us. Objects in - // |observers_| are expected to outlive a BluetoothAudioSinkChromeOS object. + // |observers_| are expected to outlive a BluetoothAudioSinkBlueZ object. base::ObserverList<BluetoothAudioSink::Observer> observers_; // Note: This should remain the last member so it'll be destroyed and // invalidate its weak pointers before any other members are destroyed. - base::WeakPtrFactory<BluetoothAudioSinkChromeOS> weak_ptr_factory_; + base::WeakPtrFactory<BluetoothAudioSinkBlueZ> weak_ptr_factory_; - DISALLOW_COPY_AND_ASSIGN(BluetoothAudioSinkChromeOS); + DISALLOW_COPY_AND_ASSIGN(BluetoothAudioSinkBlueZ); }; -} // namespace chromeos +} // namespace bluez -#endif // DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_CHROMEOS_H_ +#endif // DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_BLUEZ_H_ diff --git a/device/bluetooth/bluetooth_audio_sink_chromeos_unittest.cc b/device/bluetooth/bluetooth_audio_sink_bluez_unittest.cc index 22918f7..663ec81 100644 --- a/device/bluetooth/bluetooth_audio_sink_chromeos_unittest.cc +++ b/device/bluetooth/bluetooth_audio_sink_bluez_unittest.cc @@ -12,7 +12,7 @@ #include "device/bluetooth/bluetooth_adapter.h" #include "device/bluetooth/bluetooth_adapter_factory.h" #include "device/bluetooth/bluetooth_audio_sink.h" -#include "device/bluetooth/bluetooth_audio_sink_chromeos.h" +#include "device/bluetooth/bluetooth_audio_sink_bluez.h" #include "device/bluetooth/dbus/bluetooth_media_client.h" #include "device/bluetooth/dbus/bluetooth_media_endpoint_service_provider.h" #include "device/bluetooth/dbus/bluetooth_media_transport_client.h" @@ -27,7 +27,7 @@ using device::BluetoothAdapter; using device::BluetoothAdapterFactory; using device::BluetoothAudioSink; -namespace chromeos { +namespace bluez { class TestAudioSinkObserver : public BluetoothAudioSink::Observer { public: @@ -78,7 +78,7 @@ class TestAudioSinkObserver : public BluetoothAudioSink::Observer { scoped_refptr<BluetoothAudioSink> audio_sink_; }; -class BluetoothAudioSinkChromeOSTest : public testing::Test { +class BluetoothAudioSinkBlueZTest : public testing::Test { public: void SetUp() override { bluez::BluezDBusManager::Initialize(NULL, true); @@ -124,7 +124,7 @@ class BluetoothAudioSinkChromeOSTest : public testing::Test { // Gets the existing Bluetooth adapter. void GetAdapter() { BluetoothAdapterFactory::GetAdapter( - base::Bind(&BluetoothAudioSinkChromeOSTest::GetAdapterCallback, + base::Bind(&BluetoothAudioSinkBlueZTest::GetAdapterCallback, base::Unretained(this))); } @@ -134,12 +134,11 @@ class BluetoothAudioSinkChromeOSTest : public testing::Test { ASSERT_NE(adapter_.get(), nullptr); ASSERT_TRUE(adapter_->IsInitialized()); - adapter_->SetPowered( - true, - base::Bind(&BluetoothAudioSinkChromeOSTest::Callback, - base::Unretained(this)), - base::Bind(&BluetoothAudioSinkChromeOSTest::ErrorCallback, - base::Unretained(this))); + adapter_->SetPowered(true, + base::Bind(&BluetoothAudioSinkBlueZTest::Callback, + base::Unretained(this)), + base::Bind(&BluetoothAudioSinkBlueZTest::ErrorCallback, + base::Unretained(this))); ASSERT_TRUE(adapter_->IsPresent()); ASSERT_TRUE(adapter_->IsPowered()); EXPECT_EQ(callback_count_, 1); @@ -149,7 +148,7 @@ class BluetoothAudioSinkChromeOSTest : public testing::Test { --callback_count_; } - // Registers BluetoothAudioSinkChromeOS with default codec and capabilities. + // Registers BluetoothAudioSinkBlueZ with default codec and capabilities. // If the audio sink is retrieved successfully, the state changes to // STATE_DISCONNECTED. void GetAudioSink() { @@ -161,10 +160,9 @@ class BluetoothAudioSinkChromeOSTest : public testing::Test { // Registers |audio_sink_| with valid codec and capabilities adapter_->RegisterAudioSink( - options, - base::Bind(&BluetoothAudioSinkChromeOSTest::RegisterCallback, - base::Unretained(this)), - base::Bind(&BluetoothAudioSinkChromeOSTest::RegisterErrorCallback, + options, base::Bind(&BluetoothAudioSinkBlueZTest::RegisterCallback, + base::Unretained(this)), + base::Bind(&BluetoothAudioSinkBlueZTest::RegisterErrorCallback, base::Unretained(this))); observer_.reset(new TestAudioSinkObserver(audio_sink_)); @@ -175,18 +173,17 @@ class BluetoothAudioSinkChromeOSTest : public testing::Test { } void GetFakeMediaEndpoint() { - BluetoothAudioSinkChromeOS* audio_sink_chromeos = - static_cast<BluetoothAudioSinkChromeOS*>(audio_sink_.get()); - ASSERT_NE(audio_sink_chromeos, nullptr); + BluetoothAudioSinkBlueZ* audio_sink_bluez = + static_cast<BluetoothAudioSinkBlueZ*>(audio_sink_.get()); + ASSERT_NE(audio_sink_bluez, nullptr); media_endpoint_ = static_cast<bluez::FakeBluetoothMediaEndpointServiceProvider*>( - audio_sink_chromeos->GetEndpointServiceProvider()); + audio_sink_bluez->GetEndpointServiceProvider()); } // Called whenever RegisterAudioSink is completed successfully. - void RegisterCallback( - scoped_refptr<BluetoothAudioSink> audio_sink) { + void RegisterCallback(scoped_refptr<BluetoothAudioSink> audio_sink) { ++callback_count_; audio_sink_ = audio_sink; @@ -219,13 +216,9 @@ class BluetoothAudioSinkChromeOSTest : public testing::Test { } // Generic callbacks. - void Callback() { - ++callback_count_; - } + void Callback() { ++callback_count_; } - void ErrorCallback() { - ++error_callback_count_; - } + void ErrorCallback() { ++error_callback_count_; } protected: int callback_count_; @@ -246,21 +239,20 @@ class BluetoothAudioSinkChromeOSTest : public testing::Test { properties_; }; -TEST_F(BluetoothAudioSinkChromeOSTest, RegisterSucceeded) { +TEST_F(BluetoothAudioSinkBlueZTest, RegisterSucceeded) { GetAudioSink(); } -TEST_F(BluetoothAudioSinkChromeOSTest, RegisterFailedWithInvalidOptions) { +TEST_F(BluetoothAudioSinkBlueZTest, RegisterFailedWithInvalidOptions) { // Sets options with an invalid codec and valid capabilities. BluetoothAudioSink::Options options; options.codec = 0xff; options.capabilities = std::vector<uint8_t>({0x3f, 0xff, 0x12, 0x35}); adapter_->RegisterAudioSink( - options, - base::Bind(&BluetoothAudioSinkChromeOSTest::RegisterCallback, - base::Unretained(this)), - base::Bind(&BluetoothAudioSinkChromeOSTest::RegisterErrorCallback, + options, base::Bind(&BluetoothAudioSinkBlueZTest::RegisterCallback, + base::Unretained(this)), + base::Bind(&BluetoothAudioSinkBlueZTest::RegisterErrorCallback, base::Unretained(this))); EXPECT_EQ(callback_count_, 0); @@ -270,24 +262,23 @@ TEST_F(BluetoothAudioSinkChromeOSTest, RegisterFailedWithInvalidOptions) { options.codec = 0x00; options.capabilities.clear(); adapter_->RegisterAudioSink( - options, - base::Bind(&BluetoothAudioSinkChromeOSTest::RegisterCallback, - base::Unretained(this)), - base::Bind(&BluetoothAudioSinkChromeOSTest::RegisterErrorCallback, + options, base::Bind(&BluetoothAudioSinkBlueZTest::RegisterCallback, + base::Unretained(this)), + base::Bind(&BluetoothAudioSinkBlueZTest::RegisterErrorCallback, base::Unretained(this))); EXPECT_EQ(callback_count_, 0); EXPECT_EQ(error_callback_count_, 2); } -TEST_F(BluetoothAudioSinkChromeOSTest, SelectConfiguration) { +TEST_F(BluetoothAudioSinkBlueZTest, SelectConfiguration) { GetAudioSink(); // Simulates calling SelectConfiguration on the media endpoint object owned by // |audio_sink_| with some fake capabilities. media_endpoint_->SelectConfiguration( std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), - base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, + base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, base::Unretained(this))); EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); @@ -297,12 +288,12 @@ TEST_F(BluetoothAudioSinkChromeOSTest, SelectConfiguration) { EXPECT_EQ(observer_->volume_changed_count_, 0); } -TEST_F(BluetoothAudioSinkChromeOSTest, SetConfiguration) { +TEST_F(BluetoothAudioSinkBlueZTest, SetConfiguration) { GetAudioSink(); media_endpoint_->SelectConfiguration( std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), - base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, + base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, base::Unretained(this))); EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); @@ -325,12 +316,12 @@ TEST_F(BluetoothAudioSinkChromeOSTest, SetConfiguration) { EXPECT_EQ(observer_->volume_changed_count_, 1); } -TEST_F(BluetoothAudioSinkChromeOSTest, SetConfigurationWithUnexpectedState) { +TEST_F(BluetoothAudioSinkBlueZTest, SetConfigurationWithUnexpectedState) { GetAudioSink(); media_endpoint_->SelectConfiguration( std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), - base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, + base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, base::Unretained(this))); EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); @@ -356,7 +347,7 @@ TEST_F(BluetoothAudioSinkChromeOSTest, SetConfigurationWithUnexpectedState) { // Checks if the observer is notified on media-removed event when the state of // |audio_sink_| is STATE_DISCONNECTED. Once the media object is removed, the // audio sink is no longer valid. -TEST_F(BluetoothAudioSinkChromeOSTest, MediaRemovedDuringDisconnectedState) { +TEST_F(BluetoothAudioSinkBlueZTest, MediaRemovedDuringDisconnectedState) { GetAudioSink(); // Gets the media object and makes it invisible to see if the state of the @@ -374,12 +365,12 @@ TEST_F(BluetoothAudioSinkChromeOSTest, MediaRemovedDuringDisconnectedState) { // Checks if the observer is notified on media-removed event when the state of // |audio_sink_| is STATE_IDLE. Once the media object is removed, the audio sink // is no longer valid. -TEST_F(BluetoothAudioSinkChromeOSTest, MediaRemovedDuringIdleState) { +TEST_F(BluetoothAudioSinkBlueZTest, MediaRemovedDuringIdleState) { GetAudioSink(); media_endpoint_->SelectConfiguration( std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), - base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, + base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, base::Unretained(this))); EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); @@ -414,12 +405,12 @@ TEST_F(BluetoothAudioSinkChromeOSTest, MediaRemovedDuringIdleState) { EXPECT_EQ(observer_->volume_changed_count_, 2); } -TEST_F(BluetoothAudioSinkChromeOSTest, MediaRemovedDuringActiveState) { +TEST_F(BluetoothAudioSinkBlueZTest, MediaRemovedDuringActiveState) { GetAudioSink(); media_endpoint_->SelectConfiguration( std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), - base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, + base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, base::Unretained(this))); EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); @@ -467,12 +458,12 @@ TEST_F(BluetoothAudioSinkChromeOSTest, MediaRemovedDuringActiveState) { // Checks if the observer is notified on transport-removed event when the state // of |audio_sink_| is STATE_IDEL. Once the media transport object is removed, // the audio sink is disconnected. -TEST_F(BluetoothAudioSinkChromeOSTest, TransportRemovedDuringIdleState) { +TEST_F(BluetoothAudioSinkBlueZTest, TransportRemovedDuringIdleState) { GetAudioSink(); media_endpoint_->SelectConfiguration( std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), - base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, + base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, base::Unretained(this))); EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); @@ -501,12 +492,12 @@ TEST_F(BluetoothAudioSinkChromeOSTest, TransportRemovedDuringIdleState) { EXPECT_EQ(observer_->volume_changed_count_, 2); } -TEST_F(BluetoothAudioSinkChromeOSTest, TransportRemovedDuringActiveState) { +TEST_F(BluetoothAudioSinkBlueZTest, TransportRemovedDuringActiveState) { GetAudioSink(); media_endpoint_->SelectConfiguration( std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), - base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, + base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, base::Unretained(this))); EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); @@ -545,16 +536,14 @@ TEST_F(BluetoothAudioSinkChromeOSTest, TransportRemovedDuringActiveState) { EXPECT_EQ(observer_->volume_changed_count_, 2); } -TEST_F(BluetoothAudioSinkChromeOSTest, +TEST_F(BluetoothAudioSinkBlueZTest, AdapterPoweredChangedDuringDisconnectedState) { GetAudioSink(); - adapter_->SetPowered( - false, - base::Bind(&BluetoothAudioSinkChromeOSTest::Callback, - base::Unretained(this)), - base::Bind(&BluetoothAudioSinkChromeOSTest::ErrorCallback, - base::Unretained(this))); + adapter_->SetPowered(false, base::Bind(&BluetoothAudioSinkBlueZTest::Callback, + base::Unretained(this)), + base::Bind(&BluetoothAudioSinkBlueZTest::ErrorCallback, + base::Unretained(this))); EXPECT_TRUE(adapter_->IsPresent()); EXPECT_FALSE(adapter_->IsPowered()); @@ -564,12 +553,10 @@ TEST_F(BluetoothAudioSinkChromeOSTest, EXPECT_EQ(observer_->state_changed_count_, 0); EXPECT_EQ(observer_->volume_changed_count_, 0); - adapter_->SetPowered( - true, - base::Bind(&BluetoothAudioSinkChromeOSTest::Callback, - base::Unretained(this)), - base::Bind(&BluetoothAudioSinkChromeOSTest::ErrorCallback, - base::Unretained(this))); + adapter_->SetPowered(true, base::Bind(&BluetoothAudioSinkBlueZTest::Callback, + base::Unretained(this)), + base::Bind(&BluetoothAudioSinkBlueZTest::ErrorCallback, + base::Unretained(this))); EXPECT_TRUE(adapter_->IsPresent()); EXPECT_TRUE(adapter_->IsPowered()); @@ -580,12 +567,12 @@ TEST_F(BluetoothAudioSinkChromeOSTest, EXPECT_EQ(observer_->volume_changed_count_, 0); } -TEST_F(BluetoothAudioSinkChromeOSTest, AdapterPoweredChangedDuringIdleState) { +TEST_F(BluetoothAudioSinkBlueZTest, AdapterPoweredChangedDuringIdleState) { GetAudioSink(); media_endpoint_->SelectConfiguration( std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), - base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, + base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, base::Unretained(this))); EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); @@ -604,12 +591,10 @@ TEST_F(BluetoothAudioSinkChromeOSTest, AdapterPoweredChangedDuringIdleState) { EXPECT_EQ(observer_->state_changed_count_, 1); EXPECT_EQ(observer_->volume_changed_count_, 1); - adapter_->SetPowered( - false, - base::Bind(&BluetoothAudioSinkChromeOSTest::Callback, - base::Unretained(this)), - base::Bind(&BluetoothAudioSinkChromeOSTest::ErrorCallback, - base::Unretained(this))); + adapter_->SetPowered(false, base::Bind(&BluetoothAudioSinkBlueZTest::Callback, + base::Unretained(this)), + base::Bind(&BluetoothAudioSinkBlueZTest::ErrorCallback, + base::Unretained(this))); GetFakeMediaEndpoint(); EXPECT_TRUE(adapter_->IsPresent()); @@ -622,14 +607,14 @@ TEST_F(BluetoothAudioSinkChromeOSTest, AdapterPoweredChangedDuringIdleState) { EXPECT_EQ(observer_->volume_changed_count_, 2); } -TEST_F(BluetoothAudioSinkChromeOSTest, +TEST_F(BluetoothAudioSinkBlueZTest, UnregisterAudioSinkDuringDisconnectedState) { GetAudioSink(); audio_sink_->Unregister( - base::Bind(&BluetoothAudioSinkChromeOSTest::Callback, + base::Bind(&BluetoothAudioSinkBlueZTest::Callback, base::Unretained(this)), - base::Bind(&BluetoothAudioSinkChromeOSTest::UnregisterErrorCallback, + base::Bind(&BluetoothAudioSinkBlueZTest::UnregisterErrorCallback, base::Unretained(this))); EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_INVALID); @@ -639,12 +624,12 @@ TEST_F(BluetoothAudioSinkChromeOSTest, EXPECT_EQ(observer_->volume_changed_count_, 0); } -TEST_F(BluetoothAudioSinkChromeOSTest, UnregisterAudioSinkDuringIdleState) { +TEST_F(BluetoothAudioSinkBlueZTest, UnregisterAudioSinkDuringIdleState) { GetAudioSink(); media_endpoint_->SelectConfiguration( std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), - base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, + base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, base::Unretained(this))); EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); @@ -664,9 +649,9 @@ TEST_F(BluetoothAudioSinkChromeOSTest, UnregisterAudioSinkDuringIdleState) { EXPECT_EQ(observer_->volume_changed_count_, 1); audio_sink_->Unregister( - base::Bind(&BluetoothAudioSinkChromeOSTest::Callback, + base::Bind(&BluetoothAudioSinkBlueZTest::Callback, base::Unretained(this)), - base::Bind(&BluetoothAudioSinkChromeOSTest::UnregisterErrorCallback, + base::Bind(&BluetoothAudioSinkBlueZTest::UnregisterErrorCallback, base::Unretained(this))); EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_INVALID); @@ -680,12 +665,12 @@ TEST_F(BluetoothAudioSinkChromeOSTest, UnregisterAudioSinkDuringIdleState) { EXPECT_EQ(observer_->volume_changed_count_, 2); } -TEST_F(BluetoothAudioSinkChromeOSTest, UnregisterAudioSinkDuringActiveState) { +TEST_F(BluetoothAudioSinkBlueZTest, UnregisterAudioSinkDuringActiveState) { GetAudioSink(); media_endpoint_->SelectConfiguration( std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), - base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, + base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, base::Unretained(this))); EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); @@ -715,9 +700,9 @@ TEST_F(BluetoothAudioSinkChromeOSTest, UnregisterAudioSinkDuringActiveState) { EXPECT_EQ(observer_->state_changed_count_, 3); audio_sink_->Unregister( - base::Bind(&BluetoothAudioSinkChromeOSTest::Callback, + base::Bind(&BluetoothAudioSinkBlueZTest::Callback, base::Unretained(this)), - base::Bind(&BluetoothAudioSinkChromeOSTest::UnregisterErrorCallback, + base::Bind(&BluetoothAudioSinkBlueZTest::UnregisterErrorCallback, base::Unretained(this))); EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_INVALID); @@ -727,12 +712,12 @@ TEST_F(BluetoothAudioSinkChromeOSTest, UnregisterAudioSinkDuringActiveState) { EXPECT_EQ(observer_->volume_changed_count_, 2); } -TEST_F(BluetoothAudioSinkChromeOSTest, StateChanged) { +TEST_F(BluetoothAudioSinkBlueZTest, StateChanged) { GetAudioSink(); media_endpoint_->SelectConfiguration( std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), - base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, + base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, base::Unretained(this))); EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); @@ -759,12 +744,12 @@ TEST_F(BluetoothAudioSinkChromeOSTest, StateChanged) { EXPECT_EQ(observer_->volume_changed_count_, 1); } -TEST_F(BluetoothAudioSinkChromeOSTest, VolumeChanged) { +TEST_F(BluetoothAudioSinkBlueZTest, VolumeChanged) { GetAudioSink(); media_endpoint_->SelectConfiguration( std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), - base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, + base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, base::Unretained(this))); EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); @@ -805,12 +790,12 @@ TEST_F(BluetoothAudioSinkChromeOSTest, VolumeChanged) { EXPECT_EQ(audio_sink_->GetVolume(), BluetoothAudioSink::kInvalidVolume); } -TEST_F(BluetoothAudioSinkChromeOSTest, AcquireFD) { +TEST_F(BluetoothAudioSinkBlueZTest, AcquireFD) { GetAudioSink(); media_endpoint_->SelectConfiguration( std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), - base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, + base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, base::Unretained(this))); EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); @@ -848,12 +833,12 @@ TEST_F(BluetoothAudioSinkChromeOSTest, AcquireFD) { } // Tests the case where the remote device pauses and resume audio streaming. -TEST_F(BluetoothAudioSinkChromeOSTest, PauseAndResume) { +TEST_F(BluetoothAudioSinkBlueZTest, PauseAndResume) { GetAudioSink(); media_endpoint_->SelectConfiguration( std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), - base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, + base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, base::Unretained(this))); EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); @@ -906,12 +891,12 @@ TEST_F(BluetoothAudioSinkChromeOSTest, PauseAndResume) { EXPECT_EQ(observer_->total_read_, data_two.size()); } -TEST_F(BluetoothAudioSinkChromeOSTest, ContinuouslyStreaming) { +TEST_F(BluetoothAudioSinkBlueZTest, ContinuouslyStreaming) { GetAudioSink(); media_endpoint_->SelectConfiguration( std::vector<uint8_t>({0x21, 0x15, 0x33, 0x2C}), - base::Bind(&BluetoothAudioSinkChromeOSTest::SelectConfigurationCallback, + base::Bind(&BluetoothAudioSinkBlueZTest::SelectConfigurationCallback, base::Unretained(this))); EXPECT_EQ(audio_sink_->GetState(), BluetoothAudioSink::STATE_DISCONNECTED); @@ -955,4 +940,4 @@ TEST_F(BluetoothAudioSinkChromeOSTest, ContinuouslyStreaming) { EXPECT_EQ(observer_->total_read_, data_one.size() + data_two.size()); } -} // namespace chromeos +} // namespace bluez diff --git a/device/bluetooth/bluetooth_chromeos_unittest.cc b/device/bluetooth/bluetooth_bluez_unittest.cc index cd17a9a..e93b39d 100644 --- a/device/bluetooth/bluetooth_chromeos_unittest.cc +++ b/device/bluetooth/bluetooth_bluez_unittest.cc @@ -8,12 +8,12 @@ #include "base/strings/utf_string_conversions.h" #include "dbus/object_path.h" #include "device/bluetooth/bluetooth_adapter.h" -#include "device/bluetooth/bluetooth_adapter_chromeos.h" +#include "device/bluetooth/bluetooth_adapter_bluez.h" #include "device/bluetooth/bluetooth_adapter_factory.h" #include "device/bluetooth/bluetooth_device.h" -#include "device/bluetooth/bluetooth_device_chromeos.h" +#include "device/bluetooth/bluetooth_device_bluez.h" #include "device/bluetooth/bluetooth_discovery_session.h" -#include "device/bluetooth/bluetooth_pairing_chromeos.h" +#include "device/bluetooth/bluetooth_pairing_bluez.h" #include "device/bluetooth/dbus/bluez_dbus_manager.h" #include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h" #include "device/bluetooth/dbus/fake_bluetooth_agent_manager_client.h" @@ -33,7 +33,7 @@ using device::BluetoothDiscoverySession; using device::BluetoothUUID; using device::TestBluetoothAdapterObserver; -namespace chromeos { +namespace bluez { namespace { @@ -151,7 +151,7 @@ class TestPairingDelegate : public BluetoothDevice::PairingDelegate { } }; -class BluetoothChromeOSTest : public testing::Test { +class BluetoothBlueZTest : public testing::Test { public: void SetUp() override { scoped_ptr<bluez::BluezDBusManagerSetter> dbus_setter = @@ -187,9 +187,8 @@ class BluetoothChromeOSTest : public testing::Test { void TearDown() override { for (ScopedVector<BluetoothDiscoverySession>::iterator iter = - discovery_sessions_.begin(); - iter != discovery_sessions_.end(); - ++iter) { + discovery_sessions_.begin(); + iter != discovery_sessions_.end(); ++iter) { BluetoothDiscoverySession* session = *iter; if (!session->IsActive()) continue; @@ -210,7 +209,7 @@ class BluetoothChromeOSTest : public testing::Test { } base::Closure GetCallback() { - return base::Bind(&BluetoothChromeOSTest::Callback, base::Unretained(this)); + return base::Bind(&BluetoothBlueZTest::Callback, base::Unretained(this)); } void DiscoverySessionCallback( @@ -225,7 +224,7 @@ class BluetoothChromeOSTest : public testing::Test { QuitMessageLoop(); } - void ProfileRegisteredCallback(BluetoothAdapterProfileChromeOS* profile) { + void ProfileRegisteredCallback(BluetoothAdapterProfileBlueZ* profile) { adapter_profile_ = profile; ++callback_count_; QuitMessageLoop(); @@ -241,13 +240,13 @@ class BluetoothChromeOSTest : public testing::Test { } base::Closure GetErrorCallback() { - return base::Bind(&BluetoothChromeOSTest::ErrorCallback, + return base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this)); } base::Callback<void(device::UMABluetoothDiscoverySessionOutcome)> GetDiscoveryErrorCallback() { - return base::Bind(&BluetoothChromeOSTest::DiscoveryErrorCallback, + return base::Bind(&BluetoothBlueZTest::DiscoveryErrorCallback, base::Unretained(this)); } @@ -275,7 +274,7 @@ class BluetoothChromeOSTest : public testing::Test { // Call to fill the adapter_ member with a BluetoothAdapter instance. void GetAdapter() { - adapter_ = new BluetoothAdapterChromeOS(); + adapter_ = new BluetoothAdapterBlueZ(); ASSERT_TRUE(adapter_.get() != nullptr); ASSERT_TRUE(adapter_->IsInitialized()); } @@ -294,7 +293,7 @@ class BluetoothChromeOSTest : public testing::Test { adapter_->SetPowered(true, GetCallback(), GetErrorCallback()); adapter_->StartDiscoverySession( - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), GetErrorCallback()); base::MessageLoop::current()->Run(); @@ -338,7 +337,7 @@ class BluetoothChromeOSTest : public testing::Test { enum BluetoothDevice::ConnectErrorCode last_connect_error_; std::string last_client_error_; ScopedVector<BluetoothDiscoverySession> discovery_sessions_; - BluetoothAdapterProfileChromeOS* adapter_profile_; + BluetoothAdapterProfileBlueZ* adapter_profile_; private: // Some tests use a message loop since background processing is simulated; @@ -351,7 +350,7 @@ class BluetoothChromeOSTest : public testing::Test { } }; -TEST_F(BluetoothChromeOSTest, AlreadyPresent) { +TEST_F(BluetoothBlueZTest, AlreadyPresent) { GetAdapter(); // This verifies that the class gets the list of adapters when created; @@ -371,7 +370,7 @@ TEST_F(BluetoothChromeOSTest, AlreadyPresent) { devices[1]->GetAddress()); } -TEST_F(BluetoothChromeOSTest, BecomePresent) { +TEST_F(BluetoothBlueZTest, BecomePresent) { fake_bluetooth_adapter_client_->SetVisible(false); GetAdapter(); ASSERT_FALSE(adapter_->IsPresent()); @@ -399,7 +398,7 @@ TEST_F(BluetoothChromeOSTest, BecomePresent) { EXPECT_FALSE(adapter_->IsDiscovering()); } -TEST_F(BluetoothChromeOSTest, BecomeNotPresent) { +TEST_F(BluetoothBlueZTest, BecomeNotPresent) { GetAdapter(); ASSERT_TRUE(adapter_->IsPresent()); @@ -426,7 +425,7 @@ TEST_F(BluetoothChromeOSTest, BecomeNotPresent) { EXPECT_FALSE(adapter_->IsDiscovering()); } -TEST_F(BluetoothChromeOSTest, SecondAdapter) { +TEST_F(BluetoothBlueZTest, SecondAdapter) { GetAdapter(); ASSERT_TRUE(adapter_->IsPresent()); @@ -472,7 +471,7 @@ TEST_F(BluetoothChromeOSTest, SecondAdapter) { EXPECT_EQ(0, observer.discovering_changed_count()); } -TEST_F(BluetoothChromeOSTest, BecomePowered) { +TEST_F(BluetoothBlueZTest, BecomePowered) { GetAdapter(); ASSERT_FALSE(adapter_->IsPowered()); @@ -490,7 +489,7 @@ TEST_F(BluetoothChromeOSTest, BecomePowered) { EXPECT_TRUE(adapter_->IsPowered()); } -TEST_F(BluetoothChromeOSTest, BecomeNotPowered) { +TEST_F(BluetoothBlueZTest, BecomeNotPowered) { GetAdapter(); adapter_->SetPowered(true, GetCallback(), GetErrorCallback()); EXPECT_EQ(1, callback_count_); @@ -513,7 +512,7 @@ TEST_F(BluetoothChromeOSTest, BecomeNotPowered) { EXPECT_FALSE(adapter_->IsPowered()); } -TEST_F(BluetoothChromeOSTest, SetPoweredWhenNotPresent) { +TEST_F(BluetoothBlueZTest, SetPoweredWhenNotPresent) { GetAdapter(); ASSERT_TRUE(adapter_->IsPresent()); @@ -539,7 +538,7 @@ TEST_F(BluetoothChromeOSTest, SetPoweredWhenNotPresent) { EXPECT_FALSE(adapter_->IsPowered()); } -TEST_F(BluetoothChromeOSTest, ChangeAdapterName) { +TEST_F(BluetoothBlueZTest, ChangeAdapterName) { GetAdapter(); static const std::string new_name(".__."); @@ -551,7 +550,7 @@ TEST_F(BluetoothChromeOSTest, ChangeAdapterName) { EXPECT_EQ(new_name, adapter_->GetName()); } -TEST_F(BluetoothChromeOSTest, ChangeAdapterNameWhenNotPresent) { +TEST_F(BluetoothBlueZTest, ChangeAdapterNameWhenNotPresent) { GetAdapter(); ASSERT_TRUE(adapter_->IsPresent()); @@ -574,7 +573,7 @@ TEST_F(BluetoothChromeOSTest, ChangeAdapterNameWhenNotPresent) { EXPECT_EQ("", adapter_->GetName()); } -TEST_F(BluetoothChromeOSTest, BecomeDiscoverable) { +TEST_F(BluetoothBlueZTest, BecomeDiscoverable) { GetAdapter(); ASSERT_FALSE(adapter_->IsDiscoverable()); @@ -591,7 +590,7 @@ TEST_F(BluetoothChromeOSTest, BecomeDiscoverable) { EXPECT_TRUE(adapter_->IsDiscoverable()); } -TEST_F(BluetoothChromeOSTest, BecomeNotDiscoverable) { +TEST_F(BluetoothBlueZTest, BecomeNotDiscoverable) { GetAdapter(); adapter_->SetDiscoverable(true, GetCallback(), GetErrorCallback()); EXPECT_EQ(1, callback_count_); @@ -613,7 +612,7 @@ TEST_F(BluetoothChromeOSTest, BecomeNotDiscoverable) { EXPECT_FALSE(adapter_->IsDiscoverable()); } -TEST_F(BluetoothChromeOSTest, SetDiscoverableWhenNotPresent) { +TEST_F(BluetoothBlueZTest, SetDiscoverableWhenNotPresent) { GetAdapter(); ASSERT_TRUE(adapter_->IsPresent()); ASSERT_FALSE(adapter_->IsDiscoverable()); @@ -639,12 +638,12 @@ TEST_F(BluetoothChromeOSTest, SetDiscoverableWhenNotPresent) { EXPECT_FALSE(adapter_->IsDiscoverable()); } -TEST_F(BluetoothChromeOSTest, StopDiscovery) { +TEST_F(BluetoothBlueZTest, StopDiscovery) { GetAdapter(); adapter_->SetPowered(true, GetCallback(), GetErrorCallback()); adapter_->StartDiscoverySession( - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), GetErrorCallback()); message_loop_.Run(); @@ -678,7 +677,7 @@ TEST_F(BluetoothChromeOSTest, StopDiscovery) { // BluetoothDiscoverySession objects gets deleted adapter_->SetPowered(true, GetCallback(), GetErrorCallback()); adapter_->StartDiscoverySession( - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), GetErrorCallback()); message_loop_.Run(); @@ -698,7 +697,7 @@ TEST_F(BluetoothChromeOSTest, StopDiscovery) { EXPECT_EQ(0, error_callback_count_); } -TEST_F(BluetoothChromeOSTest, Discovery) { +TEST_F(BluetoothBlueZTest, Discovery) { // Test a simulated discovery session. fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); @@ -707,7 +706,7 @@ TEST_F(BluetoothChromeOSTest, Discovery) { adapter_->SetPowered(true, GetCallback(), GetErrorCallback()); adapter_->StartDiscoverySession( - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), GetErrorCallback()); message_loop_.Run(); @@ -740,11 +739,11 @@ TEST_F(BluetoothChromeOSTest, Discovery) { observer.last_device_address()); } -TEST_F(BluetoothChromeOSTest, PoweredAndDiscovering) { +TEST_F(BluetoothBlueZTest, PoweredAndDiscovering) { GetAdapter(); adapter_->SetPowered(true, GetCallback(), GetErrorCallback()); adapter_->StartDiscoverySession( - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), GetErrorCallback()); message_loop_.Run(); @@ -806,7 +805,7 @@ TEST_F(BluetoothChromeOSTest, PoweredAndDiscovering) { // This unit test asserts that the basic reference counting logic works // correctly for discovery requests done via the BluetoothAdapter. -TEST_F(BluetoothChromeOSTest, MultipleDiscoverySessions) { +TEST_F(BluetoothBlueZTest, MultipleDiscoverySessions) { GetAdapter(); adapter_->SetPowered(true, GetCallback(), GetErrorCallback()); EXPECT_EQ(1, callback_count_); @@ -823,7 +822,7 @@ TEST_F(BluetoothChromeOSTest, MultipleDiscoverySessions) { // Request device discovery 3 times. for (int i = 0; i < 3; i++) { adapter_->StartDiscoverySession( - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), GetErrorCallback()); } @@ -861,7 +860,7 @@ TEST_F(BluetoothChromeOSTest, MultipleDiscoverySessions) { // Request device discovery 3 times. for (int i = 0; i < 3; i++) { adapter_->StartDiscoverySession( - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), GetErrorCallback()); } @@ -910,8 +909,7 @@ TEST_F(BluetoothChromeOSTest, MultipleDiscoverySessions) { // This unit test asserts that the reference counting logic works correctly in // the cases when the adapter gets reset and D-Bus calls are made outside of // the BluetoothAdapter. -TEST_F(BluetoothChromeOSTest, - UnexpectedChangesDuringMultipleDiscoverySessions) { +TEST_F(BluetoothBlueZTest, UnexpectedChangesDuringMultipleDiscoverySessions) { GetAdapter(); adapter_->SetPowered(true, GetCallback(), GetErrorCallback()); EXPECT_EQ(1, callback_count_); @@ -928,7 +926,7 @@ TEST_F(BluetoothChromeOSTest, // Request device discovery 3 times. for (int i = 0; i < 3; i++) { adapter_->StartDiscoverySession( - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), GetErrorCallback()); } @@ -965,7 +963,7 @@ TEST_F(BluetoothChromeOSTest, // bluez::FakeBluetoothAdapterClient::StopDiscovery should work. fake_bluetooth_adapter_client_->StopDiscovery( dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), - GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, + GetCallback(), base::Bind(&BluetoothBlueZTest::DBusErrorCallback, base::Unretained(this))); message_loop_.Run(); EXPECT_EQ(2, observer.discovering_changed_count()); @@ -982,7 +980,7 @@ TEST_F(BluetoothChromeOSTest, // It should be possible to successfully start discovery. for (int i = 0; i < 2; i++) { adapter_->StartDiscoverySession( - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), GetErrorCallback()); } @@ -1030,7 +1028,7 @@ TEST_F(BluetoothChromeOSTest, // application other than us. Starting and stopping discovery will succeed // but it won't cause the discovery state to change. adapter_->StartDiscoverySession( - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), GetErrorCallback()); message_loop_.Run(); // Run the loop, as there should have been a D-Bus call. @@ -1054,7 +1052,7 @@ TEST_F(BluetoothChromeOSTest, // Start discovery again. adapter_->StartDiscoverySession( - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), GetErrorCallback()); message_loop_.Run(); // Run the loop, as there should have been a D-Bus call. @@ -1071,7 +1069,7 @@ TEST_F(BluetoothChromeOSTest, // requested it via D-Bus. fake_bluetooth_adapter_client_->StopDiscovery( dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), - GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, + GetCallback(), base::Bind(&BluetoothBlueZTest::DBusErrorCallback, base::Unretained(this))); message_loop_.Run(); EXPECT_EQ(5, observer.discovering_changed_count()); @@ -1092,7 +1090,7 @@ TEST_F(BluetoothChromeOSTest, EXPECT_FALSE(discovery_sessions_[0]->IsActive()); } -TEST_F(BluetoothChromeOSTest, InvalidatedDiscoverySessions) { +TEST_F(BluetoothBlueZTest, InvalidatedDiscoverySessions) { GetAdapter(); adapter_->SetPowered(true, GetCallback(), GetErrorCallback()); EXPECT_EQ(1, callback_count_); @@ -1109,7 +1107,7 @@ TEST_F(BluetoothChromeOSTest, InvalidatedDiscoverySessions) { // Request device discovery 3 times. for (int i = 0; i < 3; i++) { adapter_->StartDiscoverySession( - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), GetErrorCallback()); } @@ -1149,7 +1147,7 @@ TEST_F(BluetoothChromeOSTest, InvalidatedDiscoverySessions) { // cleaned up. fake_bluetooth_adapter_client_->StopDiscovery( dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), - GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, + GetCallback(), base::Bind(&BluetoothBlueZTest::DBusErrorCallback, base::Unretained(this))); message_loop_.Run(); EXPECT_EQ(2, observer.discovering_changed_count()); @@ -1160,7 +1158,7 @@ TEST_F(BluetoothChromeOSTest, InvalidatedDiscoverySessions) { EXPECT_FALSE(discovery_sessions_[0]->IsActive()); } -TEST_F(BluetoothChromeOSTest, QueuedDiscoveryRequests) { +TEST_F(BluetoothBlueZTest, QueuedDiscoveryRequests) { GetAdapter(); adapter_->SetPowered(true, GetCallback(), GetErrorCallback()); @@ -1177,7 +1175,7 @@ TEST_F(BluetoothChromeOSTest, QueuedDiscoveryRequests) { // Request to start discovery. The call should be pending. adapter_->StartDiscoverySession( - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), GetErrorCallback()); EXPECT_EQ(0, callback_count_); @@ -1196,7 +1194,7 @@ TEST_F(BluetoothChromeOSTest, QueuedDiscoveryRequests) { // be no change in state. for (int i = 0; i < 2; i++) { adapter_->StartDiscoverySession( - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), GetErrorCallback()); } @@ -1242,7 +1240,7 @@ TEST_F(BluetoothChromeOSTest, QueuedDiscoveryRequests) { // Request to start should get queued. adapter_->StartDiscoverySession( - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), GetErrorCallback()); EXPECT_EQ(5, callback_count_); @@ -1274,7 +1272,7 @@ TEST_F(BluetoothChromeOSTest, QueuedDiscoveryRequests) { EXPECT_TRUE(discovery_sessions_[3]->IsActive()); } -TEST_F(BluetoothChromeOSTest, StartDiscoverySession) { +TEST_F(BluetoothBlueZTest, StartDiscoverySession) { GetAdapter(); adapter_->SetPowered(true, GetCallback(), GetErrorCallback()); @@ -1292,7 +1290,7 @@ TEST_F(BluetoothChromeOSTest, StartDiscoverySession) { // Request a new discovery session. adapter_->StartDiscoverySession( - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), GetErrorCallback()); message_loop_.Run(); @@ -1308,7 +1306,7 @@ TEST_F(BluetoothChromeOSTest, StartDiscoverySession) { // in turn will destroy the previous session. Adapter should still be // discovering and the reference count should be 1. adapter_->StartDiscoverySession( - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), GetErrorCallback()); message_loop_.Run(); @@ -1322,7 +1320,7 @@ TEST_F(BluetoothChromeOSTest, StartDiscoverySession) { // Request a new session. adapter_->StartDiscoverySession( - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), GetErrorCallback()); message_loop_.Run(); @@ -1360,7 +1358,7 @@ TEST_F(BluetoothChromeOSTest, StartDiscoverySession) { EXPECT_FALSE(adapter_->IsDiscovering()); } -TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterBeforeStartDiscovery) { +TEST_F(BluetoothBlueZTest, SetDiscoveryFilterBeforeStartDiscovery) { // Test a simulated discovery session. fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); @@ -1373,16 +1371,14 @@ TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterBeforeStartDiscovery) { df->AddUUID(BluetoothUUID("1000")); scoped_ptr<BluetoothDiscoveryFilter> discovery_filter(df); - adapter_->SetPowered(true, base::Bind(&BluetoothChromeOSTest::Callback, - base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + adapter_->SetPowered( + true, base::Bind(&BluetoothBlueZTest::Callback, base::Unretained(this)), + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); adapter_->StartDiscoverySessionWithFilter( discovery_filter.Pass(), - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); message_loop_.Run(); EXPECT_EQ(2, callback_count_); EXPECT_EQ(0, error_callback_count_); @@ -1403,9 +1399,8 @@ TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterBeforeStartDiscovery) { EXPECT_NE(uuids.end(), std::find(uuids.begin(), uuids.end(), "1000")); discovery_sessions_[0]->Stop( - base::Bind(&BluetoothChromeOSTest::Callback, base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + base::Bind(&BluetoothBlueZTest::Callback, base::Unretained(this)), + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); message_loop_.Run(); @@ -1423,7 +1418,7 @@ TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterBeforeStartDiscovery) { EXPECT_EQ(nullptr, filter); } -TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterBeforeStartDiscoveryFail) { +TEST_F(BluetoothBlueZTest, SetDiscoveryFilterBeforeStartDiscoveryFail) { // Test a simulated discovery session. fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); @@ -1436,10 +1431,9 @@ TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterBeforeStartDiscoveryFail) { df->AddUUID(BluetoothUUID("1000")); scoped_ptr<BluetoothDiscoveryFilter> discovery_filter(df); - adapter_->SetPowered(true, base::Bind(&BluetoothChromeOSTest::Callback, - base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + adapter_->SetPowered( + true, base::Bind(&BluetoothBlueZTest::Callback, base::Unretained(this)), + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); EXPECT_EQ(1, callback_count_); callback_count_ = 0; @@ -1447,10 +1441,9 @@ TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterBeforeStartDiscoveryFail) { adapter_->StartDiscoverySessionWithFilter( discovery_filter.Pass(), - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); message_loop_.Run(); @@ -1468,7 +1461,7 @@ TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterBeforeStartDiscoveryFail) { // This test queues two requests to StartDiscovery with pre set filter. This // should result in SetDiscoveryFilter, then StartDiscovery, and SetDiscovery // DBus calls -TEST_F(BluetoothChromeOSTest, QueuedSetDiscoveryFilterBeforeStartDiscovery) { +TEST_F(BluetoothBlueZTest, QueuedSetDiscoveryFilterBeforeStartDiscovery) { // Test a simulated discovery session. fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); @@ -1487,10 +1480,9 @@ TEST_F(BluetoothChromeOSTest, QueuedSetDiscoveryFilterBeforeStartDiscovery) { df2->AddUUID(BluetoothUUID("1002")); scoped_ptr<BluetoothDiscoveryFilter> discovery_filter2(df2); - adapter_->SetPowered(true, base::Bind(&BluetoothChromeOSTest::Callback, - base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + adapter_->SetPowered( + true, base::Bind(&BluetoothBlueZTest::Callback, base::Unretained(this)), + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); EXPECT_EQ(1, callback_count_); EXPECT_EQ(0, error_callback_count_); @@ -1499,17 +1491,15 @@ TEST_F(BluetoothChromeOSTest, QueuedSetDiscoveryFilterBeforeStartDiscovery) { // Queue two requests to start discovery session with filter. adapter_->StartDiscoverySessionWithFilter( discovery_filter.Pass(), - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); adapter_->StartDiscoverySessionWithFilter( discovery_filter2.Pass(), - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); // Run requests, on DBus level there should be call SetDiscoveryFilter, then // StartDiscovery, then SetDiscoveryFilter again. @@ -1538,14 +1528,12 @@ TEST_F(BluetoothChromeOSTest, QueuedSetDiscoveryFilterBeforeStartDiscovery) { EXPECT_NE(uuids.end(), std::find(uuids.begin(), uuids.end(), "1002")); discovery_sessions_[0]->Stop( - base::Bind(&BluetoothChromeOSTest::Callback, base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + base::Bind(&BluetoothBlueZTest::Callback, base::Unretained(this)), + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); discovery_sessions_[1]->Stop( - base::Bind(&BluetoothChromeOSTest::Callback, base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + base::Bind(&BluetoothBlueZTest::Callback, base::Unretained(this)), + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); message_loop_.Run(); @@ -1568,8 +1556,7 @@ TEST_F(BluetoothChromeOSTest, QueuedSetDiscoveryFilterBeforeStartDiscovery) { // Call StartFilteredDiscovery twice (2nd time while 1st call is still pending). // Make the first SetDiscoveryFilter fail and the second one succeed. It should // end up with one active discovery session. -TEST_F(BluetoothChromeOSTest, - QueuedSetDiscoveryFilterBeforeStartDiscoveryFail) { +TEST_F(BluetoothBlueZTest, QueuedSetDiscoveryFilterBeforeStartDiscoveryFail) { // Test a simulated discovery session. fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); @@ -1588,10 +1575,9 @@ TEST_F(BluetoothChromeOSTest, df2->AddUUID(BluetoothUUID("1002")); scoped_ptr<BluetoothDiscoveryFilter> discovery_filter2(df2); - adapter_->SetPowered(true, base::Bind(&BluetoothChromeOSTest::Callback, - base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + adapter_->SetPowered( + true, base::Bind(&BluetoothBlueZTest::Callback, base::Unretained(this)), + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); EXPECT_EQ(1, callback_count_); EXPECT_EQ(0, error_callback_count_); @@ -1602,17 +1588,15 @@ TEST_F(BluetoothChromeOSTest, // Queue two requests to start discovery session with filter. adapter_->StartDiscoverySessionWithFilter( discovery_filter.Pass(), - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); adapter_->StartDiscoverySessionWithFilter( discovery_filter2.Pass(), - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); message_loop_.Run(); @@ -1647,9 +1631,8 @@ TEST_F(BluetoothChromeOSTest, EXPECT_NE(uuids.end(), std::find(uuids.begin(), uuids.end(), "1002")); discovery_sessions_[0]->Stop( - base::Bind(&BluetoothChromeOSTest::Callback, base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + base::Bind(&BluetoothBlueZTest::Callback, base::Unretained(this)), + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); message_loop_.Run(); @@ -1666,22 +1649,20 @@ TEST_F(BluetoothChromeOSTest, EXPECT_EQ(nullptr, filter); } -TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterAfterStartDiscovery) { +TEST_F(BluetoothBlueZTest, SetDiscoveryFilterAfterStartDiscovery) { // Test a simulated discovery session. fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); TestBluetoothAdapterObserver observer(adapter_); - adapter_->SetPowered(true, base::Bind(&BluetoothChromeOSTest::Callback, - base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + adapter_->SetPowered( + true, base::Bind(&BluetoothBlueZTest::Callback, base::Unretained(this)), + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); adapter_->StartDiscoverySession( - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); message_loop_.Run(); EXPECT_EQ(2, callback_count_); EXPECT_EQ(0, error_callback_count_); @@ -1709,9 +1690,8 @@ TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterAfterStartDiscovery) { discovery_sessions_[0]->SetDiscoveryFilter( discovery_filter.Pass(), - base::Bind(&BluetoothChromeOSTest::Callback, base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + base::Bind(&BluetoothBlueZTest::Callback, base::Unretained(this)), + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); message_loop_.Run(); EXPECT_EQ(1, callback_count_); @@ -1729,9 +1709,8 @@ TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterAfterStartDiscovery) { EXPECT_NE(uuids.end(), std::find(uuids.begin(), uuids.end(), "1000")); discovery_sessions_[0]->Stop( - base::Bind(&BluetoothChromeOSTest::Callback, base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + base::Bind(&BluetoothBlueZTest::Callback, base::Unretained(this)), + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); message_loop_.Run(); @@ -1751,12 +1730,11 @@ TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterAfterStartDiscovery) { // This unit test asserts that the basic reference counting, and filter merging // works correctly for discovery requests done via the BluetoothAdapter. -TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterBeforeStartDiscoveryMultiple) { +TEST_F(BluetoothBlueZTest, SetDiscoveryFilterBeforeStartDiscoveryMultiple) { GetAdapter(); - adapter_->SetPowered(true, base::Bind(&BluetoothChromeOSTest::Callback, - base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + adapter_->SetPowered( + true, base::Bind(&BluetoothBlueZTest::Callback, base::Unretained(this)), + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); EXPECT_EQ(1, callback_count_); EXPECT_EQ(0, error_callback_count_); EXPECT_TRUE(adapter_->IsPowered()); @@ -1791,10 +1769,9 @@ TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterBeforeStartDiscoveryMultiple) { adapter_->StartDiscoverySessionWithFilter( discovery_filter.Pass(), - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); message_loop_.Run(); @@ -1841,9 +1818,8 @@ TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterBeforeStartDiscoveryMultiple) { // Request to stop discovery twice. for (int i = 0; i < 2; i++) { discovery_sessions_[i]->Stop( - base::Bind(&BluetoothChromeOSTest::Callback, base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + base::Bind(&BluetoothBlueZTest::Callback, base::Unretained(this)), + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); message_loop_.Run(); if (i == 0) { @@ -1917,10 +1893,9 @@ TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterBeforeStartDiscoveryMultiple) { adapter_->StartDiscoverySessionWithFilter( discovery_filter.Pass(), - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); // each result in 1 requests. message_loop_.Run(); @@ -1958,9 +1933,8 @@ TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterBeforeStartDiscoveryMultiple) { // Request to stop discovery 4 times. for (int i = 2; i < 6; i++) { discovery_sessions_[i]->Stop( - base::Bind(&BluetoothChromeOSTest::Callback, base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + base::Bind(&BluetoothBlueZTest::Callback, base::Unretained(this)), + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); // filter no 2 is same as filter no 5, so removing it shouldn't cause any // filter update @@ -1987,12 +1961,11 @@ TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterBeforeStartDiscoveryMultiple) { // This unit test asserts that filter merging logic works correctly for filtered // discovery requests done via the BluetoothAdapter. -TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterMergingTest) { +TEST_F(BluetoothBlueZTest, SetDiscoveryFilterMergingTest) { GetAdapter(); - adapter_->SetPowered(true, base::Bind(&BluetoothChromeOSTest::Callback, - base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + adapter_->SetPowered( + true, base::Bind(&BluetoothBlueZTest::Callback, base::Unretained(this)), + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); BluetoothDiscoveryFilter* df = new BluetoothDiscoveryFilter( BluetoothDiscoveryFilter::Transport::TRANSPORT_LE); @@ -2002,10 +1975,9 @@ TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterMergingTest) { adapter_->StartDiscoverySessionWithFilter( discovery_filter.Pass(), - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); message_loop_.Run(); @@ -2025,10 +1997,9 @@ TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterMergingTest) { adapter_->StartDiscoverySessionWithFilter( discovery_filter.Pass(), - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); message_loop_.Run(); @@ -2050,10 +2021,9 @@ TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterMergingTest) { adapter_->StartDiscoverySessionWithFilter( discovery_filter3.Pass(), - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); message_loop_.Run(); @@ -2069,10 +2039,9 @@ TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterMergingTest) { // start additionally classic scan adapter_->StartDiscoverySession( - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); message_loop_.Run(); @@ -2085,16 +2054,15 @@ TEST_F(BluetoothChromeOSTest, SetDiscoveryFilterMergingTest) { // Request to stop discovery 4 times. for (int i = 3; i >= 0; i--) { discovery_sessions_[i]->Stop( - base::Bind(&BluetoothChromeOSTest::Callback, base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCallback, - base::Unretained(this))); + base::Bind(&BluetoothBlueZTest::Callback, base::Unretained(this)), + base::Bind(&BluetoothBlueZTest::ErrorCallback, base::Unretained(this))); // Every session stopping would trigger filter update message_loop_.Run(); } } -TEST_F(BluetoothChromeOSTest, DeviceProperties) { +TEST_F(BluetoothBlueZTest, DeviceProperties) { GetAdapter(); BluetoothAdapter::DeviceList devices = adapter_->GetDevices(); @@ -2125,7 +2093,7 @@ TEST_F(BluetoothChromeOSTest, DeviceProperties) { EXPECT_EQ(0x0306, devices[0]->GetDeviceID()); } -TEST_F(BluetoothChromeOSTest, DeviceClassChanged) { +TEST_F(BluetoothBlueZTest, DeviceClassChanged) { // Simulate a change of class of a device, as sometimes occurs // during discovery. GetAdapter(); @@ -2152,7 +2120,7 @@ TEST_F(BluetoothChromeOSTest, DeviceClassChanged) { EXPECT_EQ(BluetoothDevice::DEVICE_MOUSE, devices[0]->GetDeviceType()); } -TEST_F(BluetoothChromeOSTest, DeviceNameChanged) { +TEST_F(BluetoothBlueZTest, DeviceNameChanged) { // Simulate a change of name of a device. GetAdapter(); @@ -2181,7 +2149,7 @@ TEST_F(BluetoothChromeOSTest, DeviceNameChanged) { EXPECT_EQ(base::UTF8ToUTF16(new_name), devices[0]->GetName()); } -TEST_F(BluetoothChromeOSTest, DeviceAddressChanged) { +TEST_F(BluetoothBlueZTest, DeviceAddressChanged) { // Simulate a change of address of a device. GetAdapter(); @@ -2211,7 +2179,7 @@ TEST_F(BluetoothChromeOSTest, DeviceAddressChanged) { EXPECT_EQ(std::string(kNewAddress), devices[0]->GetAddress()); } -TEST_F(BluetoothChromeOSTest, DeviceUuidsChanged) { +TEST_F(BluetoothBlueZTest, DeviceUuidsChanged) { // Simulate a change of advertised services of a device. GetAdapter(); @@ -2255,7 +2223,7 @@ TEST_F(BluetoothChromeOSTest, DeviceUuidsChanged) { EXPECT_EQ(uuids[4], BluetoothUUID("110a")); } -TEST_F(BluetoothChromeOSTest, DeviceInquiryRSSIInvalidated) { +TEST_F(BluetoothBlueZTest, DeviceInquiryRSSIInvalidated) { // Simulate invalidation of inquiry RSSI of a device, as it occurs // when discovery is finished. GetAdapter(); @@ -2290,7 +2258,7 @@ TEST_F(BluetoothChromeOSTest, DeviceInquiryRSSIInvalidated) { EXPECT_EQ(unknown_power, devices[0]->GetInquiryRSSI()); } -TEST_F(BluetoothChromeOSTest, DeviceInquiryTxPowerInvalidated) { +TEST_F(BluetoothBlueZTest, DeviceInquiryTxPowerInvalidated) { // Simulate invalidation of inquiry TxPower of a device, as it occurs // when discovery is finished. GetAdapter(); @@ -2325,7 +2293,7 @@ TEST_F(BluetoothChromeOSTest, DeviceInquiryTxPowerInvalidated) { EXPECT_EQ(unknown_power, devices[0]->GetInquiryTxPower()); } -TEST_F(BluetoothChromeOSTest, ForgetDevice) { +TEST_F(BluetoothBlueZTest, ForgetDevice) { GetAdapter(); BluetoothAdapter::DeviceList devices = adapter_->GetDevices(); @@ -2350,7 +2318,7 @@ TEST_F(BluetoothChromeOSTest, ForgetDevice) { ASSERT_EQ(1U, devices.size()); } -TEST_F(BluetoothChromeOSTest, ForgetUnpairedDevice) { +TEST_F(BluetoothBlueZTest, ForgetUnpairedDevice) { GetAdapter(); DiscoverDevices(); @@ -2361,7 +2329,7 @@ TEST_F(BluetoothChromeOSTest, ForgetUnpairedDevice) { // Connect the device so it becomes trusted and remembered. device->Connect(nullptr, GetCallback(), - base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, + base::Bind(&BluetoothBlueZTest::ConnectErrorCallback, base::Unretained(this))); ASSERT_EQ(1, callback_count_); @@ -2394,7 +2362,7 @@ TEST_F(BluetoothChromeOSTest, ForgetUnpairedDevice) { EXPECT_FALSE(device != nullptr); } -TEST_F(BluetoothChromeOSTest, ConnectPairedDevice) { +TEST_F(BluetoothBlueZTest, ConnectPairedDevice) { GetAdapter(); BluetoothDevice* device = adapter_->GetDevice( @@ -2407,7 +2375,7 @@ TEST_F(BluetoothChromeOSTest, ConnectPairedDevice) { // Connect without a pairing delegate; since the device is already Paired // this should succeed and the device should become connected. device->Connect(nullptr, GetCallback(), - base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, + base::Bind(&BluetoothBlueZTest::ConnectErrorCallback, base::Unretained(this))); EXPECT_EQ(1, callback_count_); @@ -2422,7 +2390,7 @@ TEST_F(BluetoothChromeOSTest, ConnectPairedDevice) { EXPECT_FALSE(device->IsConnecting()); } -TEST_F(BluetoothChromeOSTest, ConnectUnpairableDevice) { +TEST_F(BluetoothBlueZTest, ConnectUnpairableDevice) { GetAdapter(); DiscoverDevices(); @@ -2436,7 +2404,7 @@ TEST_F(BluetoothChromeOSTest, ConnectUnpairableDevice) { // Connect without a pairing delegate; since the device does not require // pairing, this should succeed and the device should become connected. device->Connect(nullptr, GetCallback(), - base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, + base::Bind(&BluetoothBlueZTest::ConnectErrorCallback, base::Unretained(this))); EXPECT_EQ(1, callback_count_); @@ -2463,7 +2431,7 @@ TEST_F(BluetoothChromeOSTest, ConnectUnpairableDevice) { EXPECT_FALSE(device->IsConnectable()); } -TEST_F(BluetoothChromeOSTest, ConnectConnectedDevice) { +TEST_F(BluetoothBlueZTest, ConnectConnectedDevice) { GetAdapter(); BluetoothDevice* device = adapter_->GetDevice( @@ -2472,7 +2440,7 @@ TEST_F(BluetoothChromeOSTest, ConnectConnectedDevice) { ASSERT_TRUE(device->IsPaired()); device->Connect(nullptr, GetCallback(), - base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, + base::Bind(&BluetoothBlueZTest::ConnectErrorCallback, base::Unretained(this))); ASSERT_EQ(1, callback_count_); @@ -2486,7 +2454,7 @@ TEST_F(BluetoothChromeOSTest, ConnectConnectedDevice) { TestBluetoothAdapterObserver observer(adapter_); device->Connect(nullptr, GetCallback(), - base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, + base::Bind(&BluetoothBlueZTest::ConnectErrorCallback, base::Unretained(this))); EXPECT_EQ(1, callback_count_); @@ -2500,7 +2468,7 @@ TEST_F(BluetoothChromeOSTest, ConnectConnectedDevice) { EXPECT_FALSE(device->IsConnecting()); } -TEST_F(BluetoothChromeOSTest, ConnectDeviceFails) { +TEST_F(BluetoothBlueZTest, ConnectDeviceFails) { GetAdapter(); DiscoverDevices(); @@ -2514,7 +2482,7 @@ TEST_F(BluetoothChromeOSTest, ConnectDeviceFails) { // Connect without a pairing delegate; since the device requires pairing, // this should fail with an error. device->Connect(nullptr, GetCallback(), - base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, + base::Bind(&BluetoothBlueZTest::ConnectErrorCallback, base::Unretained(this))); EXPECT_EQ(0, callback_count_); @@ -2527,7 +2495,7 @@ TEST_F(BluetoothChromeOSTest, ConnectDeviceFails) { EXPECT_FALSE(device->IsConnecting()); } -TEST_F(BluetoothChromeOSTest, DisconnectDevice) { +TEST_F(BluetoothBlueZTest, DisconnectDevice) { GetAdapter(); BluetoothDevice* device = adapter_->GetDevice( @@ -2536,7 +2504,7 @@ TEST_F(BluetoothChromeOSTest, DisconnectDevice) { ASSERT_TRUE(device->IsPaired()); device->Connect(nullptr, GetCallback(), - base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, + base::Bind(&BluetoothBlueZTest::ConnectErrorCallback, base::Unretained(this))); ASSERT_EQ(1, callback_count_); @@ -2561,7 +2529,7 @@ TEST_F(BluetoothChromeOSTest, DisconnectDevice) { EXPECT_FALSE(device->IsConnected()); } -TEST_F(BluetoothChromeOSTest, DisconnectUnconnectedDevice) { +TEST_F(BluetoothBlueZTest, DisconnectUnconnectedDevice) { GetAdapter(); BluetoothDevice* device = adapter_->GetDevice( @@ -2584,7 +2552,7 @@ TEST_F(BluetoothChromeOSTest, DisconnectUnconnectedDevice) { EXPECT_FALSE(device->IsConnected()); } -TEST_F(BluetoothChromeOSTest, PairLegacyAutopair) { +TEST_F(BluetoothBlueZTest, PairLegacyAutopair) { fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); @@ -2601,7 +2569,7 @@ TEST_F(BluetoothChromeOSTest, PairLegacyAutopair) { TestPairingDelegate pairing_delegate; device->Connect(&pairing_delegate, GetCallback(), - base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, + base::Bind(&BluetoothBlueZTest::ConnectErrorCallback, base::Unretained(this))); EXPECT_EQ(0, pairing_delegate.call_count_); @@ -2636,7 +2604,7 @@ TEST_F(BluetoothChromeOSTest, PairLegacyAutopair) { EXPECT_TRUE(properties->trusted.value()); } -TEST_F(BluetoothChromeOSTest, PairDisplayPinCode) { +TEST_F(BluetoothBlueZTest, PairDisplayPinCode) { fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); @@ -2652,7 +2620,7 @@ TEST_F(BluetoothChromeOSTest, PairDisplayPinCode) { TestPairingDelegate pairing_delegate; device->Connect(&pairing_delegate, GetCallback(), - base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, + base::Bind(&BluetoothBlueZTest::ConnectErrorCallback, base::Unretained(this))); EXPECT_EQ(1, pairing_delegate.call_count_); @@ -2689,7 +2657,7 @@ TEST_F(BluetoothChromeOSTest, PairDisplayPinCode) { EXPECT_TRUE(properties->trusted.value()); } -TEST_F(BluetoothChromeOSTest, PairDisplayPasskey) { +TEST_F(BluetoothBlueZTest, PairDisplayPasskey) { fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); @@ -2706,7 +2674,7 @@ TEST_F(BluetoothChromeOSTest, PairDisplayPasskey) { TestPairingDelegate pairing_delegate; device->Connect(&pairing_delegate, GetCallback(), - base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, + base::Bind(&BluetoothBlueZTest::ConnectErrorCallback, base::Unretained(this))); // One call for DisplayPasskey() and one for KeysEntered(). @@ -2764,7 +2732,7 @@ TEST_F(BluetoothChromeOSTest, PairDisplayPasskey) { EXPECT_TRUE(properties->trusted.value()); } -TEST_F(BluetoothChromeOSTest, PairRequestPinCode) { +TEST_F(BluetoothBlueZTest, PairRequestPinCode) { fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); @@ -2780,7 +2748,7 @@ TEST_F(BluetoothChromeOSTest, PairRequestPinCode) { TestPairingDelegate pairing_delegate; device->Connect(&pairing_delegate, GetCallback(), - base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, + base::Bind(&BluetoothBlueZTest::ConnectErrorCallback, base::Unretained(this))); EXPECT_EQ(1, pairing_delegate.call_count_); @@ -2818,7 +2786,7 @@ TEST_F(BluetoothChromeOSTest, PairRequestPinCode) { EXPECT_TRUE(properties->trusted.value()); } -TEST_F(BluetoothChromeOSTest, PairConfirmPasskey) { +TEST_F(BluetoothBlueZTest, PairConfirmPasskey) { fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); @@ -2834,7 +2802,7 @@ TEST_F(BluetoothChromeOSTest, PairConfirmPasskey) { TestPairingDelegate pairing_delegate; device->Connect(&pairing_delegate, GetCallback(), - base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, + base::Bind(&BluetoothBlueZTest::ConnectErrorCallback, base::Unretained(this))); EXPECT_EQ(1, pairing_delegate.call_count_); @@ -2869,7 +2837,7 @@ TEST_F(BluetoothChromeOSTest, PairConfirmPasskey) { EXPECT_TRUE(properties->trusted.value()); } -TEST_F(BluetoothChromeOSTest, PairRequestPasskey) { +TEST_F(BluetoothBlueZTest, PairRequestPasskey) { fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); @@ -2886,7 +2854,7 @@ TEST_F(BluetoothChromeOSTest, PairRequestPasskey) { TestPairingDelegate pairing_delegate; device->Connect(&pairing_delegate, GetCallback(), - base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, + base::Bind(&BluetoothBlueZTest::ConnectErrorCallback, base::Unretained(this))); EXPECT_EQ(1, pairing_delegate.call_count_); @@ -2920,7 +2888,7 @@ TEST_F(BluetoothChromeOSTest, PairRequestPasskey) { EXPECT_TRUE(properties->trusted.value()); } -TEST_F(BluetoothChromeOSTest, PairJustWorks) { +TEST_F(BluetoothBlueZTest, PairJustWorks) { fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); @@ -2937,7 +2905,7 @@ TEST_F(BluetoothChromeOSTest, PairJustWorks) { TestPairingDelegate pairing_delegate; device->Connect(&pairing_delegate, GetCallback(), - base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, + base::Bind(&BluetoothBlueZTest::ConnectErrorCallback, base::Unretained(this))); EXPECT_EQ(0, pairing_delegate.call_count_); @@ -2967,7 +2935,7 @@ TEST_F(BluetoothChromeOSTest, PairJustWorks) { EXPECT_TRUE(properties->trusted.value()); } -TEST_F(BluetoothChromeOSTest, PairUnpairableDeviceFails) { +TEST_F(BluetoothBlueZTest, PairUnpairableDeviceFails) { fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); @@ -2982,7 +2950,7 @@ TEST_F(BluetoothChromeOSTest, PairUnpairableDeviceFails) { TestPairingDelegate pairing_delegate; device->Connect(&pairing_delegate, GetCallback(), - base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, + base::Bind(&BluetoothBlueZTest::ConnectErrorCallback, base::Unretained(this))); EXPECT_EQ(0, pairing_delegate.call_count_); @@ -3001,7 +2969,7 @@ TEST_F(BluetoothChromeOSTest, PairUnpairableDeviceFails) { EXPECT_FALSE(device->IsPaired()); } -TEST_F(BluetoothChromeOSTest, PairingFails) { +TEST_F(BluetoothBlueZTest, PairingFails) { fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); @@ -3017,7 +2985,7 @@ TEST_F(BluetoothChromeOSTest, PairingFails) { TestPairingDelegate pairing_delegate; device->Connect(&pairing_delegate, GetCallback(), - base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, + base::Bind(&BluetoothBlueZTest::ConnectErrorCallback, base::Unretained(this))); EXPECT_EQ(0, pairing_delegate.call_count_); @@ -3036,7 +3004,7 @@ TEST_F(BluetoothChromeOSTest, PairingFails) { EXPECT_FALSE(device->IsPaired()); } -TEST_F(BluetoothChromeOSTest, PairingFailsAtConnection) { +TEST_F(BluetoothBlueZTest, PairingFailsAtConnection) { fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); @@ -3053,7 +3021,7 @@ TEST_F(BluetoothChromeOSTest, PairingFailsAtConnection) { TestPairingDelegate pairing_delegate; device->Connect(&pairing_delegate, GetCallback(), - base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, + base::Bind(&BluetoothBlueZTest::ConnectErrorCallback, base::Unretained(this))); EXPECT_EQ(0, pairing_delegate.call_count_); @@ -3083,7 +3051,7 @@ TEST_F(BluetoothChromeOSTest, PairingFailsAtConnection) { EXPECT_TRUE(properties->trusted.value()); } -TEST_F(BluetoothChromeOSTest, PairingRejectedAtPinCode) { +TEST_F(BluetoothBlueZTest, PairingRejectedAtPinCode) { fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); @@ -3099,7 +3067,7 @@ TEST_F(BluetoothChromeOSTest, PairingRejectedAtPinCode) { TestPairingDelegate pairing_delegate; device->Connect(&pairing_delegate, GetCallback(), - base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, + base::Bind(&BluetoothBlueZTest::ConnectErrorCallback, base::Unretained(this))); EXPECT_EQ(1, pairing_delegate.call_count_); @@ -3121,7 +3089,7 @@ TEST_F(BluetoothChromeOSTest, PairingRejectedAtPinCode) { EXPECT_FALSE(device->IsPaired()); } -TEST_F(BluetoothChromeOSTest, PairingCancelledAtPinCode) { +TEST_F(BluetoothBlueZTest, PairingCancelledAtPinCode) { fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); @@ -3137,7 +3105,7 @@ TEST_F(BluetoothChromeOSTest, PairingCancelledAtPinCode) { TestPairingDelegate pairing_delegate; device->Connect(&pairing_delegate, GetCallback(), - base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, + base::Bind(&BluetoothBlueZTest::ConnectErrorCallback, base::Unretained(this))); EXPECT_EQ(1, pairing_delegate.call_count_); @@ -3159,7 +3127,7 @@ TEST_F(BluetoothChromeOSTest, PairingCancelledAtPinCode) { EXPECT_FALSE(device->IsPaired()); } -TEST_F(BluetoothChromeOSTest, PairingRejectedAtPasskey) { +TEST_F(BluetoothBlueZTest, PairingRejectedAtPasskey) { fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); @@ -3175,7 +3143,7 @@ TEST_F(BluetoothChromeOSTest, PairingRejectedAtPasskey) { TestPairingDelegate pairing_delegate; device->Connect(&pairing_delegate, GetCallback(), - base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, + base::Bind(&BluetoothBlueZTest::ConnectErrorCallback, base::Unretained(this))); EXPECT_EQ(1, pairing_delegate.call_count_); @@ -3197,7 +3165,7 @@ TEST_F(BluetoothChromeOSTest, PairingRejectedAtPasskey) { EXPECT_FALSE(device->IsPaired()); } -TEST_F(BluetoothChromeOSTest, PairingCancelledAtPasskey) { +TEST_F(BluetoothBlueZTest, PairingCancelledAtPasskey) { fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); @@ -3213,7 +3181,7 @@ TEST_F(BluetoothChromeOSTest, PairingCancelledAtPasskey) { TestPairingDelegate pairing_delegate; device->Connect(&pairing_delegate, GetCallback(), - base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, + base::Bind(&BluetoothBlueZTest::ConnectErrorCallback, base::Unretained(this))); EXPECT_EQ(1, pairing_delegate.call_count_); @@ -3235,7 +3203,7 @@ TEST_F(BluetoothChromeOSTest, PairingCancelledAtPasskey) { EXPECT_FALSE(device->IsPaired()); } -TEST_F(BluetoothChromeOSTest, PairingRejectedAtConfirmation) { +TEST_F(BluetoothBlueZTest, PairingRejectedAtConfirmation) { fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); @@ -3251,7 +3219,7 @@ TEST_F(BluetoothChromeOSTest, PairingRejectedAtConfirmation) { TestPairingDelegate pairing_delegate; device->Connect(&pairing_delegate, GetCallback(), - base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, + base::Bind(&BluetoothBlueZTest::ConnectErrorCallback, base::Unretained(this))); EXPECT_EQ(1, pairing_delegate.call_count_); @@ -3273,7 +3241,7 @@ TEST_F(BluetoothChromeOSTest, PairingRejectedAtConfirmation) { EXPECT_FALSE(device->IsPaired()); } -TEST_F(BluetoothChromeOSTest, PairingCancelledAtConfirmation) { +TEST_F(BluetoothBlueZTest, PairingCancelledAtConfirmation) { fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); @@ -3289,7 +3257,7 @@ TEST_F(BluetoothChromeOSTest, PairingCancelledAtConfirmation) { TestPairingDelegate pairing_delegate; device->Connect(&pairing_delegate, GetCallback(), - base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, + base::Bind(&BluetoothBlueZTest::ConnectErrorCallback, base::Unretained(this))); EXPECT_EQ(1, pairing_delegate.call_count_); @@ -3311,7 +3279,7 @@ TEST_F(BluetoothChromeOSTest, PairingCancelledAtConfirmation) { EXPECT_FALSE(device->IsPaired()); } -TEST_F(BluetoothChromeOSTest, PairingCancelledInFlight) { +TEST_F(BluetoothBlueZTest, PairingCancelledInFlight) { fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); @@ -3327,7 +3295,7 @@ TEST_F(BluetoothChromeOSTest, PairingCancelledInFlight) { TestPairingDelegate pairing_delegate; device->Connect(&pairing_delegate, GetCallback(), - base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, + base::Bind(&BluetoothBlueZTest::ConnectErrorCallback, base::Unretained(this))); EXPECT_EQ(0, pairing_delegate.call_count_); @@ -3348,15 +3316,14 @@ TEST_F(BluetoothChromeOSTest, PairingCancelledInFlight) { EXPECT_FALSE(device->IsPaired()); } -TEST_F(BluetoothChromeOSTest, IncomingPairRequestPinCode) { +TEST_F(BluetoothBlueZTest, IncomingPairRequestPinCode) { fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); TestPairingDelegate pairing_delegate; adapter_->AddPairingDelegate( - &pairing_delegate, - BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); + &pairing_delegate, BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); // Requires that we provide a PIN code. fake_bluetooth_device_client_->CreateDevice( @@ -3371,7 +3338,7 @@ TEST_F(BluetoothChromeOSTest, IncomingPairRequestPinCode) { fake_bluetooth_device_client_->SimulatePairing( dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kRequestPinCodePath), - true, GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, + true, GetCallback(), base::Bind(&BluetoothBlueZTest::DBusErrorCallback, base::Unretained(this))); EXPECT_EQ(1, pairing_delegate.call_count_); @@ -3397,20 +3364,19 @@ TEST_F(BluetoothChromeOSTest, IncomingPairRequestPinCode) { ASSERT_TRUE(properties->trusted.value()); // No pairing context should remain on the device. - BluetoothDeviceChromeOS* device_chromeos = - static_cast<BluetoothDeviceChromeOS*>(device); - EXPECT_TRUE(device_chromeos->GetPairing() == nullptr); + BluetoothDeviceBlueZ* device_bluez = + static_cast<BluetoothDeviceBlueZ*>(device); + EXPECT_TRUE(device_bluez->GetPairing() == nullptr); } -TEST_F(BluetoothChromeOSTest, IncomingPairConfirmPasskey) { +TEST_F(BluetoothBlueZTest, IncomingPairConfirmPasskey) { fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); TestPairingDelegate pairing_delegate; adapter_->AddPairingDelegate( - &pairing_delegate, - BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); + &pairing_delegate, BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); // Requests that we confirm a displayed passkey. fake_bluetooth_device_client_->CreateDevice( @@ -3425,7 +3391,7 @@ TEST_F(BluetoothChromeOSTest, IncomingPairConfirmPasskey) { fake_bluetooth_device_client_->SimulatePairing( dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kConfirmPasskeyPath), - true, GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, + true, GetCallback(), base::Bind(&BluetoothBlueZTest::DBusErrorCallback, base::Unretained(this))); EXPECT_EQ(1, pairing_delegate.call_count_); @@ -3452,20 +3418,19 @@ TEST_F(BluetoothChromeOSTest, IncomingPairConfirmPasskey) { ASSERT_TRUE(properties->trusted.value()); // No pairing context should remain on the device. - BluetoothDeviceChromeOS* device_chromeos = - static_cast<BluetoothDeviceChromeOS*>(device); - EXPECT_TRUE(device_chromeos->GetPairing() == nullptr); + BluetoothDeviceBlueZ* device_bluez = + static_cast<BluetoothDeviceBlueZ*>(device); + EXPECT_TRUE(device_bluez->GetPairing() == nullptr); } -TEST_F(BluetoothChromeOSTest, IncomingPairRequestPasskey) { +TEST_F(BluetoothBlueZTest, IncomingPairRequestPasskey) { fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); TestPairingDelegate pairing_delegate; adapter_->AddPairingDelegate( - &pairing_delegate, - BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); + &pairing_delegate, BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); // Requests that we provide a Passkey. fake_bluetooth_device_client_->CreateDevice( @@ -3480,7 +3445,7 @@ TEST_F(BluetoothChromeOSTest, IncomingPairRequestPasskey) { fake_bluetooth_device_client_->SimulatePairing( dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kRequestPasskeyPath), - true, GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, + true, GetCallback(), base::Bind(&BluetoothBlueZTest::DBusErrorCallback, base::Unretained(this))); EXPECT_EQ(1, pairing_delegate.call_count_); @@ -3506,20 +3471,19 @@ TEST_F(BluetoothChromeOSTest, IncomingPairRequestPasskey) { ASSERT_TRUE(properties->trusted.value()); // No pairing context should remain on the device. - BluetoothDeviceChromeOS* device_chromeos = - static_cast<BluetoothDeviceChromeOS*>(device); - EXPECT_TRUE(device_chromeos->GetPairing() == nullptr); + BluetoothDeviceBlueZ* device_bluez = + static_cast<BluetoothDeviceBlueZ*>(device); + EXPECT_TRUE(device_bluez->GetPairing() == nullptr); } -TEST_F(BluetoothChromeOSTest, IncomingPairJustWorks) { +TEST_F(BluetoothBlueZTest, IncomingPairJustWorks) { fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); TestPairingDelegate pairing_delegate; adapter_->AddPairingDelegate( - &pairing_delegate, - BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); + &pairing_delegate, BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); // Uses just-works pairing so, sinec this an incoming pairing, require // authorization from the user. @@ -3535,7 +3499,7 @@ TEST_F(BluetoothChromeOSTest, IncomingPairJustWorks) { fake_bluetooth_device_client_->SimulatePairing( dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kJustWorksPath), true, - GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, + GetCallback(), base::Bind(&BluetoothBlueZTest::DBusErrorCallback, base::Unretained(this))); EXPECT_EQ(1, pairing_delegate.call_count_); @@ -3561,12 +3525,12 @@ TEST_F(BluetoothChromeOSTest, IncomingPairJustWorks) { ASSERT_TRUE(properties->trusted.value()); // No pairing context should remain on the device. - BluetoothDeviceChromeOS* device_chromeos = - static_cast<BluetoothDeviceChromeOS*>(device); - EXPECT_TRUE(device_chromeos->GetPairing() == nullptr); + BluetoothDeviceBlueZ* device_bluez = + static_cast<BluetoothDeviceBlueZ*>(device); + EXPECT_TRUE(device_bluez->GetPairing() == nullptr); } -TEST_F(BluetoothChromeOSTest, IncomingPairRequestPinCodeWithoutDelegate) { +TEST_F(BluetoothBlueZTest, IncomingPairRequestPinCodeWithoutDelegate) { fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); @@ -3585,7 +3549,7 @@ TEST_F(BluetoothChromeOSTest, IncomingPairRequestPinCodeWithoutDelegate) { fake_bluetooth_device_client_->SimulatePairing( dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kRequestPinCodePath), - true, GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, + true, GetCallback(), base::Bind(&BluetoothBlueZTest::DBusErrorCallback, base::Unretained(this))); message_loop_.Run(); @@ -3600,12 +3564,12 @@ TEST_F(BluetoothChromeOSTest, IncomingPairRequestPinCodeWithoutDelegate) { EXPECT_FALSE(device->IsPaired()); // No pairing context should remain on the device. - BluetoothDeviceChromeOS* device_chromeos = - static_cast<BluetoothDeviceChromeOS*>(device); - EXPECT_TRUE(device_chromeos->GetPairing() == nullptr); + BluetoothDeviceBlueZ* device_bluez = + static_cast<BluetoothDeviceBlueZ*>(device); + EXPECT_TRUE(device_bluez->GetPairing() == nullptr); } -TEST_F(BluetoothChromeOSTest, IncomingPairConfirmPasskeyWithoutDelegate) { +TEST_F(BluetoothBlueZTest, IncomingPairConfirmPasskeyWithoutDelegate) { fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); @@ -3624,7 +3588,7 @@ TEST_F(BluetoothChromeOSTest, IncomingPairConfirmPasskeyWithoutDelegate) { fake_bluetooth_device_client_->SimulatePairing( dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kConfirmPasskeyPath), - true, GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, + true, GetCallback(), base::Bind(&BluetoothBlueZTest::DBusErrorCallback, base::Unretained(this))); message_loop_.Run(); @@ -3639,12 +3603,12 @@ TEST_F(BluetoothChromeOSTest, IncomingPairConfirmPasskeyWithoutDelegate) { EXPECT_FALSE(device->IsPaired()); // No pairing context should remain on the device. - BluetoothDeviceChromeOS* device_chromeos = - static_cast<BluetoothDeviceChromeOS*>(device); - EXPECT_TRUE(device_chromeos->GetPairing() == nullptr); + BluetoothDeviceBlueZ* device_bluez = + static_cast<BluetoothDeviceBlueZ*>(device); + EXPECT_TRUE(device_bluez->GetPairing() == nullptr); } -TEST_F(BluetoothChromeOSTest, IncomingPairRequestPasskeyWithoutDelegate) { +TEST_F(BluetoothBlueZTest, IncomingPairRequestPasskeyWithoutDelegate) { fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); @@ -3663,7 +3627,7 @@ TEST_F(BluetoothChromeOSTest, IncomingPairRequestPasskeyWithoutDelegate) { fake_bluetooth_device_client_->SimulatePairing( dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kRequestPasskeyPath), - true, GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, + true, GetCallback(), base::Bind(&BluetoothBlueZTest::DBusErrorCallback, base::Unretained(this))); message_loop_.Run(); @@ -3678,12 +3642,12 @@ TEST_F(BluetoothChromeOSTest, IncomingPairRequestPasskeyWithoutDelegate) { EXPECT_FALSE(device->IsPaired()); // No pairing context should remain on the device. - BluetoothDeviceChromeOS* device_chromeos = - static_cast<BluetoothDeviceChromeOS*>(device); - EXPECT_TRUE(device_chromeos->GetPairing() == nullptr); + BluetoothDeviceBlueZ* device_bluez = + static_cast<BluetoothDeviceBlueZ*>(device); + EXPECT_TRUE(device_bluez->GetPairing() == nullptr); } -TEST_F(BluetoothChromeOSTest, IncomingPairJustWorksWithoutDelegate) { +TEST_F(BluetoothBlueZTest, IncomingPairJustWorksWithoutDelegate) { fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); @@ -3702,7 +3666,7 @@ TEST_F(BluetoothChromeOSTest, IncomingPairJustWorksWithoutDelegate) { fake_bluetooth_device_client_->SimulatePairing( dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kJustWorksPath), true, - GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, + GetCallback(), base::Bind(&BluetoothBlueZTest::DBusErrorCallback, base::Unretained(this))); message_loop_.Run(); @@ -3717,20 +3681,19 @@ TEST_F(BluetoothChromeOSTest, IncomingPairJustWorksWithoutDelegate) { EXPECT_FALSE(device->IsPaired()); // No pairing context should remain on the device. - BluetoothDeviceChromeOS* device_chromeos = - static_cast<BluetoothDeviceChromeOS*>(device); - EXPECT_TRUE(device_chromeos->GetPairing() == nullptr); + BluetoothDeviceBlueZ* device_bluez = + static_cast<BluetoothDeviceBlueZ*>(device); + EXPECT_TRUE(device_bluez->GetPairing() == nullptr); } -TEST_F(BluetoothChromeOSTest, RemovePairingDelegateDuringPairing) { +TEST_F(BluetoothBlueZTest, RemovePairingDelegateDuringPairing) { fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); TestPairingDelegate pairing_delegate; adapter_->AddPairingDelegate( - &pairing_delegate, - BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); + &pairing_delegate, BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); // Requests that we provide a Passkey. fake_bluetooth_device_client_->CreateDevice( @@ -3745,21 +3708,21 @@ TEST_F(BluetoothChromeOSTest, RemovePairingDelegateDuringPairing) { fake_bluetooth_device_client_->SimulatePairing( dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kRequestPasskeyPath), - true, GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, + true, GetCallback(), base::Bind(&BluetoothBlueZTest::DBusErrorCallback, base::Unretained(this))); EXPECT_EQ(1, pairing_delegate.call_count_); EXPECT_EQ(1, pairing_delegate.request_passkey_count_); // A pairing context should now be set on the device. - BluetoothDeviceChromeOS* device_chromeos = - static_cast<BluetoothDeviceChromeOS*>(device); - ASSERT_TRUE(device_chromeos->GetPairing() != nullptr); + BluetoothDeviceBlueZ* device_bluez = + static_cast<BluetoothDeviceBlueZ*>(device); + ASSERT_TRUE(device_bluez->GetPairing() != nullptr); // Removing the pairing delegate should remove that pairing context. adapter_->RemovePairingDelegate(&pairing_delegate); - EXPECT_TRUE(device_chromeos->GetPairing() == nullptr); + EXPECT_TRUE(device_bluez->GetPairing() == nullptr); // Set the Passkey, this should now have no effect since the pairing has // been, in-effect, cancelled @@ -3772,7 +3735,7 @@ TEST_F(BluetoothChromeOSTest, RemovePairingDelegateDuringPairing) { EXPECT_FALSE(device->IsPaired()); } -TEST_F(BluetoothChromeOSTest, DeviceId) { +TEST_F(BluetoothBlueZTest, DeviceId) { GetAdapter(); // Use the built-in paired device for this test, grab its Properties @@ -3827,7 +3790,7 @@ TEST_F(BluetoothChromeOSTest, DeviceId) { EXPECT_EQ(0, device->GetDeviceID()); } -TEST_F(BluetoothChromeOSTest, GetConnectionInfoForDisconnectedDevice) { +TEST_F(BluetoothBlueZTest, GetConnectionInfoForDisconnectedDevice) { GetAdapter(); BluetoothDevice* device = adapter_->GetDevice( bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); @@ -3843,13 +3806,13 @@ TEST_F(BluetoothChromeOSTest, GetConnectionInfoForDisconnectedDevice) { EXPECT_EQ(unknown_power, conn_info.max_transmit_power); } -TEST_F(BluetoothChromeOSTest, GetConnectionInfoForConnectedDevice) { +TEST_F(BluetoothBlueZTest, GetConnectionInfoForConnectedDevice) { GetAdapter(); BluetoothDevice* device = adapter_->GetDevice( bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); device->Connect(nullptr, GetCallback(), - base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, + base::Bind(&BluetoothBlueZTest::ConnectErrorCallback, base::Unretained(this))); EXPECT_TRUE(device->IsConnected()); @@ -3864,13 +3827,13 @@ TEST_F(BluetoothChromeOSTest, GetConnectionInfoForConnectedDevice) { } // Verifies Shutdown shuts down the adapter as expected. -TEST_F(BluetoothChromeOSTest, Shutdown) { +TEST_F(BluetoothBlueZTest, Shutdown) { // Set up adapter. Set powered & discoverable, start discovery. GetAdapter(); adapter_->SetPowered(true, GetCallback(), GetErrorCallback()); adapter_->SetDiscoverable(true, GetCallback(), GetErrorCallback()); adapter_->StartDiscoverySession( - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), GetErrorCallback()); base::MessageLoop::current()->Run(); @@ -3894,13 +3857,13 @@ TEST_F(BluetoothChromeOSTest, Shutdown) { EXPECT_NE(nullptr, adapter_->GetDevice( bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress)); - EXPECT_NE(dbus::ObjectPath(""), static_cast<BluetoothAdapterChromeOS*>( - adapter_.get())->object_path()); + EXPECT_NE(dbus::ObjectPath(""), + static_cast<BluetoothAdapterBlueZ*>(adapter_.get())->object_path()); // Shutdown adapter_->Shutdown(); - // Validate post shutdown state by calling all BluetoothAdapterChromeOS + // Validate post shutdown state by calling all BluetoothAdapterBlueZ // members, in declaration order: adapter_->Shutdown(); @@ -3936,15 +3899,15 @@ TEST_F(BluetoothChromeOSTest, Shutdown) { BluetoothAudioSink::Options audio_sink_options; adapter_->RegisterAudioSink( audio_sink_options, - base::Bind(&BluetoothChromeOSTest::AudioSinkAcquiredCallback, + base::Bind(&BluetoothBlueZTest::AudioSinkAcquiredCallback, base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::AudioSinkErrorCallback, + base::Bind(&BluetoothBlueZTest::AudioSinkErrorCallback, base::Unretained(this))); EXPECT_EQ(0, callback_count_); EXPECT_EQ(1, error_callback_count_--) << "RegisterAudioSink error"; - BluetoothAdapterChromeOS* adapter_chrome_os = - static_cast<BluetoothAdapterChromeOS*>(adapter_.get()); + BluetoothAdapterBlueZ* adapter_chrome_os = + static_cast<BluetoothAdapterBlueZ*>(adapter_.get()); EXPECT_EQ(nullptr, adapter_chrome_os->GetDeviceWithPath(dbus::ObjectPath(""))); @@ -3971,9 +3934,9 @@ TEST_F(BluetoothChromeOSTest, Shutdown) { adapter_chrome_os->UseProfile( BluetoothUUID(), dbus::ObjectPath(""), bluez::BluetoothProfileManagerClient::Options(), &profile_delegate, - base::Bind(&BluetoothChromeOSTest::ProfileRegisteredCallback, + base::Bind(&BluetoothBlueZTest::ProfileRegisteredCallback, base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCompletionCallback, + base::Bind(&BluetoothBlueZTest::ErrorCompletionCallback, base::Unretained(this))); EXPECT_FALSE(adapter_profile_) << "UseProfile error"; @@ -4001,9 +3964,9 @@ TEST_F(BluetoothChromeOSTest, Shutdown) { adapter_chrome_os->OnRequestDefaultAgentError("", ""); adapter_chrome_os->OnRegisterAudioSink( - base::Bind(&BluetoothChromeOSTest::AudioSinkAcquiredCallback, + base::Bind(&BluetoothBlueZTest::AudioSinkAcquiredCallback, base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::AudioSinkErrorCallback, + base::Bind(&BluetoothBlueZTest::AudioSinkErrorCallback, base::Unretained(this)), scoped_refptr<device::BluetoothAudioSink>()); EXPECT_EQ(0, callback_count_); @@ -4049,9 +4012,9 @@ TEST_F(BluetoothChromeOSTest, Shutdown) { adapter_chrome_os->UseProfile( BluetoothUUID(), dbus::ObjectPath(""), bluez::BluetoothProfileManagerClient::Options(), &profile_delegate, - base::Bind(&BluetoothChromeOSTest::ProfileRegisteredCallback, + base::Bind(&BluetoothBlueZTest::ProfileRegisteredCallback, base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCompletionCallback, + base::Bind(&BluetoothBlueZTest::ErrorCompletionCallback, base::Unretained(this))); EXPECT_FALSE(adapter_profile_) << "UseProfile error"; @@ -4060,9 +4023,9 @@ TEST_F(BluetoothChromeOSTest, Shutdown) { adapter_chrome_os->SetProfileDelegate( BluetoothUUID(), dbus::ObjectPath(""), &profile_delegate, - base::Bind(&BluetoothChromeOSTest::ProfileRegisteredCallback, + base::Bind(&BluetoothBlueZTest::ProfileRegisteredCallback, base::Unretained(this)), - base::Bind(&BluetoothChromeOSTest::ErrorCompletionCallback, + base::Bind(&BluetoothBlueZTest::ErrorCompletionCallback, base::Unretained(this))); EXPECT_EQ(0, callback_count_) << "SetProfileDelegate error"; EXPECT_EQ(1, error_callback_count_--) << "SetProfileDelegate error"; @@ -4076,7 +4039,7 @@ TEST_F(BluetoothChromeOSTest, Shutdown) { // From BluetoothAdapater: adapter_->StartDiscoverySession( - base::Bind(&BluetoothChromeOSTest::DiscoverySessionCallback, + base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, base::Unretained(this)), GetErrorCallback()); EXPECT_EQ(0, callback_count_) << "StartDiscoverySession error"; @@ -4093,11 +4056,11 @@ TEST_F(BluetoothChromeOSTest, Shutdown) { } // Verifies post-Shutdown of discovery sessions and OnStartDiscovery. -TEST_F(BluetoothChromeOSTest, Shutdown_OnStartDiscovery) { +TEST_F(BluetoothBlueZTest, Shutdown_OnStartDiscovery) { const int kNumberOfDiscoverySessions = 10; GetAdapter(); - BluetoothAdapterChromeOS* adapter_chrome_os = - static_cast<BluetoothAdapterChromeOS*>(adapter_.get()); + BluetoothAdapterBlueZ* adapter_chrome_os = + static_cast<BluetoothAdapterBlueZ*>(adapter_.get()); for (int i = 0; i < kNumberOfDiscoverySessions; i++) { adapter_chrome_os->AddDiscoverySession(nullptr, GetCallback(), @@ -4112,11 +4075,11 @@ TEST_F(BluetoothChromeOSTest, Shutdown_OnStartDiscovery) { } // Verifies post-Shutdown of discovery sessions and OnStartDiscoveryError. -TEST_F(BluetoothChromeOSTest, Shutdown_OnStartDiscoveryError) { +TEST_F(BluetoothBlueZTest, Shutdown_OnStartDiscoveryError) { const int kNumberOfDiscoverySessions = 10; GetAdapter(); - BluetoothAdapterChromeOS* adapter_chrome_os = - static_cast<BluetoothAdapterChromeOS*>(adapter_.get()); + BluetoothAdapterBlueZ* adapter_chrome_os = + static_cast<BluetoothAdapterBlueZ*>(adapter_.get()); for (int i = 0; i < kNumberOfDiscoverySessions; i++) { adapter_chrome_os->AddDiscoverySession(nullptr, GetCallback(), @@ -4131,11 +4094,11 @@ TEST_F(BluetoothChromeOSTest, Shutdown_OnStartDiscoveryError) { } // Verifies post-Shutdown of discovery sessions and OnStartDiscovery. -TEST_F(BluetoothChromeOSTest, Shutdown_OnStopDiscovery) { +TEST_F(BluetoothBlueZTest, Shutdown_OnStopDiscovery) { const int kNumberOfDiscoverySessions = 10; GetAdapter(); - BluetoothAdapterChromeOS* adapter_chrome_os = - static_cast<BluetoothAdapterChromeOS*>(adapter_.get()); + BluetoothAdapterBlueZ* adapter_chrome_os = + static_cast<BluetoothAdapterBlueZ*>(adapter_.get()); // In order to queue up discovery sessions before an OnStopDiscovery call // RemoveDiscoverySession must be called, so Add, Start, and Remove: @@ -4162,11 +4125,11 @@ TEST_F(BluetoothChromeOSTest, Shutdown_OnStopDiscovery) { } // Verifies post-Shutdown of discovery sessions and OnStopDiscoveryError. -TEST_F(BluetoothChromeOSTest, Shutdown_OnStopDiscoveryError) { +TEST_F(BluetoothBlueZTest, Shutdown_OnStopDiscoveryError) { const int kNumberOfDiscoverySessions = 10; GetAdapter(); - BluetoothAdapterChromeOS* adapter_chrome_os = - static_cast<BluetoothAdapterChromeOS*>(adapter_.get()); + BluetoothAdapterBlueZ* adapter_chrome_os = + static_cast<BluetoothAdapterBlueZ*>(adapter_.get()); // In order to queue up discovery sessions before an OnStopDiscoveryError call // RemoveDiscoverySession must be called, so Add, Start, and Remove: @@ -4192,4 +4155,4 @@ TEST_F(BluetoothChromeOSTest, Shutdown_OnStopDiscoveryError) { EXPECT_EQ(1 + kNumberOfDiscoverySessions, error_callback_count_); } -} // namespace chromeos +} // namespace bluez diff --git a/device/bluetooth/bluetooth_device_chromeos.cc b/device/bluetooth/bluetooth_device_bluez.cc index 89c5572..731e5e5 100644 --- a/device/bluetooth/bluetooth_device_chromeos.cc +++ b/device/bluetooth/bluetooth_device_bluez.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "device/bluetooth/bluetooth_device_chromeos.h" +#include "device/bluetooth/bluetooth_device_bluez.h" #include <stdio.h> @@ -12,12 +12,12 @@ #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "dbus/bus.h" -#include "device/bluetooth/bluetooth_adapter_chromeos.h" -#include "device/bluetooth/bluetooth_gatt_connection_chromeos.h" -#include "device/bluetooth/bluetooth_pairing_chromeos.h" -#include "device/bluetooth/bluetooth_remote_gatt_service_chromeos.h" +#include "device/bluetooth/bluetooth_adapter_bluez.h" +#include "device/bluetooth/bluetooth_gatt_connection_bluez.h" +#include "device/bluetooth/bluetooth_pairing_bluez.h" +#include "device/bluetooth/bluetooth_remote_gatt_service_bluez.h" #include "device/bluetooth/bluetooth_socket.h" -#include "device/bluetooth/bluetooth_socket_chromeos.h" +#include "device/bluetooth/bluetooth_socket_bluez.h" #include "device/bluetooth/bluetooth_socket_thread.h" #include "device/bluetooth/bluetooth_uuid.h" #include "device/bluetooth/dbus/bluetooth_adapter_client.h" @@ -63,11 +63,11 @@ void ParseModalias(const dbus::ObjectPath& object_path, BluetoothDevice::VendorIDSource source_value; int vendor_value, product_value, device_value; - if (sscanf(modalias.c_str(), "bluetooth:v%04xp%04xd%04x", - &vendor_value, &product_value, &device_value) == 3) { + if (sscanf(modalias.c_str(), "bluetooth:v%04xp%04xd%04x", &vendor_value, + &product_value, &device_value) == 3) { source_value = BluetoothDevice::VENDOR_ID_BLUETOOTH; - } else if (sscanf(modalias.c_str(), "usb:v%04xp%04xd%04x", - &vendor_value, &product_value, &device_value) == 3) { + } else if (sscanf(modalias.c_str(), "usb:v%04xp%04xd%04x", &vendor_value, + &product_value, &device_value) == 3) { source_value = BluetoothDevice::VENDOR_ID_USB; } else { return; @@ -111,17 +111,16 @@ void RecordPairingResult(BluetoothDevice::ConnectErrorCode error_code) { pairing_result = UMA_PAIRING_RESULT_UNKNOWN_ERROR; } - UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingResult", - pairing_result, + UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingResult", pairing_result, UMA_PAIRING_RESULT_COUNT); } } // namespace -namespace chromeos { +namespace bluez { -BluetoothDeviceChromeOS::BluetoothDeviceChromeOS( - BluetoothAdapterChromeOS* adapter, +BluetoothDeviceBlueZ::BluetoothDeviceBlueZ( + BluetoothAdapterBlueZ* adapter, const dbus::ObjectPath& object_path, scoped_refptr<base::SequencedTaskRunner> ui_task_runner, scoped_refptr<device::BluetoothSocketThread> socket_thread) @@ -146,7 +145,7 @@ BluetoothDeviceChromeOS::BluetoothDeviceChromeOS( } } -BluetoothDeviceChromeOS::~BluetoothDeviceChromeOS() { +BluetoothDeviceBlueZ::~BluetoothDeviceBlueZ() { bluez::BluezDBusManager::Get() ->GetBluetoothGattServiceClient() ->RemoveObserver(this); @@ -159,12 +158,12 @@ BluetoothDeviceChromeOS::~BluetoothDeviceChromeOS() { iter != gatt_services.end(); ++iter) { DCHECK(adapter_); adapter()->NotifyGattServiceRemoved( - static_cast<BluetoothRemoteGattServiceChromeOS*>(iter->second)); + static_cast<BluetoothRemoteGattServiceBlueZ*>(iter->second)); delete iter->second; } } -uint32 BluetoothDeviceChromeOS::GetBluetoothClass() const { +uint32 BluetoothDeviceBlueZ::GetBluetoothClass() const { bluez::BluetoothDeviceClient::Properties* properties = bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( object_path_); @@ -173,7 +172,7 @@ uint32 BluetoothDeviceChromeOS::GetBluetoothClass() const { return properties->bluetooth_class.value(); } -std::string BluetoothDeviceChromeOS::GetDeviceName() const { +std::string BluetoothDeviceBlueZ::GetDeviceName() const { bluez::BluetoothDeviceClient::Properties* properties = bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( object_path_); @@ -182,19 +181,19 @@ std::string BluetoothDeviceChromeOS::GetDeviceName() const { return properties->alias.value(); } -void BluetoothDeviceChromeOS::CreateGattConnectionImpl() { - // ChromeOS implementation does not use the default CreateGattConnection +void BluetoothDeviceBlueZ::CreateGattConnectionImpl() { + // BlueZ implementation does not use the default CreateGattConnection // implementation. NOTIMPLEMENTED(); } -void BluetoothDeviceChromeOS::DisconnectGatt() { - // ChromeOS implementation does not use the default CreateGattConnection +void BluetoothDeviceBlueZ::DisconnectGatt() { + // BlueZ implementation does not use the default CreateGattConnection // implementation. NOTIMPLEMENTED(); } -std::string BluetoothDeviceChromeOS::GetAddress() const { +std::string BluetoothDeviceBlueZ::GetAddress() const { bluez::BluetoothDeviceClient::Properties* properties = bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( object_path_); @@ -203,32 +202,32 @@ std::string BluetoothDeviceChromeOS::GetAddress() const { return CanonicalizeAddress(properties->address.value()); } -BluetoothDevice::VendorIDSource -BluetoothDeviceChromeOS::GetVendorIDSource() const { +BluetoothDevice::VendorIDSource BluetoothDeviceBlueZ::GetVendorIDSource() + const { VendorIDSource vendor_id_source = VENDOR_ID_UNKNOWN; ParseModalias(object_path_, &vendor_id_source, NULL, NULL, NULL); return vendor_id_source; } -uint16 BluetoothDeviceChromeOS::GetVendorID() const { - uint16 vendor_id = 0; +uint16 BluetoothDeviceBlueZ::GetVendorID() const { + uint16 vendor_id = 0; ParseModalias(object_path_, NULL, &vendor_id, NULL, NULL); return vendor_id; } -uint16 BluetoothDeviceChromeOS::GetProductID() const { - uint16 product_id = 0; +uint16 BluetoothDeviceBlueZ::GetProductID() const { + uint16 product_id = 0; ParseModalias(object_path_, NULL, NULL, &product_id, NULL); return product_id; } -uint16 BluetoothDeviceChromeOS::GetDeviceID() const { - uint16 device_id = 0; +uint16 BluetoothDeviceBlueZ::GetDeviceID() const { + uint16 device_id = 0; ParseModalias(object_path_, NULL, NULL, NULL, &device_id); return device_id; } -bool BluetoothDeviceChromeOS::IsPaired() const { +bool BluetoothDeviceBlueZ::IsPaired() const { bluez::BluetoothDeviceClient::Properties* properties = bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( object_path_); @@ -240,7 +239,7 @@ bool BluetoothDeviceChromeOS::IsPaired() const { return properties->paired.value() || properties->trusted.value(); } -bool BluetoothDeviceChromeOS::IsConnected() const { +bool BluetoothDeviceBlueZ::IsConnected() const { bluez::BluetoothDeviceClient::Properties* properties = bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( object_path_); @@ -249,12 +248,12 @@ bool BluetoothDeviceChromeOS::IsConnected() const { return properties->connected.value(); } -bool BluetoothDeviceChromeOS::IsGattConnected() const { +bool BluetoothDeviceBlueZ::IsGattConnected() const { NOTIMPLEMENTED(); return false; } -bool BluetoothDeviceChromeOS::IsConnectable() const { +bool BluetoothDeviceBlueZ::IsConnectable() const { bluez::BluetoothInputClient::Properties* input_properties = bluez::BluezDBusManager::Get()->GetBluetoothInputClient()->GetProperties( object_path_); @@ -266,18 +265,18 @@ bool BluetoothDeviceChromeOS::IsConnectable() const { return input_properties->reconnect_mode.value() != "device"; } -bool BluetoothDeviceChromeOS::IsConnecting() const { +bool BluetoothDeviceBlueZ::IsConnecting() const { return num_connecting_calls_ > 0; } -BluetoothDeviceChromeOS::UUIDList BluetoothDeviceChromeOS::GetUUIDs() const { +BluetoothDeviceBlueZ::UUIDList BluetoothDeviceBlueZ::GetUUIDs() const { bluez::BluetoothDeviceClient::Properties* properties = bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( object_path_); DCHECK(properties); std::vector<device::BluetoothUUID> uuids; - const std::vector<std::string> &dbus_uuids = properties->uuids.value(); + const std::vector<std::string>& dbus_uuids = properties->uuids.value(); for (std::vector<std::string>::const_iterator iter = dbus_uuids.begin(); iter != dbus_uuids.end(); ++iter) { device::BluetoothUUID uuid(*iter); @@ -287,7 +286,7 @@ BluetoothDeviceChromeOS::UUIDList BluetoothDeviceChromeOS::GetUUIDs() const { return uuids; } -int16 BluetoothDeviceChromeOS::GetInquiryRSSI() const { +int16 BluetoothDeviceBlueZ::GetInquiryRSSI() const { bluez::BluetoothDeviceClient::Properties* properties = bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( object_path_); @@ -299,7 +298,7 @@ int16 BluetoothDeviceChromeOS::GetInquiryRSSI() const { return properties->rssi.value(); } -int16 BluetoothDeviceChromeOS::GetInquiryTxPower() const { +int16 BluetoothDeviceBlueZ::GetInquiryTxPower() const { bluez::BluetoothDeviceClient::Properties* properties = bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( object_path_); @@ -311,30 +310,30 @@ int16 BluetoothDeviceChromeOS::GetInquiryTxPower() const { return properties->tx_power.value(); } -bool BluetoothDeviceChromeOS::ExpectingPinCode() const { +bool BluetoothDeviceBlueZ::ExpectingPinCode() const { return pairing_.get() && pairing_->ExpectingPinCode(); } -bool BluetoothDeviceChromeOS::ExpectingPasskey() const { +bool BluetoothDeviceBlueZ::ExpectingPasskey() const { return pairing_.get() && pairing_->ExpectingPasskey(); } -bool BluetoothDeviceChromeOS::ExpectingConfirmation() const { +bool BluetoothDeviceBlueZ::ExpectingConfirmation() const { return pairing_.get() && pairing_->ExpectingConfirmation(); } -void BluetoothDeviceChromeOS::GetConnectionInfo( +void BluetoothDeviceBlueZ::GetConnectionInfo( const ConnectionInfoCallback& callback) { // DBus method call should gracefully return an error if the device is not // currently connected. bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetConnInfo( - object_path_, base::Bind(&BluetoothDeviceChromeOS::OnGetConnInfo, + object_path_, base::Bind(&BluetoothDeviceBlueZ::OnGetConnInfo, weak_ptr_factory_.GetWeakPtr(), callback), - base::Bind(&BluetoothDeviceChromeOS::OnGetConnInfoError, + base::Bind(&BluetoothDeviceBlueZ::OnGetConnInfoError, weak_ptr_factory_.GetWeakPtr(), callback)); } -void BluetoothDeviceChromeOS::Connect( +void BluetoothDeviceBlueZ::Connect( BluetoothDevice::PairingDelegate* pairing_delegate, const base::Closure& callback, const ConnectErrorCallback& error_callback) { @@ -353,42 +352,42 @@ void BluetoothDeviceChromeOS::Connect( bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->Pair( object_path_, - base::Bind(&BluetoothDeviceChromeOS::OnPair, + base::Bind(&BluetoothDeviceBlueZ::OnPair, weak_ptr_factory_.GetWeakPtr(), callback, error_callback), - base::Bind(&BluetoothDeviceChromeOS::OnPairError, + base::Bind(&BluetoothDeviceBlueZ::OnPairError, weak_ptr_factory_.GetWeakPtr(), error_callback)); } } -void BluetoothDeviceChromeOS::SetPinCode(const std::string& pincode) { +void BluetoothDeviceBlueZ::SetPinCode(const std::string& pincode) { if (!pairing_.get()) return; pairing_->SetPinCode(pincode); } -void BluetoothDeviceChromeOS::SetPasskey(uint32 passkey) { +void BluetoothDeviceBlueZ::SetPasskey(uint32 passkey) { if (!pairing_.get()) return; pairing_->SetPasskey(passkey); } -void BluetoothDeviceChromeOS::ConfirmPairing() { +void BluetoothDeviceBlueZ::ConfirmPairing() { if (!pairing_.get()) return; pairing_->ConfirmPairing(); } -void BluetoothDeviceChromeOS::RejectPairing() { +void BluetoothDeviceBlueZ::RejectPairing() { if (!pairing_.get()) return; pairing_->RejectPairing(); } -void BluetoothDeviceChromeOS::CancelPairing() { +void BluetoothDeviceBlueZ::CancelPairing() { bool canceled = false; // If there is a callback in progress that we can reply to then use that @@ -402,7 +401,7 @@ void BluetoothDeviceChromeOS::CancelPairing() { << "Sending explicit cancel"; bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->CancelPairing( object_path_, base::Bind(&base::DoNothing), - base::Bind(&BluetoothDeviceChromeOS::OnCancelPairingError, + base::Bind(&BluetoothDeviceBlueZ::OnCancelPairingError, weak_ptr_factory_.GetWeakPtr())); } @@ -413,53 +412,53 @@ void BluetoothDeviceChromeOS::CancelPairing() { EndPairing(); } -void BluetoothDeviceChromeOS::Disconnect(const base::Closure& callback, - const ErrorCallback& error_callback) { +void BluetoothDeviceBlueZ::Disconnect(const base::Closure& callback, + const ErrorCallback& error_callback) { VLOG(1) << object_path_.value() << ": Disconnecting"; bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->Disconnect( - object_path_, base::Bind(&BluetoothDeviceChromeOS::OnDisconnect, + object_path_, base::Bind(&BluetoothDeviceBlueZ::OnDisconnect, weak_ptr_factory_.GetWeakPtr(), callback), - base::Bind(&BluetoothDeviceChromeOS::OnDisconnectError, + base::Bind(&BluetoothDeviceBlueZ::OnDisconnectError, weak_ptr_factory_.GetWeakPtr(), error_callback)); } -void BluetoothDeviceChromeOS::Forget(const ErrorCallback& error_callback) { +void BluetoothDeviceBlueZ::Forget(const ErrorCallback& error_callback) { VLOG(1) << object_path_.value() << ": Removing device"; bluez::BluezDBusManager::Get()->GetBluetoothAdapterClient()->RemoveDevice( adapter()->object_path(), object_path_, base::Bind(&base::DoNothing), - base::Bind(&BluetoothDeviceChromeOS::OnForgetError, + base::Bind(&BluetoothDeviceBlueZ::OnForgetError, weak_ptr_factory_.GetWeakPtr(), error_callback)); } -void BluetoothDeviceChromeOS::ConnectToService( +void BluetoothDeviceBlueZ::ConnectToService( const BluetoothUUID& uuid, const ConnectToServiceCallback& callback, const ConnectToServiceErrorCallback& error_callback) { - VLOG(1) << object_path_.value() << ": Connecting to service: " - << uuid.canonical_value(); - scoped_refptr<BluetoothSocketChromeOS> socket = - BluetoothSocketChromeOS::CreateBluetoothSocket( - ui_task_runner_, socket_thread_); - socket->Connect(this, uuid, BluetoothSocketChromeOS::SECURITY_LEVEL_MEDIUM, + VLOG(1) << object_path_.value() + << ": Connecting to service: " << uuid.canonical_value(); + scoped_refptr<BluetoothSocketBlueZ> socket = + BluetoothSocketBlueZ::CreateBluetoothSocket(ui_task_runner_, + socket_thread_); + socket->Connect(this, uuid, BluetoothSocketBlueZ::SECURITY_LEVEL_MEDIUM, base::Bind(callback, socket), error_callback); } -void BluetoothDeviceChromeOS::ConnectToServiceInsecurely( +void BluetoothDeviceBlueZ::ConnectToServiceInsecurely( const BluetoothUUID& uuid, const ConnectToServiceCallback& callback, const ConnectToServiceErrorCallback& error_callback) { - VLOG(1) << object_path_.value() << ": Connecting insecurely to service: " - << uuid.canonical_value(); - scoped_refptr<BluetoothSocketChromeOS> socket = - BluetoothSocketChromeOS::CreateBluetoothSocket( - ui_task_runner_, socket_thread_); - socket->Connect(this, uuid, BluetoothSocketChromeOS::SECURITY_LEVEL_LOW, + VLOG(1) << object_path_.value() + << ": Connecting insecurely to service: " << uuid.canonical_value(); + scoped_refptr<BluetoothSocketBlueZ> socket = + BluetoothSocketBlueZ::CreateBluetoothSocket(ui_task_runner_, + socket_thread_); + socket->Connect(this, uuid, BluetoothSocketBlueZ::SECURITY_LEVEL_LOW, base::Bind(callback, socket), error_callback); } -void BluetoothDeviceChromeOS::CreateGattConnection( - const GattConnectionCallback& callback, - const ConnectErrorCallback& error_callback) { +void BluetoothDeviceBlueZ::CreateGattConnection( + const GattConnectionCallback& callback, + const ConnectErrorCallback& error_callback) { // TODO(sacomoto): Workaround to retrieve the connection for already connected // devices. Currently, BluetoothGattConnection::Disconnect doesn't do // anything, the unique underlying physical GATT connection is kept. This @@ -472,32 +471,30 @@ void BluetoothDeviceChromeOS::CreateGattConnection( // TODO(armansito): Until there is a way to create a reference counted GATT // connection in bluetoothd, simply do a regular connect. - Connect(NULL, - base::Bind(&BluetoothDeviceChromeOS::OnCreateGattConnection, - weak_ptr_factory_.GetWeakPtr(), - callback), + Connect(NULL, base::Bind(&BluetoothDeviceBlueZ::OnCreateGattConnection, + weak_ptr_factory_.GetWeakPtr(), callback), error_callback); } -BluetoothPairingChromeOS* BluetoothDeviceChromeOS::BeginPairing( +BluetoothPairingBlueZ* BluetoothDeviceBlueZ::BeginPairing( BluetoothDevice::PairingDelegate* pairing_delegate) { - pairing_.reset(new BluetoothPairingChromeOS(this, pairing_delegate)); + pairing_.reset(new BluetoothPairingBlueZ(this, pairing_delegate)); return pairing_.get(); } -void BluetoothDeviceChromeOS::EndPairing() { +void BluetoothDeviceBlueZ::EndPairing() { pairing_.reset(); } -BluetoothPairingChromeOS* BluetoothDeviceChromeOS::GetPairing() const { +BluetoothPairingBlueZ* BluetoothDeviceBlueZ::GetPairing() const { return pairing_.get(); } -BluetoothAdapterChromeOS* BluetoothDeviceChromeOS::adapter() const { - return static_cast<BluetoothAdapterChromeOS*>(adapter_); +BluetoothAdapterBlueZ* BluetoothDeviceBlueZ::adapter() const { + return static_cast<BluetoothAdapterBlueZ*>(adapter_); } -void BluetoothDeviceChromeOS::GattServiceAdded( +void BluetoothDeviceBlueZ::GattServiceAdded( const dbus::ObjectPath& object_path) { if (GetGattService(object_path.value())) { VLOG(1) << "Remote GATT service already exists: " << object_path.value(); @@ -516,8 +513,8 @@ void BluetoothDeviceChromeOS::GattServiceAdded( VLOG(1) << "Adding new remote GATT service for device: " << GetAddress(); - BluetoothRemoteGattServiceChromeOS* service = - new BluetoothRemoteGattServiceChromeOS(adapter(), this, object_path); + BluetoothRemoteGattServiceBlueZ* service = + new BluetoothRemoteGattServiceBlueZ(adapter(), this, object_path); gatt_services_[service->GetIdentifier()] = service; DCHECK(service->object_path() == object_path); @@ -527,7 +524,7 @@ void BluetoothDeviceChromeOS::GattServiceAdded( adapter()->NotifyGattServiceAdded(service); } -void BluetoothDeviceChromeOS::GattServiceRemoved( +void BluetoothDeviceBlueZ::GattServiceRemoved( const dbus::ObjectPath& object_path) { GattServiceMap::iterator iter = gatt_services_.find(object_path.value()); if (iter == gatt_services_.end()) { @@ -535,8 +532,8 @@ void BluetoothDeviceChromeOS::GattServiceRemoved( return; } - BluetoothRemoteGattServiceChromeOS* service = - static_cast<BluetoothRemoteGattServiceChromeOS*>(iter->second); + BluetoothRemoteGattServiceBlueZ* service = + static_cast<BluetoothRemoteGattServiceBlueZ*>(iter->second); VLOG(1) << "Removing remote GATT service with UUID: '" << service->GetUUID().canonical_value() @@ -551,15 +548,14 @@ void BluetoothDeviceChromeOS::GattServiceRemoved( delete service; } -void BluetoothDeviceChromeOS::OnGetConnInfo( - const ConnectionInfoCallback& callback, - int16 rssi, - int16 transmit_power, - int16 max_transmit_power) { +void BluetoothDeviceBlueZ::OnGetConnInfo(const ConnectionInfoCallback& callback, + int16 rssi, + int16 transmit_power, + int16 max_transmit_power) { callback.Run(ConnectionInfo(rssi, transmit_power, max_transmit_power)); } -void BluetoothDeviceChromeOS::OnGetConnInfoError( +void BluetoothDeviceBlueZ::OnGetConnInfoError( const ConnectionInfoCallback& callback, const std::string& error_name, const std::string& error_message) { @@ -569,28 +565,28 @@ void BluetoothDeviceChromeOS::OnGetConnInfoError( callback.Run(ConnectionInfo()); } -void BluetoothDeviceChromeOS::ConnectInternal( +void BluetoothDeviceBlueZ::ConnectInternal( bool after_pairing, const base::Closure& callback, const ConnectErrorCallback& error_callback) { VLOG(1) << object_path_.value() << ": Connecting"; bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->Connect( object_path_, - base::Bind(&BluetoothDeviceChromeOS::OnConnect, + base::Bind(&BluetoothDeviceBlueZ::OnConnect, weak_ptr_factory_.GetWeakPtr(), after_pairing, callback), - base::Bind(&BluetoothDeviceChromeOS::OnConnectError, + base::Bind(&BluetoothDeviceBlueZ::OnConnectError, weak_ptr_factory_.GetWeakPtr(), after_pairing, error_callback)); } -void BluetoothDeviceChromeOS::OnConnect(bool after_pairing, - const base::Closure& callback) { +void BluetoothDeviceBlueZ::OnConnect(bool after_pairing, + const base::Closure& callback) { if (--num_connecting_calls_ == 0) adapter()->NotifyDeviceChanged(this); DCHECK(num_connecting_calls_ >= 0); VLOG(1) << object_path_.value() << ": Connected, " << num_connecting_calls_ - << " still in progress"; + << " still in progress"; SetTrusted(); @@ -602,15 +598,14 @@ void BluetoothDeviceChromeOS::OnConnect(bool after_pairing, callback.Run(); } -void BluetoothDeviceChromeOS::OnCreateGattConnection( +void BluetoothDeviceBlueZ::OnCreateGattConnection( const GattConnectionCallback& callback) { scoped_ptr<device::BluetoothGattConnection> conn( - new BluetoothGattConnectionChromeOS( - adapter_, GetAddress(), object_path_)); + new BluetoothGattConnectionBlueZ(adapter_, GetAddress(), object_path_)); callback.Run(conn.Pass()); } -void BluetoothDeviceChromeOS::OnConnectError( +void BluetoothDeviceBlueZ::OnConnectError( bool after_pairing, const ConnectErrorCallback& error_callback, const std::string& error_name, @@ -619,8 +614,9 @@ void BluetoothDeviceChromeOS::OnConnectError( adapter()->NotifyDeviceChanged(this); DCHECK(num_connecting_calls_ >= 0); - LOG(WARNING) << object_path_.value() << ": Failed to connect device: " - << error_name << ": " << error_message; + LOG(WARNING) << object_path_.value() + << ": Failed to connect device: " << error_name << ": " + << error_message; VLOG(1) << object_path_.value() << ": " << num_connecting_calls_ << " still in progress"; @@ -639,9 +635,8 @@ void BluetoothDeviceChromeOS::OnConnectError( error_callback.Run(error_code); } -void BluetoothDeviceChromeOS::OnPair( - const base::Closure& callback, - const ConnectErrorCallback& error_callback) { +void BluetoothDeviceBlueZ::OnPair(const base::Closure& callback, + const ConnectErrorCallback& error_callback) { VLOG(1) << object_path_.value() << ": Paired"; EndPairing(); @@ -649,7 +644,7 @@ void BluetoothDeviceChromeOS::OnPair( ConnectInternal(true, callback, error_callback); } -void BluetoothDeviceChromeOS::OnPairError( +void BluetoothDeviceBlueZ::OnPairError( const ConnectErrorCallback& error_callback, const std::string& error_name, const std::string& error_message) { @@ -657,8 +652,9 @@ void BluetoothDeviceChromeOS::OnPairError( adapter()->NotifyDeviceChanged(this); DCHECK(num_connecting_calls_ >= 0); - LOG(WARNING) << object_path_.value() << ": Failed to pair device: " - << error_name << ": " << error_message; + LOG(WARNING) << object_path_.value() + << ": Failed to pair device: " << error_name << ": " + << error_message; VLOG(1) << object_path_.value() << ": " << num_connecting_calls_ << " still in progress"; @@ -684,14 +680,15 @@ void BluetoothDeviceChromeOS::OnPairError( error_callback.Run(error_code); } -void BluetoothDeviceChromeOS::OnCancelPairingError( +void BluetoothDeviceBlueZ::OnCancelPairingError( const std::string& error_name, const std::string& error_message) { - LOG(WARNING) << object_path_.value() << ": Failed to cancel pairing: " - << error_name << ": " << error_message; + LOG(WARNING) << object_path_.value() + << ": Failed to cancel pairing: " << error_name << ": " + << error_message; } -void BluetoothDeviceChromeOS::SetTrusted() { +void BluetoothDeviceBlueZ::SetTrusted() { // Unconditionally send the property change, rather than checking the value // first; there's no harm in doing this and it solves any race conditions // with the property becoming true or false and this call happening before @@ -699,36 +696,37 @@ void BluetoothDeviceChromeOS::SetTrusted() { bluez::BluezDBusManager::Get() ->GetBluetoothDeviceClient() ->GetProperties(object_path_) - ->trusted.Set(true, base::Bind(&BluetoothDeviceChromeOS::OnSetTrusted, + ->trusted.Set(true, base::Bind(&BluetoothDeviceBlueZ::OnSetTrusted, weak_ptr_factory_.GetWeakPtr())); } -void BluetoothDeviceChromeOS::OnSetTrusted(bool success) { +void BluetoothDeviceBlueZ::OnSetTrusted(bool success) { LOG_IF(WARNING, !success) << object_path_.value() << ": Failed to set device as trusted"; } -void BluetoothDeviceChromeOS::OnDisconnect(const base::Closure& callback) { +void BluetoothDeviceBlueZ::OnDisconnect(const base::Closure& callback) { VLOG(1) << object_path_.value() << ": Disconnected"; callback.Run(); } -void BluetoothDeviceChromeOS::OnDisconnectError( +void BluetoothDeviceBlueZ::OnDisconnectError( const ErrorCallback& error_callback, const std::string& error_name, const std::string& error_message) { - LOG(WARNING) << object_path_.value() << ": Failed to disconnect device: " - << error_name << ": " << error_message; + LOG(WARNING) << object_path_.value() + << ": Failed to disconnect device: " << error_name << ": " + << error_message; error_callback.Run(); } -void BluetoothDeviceChromeOS::OnForgetError( - const ErrorCallback& error_callback, - const std::string& error_name, - const std::string& error_message) { - LOG(WARNING) << object_path_.value() << ": Failed to remove device: " - << error_name << ": " << error_message; +void BluetoothDeviceBlueZ::OnForgetError(const ErrorCallback& error_callback, + const std::string& error_name, + const std::string& error_message) { + LOG(WARNING) << object_path_.value() + << ": Failed to remove device: " << error_name << ": " + << error_message; error_callback.Run(); } -} // namespace chromeos +} // namespace bluez diff --git a/device/bluetooth/bluetooth_device_chromeos.h b/device/bluetooth/bluetooth_device_bluez.h index 92428ac..42b466b 100644 --- a/device/bluetooth/bluetooth_device_chromeos.h +++ b/device/bluetooth/bluetooth_device_bluez.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H -#define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H +#ifndef DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_BLUEZ_H_ +#define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_BLUEZ_H_ #include <string> @@ -21,19 +21,19 @@ namespace device { class BluetoothSocketThread; } // namespace device -namespace chromeos { +namespace bluez { -class BluetoothAdapterChromeOS; -class BluetoothPairingChromeOS; +class BluetoothAdapterBlueZ; +class BluetoothPairingBlueZ; -// The BluetoothDeviceChromeOS class implements BluetoothDevice for the +// The BluetoothDeviceBlueZ class implements BluetoothDevice for the // Chrome OS platform. // // This class is not thread-safe, but is only called from the UI thread. // // A socket thread is used to create sockets but posts all callbacks on the UI // thread. -class DEVICE_BLUETOOTH_EXPORT BluetoothDeviceChromeOS +class DEVICE_BLUETOOTH_EXPORT BluetoothDeviceBlueZ : public device::BluetoothDevice, public bluez::BluetoothGattServiceClient::Observer { public: @@ -55,8 +55,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothDeviceChromeOS bool ExpectingPinCode() const override; bool ExpectingPasskey() const override; bool ExpectingConfirmation() const override; - void GetConnectionInfo( - const ConnectionInfoCallback& callback) override; + void GetConnectionInfo(const ConnectionInfoCallback& callback) override; void Connect(device::BluetoothDevice::PairingDelegate* pairing_delegate, const base::Closure& callback, const ConnectErrorCallback& error_callback) override; @@ -83,7 +82,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothDeviceChromeOS // Creates a pairing object with the given delegate |pairing_delegate| and // establishes it as the pairing context for this device. All pairing-related // method calls will be forwarded to this object until it is released. - BluetoothPairingChromeOS* BeginPairing( + BluetoothPairingBlueZ* BeginPairing( BluetoothDevice::PairingDelegate* pairing_delegate); // Releases the current pairing object, any pairing-related method calls will @@ -91,13 +90,13 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothDeviceChromeOS void EndPairing(); // Returns the current pairing object or NULL if no pairing is in progress. - BluetoothPairingChromeOS* GetPairing() const; + BluetoothPairingBlueZ* GetPairing() const; // Returns the object path of the device. const dbus::ObjectPath& object_path() const { return object_path_; } // Returns the adapter which owns this device instance. - BluetoothAdapterChromeOS* adapter() const; + BluetoothAdapterBlueZ* adapter() const; protected: // BluetoothDevice override @@ -106,14 +105,14 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothDeviceChromeOS void DisconnectGatt() override; private: - friend class BluetoothAdapterChromeOS; + friend class BluetoothAdapterBlueZ; - BluetoothDeviceChromeOS( - BluetoothAdapterChromeOS* adapter, + BluetoothDeviceBlueZ( + BluetoothAdapterBlueZ* adapter, const dbus::ObjectPath& object_path, scoped_refptr<base::SequencedTaskRunner> ui_task_runner, scoped_refptr<device::BluetoothSocketThread> socket_thread); - ~BluetoothDeviceChromeOS() override; + ~BluetoothDeviceBlueZ() override; // bluez::BluetoothGattServiceClient::Observer overrides. void GattServiceAdded(const dbus::ObjectPath& object_path) override; @@ -134,8 +133,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothDeviceChromeOS void ConnectInternal(bool after_pairing, const base::Closure& callback, const ConnectErrorCallback& error_callback); - void OnConnect(bool after_pairing, - const base::Closure& callback); + void OnConnect(bool after_pairing, const base::Closure& callback); void OnCreateGattConnection(const GattConnectionCallback& callback); void OnConnectError(bool after_pairing, const ConnectErrorCallback& error_callback, @@ -193,15 +191,15 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothDeviceChromeOS // During pairing this is set to an object that we don't own, but on which // we can make method calls to request, display or confirm PIN Codes and // Passkeys. Generally it is the object that owns this one. - scoped_ptr<BluetoothPairingChromeOS> pairing_; + scoped_ptr<BluetoothPairingBlueZ> pairing_; // Note: This should remain the last member so it'll be destroyed and // invalidate its weak pointers before any other members are destroyed. - base::WeakPtrFactory<BluetoothDeviceChromeOS> weak_ptr_factory_; + base::WeakPtrFactory<BluetoothDeviceBlueZ> weak_ptr_factory_; - DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceChromeOS); + DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceBlueZ); }; -} // namespace chromeos +} // namespace bluez -#endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H +#endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_BLUEZ_H_ diff --git a/device/bluetooth/bluetooth_discovery_session_outcome.h b/device/bluetooth/bluetooth_discovery_session_outcome.h index 38cf3a1..9bc83a3 100644 --- a/device/bluetooth/bluetooth_discovery_session_outcome.h +++ b/device/bluetooth/bluetooth_discovery_session_outcome.h @@ -23,12 +23,12 @@ enum class UMABluetoothDiscoverySessionOutcome { ACTIVE_SESSION_NOT_IN_ADAPTER = 7, FAILED = 8, - // ChromeOS-specific failures: - CHROMEOS_DBUS_UNKNOWN_ADAPTER = 9, - CHROMEOS_DBUS_NO_RESPONSE = 10, - CHROMEOS_DBUS_IN_PROGRESS = 11, - CHROMEOS_DBUS_NOT_READY = 12, - CHROMEOS_DBUS_FAILED_MAYBE_UNSUPPORTED_TRANSPORT = 13, + // BlueZ-specific failures: + BLUEZ_DBUS_UNKNOWN_ADAPTER = 9, + BLUEZ_DBUS_NO_RESPONSE = 10, + BLUEZ_DBUS_IN_PROGRESS = 11, + BLUEZ_DBUS_NOT_READY = 12, + BLUEZ_DBUS_FAILED_MAYBE_UNSUPPORTED_TRANSPORT = 13, // NOTE: Add new outcomes immediately above this line. Make sure to update the // enum list in tools/metrics/histograms/histograms.xml accordingly. COUNT diff --git a/device/bluetooth/bluetooth_gatt_chromeos_unittest.cc b/device/bluetooth/bluetooth_gatt_bluez_unittest.cc index cc5860d..fdc9253 100644 --- a/device/bluetooth/bluetooth_gatt_chromeos_unittest.cc +++ b/device/bluetooth/bluetooth_gatt_bluez_unittest.cc @@ -36,7 +36,7 @@ using device::BluetoothGattNotifySession; using device::BluetoothUUID; using device::TestBluetoothAdapterObserver; -namespace chromeos { +namespace bluez { namespace { @@ -61,13 +61,12 @@ bool ValuesEqual(const std::vector<uint8>& value0, } // namespace -class BluetoothGattChromeOSTest : public testing::Test { +class BluetoothGattBlueZTest : public testing::Test { public: - BluetoothGattChromeOSTest() + BluetoothGattBlueZTest() : fake_bluetooth_gatt_service_client_(NULL), success_callback_count_(0), - error_callback_count_(0) { - } + error_callback_count_(0) {} void SetUp() override { scoped_ptr<bluez::BluezDBusManagerSetter> dbus_setter = @@ -103,10 +102,8 @@ class BluetoothGattChromeOSTest : public testing::Test { GetAdapter(); - adapter_->SetPowered( - true, - base::Bind(&base::DoNothing), - base::Bind(&base::DoNothing)); + adapter_->SetPowered(true, base::Bind(&base::DoNothing), + base::Bind(&base::DoNothing)); ASSERT_TRUE(adapter_->IsPowered()); } @@ -118,9 +115,8 @@ class BluetoothGattChromeOSTest : public testing::Test { } void GetAdapter() { - device::BluetoothAdapterFactory::GetAdapter( - base::Bind(&BluetoothGattChromeOSTest::AdapterCallback, - base::Unretained(this))); + device::BluetoothAdapterFactory::GetAdapter(base::Bind( + &BluetoothGattBlueZTest::AdapterCallback, base::Unretained(this))); ASSERT_TRUE(adapter_.get() != NULL); ASSERT_TRUE(adapter_->IsInitialized()); ASSERT_TRUE(adapter_->IsPresent()); @@ -130,9 +126,7 @@ class BluetoothGattChromeOSTest : public testing::Test { adapter_ = adapter; } - void SuccessCallback() { - ++success_callback_count_; - } + void SuccessCallback() { ++success_callback_count_; } void ValueCallback(const std::vector<uint8>& value) { ++success_callback_count_; @@ -155,9 +149,7 @@ class BluetoothGattChromeOSTest : public testing::Test { last_service_error_ = err; } - void ErrorCallback() { - ++error_callback_count_; - } + void ErrorCallback() { ++error_callback_count_; } void DBusErrorCallback(const std::string& error_name, const std::string& error_message) { @@ -193,7 +185,7 @@ class BluetoothGattChromeOSTest : public testing::Test { BluetoothGattService::GattErrorCode last_service_error_; }; -TEST_F(BluetoothGattChromeOSTest, GattConnection) { +TEST_F(BluetoothGattBlueZTest, GattConnection) { fake_bluetooth_device_client_->CreateDevice( dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); @@ -206,9 +198,9 @@ TEST_F(BluetoothGattChromeOSTest, GattConnection) { ASSERT_EQ(0, error_callback_count_); device->CreateGattConnection( - base::Bind(&BluetoothGattChromeOSTest::GattConnectionCallback, + base::Bind(&BluetoothGattBlueZTest::GattConnectionCallback, base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ConnectErrorCallback, + base::Bind(&BluetoothGattBlueZTest::ConnectErrorCallback, base::Unretained(this))); EXPECT_EQ(1, success_callback_count_); @@ -224,9 +216,9 @@ TEST_F(BluetoothGattChromeOSTest, GattConnection) { EXPECT_FALSE(gatt_conn_->IsConnected()); device->CreateGattConnection( - base::Bind(&BluetoothGattChromeOSTest::GattConnectionCallback, + base::Bind(&BluetoothGattBlueZTest::GattConnectionCallback, base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ConnectErrorCallback, + base::Bind(&BluetoothGattBlueZTest::ConnectErrorCallback, base::Unretained(this))); EXPECT_EQ(2, success_callback_count_); @@ -235,11 +227,10 @@ TEST_F(BluetoothGattChromeOSTest, GattConnection) { ASSERT_TRUE(gatt_conn_.get()); EXPECT_TRUE(gatt_conn_->IsConnected()); - device->Disconnect( - base::Bind(&BluetoothGattChromeOSTest::SuccessCallback, - base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ErrorCallback, - base::Unretained(this))); + device->Disconnect(base::Bind(&BluetoothGattBlueZTest::SuccessCallback, + base::Unretained(this)), + base::Bind(&BluetoothGattBlueZTest::ErrorCallback, + base::Unretained(this))); EXPECT_EQ(3, success_callback_count_); EXPECT_EQ(0, error_callback_count_); @@ -247,9 +238,9 @@ TEST_F(BluetoothGattChromeOSTest, GattConnection) { EXPECT_FALSE(gatt_conn_->IsConnected()); device->CreateGattConnection( - base::Bind(&BluetoothGattChromeOSTest::GattConnectionCallback, + base::Bind(&BluetoothGattBlueZTest::GattConnectionCallback, base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ConnectErrorCallback, + base::Bind(&BluetoothGattBlueZTest::ConnectErrorCallback, base::Unretained(this))); EXPECT_EQ(4, success_callback_count_); @@ -264,7 +255,7 @@ TEST_F(BluetoothGattChromeOSTest, GattConnection) { EXPECT_FALSE(gatt_conn_->IsConnected()); } -TEST_F(BluetoothGattChromeOSTest, GattServiceAddedAndRemoved) { +TEST_F(BluetoothGattBlueZTest, GattServiceAddedAndRemoved) { // Create a fake LE device. We store the device pointer here because this is a // test. It's unsafe to do this in production as the device might get deleted. fake_bluetooth_device_client_->CreateDevice( @@ -357,7 +348,7 @@ TEST_F(BluetoothGattChromeOSTest, GattServiceAddedAndRemoved) { bluez::FakeBluetoothDeviceClient::kLowEnergyAddress)); } -TEST_F(BluetoothGattChromeOSTest, GattCharacteristicAddedAndRemoved) { +TEST_F(BluetoothGattBlueZTest, GattCharacteristicAddedAndRemoved) { fake_bluetooth_device_client_->CreateDevice( dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); @@ -425,7 +416,7 @@ TEST_F(BluetoothGattChromeOSTest, GattCharacteristicAddedAndRemoved) { EXPECT_EQ(0, observer.gatt_characteristic_value_changed_count()); } -TEST_F(BluetoothGattChromeOSTest, GattDescriptorAddedAndRemoved) { +TEST_F(BluetoothGattBlueZTest, GattDescriptorAddedAndRemoved) { fake_bluetooth_device_client_->CreateDevice( dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); @@ -461,20 +452,20 @@ TEST_F(BluetoothGattChromeOSTest, GattDescriptorAddedAndRemoved) { EXPECT_EQ(0, observer.gatt_descriptor_value_changed_count()); BluetoothGattCharacteristic* characteristic = service->GetCharacteristic( - fake_bluetooth_gatt_characteristic_client_-> - GetBodySensorLocationPath().value()); + fake_bluetooth_gatt_characteristic_client_->GetBodySensorLocationPath() + .value()); ASSERT_TRUE(characteristic); EXPECT_TRUE(characteristic->GetDescriptors().empty()); characteristic = service->GetCharacteristic( - fake_bluetooth_gatt_characteristic_client_-> - GetHeartRateControlPointPath().value()); + fake_bluetooth_gatt_characteristic_client_->GetHeartRateControlPointPath() + .value()); ASSERT_TRUE(characteristic); EXPECT_TRUE(characteristic->GetDescriptors().empty()); characteristic = service->GetCharacteristic( - fake_bluetooth_gatt_characteristic_client_-> - GetHeartRateMeasurementPath().value()); + fake_bluetooth_gatt_characteristic_client_->GetHeartRateMeasurementPath() + .value()); ASSERT_TRUE(characteristic); EXPECT_EQ(1U, characteristic->GetDescriptors().size()); @@ -515,7 +506,7 @@ TEST_F(BluetoothGattChromeOSTest, GattDescriptorAddedAndRemoved) { EXPECT_EQ(descriptor->GetIdentifier(), observer.last_gatt_descriptor_id()); } -TEST_F(BluetoothGattChromeOSTest, AdapterAddedAfterGattService) { +TEST_F(BluetoothGattBlueZTest, AdapterAddedAfterGattService) { // This unit test tests that all remote GATT objects are created for D-Bus // objects that were already exposed. adapter_ = NULL; @@ -552,8 +543,8 @@ TEST_F(BluetoothGattChromeOSTest, AdapterAddedAfterGattService) { EXPECT_EQ(3U, service->GetCharacteristics().size()); BluetoothGattCharacteristic* characteristic = service->GetCharacteristic( - fake_bluetooth_gatt_characteristic_client_-> - GetBodySensorLocationPath().value()); + fake_bluetooth_gatt_characteristic_client_->GetBodySensorLocationPath() + .value()); ASSERT_TRUE(characteristic); EXPECT_EQ(BluetoothUUID(bluez::FakeBluetoothGattCharacteristicClient:: kBodySensorLocationUUID), @@ -562,8 +553,8 @@ TEST_F(BluetoothGattChromeOSTest, AdapterAddedAfterGattService) { EXPECT_TRUE(characteristic->GetDescriptors().empty()); characteristic = service->GetCharacteristic( - fake_bluetooth_gatt_characteristic_client_-> - GetHeartRateControlPointPath().value()); + fake_bluetooth_gatt_characteristic_client_->GetHeartRateControlPointPath() + .value()); ASSERT_TRUE(characteristic); EXPECT_EQ(BluetoothUUID(bluez::FakeBluetoothGattCharacteristicClient:: kHeartRateControlPointUUID), @@ -572,8 +563,8 @@ TEST_F(BluetoothGattChromeOSTest, AdapterAddedAfterGattService) { EXPECT_TRUE(characteristic->GetDescriptors().empty()); characteristic = service->GetCharacteristic( - fake_bluetooth_gatt_characteristic_client_-> - GetHeartRateMeasurementPath().value()); + fake_bluetooth_gatt_characteristic_client_->GetHeartRateMeasurementPath() + .value()); ASSERT_TRUE(characteristic); EXPECT_EQ(BluetoothUUID(bluez::FakeBluetoothGattCharacteristicClient:: kHeartRateMeasurementUUID), @@ -588,7 +579,7 @@ TEST_F(BluetoothGattChromeOSTest, AdapterAddedAfterGattService) { EXPECT_FALSE(descriptor->IsLocal()); } -TEST_F(BluetoothGattChromeOSTest, GattCharacteristicValue) { +TEST_F(BluetoothGattBlueZTest, GattCharacteristicValue) { fake_bluetooth_device_client_->CreateDevice( dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); @@ -617,20 +608,20 @@ TEST_F(BluetoothGattChromeOSTest, GattCharacteristicValue) { std::vector<uint8> write_value; write_value.push_back(0x01); - BluetoothGattCharacteristic* characteristic = - service->GetCharacteristic(fake_bluetooth_gatt_characteristic_client_-> - GetHeartRateMeasurementPath().value()); + BluetoothGattCharacteristic* characteristic = service->GetCharacteristic( + fake_bluetooth_gatt_characteristic_client_->GetHeartRateMeasurementPath() + .value()); ASSERT_TRUE(characteristic); EXPECT_FALSE(characteristic->IsNotifying()); - EXPECT_EQ(fake_bluetooth_gatt_characteristic_client_-> - GetHeartRateMeasurementPath().value(), - characteristic->GetIdentifier()); + EXPECT_EQ( + fake_bluetooth_gatt_characteristic_client_->GetHeartRateMeasurementPath() + .value(), + characteristic->GetIdentifier()); EXPECT_EQ(kHeartRateMeasurementUUID, characteristic->GetUUID()); characteristic->WriteRemoteCharacteristic( - write_value, - base::Bind(&BluetoothGattChromeOSTest::SuccessCallback, - base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback, + write_value, base::Bind(&BluetoothGattBlueZTest::SuccessCallback, + base::Unretained(this)), + base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback, base::Unretained(this))); EXPECT_TRUE(observer.last_gatt_characteristic_id().empty()); EXPECT_FALSE(observer.last_gatt_characteristic_uuid().IsValid()); @@ -641,18 +632,18 @@ TEST_F(BluetoothGattChromeOSTest, GattCharacteristicValue) { EXPECT_EQ(0, observer.gatt_characteristic_value_changed_count()); characteristic = service->GetCharacteristic( - fake_bluetooth_gatt_characteristic_client_-> - GetBodySensorLocationPath().value()); + fake_bluetooth_gatt_characteristic_client_->GetBodySensorLocationPath() + .value()); ASSERT_TRUE(characteristic); - EXPECT_EQ(fake_bluetooth_gatt_characteristic_client_-> - GetBodySensorLocationPath().value(), - characteristic->GetIdentifier()); + EXPECT_EQ( + fake_bluetooth_gatt_characteristic_client_->GetBodySensorLocationPath() + .value(), + characteristic->GetIdentifier()); EXPECT_EQ(kBodySensorLocationUUID, characteristic->GetUUID()); characteristic->WriteRemoteCharacteristic( - write_value, - base::Bind(&BluetoothGattChromeOSTest::SuccessCallback, - base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback, + write_value, base::Bind(&BluetoothGattBlueZTest::SuccessCallback, + base::Unretained(this)), + base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback, base::Unretained(this))); EXPECT_TRUE(observer.last_gatt_characteristic_id().empty()); EXPECT_FALSE(observer.last_gatt_characteristic_uuid().IsValid()); @@ -667,18 +658,18 @@ TEST_F(BluetoothGattChromeOSTest, GattCharacteristicValue) { // in a CharacteristicValueChanged event, thus no such event should be // received. characteristic = service->GetCharacteristic( - fake_bluetooth_gatt_characteristic_client_-> - GetHeartRateControlPointPath().value()); + fake_bluetooth_gatt_characteristic_client_->GetHeartRateControlPointPath() + .value()); ASSERT_TRUE(characteristic); - EXPECT_EQ(fake_bluetooth_gatt_characteristic_client_-> - GetHeartRateControlPointPath().value(), - characteristic->GetIdentifier()); + EXPECT_EQ( + fake_bluetooth_gatt_characteristic_client_->GetHeartRateControlPointPath() + .value(), + characteristic->GetIdentifier()); EXPECT_EQ(kHeartRateControlPointUUID, characteristic->GetUUID()); characteristic->WriteRemoteCharacteristic( - write_value, - base::Bind(&BluetoothGattChromeOSTest::SuccessCallback, - base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback, + write_value, base::Bind(&BluetoothGattBlueZTest::SuccessCallback, + base::Unretained(this)), + base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback, base::Unretained(this))); EXPECT_TRUE(observer.last_gatt_characteristic_id().empty()); EXPECT_FALSE(observer.last_gatt_characteristic_uuid().IsValid()); @@ -693,10 +684,9 @@ TEST_F(BluetoothGattChromeOSTest, GattCharacteristicValue) { invalid_write_length.push_back(0x01); invalid_write_length.push_back(0x00); characteristic->WriteRemoteCharacteristic( - invalid_write_length, - base::Bind(&BluetoothGattChromeOSTest::SuccessCallback, - base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback, + invalid_write_length, base::Bind(&BluetoothGattBlueZTest::SuccessCallback, + base::Unretained(this)), + base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback, base::Unretained(this))); EXPECT_EQ(1, success_callback_count_); EXPECT_EQ(3, error_callback_count_); @@ -707,10 +697,9 @@ TEST_F(BluetoothGattChromeOSTest, GattCharacteristicValue) { std::vector<uint8> invalid_write_value; invalid_write_value.push_back(0x02); characteristic->WriteRemoteCharacteristic( - invalid_write_value, - base::Bind(&BluetoothGattChromeOSTest::SuccessCallback, - base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback, + invalid_write_value, base::Bind(&BluetoothGattBlueZTest::SuccessCallback, + base::Unretained(this)), + base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback, base::Unretained(this))); EXPECT_EQ(1, success_callback_count_); EXPECT_EQ(4, error_callback_count_); @@ -720,17 +709,18 @@ TEST_F(BluetoothGattChromeOSTest, GattCharacteristicValue) { // Issue a read request. A successful read results in a // CharacteristicValueChanged notification. characteristic = service->GetCharacteristic( - fake_bluetooth_gatt_characteristic_client_-> - GetBodySensorLocationPath().value()); + fake_bluetooth_gatt_characteristic_client_->GetBodySensorLocationPath() + .value()); ASSERT_TRUE(characteristic); - EXPECT_EQ(fake_bluetooth_gatt_characteristic_client_-> - GetBodySensorLocationPath().value(), - characteristic->GetIdentifier()); + EXPECT_EQ( + fake_bluetooth_gatt_characteristic_client_->GetBodySensorLocationPath() + .value(), + characteristic->GetIdentifier()); EXPECT_EQ(kBodySensorLocationUUID, characteristic->GetUUID()); characteristic->ReadRemoteCharacteristic( - base::Bind(&BluetoothGattChromeOSTest::ValueCallback, + base::Bind(&BluetoothGattBlueZTest::ValueCallback, base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback, + base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback, base::Unretained(this))); EXPECT_EQ(2, success_callback_count_); EXPECT_EQ(4, error_callback_count_); @@ -749,9 +739,9 @@ TEST_F(BluetoothGattChromeOSTest, GattCharacteristicValue) { characteristic->GetIdentifier()); EXPECT_EQ(kBodySensorLocationUUID, characteristic->GetUUID()); characteristic->ReadRemoteCharacteristic( - base::Bind(&BluetoothGattChromeOSTest::ValueCallback, + base::Bind(&BluetoothGattBlueZTest::ValueCallback, base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback, + base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback, base::Unretained(this))); // Callback counts shouldn't change, this one will be delayed until after @@ -762,9 +752,9 @@ TEST_F(BluetoothGattChromeOSTest, GattCharacteristicValue) { // Next read should error because IN_PROGRESS characteristic->ReadRemoteCharacteristic( - base::Bind(&BluetoothGattChromeOSTest::ValueCallback, + base::Bind(&BluetoothGattBlueZTest::ValueCallback, base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback, + base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback, base::Unretained(this))); EXPECT_EQ(5, error_callback_count_); EXPECT_EQ(BluetoothGattService::GATT_ERROR_IN_PROGRESS, last_service_error_); @@ -778,9 +768,9 @@ TEST_F(BluetoothGattChromeOSTest, GattCharacteristicValue) { // Test unauthorized actions. fake_bluetooth_gatt_characteristic_client_->SetAuthorized(false); characteristic->ReadRemoteCharacteristic( - base::Bind(&BluetoothGattChromeOSTest::ValueCallback, + base::Bind(&BluetoothGattBlueZTest::ValueCallback, base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback, + base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback, base::Unretained(this))); EXPECT_EQ(3, success_callback_count_); EXPECT_EQ(6, error_callback_count_); @@ -792,9 +782,9 @@ TEST_F(BluetoothGattChromeOSTest, GattCharacteristicValue) { // Test unauthenticated / needs login. fake_bluetooth_gatt_characteristic_client_->SetAuthenticated(false); characteristic->ReadRemoteCharacteristic( - base::Bind(&BluetoothGattChromeOSTest::ValueCallback, + base::Bind(&BluetoothGattBlueZTest::ValueCallback, base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback, + base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback, base::Unretained(this))); EXPECT_EQ(3, success_callback_count_); EXPECT_EQ(7, error_callback_count_); @@ -803,7 +793,7 @@ TEST_F(BluetoothGattChromeOSTest, GattCharacteristicValue) { fake_bluetooth_gatt_characteristic_client_->SetAuthenticated(true); } -TEST_F(BluetoothGattChromeOSTest, GattCharacteristicProperties) { +TEST_F(BluetoothGattBlueZTest, GattCharacteristicProperties) { fake_bluetooth_device_client_->CreateDevice( dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); @@ -826,26 +816,26 @@ TEST_F(BluetoothGattChromeOSTest, GattCharacteristicProperties) { // Run the message loop so that the characteristics appear. base::MessageLoop::current()->Run(); - BluetoothGattCharacteristic *characteristic = service->GetCharacteristic( - fake_bluetooth_gatt_characteristic_client_-> - GetBodySensorLocationPath().value()); + BluetoothGattCharacteristic* characteristic = service->GetCharacteristic( + fake_bluetooth_gatt_characteristic_client_->GetBodySensorLocationPath() + .value()); EXPECT_EQ(BluetoothGattCharacteristic::PROPERTY_READ, characteristic->GetProperties()); characteristic = service->GetCharacteristic( - fake_bluetooth_gatt_characteristic_client_-> - GetHeartRateControlPointPath().value()); + fake_bluetooth_gatt_characteristic_client_->GetHeartRateControlPointPath() + .value()); EXPECT_EQ(BluetoothGattCharacteristic::PROPERTY_WRITE, characteristic->GetProperties()); characteristic = service->GetCharacteristic( - fake_bluetooth_gatt_characteristic_client_-> - GetHeartRateMeasurementPath().value()); + fake_bluetooth_gatt_characteristic_client_->GetHeartRateMeasurementPath() + .value()); EXPECT_EQ(BluetoothGattCharacteristic::PROPERTY_NOTIFY, characteristic->GetProperties()); } -TEST_F(BluetoothGattChromeOSTest, GattDescriptorValue) { +TEST_F(BluetoothGattBlueZTest, GattDescriptorValue) { fake_bluetooth_device_client_->CreateDevice( dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); @@ -876,8 +866,8 @@ TEST_F(BluetoothGattChromeOSTest, GattDescriptorValue) { // Only the Heart Rate Measurement characteristic has a descriptor. BluetoothGattCharacteristic* characteristic = service->GetCharacteristic( - fake_bluetooth_gatt_characteristic_client_-> - GetHeartRateMeasurementPath().value()); + fake_bluetooth_gatt_characteristic_client_->GetHeartRateMeasurementPath() + .value()); ASSERT_TRUE(characteristic); EXPECT_EQ(1U, characteristic->GetDescriptors().size()); EXPECT_FALSE(characteristic->IsNotifying()); @@ -900,9 +890,9 @@ TEST_F(BluetoothGattChromeOSTest, GattDescriptorValue) { // Read value. GattDescriptorValueChanged event will be sent after a // successful read. descriptor->ReadRemoteDescriptor( - base::Bind(&BluetoothGattChromeOSTest::ValueCallback, + base::Bind(&BluetoothGattBlueZTest::ValueCallback, base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback, + base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback, base::Unretained(this))); EXPECT_EQ(1, success_callback_count_); EXPECT_EQ(0, error_callback_count_); @@ -914,10 +904,9 @@ TEST_F(BluetoothGattChromeOSTest, GattDescriptorValue) { // Write value. Writes to this descriptor will fail. desc_value[0] = 0x03; descriptor->WriteRemoteDescriptor( - desc_value, - base::Bind(&BluetoothGattChromeOSTest::SuccessCallback, - base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback, + desc_value, base::Bind(&BluetoothGattBlueZTest::SuccessCallback, + base::Unretained(this)), + base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback, base::Unretained(this))); EXPECT_EQ(1, success_callback_count_); EXPECT_EQ(1, error_callback_count_); @@ -930,9 +919,9 @@ TEST_F(BluetoothGattChromeOSTest, GattDescriptorValue) { // Read value. The value should remain unchanged. descriptor->ReadRemoteDescriptor( - base::Bind(&BluetoothGattChromeOSTest::ValueCallback, + base::Bind(&BluetoothGattBlueZTest::ValueCallback, base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback, + base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback, base::Unretained(this))); EXPECT_EQ(2, success_callback_count_); EXPECT_EQ(1, error_callback_count_); @@ -944,9 +933,9 @@ TEST_F(BluetoothGattChromeOSTest, GattDescriptorValue) { // Start notifications on the descriptor's characteristic. The descriptor // value should change. characteristic->StartNotifySession( - base::Bind(&BluetoothGattChromeOSTest::NotifySessionCallback, + base::Bind(&BluetoothGattBlueZTest::NotifySessionCallback, base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback, + base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback, base::Unretained(this))); base::MessageLoop::current()->Run(); EXPECT_EQ(3, success_callback_count_); @@ -956,9 +945,9 @@ TEST_F(BluetoothGattChromeOSTest, GattDescriptorValue) { // Read the new descriptor value. We should receive a value updated event. descriptor->ReadRemoteDescriptor( - base::Bind(&BluetoothGattChromeOSTest::ValueCallback, + base::Bind(&BluetoothGattBlueZTest::ValueCallback, base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback, + base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback, base::Unretained(this))); EXPECT_EQ(4, success_callback_count_); EXPECT_EQ(1, error_callback_count_); @@ -968,7 +957,7 @@ TEST_F(BluetoothGattChromeOSTest, GattDescriptorValue) { EXPECT_EQ(2, observer.gatt_descriptor_value_changed_count()); } -TEST_F(BluetoothGattChromeOSTest, NotifySessions) { +TEST_F(BluetoothGattBlueZTest, NotifySessions) { fake_bluetooth_device_client_->CreateDevice( dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); @@ -1001,9 +990,9 @@ TEST_F(BluetoothGattChromeOSTest, NotifySessions) { // Request to start notifications. characteristic->StartNotifySession( - base::Bind(&BluetoothGattChromeOSTest::NotifySessionCallback, + base::Bind(&BluetoothGattBlueZTest::NotifySessionCallback, base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback, + base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback, base::Unretained(this))); // The operation still hasn't completed but we should have received the first @@ -1015,14 +1004,14 @@ TEST_F(BluetoothGattChromeOSTest, NotifySessions) { // Send a two more requests, which should get queued. characteristic->StartNotifySession( - base::Bind(&BluetoothGattChromeOSTest::NotifySessionCallback, + base::Bind(&BluetoothGattBlueZTest::NotifySessionCallback, base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback, + base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback, base::Unretained(this))); characteristic->StartNotifySession( - base::Bind(&BluetoothGattChromeOSTest::NotifySessionCallback, + base::Bind(&BluetoothGattBlueZTest::NotifySessionCallback, base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback, + base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback, base::Unretained(this))); EXPECT_EQ(0, success_callback_count_); EXPECT_EQ(0, error_callback_count_); @@ -1047,7 +1036,7 @@ TEST_F(BluetoothGattChromeOSTest, NotifySessions) { // characteristic should still be notifying. BluetoothGattNotifySession* session = update_sessions_[0]; EXPECT_TRUE(session->IsActive()); - session->Stop(base::Bind(&BluetoothGattChromeOSTest::SuccessCallback, + session->Stop(base::Bind(&BluetoothGattBlueZTest::SuccessCallback, base::Unretained(this))); EXPECT_EQ(4, success_callback_count_); EXPECT_EQ(0, error_callback_count_); @@ -1073,9 +1062,9 @@ TEST_F(BluetoothGattChromeOSTest, NotifySessions) { // Enable notifications again. characteristic->StartNotifySession( - base::Bind(&BluetoothGattChromeOSTest::NotifySessionCallback, + base::Bind(&BluetoothGattBlueZTest::NotifySessionCallback, base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback, + base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback, base::Unretained(this))); EXPECT_EQ(0, success_callback_count_); EXPECT_EQ(0, error_callback_count_); @@ -1099,9 +1088,9 @@ TEST_F(BluetoothGattChromeOSTest, NotifySessions) { // Request another session. This should return immediately. characteristic->StartNotifySession( - base::Bind(&BluetoothGattChromeOSTest::NotifySessionCallback, + base::Bind(&BluetoothGattBlueZTest::NotifySessionCallback, base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback, + base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback, base::Unretained(this))); EXPECT_EQ(2, success_callback_count_); EXPECT_EQ(0, error_callback_count_); @@ -1117,7 +1106,7 @@ TEST_F(BluetoothGattChromeOSTest, NotifySessions) { EXPECT_FALSE(update_sessions_[1]->IsActive()); } -TEST_F(BluetoothGattChromeOSTest, NotifySessionsMadeInactive) { +TEST_F(BluetoothGattBlueZTest, NotifySessionsMadeInactive) { fake_bluetooth_device_client_->CreateDevice( dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); @@ -1150,24 +1139,24 @@ TEST_F(BluetoothGattChromeOSTest, NotifySessionsMadeInactive) { // Send several requests to start notifications. characteristic->StartNotifySession( - base::Bind(&BluetoothGattChromeOSTest::NotifySessionCallback, + base::Bind(&BluetoothGattBlueZTest::NotifySessionCallback, base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback, + base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback, base::Unretained(this))); characteristic->StartNotifySession( - base::Bind(&BluetoothGattChromeOSTest::NotifySessionCallback, + base::Bind(&BluetoothGattBlueZTest::NotifySessionCallback, base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback, + base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback, base::Unretained(this))); characteristic->StartNotifySession( - base::Bind(&BluetoothGattChromeOSTest::NotifySessionCallback, + base::Bind(&BluetoothGattBlueZTest::NotifySessionCallback, base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback, + base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback, base::Unretained(this))); characteristic->StartNotifySession( - base::Bind(&BluetoothGattChromeOSTest::NotifySessionCallback, + base::Bind(&BluetoothGattBlueZTest::NotifySessionCallback, base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback, + base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback, base::Unretained(this))); // The operation still hasn't completed but we should have received the first @@ -1195,9 +1184,9 @@ TEST_F(BluetoothGattChromeOSTest, NotifySessionsMadeInactive) { // marked as inactive. fake_bluetooth_gatt_characteristic_client_->StopNotify( fake_bluetooth_gatt_characteristic_client_->GetHeartRateMeasurementPath(), - base::Bind(&BluetoothGattChromeOSTest::SuccessCallback, + base::Bind(&BluetoothGattBlueZTest::SuccessCallback, base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::DBusErrorCallback, + base::Bind(&BluetoothGattBlueZTest::DBusErrorCallback, base::Unretained(this))); EXPECT_EQ(5, success_callback_count_); EXPECT_EQ(0, error_callback_count_); @@ -1213,9 +1202,9 @@ TEST_F(BluetoothGattChromeOSTest, NotifySessionsMadeInactive) { success_callback_count_ = 0; observer.Reset(); characteristic->StartNotifySession( - base::Bind(&BluetoothGattChromeOSTest::NotifySessionCallback, + base::Bind(&BluetoothGattBlueZTest::NotifySessionCallback, base::Unretained(this)), - base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback, + base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback, base::Unretained(this))); EXPECT_EQ(0, success_callback_count_); @@ -1234,4 +1223,4 @@ TEST_F(BluetoothGattChromeOSTest, NotifySessionsMadeInactive) { EXPECT_TRUE(update_sessions_[0]->IsActive()); } -} // namespace chromeos +} // namespace bluez diff --git a/device/bluetooth/bluetooth_gatt_connection_chromeos.cc b/device/bluetooth/bluetooth_gatt_connection_bluez.cc index 57aaa4d..98b6a46 100644 --- a/device/bluetooth/bluetooth_gatt_connection_chromeos.cc +++ b/device/bluetooth/bluetooth_gatt_connection_bluez.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "device/bluetooth/bluetooth_gatt_connection_chromeos.h" +#include "device/bluetooth/bluetooth_gatt_connection_bluez.h" #include "base/bind.h" #include "base/logging.h" @@ -10,9 +10,9 @@ #include "device/bluetooth/bluetooth_device.h" #include "device/bluetooth/dbus/bluez_dbus_manager.h" -namespace chromeos { +namespace bluez { -BluetoothGattConnectionChromeOS::BluetoothGattConnectionChromeOS( +BluetoothGattConnectionBlueZ::BluetoothGattConnectionBlueZ( scoped_refptr<device::BluetoothAdapter> adapter, const std::string& device_address, const dbus::ObjectPath& object_path) @@ -26,13 +26,13 @@ BluetoothGattConnectionChromeOS::BluetoothGattConnectionChromeOS( bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->AddObserver(this); } -BluetoothGattConnectionChromeOS::~BluetoothGattConnectionChromeOS() { +BluetoothGattConnectionBlueZ::~BluetoothGattConnectionBlueZ() { bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->RemoveObserver( this); Disconnect(); } -bool BluetoothGattConnectionChromeOS::IsConnected() { +bool BluetoothGattConnectionBlueZ::IsConnected() { // Lazily determine the activity state of the connection. If already // marked as inactive, then return false. Otherwise, explicitly mark // |connected_| as false if the device is removed or disconnected. We do this, @@ -50,7 +50,7 @@ bool BluetoothGattConnectionChromeOS::IsConnected() { return connected_; } -void BluetoothGattConnectionChromeOS::Disconnect() { +void BluetoothGattConnectionBlueZ::Disconnect() { if (!connected_) { VLOG(1) << "Connection already inactive."; return; @@ -66,7 +66,7 @@ void BluetoothGattConnectionChromeOS::Disconnect() { connected_ = false; } -void BluetoothGattConnectionChromeOS::DeviceRemoved( +void BluetoothGattConnectionBlueZ::DeviceRemoved( const dbus::ObjectPath& object_path) { if (object_path != object_path_) return; @@ -74,7 +74,7 @@ void BluetoothGattConnectionChromeOS::DeviceRemoved( connected_ = false; } -void BluetoothGattConnectionChromeOS::DevicePropertyChanged( +void BluetoothGattConnectionBlueZ::DevicePropertyChanged( const dbus::ObjectPath& object_path, const std::string& property_name) { if (object_path != object_path_) @@ -102,4 +102,4 @@ void BluetoothGattConnectionChromeOS::DevicePropertyChanged( device_address_ = properties->address.value(); } -} // namespace chromeos +} // namespace bluez diff --git a/device/bluetooth/bluetooth_gatt_connection_chromeos.h b/device/bluetooth/bluetooth_gatt_connection_bluez.h index 6e40283..bca25f1 100644 --- a/device/bluetooth/bluetooth_gatt_connection_chromeos.h +++ b/device/bluetooth/bluetooth_gatt_connection_bluez.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef DEVICE_BLUETOOTH_BLUETOOTH_GATT_CONNECTION_CHROMEOS_H_ -#define DEVICE_BLUETOOTH_BLUETOOTH_GATT_CONNECTION_CHROMEOS_H_ +#ifndef DEVICE_BLUETOOTH_BLUETOOTH_GATT_CONNECTION_BLUEZ_H_ +#define DEVICE_BLUETOOTH_BLUETOOTH_GATT_CONNECTION_BLUEZ_H_ #include <string> @@ -19,19 +19,19 @@ class BluetoothAdapter; } // namespace device -namespace chromeos { +namespace bluez { -// BluetoothGattConnectionChromeOS implements BluetoothGattConnection for the +// BluetoothGattConnectionBlueZ implements BluetoothGattConnection for the // Chrome OS platform. -class BluetoothGattConnectionChromeOS +class BluetoothGattConnectionBlueZ : public device::BluetoothGattConnection, public bluez::BluetoothDeviceClient::Observer { public: - explicit BluetoothGattConnectionChromeOS( + explicit BluetoothGattConnectionBlueZ( scoped_refptr<device::BluetoothAdapter> adapter, const std::string& device_address, const dbus::ObjectPath& object_path); - ~BluetoothGattConnectionChromeOS() override; + ~BluetoothGattConnectionBlueZ() override; // BluetoothGattConnection overrides. bool IsConnected() override; @@ -50,9 +50,9 @@ class BluetoothGattConnectionChromeOS // events. dbus::ObjectPath object_path_; - DISALLOW_COPY_AND_ASSIGN(BluetoothGattConnectionChromeOS); + DISALLOW_COPY_AND_ASSIGN(BluetoothGattConnectionBlueZ); }; -} // namespace chromeos +} // namespace bluez -#endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_CONNECTION_CHROMEOS_H_ +#endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_CONNECTION_BLUEZ_H_ diff --git a/device/bluetooth/bluetooth_gatt_notify_session_chromeos.cc b/device/bluetooth/bluetooth_gatt_notify_session_bluez.cc index 02f7ed8..7e1cfed 100644 --- a/device/bluetooth/bluetooth_gatt_notify_session_chromeos.cc +++ b/device/bluetooth/bluetooth_gatt_notify_session_bluez.cc @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "device/bluetooth/bluetooth_gatt_notify_session_chromeos.h" +#include "device/bluetooth/bluetooth_gatt_notify_session_bluez.h" #include "base/bind.h" #include "base/logging.h" #include "device/bluetooth/bluetooth_adapter.h" #include "device/bluetooth/bluetooth_device.h" #include "device/bluetooth/bluetooth_gatt_service.h" -#include "device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h" +#include "device/bluetooth/bluetooth_remote_gatt_characteristic_bluez.h" #include "device/bluetooth/dbus/bluez_dbus_manager.h" -namespace chromeos { +namespace bluez { -BluetoothGattNotifySessionChromeOS::BluetoothGattNotifySessionChromeOS( +BluetoothGattNotifySessionBlueZ::BluetoothGattNotifySessionBlueZ( scoped_refptr<device::BluetoothAdapter> adapter, const std::string& device_address, const std::string& service_identifier, @@ -37,19 +37,19 @@ BluetoothGattNotifySessionChromeOS::BluetoothGattNotifySessionChromeOS( ->AddObserver(this); } -BluetoothGattNotifySessionChromeOS::~BluetoothGattNotifySessionChromeOS() { +BluetoothGattNotifySessionBlueZ::~BluetoothGattNotifySessionBlueZ() { bluez::BluezDBusManager::Get() ->GetBluetoothGattCharacteristicClient() ->RemoveObserver(this); Stop(base::Bind(&base::DoNothing)); } -std::string BluetoothGattNotifySessionChromeOS::GetCharacteristicIdentifier() +std::string BluetoothGattNotifySessionBlueZ::GetCharacteristicIdentifier() const { return characteristic_id_; } -bool BluetoothGattNotifySessionChromeOS::IsActive() { +bool BluetoothGattNotifySessionBlueZ::IsActive() { // Determine if the session is active. If |active_| is false, then it's // been explicitly marked, so return false. if (!active_) @@ -73,7 +73,7 @@ bool BluetoothGattNotifySessionChromeOS::IsActive() { return active_; } -void BluetoothGattNotifySessionChromeOS::Stop(const base::Closure& callback) { +void BluetoothGattNotifySessionBlueZ::Stop(const base::Closure& callback) { if (!active_) { VLOG(1) << "Notify session already inactive."; callback.Run(); @@ -91,8 +91,8 @@ void BluetoothGattNotifySessionChromeOS::Stop(const base::Closure& callback) { if (!service) return; - BluetoothRemoteGattCharacteristicChromeOS* chrc = - static_cast<BluetoothRemoteGattCharacteristicChromeOS*>( + BluetoothRemoteGattCharacteristicBlueZ* chrc = + static_cast<BluetoothRemoteGattCharacteristicBlueZ*>( service->GetCharacteristic(characteristic_id_)); if (!chrc) return; @@ -100,7 +100,7 @@ void BluetoothGattNotifySessionChromeOS::Stop(const base::Closure& callback) { chrc->RemoveNotifySession(callback); } -void BluetoothGattNotifySessionChromeOS::GattCharacteristicRemoved( +void BluetoothGattNotifySessionBlueZ::GattCharacteristicRemoved( const dbus::ObjectPath& object_path) { if (object_path != object_path_) return; @@ -108,7 +108,7 @@ void BluetoothGattNotifySessionChromeOS::GattCharacteristicRemoved( active_ = false; } -void BluetoothGattNotifySessionChromeOS::GattCharacteristicPropertyChanged( +void BluetoothGattNotifySessionBlueZ::GattCharacteristicPropertyChanged( const dbus::ObjectPath& object_path, const std::string& property_name) { if (object_path != object_path_) @@ -131,4 +131,4 @@ void BluetoothGattNotifySessionChromeOS::GattCharacteristicPropertyChanged( active_ = false; } -} // namespace chromeos +} // namespace bluez diff --git a/device/bluetooth/bluetooth_gatt_notify_session_chromeos.h b/device/bluetooth/bluetooth_gatt_notify_session_bluez.h index ef6e8da..6f0ea51 100644 --- a/device/bluetooth/bluetooth_gatt_notify_session_chromeos.h +++ b/device/bluetooth/bluetooth_gatt_notify_session_bluez.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef DEVICE_BLUETOOTH_BLUETOOTH_GATT_NOTIFY_SESSION_CHROMEOS_H_ -#define DEVICE_BLUETOOTH_BLUETOOTH_GATT_NOTIFY_SESSION_CHROMEOS_H_ +#ifndef DEVICE_BLUETOOTH_BLUETOOTH_GATT_NOTIFY_SESSION_BLUEZ_H_ +#define DEVICE_BLUETOOTH_BLUETOOTH_GATT_NOTIFY_SESSION_BLUEZ_H_ #include <string> @@ -17,17 +17,17 @@ class BluetoothAdapter; } // namespace device -namespace chromeos { +namespace bluez { -class BluetoothRemoteGattCharacteristicChromeOS; +class BluetoothRemoteGattCharacteristicBlueZ; -// BluetoothGattNotifySessionChromeOS implements +// BluetoothGattNotifySessionBlueZ implements // BluetoothGattNotifySession for the Chrome OS platform. -class BluetoothGattNotifySessionChromeOS +class BluetoothGattNotifySessionBlueZ : public device::BluetoothGattNotifySession, public bluez::BluetoothGattCharacteristicClient::Observer { public: - ~BluetoothGattNotifySessionChromeOS() override; + ~BluetoothGattNotifySessionBlueZ() override; // BluetoothGattNotifySession overrides. std::string GetCharacteristicIdentifier() const override; @@ -35,9 +35,9 @@ class BluetoothGattNotifySessionChromeOS void Stop(const base::Closure& callback) override; private: - friend class BluetoothRemoteGattCharacteristicChromeOS; + friend class BluetoothRemoteGattCharacteristicBlueZ; - explicit BluetoothGattNotifySessionChromeOS( + explicit BluetoothGattNotifySessionBlueZ( scoped_refptr<device::BluetoothAdapter> adapter, const std::string& device_address, const std::string& service_identifier, @@ -69,9 +69,9 @@ class BluetoothGattNotifySessionChromeOS // observer events. dbus::ObjectPath object_path_; - DISALLOW_COPY_AND_ASSIGN(BluetoothGattNotifySessionChromeOS); + DISALLOW_COPY_AND_ASSIGN(BluetoothGattNotifySessionBlueZ); }; -} // namespace chromeos +} // namespace bluez -#endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_NOTIFY_SESSION_CHROMEOS_H_ +#endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_NOTIFY_SESSION_BLUEZ_H_ diff --git a/device/bluetooth/bluetooth_pairing_chromeos.cc b/device/bluetooth/bluetooth_pairing_bluez.cc index c69bc94..a798694 100644 --- a/device/bluetooth/bluetooth_pairing_chromeos.cc +++ b/device/bluetooth/bluetooth_pairing_bluez.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "device/bluetooth/bluetooth_pairing_chromeos.h" +#include "device/bluetooth/bluetooth_pairing_bluez.h" #include "base/logging.h" #include "base/metrics/histogram.h" #include "device/bluetooth/bluetooth_device.h" -#include "device/bluetooth/bluetooth_device_chromeos.h" +#include "device/bluetooth/bluetooth_device_bluez.h" using device::BluetoothDevice; @@ -32,21 +32,19 @@ const uint16 kPasskeyMaxKeysEntered = 7; } // namespace -namespace chromeos { +namespace bluez { -BluetoothPairingChromeOS::BluetoothPairingChromeOS( - BluetoothDeviceChromeOS* device, +BluetoothPairingBlueZ::BluetoothPairingBlueZ( + BluetoothDeviceBlueZ* device, BluetoothDevice::PairingDelegate* pairing_delegate) : device_(device), pairing_delegate_(pairing_delegate), pairing_delegate_used_(false) { - VLOG(1) << "Created BluetoothPairingChromeOS for " - << device_->GetAddress(); + VLOG(1) << "Created BluetoothPairingBlueZ for " << device_->GetAddress(); } -BluetoothPairingChromeOS::~BluetoothPairingChromeOS() { - VLOG(1) << "Destroying BluetoothPairingChromeOS for " - << device_->GetAddress(); +BluetoothPairingBlueZ::~BluetoothPairingBlueZ() { + VLOG(1) << "Destroying BluetoothPairingBlueZ for " << device_->GetAddress(); if (!pairing_delegate_used_) { UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod", @@ -72,7 +70,7 @@ BluetoothPairingChromeOS::~BluetoothPairingChromeOS() { pairing_delegate_ = NULL; } -void BluetoothPairingChromeOS::RequestPinCode( +void BluetoothPairingBlueZ::RequestPinCode( const bluez::BluetoothAgentServiceProvider::Delegate::PinCodeCallback& callback) { UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod", @@ -85,11 +83,11 @@ void BluetoothPairingChromeOS::RequestPinCode( pairing_delegate_->RequestPinCode(device_); } -bool BluetoothPairingChromeOS::ExpectingPinCode() const { +bool BluetoothPairingBlueZ::ExpectingPinCode() const { return !pincode_callback_.is_null(); } -void BluetoothPairingChromeOS::SetPinCode(const std::string& pincode) { +void BluetoothPairingBlueZ::SetPinCode(const std::string& pincode) { if (pincode_callback_.is_null()) return; @@ -104,7 +102,7 @@ void BluetoothPairingChromeOS::SetPinCode(const std::string& pincode) { device_->EndPairing(); } -void BluetoothPairingChromeOS::DisplayPinCode(const std::string& pincode) { +void BluetoothPairingBlueZ::DisplayPinCode(const std::string& pincode) { UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod", UMA_PAIRING_METHOD_DISPLAY_PINCODE, UMA_PAIRING_METHOD_COUNT); @@ -120,7 +118,7 @@ void BluetoothPairingChromeOS::DisplayPinCode(const std::string& pincode) { device_->EndPairing(); } -void BluetoothPairingChromeOS::RequestPasskey( +void BluetoothPairingBlueZ::RequestPasskey( const bluez::BluetoothAgentServiceProvider::Delegate::PasskeyCallback& callback) { UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod", @@ -133,11 +131,11 @@ void BluetoothPairingChromeOS::RequestPasskey( pairing_delegate_->RequestPasskey(device_); } -bool BluetoothPairingChromeOS::ExpectingPasskey() const { +bool BluetoothPairingBlueZ::ExpectingPasskey() const { return !passkey_callback_.is_null(); } -void BluetoothPairingChromeOS::SetPasskey(uint32 passkey) { +void BluetoothPairingBlueZ::SetPasskey(uint32 passkey) { if (passkey_callback_.is_null()) return; @@ -152,7 +150,7 @@ void BluetoothPairingChromeOS::SetPasskey(uint32 passkey) { device_->EndPairing(); } -void BluetoothPairingChromeOS::DisplayPasskey(uint32 passkey) { +void BluetoothPairingBlueZ::DisplayPasskey(uint32 passkey) { UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod", UMA_PAIRING_METHOD_DISPLAY_PASSKEY, UMA_PAIRING_METHOD_COUNT); @@ -160,10 +158,9 @@ void BluetoothPairingChromeOS::DisplayPasskey(uint32 passkey) { ResetCallbacks(); pairing_delegate_used_ = true; pairing_delegate_->DisplayPasskey(device_, passkey); - } -void BluetoothPairingChromeOS::KeysEntered(uint16 entered) { +void BluetoothPairingBlueZ::KeysEntered(uint16 entered) { pairing_delegate_used_ = true; pairing_delegate_->KeysEntered(device_, entered); @@ -174,7 +171,7 @@ void BluetoothPairingChromeOS::KeysEntered(uint16 entered) { device_->EndPairing(); } -void BluetoothPairingChromeOS::RequestConfirmation( +void BluetoothPairingBlueZ::RequestConfirmation( uint32 passkey, const bluez::BluetoothAgentServiceProvider::Delegate::ConfirmationCallback& callback) { @@ -188,11 +185,10 @@ void BluetoothPairingChromeOS::RequestConfirmation( pairing_delegate_->ConfirmPasskey(device_, passkey); } -void BluetoothPairingChromeOS::RequestAuthorization( +void BluetoothPairingBlueZ::RequestAuthorization( const bluez::BluetoothAgentServiceProvider::Delegate::ConfirmationCallback& callback) { - UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod", - UMA_PAIRING_METHOD_NONE, + UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod", UMA_PAIRING_METHOD_NONE, UMA_PAIRING_METHOD_COUNT); ResetCallbacks(); @@ -201,11 +197,11 @@ void BluetoothPairingChromeOS::RequestAuthorization( pairing_delegate_->AuthorizePairing(device_); } -bool BluetoothPairingChromeOS::ExpectingConfirmation() const { +bool BluetoothPairingBlueZ::ExpectingConfirmation() const { return !confirmation_callback_.is_null(); } -void BluetoothPairingChromeOS::ConfirmPairing() { +void BluetoothPairingBlueZ::ConfirmPairing() { if (confirmation_callback_.is_null()) return; @@ -220,28 +216,28 @@ void BluetoothPairingChromeOS::ConfirmPairing() { device_->EndPairing(); } -bool BluetoothPairingChromeOS::RejectPairing() { +bool BluetoothPairingBlueZ::RejectPairing() { return RunPairingCallbacks( bluez::BluetoothAgentServiceProvider::Delegate::REJECTED); } -bool BluetoothPairingChromeOS::CancelPairing() { +bool BluetoothPairingBlueZ::CancelPairing() { return RunPairingCallbacks( bluez::BluetoothAgentServiceProvider::Delegate::CANCELLED); } -BluetoothDevice::PairingDelegate* -BluetoothPairingChromeOS::GetPairingDelegate() const { +BluetoothDevice::PairingDelegate* BluetoothPairingBlueZ::GetPairingDelegate() + const { return pairing_delegate_; } -void BluetoothPairingChromeOS::ResetCallbacks() { +void BluetoothPairingBlueZ::ResetCallbacks() { pincode_callback_.Reset(); passkey_callback_.Reset(); confirmation_callback_.Reset(); } -bool BluetoothPairingChromeOS::RunPairingCallbacks( +bool BluetoothPairingBlueZ::RunPairingCallbacks( bluez::BluetoothAgentServiceProvider::Delegate::Status status) { pairing_delegate_used_ = true; @@ -273,4 +269,4 @@ bool BluetoothPairingChromeOS::RunPairingCallbacks( return callback_run; } -} // namespace chromeos +} // namespace bluez diff --git a/device/bluetooth/bluetooth_pairing_chromeos.h b/device/bluetooth/bluetooth_pairing_bluez.h index 0a4ddb6..bda445f 100644 --- a/device/bluetooth/bluetooth_pairing_chromeos.h +++ b/device/bluetooth/bluetooth_pairing_bluez.h @@ -2,26 +2,26 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef DEVICE_BLUETOOTH_BLUETOOTH_PAIRING_CHROMEOS_H_ -#define DEVICE_BLUETOOTH_BLUETOOTH_PAIRING_CHROMEOS_H_ +#ifndef DEVICE_BLUETOOTH_BLUETOOTH_PAIRING_BLUEZ_H_ +#define DEVICE_BLUETOOTH_BLUETOOTH_PAIRING_BLUEZ_H_ #include "device/bluetooth/bluetooth_device.h" #include "device/bluetooth/dbus/bluetooth_agent_service_provider.h" -namespace chromeos { +namespace bluez { -class BluetoothDeviceChromeOS; +class BluetoothDeviceBlueZ; -// The BluetoothPairingChromeOS class encapsulates the logic for an individual -// device pairing, acting as a bridge between BluetoothAdapterChromeOS which +// The BluetoothPairingBlueZ class encapsulates the logic for an individual +// device pairing, acting as a bridge between BluetoothAdapterBlueZ which // communicates with the underlying Controller and Host Subsystem, and -// BluetoothDeviceChromeOS which presents the pairing logic to the application. -class BluetoothPairingChromeOS { +// BluetoothDeviceBlueZ which presents the pairing logic to the application. +class BluetoothPairingBlueZ { public: - BluetoothPairingChromeOS( - BluetoothDeviceChromeOS* device, + BluetoothPairingBlueZ( + BluetoothDeviceBlueZ* device, device::BluetoothDevice::PairingDelegate* pairing_delegate); - ~BluetoothPairingChromeOS(); + ~BluetoothPairingBlueZ(); // Indicates whether the device is currently pairing and expecting a // Passkey to be returned. @@ -117,8 +117,8 @@ class BluetoothPairingChromeOS { bool RunPairingCallbacks( bluez::BluetoothAgentServiceProvider::Delegate::Status status); - // The underlying BluetoothDeviceChromeOS that owns this pairing context. - BluetoothDeviceChromeOS* device_; + // The underlying BluetoothDeviceBlueZ that owns this pairing context. + BluetoothDeviceBlueZ* device_; // UI Pairing Delegate to make method calls on, this must live as long as // the object capturing the PairingContext. @@ -130,7 +130,7 @@ class BluetoothPairingChromeOS { bool pairing_delegate_used_; // During pairing these callbacks are set to those provided by method calls - // made on the BluetoothAdapterChromeOS instance by its respective + // made on the BluetoothAdapterBlueZ instance by its respective // bluez::BluetoothAgentServiceProvider instance, and are called by our own // method calls such as SetPinCode() and SetPasskey(). bluez::BluetoothAgentServiceProvider::Delegate::PinCodeCallback @@ -140,9 +140,9 @@ class BluetoothPairingChromeOS { bluez::BluetoothAgentServiceProvider::Delegate::ConfirmationCallback confirmation_callback_; - DISALLOW_COPY_AND_ASSIGN(BluetoothPairingChromeOS); + DISALLOW_COPY_AND_ASSIGN(BluetoothPairingBlueZ); }; -} // namespace chromeos +} // namespace bluez -#endif // DEVICE_BLUETOOTH_BLUETOOTH_PAIRING_CHROMEOS_H_ +#endif // DEVICE_BLUETOOTH_BLUETOOTH_PAIRING_BLUEZ_H_ diff --git a/device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.cc b/device/bluetooth/bluetooth_remote_gatt_characteristic_bluez.cc index 7374f16..75c6f1a 100644 --- a/device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.cc +++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_bluez.cc @@ -2,22 +2,22 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h" +#include "device/bluetooth/bluetooth_remote_gatt_characteristic_bluez.h" #include <limits> #include "base/logging.h" #include "base/strings/stringprintf.h" -#include "device/bluetooth/bluetooth_adapter_chromeos.h" +#include "device/bluetooth/bluetooth_adapter_bluez.h" #include "device/bluetooth/bluetooth_device.h" -#include "device/bluetooth/bluetooth_gatt_notify_session_chromeos.h" -#include "device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h" -#include "device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.h" -#include "device/bluetooth/bluetooth_remote_gatt_service_chromeos.h" +#include "device/bluetooth/bluetooth_gatt_notify_session_bluez.h" +#include "device/bluetooth/bluetooth_remote_gatt_characteristic_bluez.h" +#include "device/bluetooth/bluetooth_remote_gatt_descriptor_bluez.h" +#include "device/bluetooth/bluetooth_remote_gatt_service_bluez.h" #include "device/bluetooth/dbus/bluez_dbus_manager.h" #include "third_party/cros_system_api/dbus/service_constants.h" -namespace chromeos { +namespace bluez { namespace { @@ -33,10 +33,9 @@ std::ostream& operator<<(std::ostream& out, const std::vector<uint8> bytes) { } // namespace -BluetoothRemoteGattCharacteristicChromeOS:: - BluetoothRemoteGattCharacteristicChromeOS( - BluetoothRemoteGattServiceChromeOS* service, - const dbus::ObjectPath& object_path) +BluetoothRemoteGattCharacteristicBlueZ::BluetoothRemoteGattCharacteristicBlueZ( + BluetoothRemoteGattServiceBlueZ* service, + const dbus::ObjectPath& object_path) : object_path_(object_path), service_(service), num_notify_sessions_(0), @@ -58,8 +57,8 @@ BluetoothRemoteGattCharacteristicChromeOS:: GattDescriptorAdded(*iter); } -BluetoothRemoteGattCharacteristicChromeOS:: - ~BluetoothRemoteGattCharacteristicChromeOS() { +BluetoothRemoteGattCharacteristicBlueZ:: + ~BluetoothRemoteGattCharacteristicBlueZ() { bluez::BluezDBusManager::Get() ->GetBluetoothGattDescriptorClient() ->RemoveObserver(this); @@ -78,12 +77,11 @@ BluetoothRemoteGattCharacteristicChromeOS:: } } -std::string BluetoothRemoteGattCharacteristicChromeOS::GetIdentifier() const { +std::string BluetoothRemoteGattCharacteristicBlueZ::GetIdentifier() const { return object_path_.value(); } -device::BluetoothUUID -BluetoothRemoteGattCharacteristicChromeOS::GetUUID() const { +device::BluetoothUUID BluetoothRemoteGattCharacteristicBlueZ::GetUUID() const { bluez::BluetoothGattCharacteristicClient::Properties* properties = bluez::BluezDBusManager::Get() ->GetBluetoothGattCharacteristicClient() @@ -92,12 +90,12 @@ BluetoothRemoteGattCharacteristicChromeOS::GetUUID() const { return device::BluetoothUUID(properties->uuid.value()); } -bool BluetoothRemoteGattCharacteristicChromeOS::IsLocal() const { +bool BluetoothRemoteGattCharacteristicBlueZ::IsLocal() const { return false; } -const std::vector<uint8>& -BluetoothRemoteGattCharacteristicChromeOS::GetValue() const { +const std::vector<uint8>& BluetoothRemoteGattCharacteristicBlueZ::GetValue() + const { bluez::BluetoothGattCharacteristicClient::Properties* properties = bluez::BluezDBusManager::Get() ->GetBluetoothGattCharacteristicClient() @@ -109,12 +107,12 @@ BluetoothRemoteGattCharacteristicChromeOS::GetValue() const { } device::BluetoothGattService* -BluetoothRemoteGattCharacteristicChromeOS::GetService() const { +BluetoothRemoteGattCharacteristicBlueZ::GetService() const { return service_; } device::BluetoothGattCharacteristic::Properties -BluetoothRemoteGattCharacteristicChromeOS::GetProperties() const { +BluetoothRemoteGattCharacteristicBlueZ::GetProperties() const { bluez::BluetoothGattCharacteristicClient::Properties* properties = bluez::BluezDBusManager::Get() ->GetBluetoothGattCharacteristicClient() @@ -124,8 +122,7 @@ BluetoothRemoteGattCharacteristicChromeOS::GetProperties() const { Properties props = PROPERTY_NONE; const std::vector<std::string>& flags = properties->flags.value(); for (std::vector<std::string>::const_iterator iter = flags.begin(); - iter != flags.end(); - ++iter) { + iter != flags.end(); ++iter) { if (*iter == bluetooth_gatt_characteristic::kFlagBroadcast) props |= PROPERTY_BROADCAST; if (*iter == bluetooth_gatt_characteristic::kFlagRead) @@ -152,13 +149,13 @@ BluetoothRemoteGattCharacteristicChromeOS::GetProperties() const { } device::BluetoothGattCharacteristic::Permissions -BluetoothRemoteGattCharacteristicChromeOS::GetPermissions() const { +BluetoothRemoteGattCharacteristicBlueZ::GetPermissions() const { // TODO(armansito): Once BlueZ defines the permissions, return the correct // values here. return PERMISSION_NONE; } -bool BluetoothRemoteGattCharacteristicChromeOS::IsNotifying() const { +bool BluetoothRemoteGattCharacteristicBlueZ::IsNotifying() const { bluez::BluetoothGattCharacteristicClient::Properties* properties = bluez::BluezDBusManager::Get() ->GetBluetoothGattCharacteristicClient() @@ -169,7 +166,7 @@ bool BluetoothRemoteGattCharacteristicChromeOS::IsNotifying() const { } std::vector<device::BluetoothGattDescriptor*> -BluetoothRemoteGattCharacteristicChromeOS::GetDescriptors() const { +BluetoothRemoteGattCharacteristicBlueZ::GetDescriptors() const { std::vector<device::BluetoothGattDescriptor*> descriptors; for (DescriptorMap::const_iterator iter = descriptors_.begin(); iter != descriptors_.end(); ++iter) @@ -178,7 +175,7 @@ BluetoothRemoteGattCharacteristicChromeOS::GetDescriptors() const { } device::BluetoothGattDescriptor* -BluetoothRemoteGattCharacteristicChromeOS::GetDescriptor( +BluetoothRemoteGattCharacteristicBlueZ::GetDescriptor( const std::string& identifier) const { DescriptorMap::const_iterator iter = descriptors_.find(dbus::ObjectPath(identifier)); @@ -187,19 +184,19 @@ BluetoothRemoteGattCharacteristicChromeOS::GetDescriptor( return iter->second; } -bool BluetoothRemoteGattCharacteristicChromeOS::AddDescriptor( +bool BluetoothRemoteGattCharacteristicBlueZ::AddDescriptor( device::BluetoothGattDescriptor* descriptor) { VLOG(1) << "Descriptors cannot be added to a remote GATT characteristic."; return false; } -bool BluetoothRemoteGattCharacteristicChromeOS::UpdateValue( +bool BluetoothRemoteGattCharacteristicBlueZ::UpdateValue( const std::vector<uint8>& value) { VLOG(1) << "Cannot update the value of a remote GATT characteristic."; return false; } -void BluetoothRemoteGattCharacteristicChromeOS::ReadRemoteCharacteristic( +void BluetoothRemoteGattCharacteristicBlueZ::ReadRemoteCharacteristic( const ValueCallback& callback, const ErrorCallback& error_callback) { VLOG(1) << "Sending GATT characteristic read request to characteristic: " @@ -208,13 +205,12 @@ void BluetoothRemoteGattCharacteristicChromeOS::ReadRemoteCharacteristic( bluez::BluezDBusManager::Get() ->GetBluetoothGattCharacteristicClient() - ->ReadValue( - object_path_, callback, - base::Bind(&BluetoothRemoteGattCharacteristicChromeOS::OnError, - weak_ptr_factory_.GetWeakPtr(), error_callback)); + ->ReadValue(object_path_, callback, + base::Bind(&BluetoothRemoteGattCharacteristicBlueZ::OnError, + weak_ptr_factory_.GetWeakPtr(), error_callback)); } -void BluetoothRemoteGattCharacteristicChromeOS::WriteRemoteCharacteristic( +void BluetoothRemoteGattCharacteristicBlueZ::WriteRemoteCharacteristic( const std::vector<uint8>& new_value, const base::Closure& callback, const ErrorCallback& error_callback) { @@ -224,13 +220,12 @@ void BluetoothRemoteGattCharacteristicChromeOS::WriteRemoteCharacteristic( bluez::BluezDBusManager::Get() ->GetBluetoothGattCharacteristicClient() - ->WriteValue( - object_path_, new_value, callback, - base::Bind(&BluetoothRemoteGattCharacteristicChromeOS::OnError, - weak_ptr_factory_.GetWeakPtr(), error_callback)); + ->WriteValue(object_path_, new_value, callback, + base::Bind(&BluetoothRemoteGattCharacteristicBlueZ::OnError, + weak_ptr_factory_.GetWeakPtr(), error_callback)); } -void BluetoothRemoteGattCharacteristicChromeOS::StartNotifySession( +void BluetoothRemoteGattCharacteristicBlueZ::StartNotifySession( const NotifySessionCallback& callback, const ErrorCallback& error_callback) { VLOG(1) << __func__; @@ -253,12 +248,9 @@ void BluetoothRemoteGattCharacteristicChromeOS::StartNotifySession( DCHECK(service_->GetAdapter()); DCHECK(service_->GetDevice()); scoped_ptr<device::BluetoothGattNotifySession> session( - new BluetoothGattNotifySessionChromeOS( - service_->GetAdapter(), - service_->GetDevice()->GetAddress(), - service_->GetIdentifier(), - GetIdentifier(), - object_path_)); + new BluetoothGattNotifySessionBlueZ( + service_->GetAdapter(), service_->GetDevice()->GetAddress(), + service_->GetIdentifier(), GetIdentifier(), object_path_)); callback.Run(session.Pass()); return; } @@ -278,14 +270,14 @@ void BluetoothRemoteGattCharacteristicChromeOS::StartNotifySession( ->StartNotify( object_path_, base::Bind( - &BluetoothRemoteGattCharacteristicChromeOS::OnStartNotifySuccess, + &BluetoothRemoteGattCharacteristicBlueZ::OnStartNotifySuccess, weak_ptr_factory_.GetWeakPtr(), callback), base::Bind( - &BluetoothRemoteGattCharacteristicChromeOS::OnStartNotifyError, + &BluetoothRemoteGattCharacteristicBlueZ::OnStartNotifyError, weak_ptr_factory_.GetWeakPtr(), error_callback)); } -void BluetoothRemoteGattCharacteristicChromeOS::RemoveNotifySession( +void BluetoothRemoteGattCharacteristicBlueZ::RemoveNotifySession( const base::Closure& callback) { VLOG(1) << __func__; @@ -316,14 +308,13 @@ void BluetoothRemoteGattCharacteristicChromeOS::RemoveNotifySession( ->StopNotify( object_path_, base::Bind( - &BluetoothRemoteGattCharacteristicChromeOS::OnStopNotifySuccess, + &BluetoothRemoteGattCharacteristicBlueZ::OnStopNotifySuccess, weak_ptr_factory_.GetWeakPtr(), callback), - base::Bind( - &BluetoothRemoteGattCharacteristicChromeOS::OnStopNotifyError, - weak_ptr_factory_.GetWeakPtr(), callback)); + base::Bind(&BluetoothRemoteGattCharacteristicBlueZ::OnStopNotifyError, + weak_ptr_factory_.GetWeakPtr(), callback)); } -void BluetoothRemoteGattCharacteristicChromeOS::GattDescriptorAdded( +void BluetoothRemoteGattCharacteristicBlueZ::GattDescriptorAdded( const dbus::ObjectPath& object_path) { if (descriptors_.find(object_path) != descriptors_.end()) { VLOG(1) << "Remote GATT characteristic descriptor already exists: " @@ -344,8 +335,8 @@ void BluetoothRemoteGattCharacteristicChromeOS::GattDescriptorAdded( VLOG(1) << "Adding new remote GATT descriptor for GATT characteristic: " << GetIdentifier() << ", UUID: " << GetUUID().canonical_value(); - BluetoothRemoteGattDescriptorChromeOS* descriptor = - new BluetoothRemoteGattDescriptorChromeOS(this, object_path); + BluetoothRemoteGattDescriptorBlueZ* descriptor = + new BluetoothRemoteGattDescriptorBlueZ(this, object_path); descriptors_[object_path] = descriptor; DCHECK(descriptor->GetIdentifier() == object_path.value()); DCHECK(descriptor->GetUUID().IsValid()); @@ -354,7 +345,7 @@ void BluetoothRemoteGattCharacteristicChromeOS::GattDescriptorAdded( service_->NotifyDescriptorAddedOrRemoved(this, descriptor, true /* added */); } -void BluetoothRemoteGattCharacteristicChromeOS::GattDescriptorRemoved( +void BluetoothRemoteGattCharacteristicBlueZ::GattDescriptorRemoved( const dbus::ObjectPath& object_path) { DescriptorMap::iterator iter = descriptors_.find(object_path); if (iter == descriptors_.end()) { @@ -365,7 +356,7 @@ void BluetoothRemoteGattCharacteristicChromeOS::GattDescriptorRemoved( VLOG(1) << "Removing remote GATT descriptor from characteristic: " << GetIdentifier() << ", UUID: " << GetUUID().canonical_value(); - BluetoothRemoteGattDescriptorChromeOS* descriptor = iter->second; + BluetoothRemoteGattDescriptorBlueZ* descriptor = iter->second; DCHECK(descriptor->object_path() == object_path); descriptors_.erase(iter); @@ -375,7 +366,7 @@ void BluetoothRemoteGattCharacteristicChromeOS::GattDescriptorRemoved( delete descriptor; } -void BluetoothRemoteGattCharacteristicChromeOS::GattDescriptorPropertyChanged( +void BluetoothRemoteGattCharacteristicBlueZ::GattDescriptorPropertyChanged( const dbus::ObjectPath& object_path, const std::string& property_name) { DescriptorMap::iterator iter = descriptors_.find(object_path); @@ -399,17 +390,17 @@ void BluetoothRemoteGattCharacteristicChromeOS::GattDescriptorPropertyChanged( properties->value.value()); } -void BluetoothRemoteGattCharacteristicChromeOS::OnError( +void BluetoothRemoteGattCharacteristicBlueZ::OnError( const ErrorCallback& error_callback, const std::string& error_name, const std::string& error_message) { - VLOG(1) << "Operation failed: " << error_name << ", message: " - << error_message; + VLOG(1) << "Operation failed: " << error_name + << ", message: " << error_message; error_callback.Run( - BluetoothRemoteGattServiceChromeOS::DBusErrorToServiceError(error_name)); + BluetoothRemoteGattServiceBlueZ::DBusErrorToServiceError(error_name)); } -void BluetoothRemoteGattCharacteristicChromeOS::OnStartNotifySuccess( +void BluetoothRemoteGattCharacteristicBlueZ::OnStartNotifySuccess( const NotifySessionCallback& callback) { VLOG(1) << "Started notifications from characteristic: " << object_path_.value(); @@ -423,18 +414,15 @@ void BluetoothRemoteGattCharacteristicChromeOS::OnStartNotifySuccess( DCHECK(service_); DCHECK(service_->GetDevice()); scoped_ptr<device::BluetoothGattNotifySession> session( - new BluetoothGattNotifySessionChromeOS( - service_->GetAdapter(), - service_->GetDevice()->GetAddress(), - service_->GetIdentifier(), - GetIdentifier(), - object_path_)); + new BluetoothGattNotifySessionBlueZ( + service_->GetAdapter(), service_->GetDevice()->GetAddress(), + service_->GetIdentifier(), GetIdentifier(), object_path_)); callback.Run(session.Pass()); ProcessStartNotifyQueue(); } -void BluetoothRemoteGattCharacteristicChromeOS::OnStartNotifyError( +void BluetoothRemoteGattCharacteristicBlueZ::OnStartNotifyError( const ErrorCallback& error_callback, const std::string& error_name, const std::string& error_message) { @@ -447,12 +435,12 @@ void BluetoothRemoteGattCharacteristicChromeOS::OnStartNotifyError( notify_call_pending_ = false; error_callback.Run( - BluetoothRemoteGattServiceChromeOS::DBusErrorToServiceError(error_name)); + BluetoothRemoteGattServiceBlueZ::DBusErrorToServiceError(error_name)); ProcessStartNotifyQueue(); } -void BluetoothRemoteGattCharacteristicChromeOS::OnStopNotifySuccess( +void BluetoothRemoteGattCharacteristicBlueZ::OnStopNotifySuccess( const base::Closure& callback) { DCHECK(notify_call_pending_); DCHECK(num_notify_sessions_ == 1); @@ -464,7 +452,7 @@ void BluetoothRemoteGattCharacteristicChromeOS::OnStopNotifySuccess( ProcessStartNotifyQueue(); } -void BluetoothRemoteGattCharacteristicChromeOS::OnStopNotifyError( +void BluetoothRemoteGattCharacteristicBlueZ::OnStopNotifyError( const base::Closure& callback, const std::string& error_name, const std::string& error_message) { @@ -476,7 +464,7 @@ void BluetoothRemoteGattCharacteristicChromeOS::OnStopNotifyError( OnStopNotifySuccess(callback); } -void BluetoothRemoteGattCharacteristicChromeOS::ProcessStartNotifyQueue() { +void BluetoothRemoteGattCharacteristicBlueZ::ProcessStartNotifyQueue() { while (!pending_start_notify_calls_.empty()) { PendingStartNotifyCall callbacks = pending_start_notify_calls_.front(); pending_start_notify_calls_.pop(); @@ -484,4 +472,4 @@ void BluetoothRemoteGattCharacteristicChromeOS::ProcessStartNotifyQueue() { } } -} // namespace chromeos +} // namespace bluez diff --git a/device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h b/device/bluetooth/bluetooth_remote_gatt_characteristic_bluez.h index 361b319..c366574 100644 --- a/device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h +++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_bluez.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_CHROMEOS_H_ -#define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_CHROMEOS_H_ +#ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_BLUEZ_H_ +#define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_BLUEZ_H_ #include <map> #include <queue> @@ -24,15 +24,15 @@ class BluetoothGattService; } // namespace device -namespace chromeos { +namespace bluez { -class BluetoothRemoteGattDescriptorChromeOS; -class BluetoothRemoteGattServiceChromeOS; +class BluetoothRemoteGattDescriptorBlueZ; +class BluetoothRemoteGattServiceBlueZ; -// The BluetoothRemoteGattCharacteristicChromeOS class implements +// The BluetoothRemoteGattCharacteristicBlueZ class implements // BluetoothGattCharacteristic for remote GATT characteristics on the Chrome OS // platform. -class BluetoothRemoteGattCharacteristicChromeOS +class BluetoothRemoteGattCharacteristicBlueZ : public device::BluetoothGattCharacteristic, public bluez::BluetoothGattDescriptorClient::Observer { public: @@ -68,15 +68,15 @@ class BluetoothRemoteGattCharacteristicChromeOS const dbus::ObjectPath& object_path() const { return object_path_; } private: - friend class BluetoothRemoteGattServiceChromeOS; + friend class BluetoothRemoteGattServiceBlueZ; typedef std::pair<NotifySessionCallback, ErrorCallback> PendingStartNotifyCall; - BluetoothRemoteGattCharacteristicChromeOS( - BluetoothRemoteGattServiceChromeOS* service, + BluetoothRemoteGattCharacteristicBlueZ( + BluetoothRemoteGattServiceBlueZ* service, const dbus::ObjectPath& object_path); - ~BluetoothRemoteGattCharacteristicChromeOS() override; + ~BluetoothRemoteGattCharacteristicBlueZ() override; // bluez::BluetoothGattDescriptorClient::Observer overrides. void GattDescriptorAdded(const dbus::ObjectPath& object_path) override; @@ -117,7 +117,7 @@ class BluetoothRemoteGattCharacteristicChromeOS dbus::ObjectPath object_path_; // The GATT service this GATT characteristic belongs to. - BluetoothRemoteGattServiceChromeOS* service_; + BluetoothRemoteGattServiceBlueZ* service_; // The total number of currently active value update sessions. size_t num_notify_sessions_; @@ -133,18 +133,18 @@ class BluetoothRemoteGattCharacteristicChromeOS // this characteristic. Since the Chrome OS implementation uses object paths // as unique identifiers, we also use this mapping to return descriptors by // identifier. - typedef std::map<dbus::ObjectPath, BluetoothRemoteGattDescriptorChromeOS*> + typedef std::map<dbus::ObjectPath, BluetoothRemoteGattDescriptorBlueZ*> DescriptorMap; DescriptorMap descriptors_; // Note: This should remain the last member so it'll be destroyed and // invalidate its weak pointers before any other members are destroyed. - base::WeakPtrFactory<BluetoothRemoteGattCharacteristicChromeOS> + base::WeakPtrFactory<BluetoothRemoteGattCharacteristicBlueZ> weak_ptr_factory_; - DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicChromeOS); + DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicBlueZ); }; -} // namespace chromeos +} // namespace bluez -#endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_CHROMEOS_H_ +#endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_BLUEZ_H_ diff --git a/device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.cc b/device/bluetooth/bluetooth_remote_gatt_descriptor_bluez.cc index f864c3b..4bf9ab0 100644 --- a/device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.cc +++ b/device/bluetooth/bluetooth_remote_gatt_descriptor_bluez.cc @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.h" +#include "device/bluetooth/bluetooth_remote_gatt_descriptor_bluez.h" #include "base/bind.h" #include "base/logging.h" #include "base/strings/stringprintf.h" -#include "device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h" -#include "device/bluetooth/bluetooth_remote_gatt_service_chromeos.h" +#include "device/bluetooth/bluetooth_remote_gatt_characteristic_bluez.h" +#include "device/bluetooth/bluetooth_remote_gatt_service_bluez.h" #include "device/bluetooth/dbus/bluetooth_gatt_descriptor_client.h" #include "device/bluetooth/dbus/bluez_dbus_manager.h" -namespace chromeos { +namespace bluez { namespace { @@ -28,8 +28,8 @@ std::ostream& operator<<(std::ostream& out, const std::vector<uint8> bytes) { } // namespace -BluetoothRemoteGattDescriptorChromeOS::BluetoothRemoteGattDescriptorChromeOS( - BluetoothRemoteGattCharacteristicChromeOS* characteristic, +BluetoothRemoteGattDescriptorBlueZ::BluetoothRemoteGattDescriptorBlueZ( + BluetoothRemoteGattCharacteristicBlueZ* characteristic, const dbus::ObjectPath& object_path) : object_path_(object_path), characteristic_(characteristic), @@ -38,15 +38,13 @@ BluetoothRemoteGattDescriptorChromeOS::BluetoothRemoteGattDescriptorChromeOS( << GetIdentifier() << ", UUID: " << GetUUID().canonical_value(); } -BluetoothRemoteGattDescriptorChromeOS:: - ~BluetoothRemoteGattDescriptorChromeOS() { -} +BluetoothRemoteGattDescriptorBlueZ::~BluetoothRemoteGattDescriptorBlueZ() {} -std::string BluetoothRemoteGattDescriptorChromeOS::GetIdentifier() const { +std::string BluetoothRemoteGattDescriptorBlueZ::GetIdentifier() const { return object_path_.value(); } -device::BluetoothUUID BluetoothRemoteGattDescriptorChromeOS::GetUUID() const { +device::BluetoothUUID BluetoothRemoteGattDescriptorBlueZ::GetUUID() const { bluez::BluetoothGattDescriptorClient::Properties* properties = bluez::BluezDBusManager::Get() ->GetBluetoothGattDescriptorClient() @@ -55,12 +53,11 @@ device::BluetoothUUID BluetoothRemoteGattDescriptorChromeOS::GetUUID() const { return device::BluetoothUUID(properties->uuid.value()); } -bool BluetoothRemoteGattDescriptorChromeOS::IsLocal() const { +bool BluetoothRemoteGattDescriptorBlueZ::IsLocal() const { return false; } -const std::vector<uint8>& -BluetoothRemoteGattDescriptorChromeOS::GetValue() const { +const std::vector<uint8>& BluetoothRemoteGattDescriptorBlueZ::GetValue() const { bluez::BluetoothGattDescriptorClient::Properties* properties = bluez::BluezDBusManager::Get() ->GetBluetoothGattDescriptorClient() @@ -72,47 +69,47 @@ BluetoothRemoteGattDescriptorChromeOS::GetValue() const { } device::BluetoothGattCharacteristic* -BluetoothRemoteGattDescriptorChromeOS::GetCharacteristic() const { +BluetoothRemoteGattDescriptorBlueZ::GetCharacteristic() const { return characteristic_; } device::BluetoothGattCharacteristic::Permissions -BluetoothRemoteGattDescriptorChromeOS::GetPermissions() const { +BluetoothRemoteGattDescriptorBlueZ::GetPermissions() const { // TODO(armansito): Once BlueZ defines the permissions, return the correct // values here. return device::BluetoothGattCharacteristic::PERMISSION_NONE; } -void BluetoothRemoteGattDescriptorChromeOS::ReadRemoteDescriptor( +void BluetoothRemoteGattDescriptorBlueZ::ReadRemoteDescriptor( const ValueCallback& callback, const ErrorCallback& error_callback) { VLOG(1) << "Sending GATT characteristic descriptor read request to " - << "descriptor: " << GetIdentifier() << ", UUID: " - << GetUUID().canonical_value(); + << "descriptor: " << GetIdentifier() + << ", UUID: " << GetUUID().canonical_value(); bluez::BluezDBusManager::Get()->GetBluetoothGattDescriptorClient()->ReadValue( object_path_, callback, - base::Bind(&BluetoothRemoteGattDescriptorChromeOS::OnError, + base::Bind(&BluetoothRemoteGattDescriptorBlueZ::OnError, weak_ptr_factory_.GetWeakPtr(), error_callback)); } -void BluetoothRemoteGattDescriptorChromeOS::WriteRemoteDescriptor( +void BluetoothRemoteGattDescriptorBlueZ::WriteRemoteDescriptor( const std::vector<uint8>& new_value, const base::Closure& callback, const ErrorCallback& error_callback) { VLOG(1) << "Sending GATT characteristic descriptor write request to " - << "characteristic: " << GetIdentifier() << ", UUID: " - << GetUUID().canonical_value() << ", with value: " - << new_value << "."; + << "characteristic: " << GetIdentifier() + << ", UUID: " << GetUUID().canonical_value() + << ", with value: " << new_value << "."; bluez::BluezDBusManager::Get() ->GetBluetoothGattDescriptorClient() ->WriteValue(object_path_, new_value, callback, - base::Bind(&BluetoothRemoteGattDescriptorChromeOS::OnError, + base::Bind(&BluetoothRemoteGattDescriptorBlueZ::OnError, weak_ptr_factory_.GetWeakPtr(), error_callback)); } -void BluetoothRemoteGattDescriptorChromeOS::OnError( +void BluetoothRemoteGattDescriptorBlueZ::OnError( const ErrorCallback& error_callback, const std::string& error_name, const std::string& error_message) { @@ -120,7 +117,7 @@ void BluetoothRemoteGattDescriptorChromeOS::OnError( << ", message: " << error_message; error_callback.Run( - BluetoothRemoteGattServiceChromeOS::DBusErrorToServiceError(error_name)); + BluetoothRemoteGattServiceBlueZ::DBusErrorToServiceError(error_name)); } -} // namespace chromeos +} // namespace bluez diff --git a/device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.h b/device/bluetooth/bluetooth_remote_gatt_descriptor_bluez.h index b32dd87..138bffb 100644 --- a/device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.h +++ b/device/bluetooth/bluetooth_remote_gatt_descriptor_bluez.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_CHROMEOS_H_ -#define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_CHROMEOS_H_ +#ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_BLUEZ_H_ +#define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_BLUEZ_H_ #include <string> #include <vector> @@ -19,14 +19,14 @@ class BluetoothGattCharacteristic; } // namespace device -namespace chromeos { +namespace bluez { -class BluetoothRemoteGattCharacteristicChromeOS; +class BluetoothRemoteGattCharacteristicBlueZ; -// The BluetoothRemoteGattDescriptorChromeOS class implements +// The BluetoothRemoteGattDescriptorBlueZ class implements // BluetoothGattDescriptor for remote GATT characteristic descriptors on the // Chrome OS platform. -class BluetoothRemoteGattDescriptorChromeOS +class BluetoothRemoteGattDescriptorBlueZ : public device::BluetoothGattDescriptor { public: // device::BluetoothGattDescriptor overrides. @@ -47,12 +47,12 @@ class BluetoothRemoteGattDescriptorChromeOS const dbus::ObjectPath& object_path() const { return object_path_; } private: - friend class BluetoothRemoteGattCharacteristicChromeOS; + friend class BluetoothRemoteGattCharacteristicBlueZ; - BluetoothRemoteGattDescriptorChromeOS( - BluetoothRemoteGattCharacteristicChromeOS* characteristic, + BluetoothRemoteGattDescriptorBlueZ( + BluetoothRemoteGattCharacteristicBlueZ* characteristic, const dbus::ObjectPath& object_path); - ~BluetoothRemoteGattDescriptorChromeOS() override; + ~BluetoothRemoteGattDescriptorBlueZ() override; // Called by dbus:: on unsuccessful completion of a request to read or write // the descriptor value. @@ -64,15 +64,15 @@ class BluetoothRemoteGattDescriptorChromeOS dbus::ObjectPath object_path_; // The GATT characteristic this descriptor belongs to. - BluetoothRemoteGattCharacteristicChromeOS* characteristic_; + BluetoothRemoteGattCharacteristicBlueZ* characteristic_; // Note: This should remain the last member so it'll be destroyed and // invalidate its weak pointers before any other members are destroyed. - base::WeakPtrFactory<BluetoothRemoteGattDescriptorChromeOS> weak_ptr_factory_; + base::WeakPtrFactory<BluetoothRemoteGattDescriptorBlueZ> weak_ptr_factory_; - DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattDescriptorChromeOS); + DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattDescriptorBlueZ); }; -} // namespace chromeos +} // namespace bluez -#endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_CHROMEOS_H_ +#endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_BLUEZ_H_ diff --git a/device/bluetooth/bluetooth_remote_gatt_service_chromeos.cc b/device/bluetooth/bluetooth_remote_gatt_service_bluez.cc index 8a57fa2..e3fb5b1 100644 --- a/device/bluetooth/bluetooth_remote_gatt_service_chromeos.cc +++ b/device/bluetooth/bluetooth_remote_gatt_service_bluez.cc @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "device/bluetooth/bluetooth_remote_gatt_service_chromeos.h" +#include "device/bluetooth/bluetooth_remote_gatt_service_bluez.h" #include "base/logging.h" #include "base/strings/stringprintf.h" -#include "device/bluetooth/bluetooth_adapter_chromeos.h" -#include "device/bluetooth/bluetooth_device_chromeos.h" -#include "device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h" -#include "device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.h" +#include "device/bluetooth/bluetooth_adapter_bluez.h" +#include "device/bluetooth/bluetooth_device_bluez.h" +#include "device/bluetooth/bluetooth_remote_gatt_characteristic_bluez.h" +#include "device/bluetooth/bluetooth_remote_gatt_descriptor_bluez.h" #include "device/bluetooth/dbus/bluetooth_gatt_service_client.h" #include "device/bluetooth/dbus/bluez_dbus_manager.h" -namespace chromeos { +namespace bluez { namespace { @@ -28,9 +28,9 @@ const char kErrorNotPermitted[] = "org.bluez.Error.NotPermitted"; } // namespace -BluetoothRemoteGattServiceChromeOS::BluetoothRemoteGattServiceChromeOS( - BluetoothAdapterChromeOS* adapter, - BluetoothDeviceChromeOS* device, +BluetoothRemoteGattServiceBlueZ::BluetoothRemoteGattServiceBlueZ( + BluetoothAdapterBlueZ* adapter, + BluetoothDeviceBlueZ* device, const dbus::ObjectPath& object_path) : object_path_(object_path), adapter_(adapter), @@ -57,7 +57,7 @@ BluetoothRemoteGattServiceChromeOS::BluetoothRemoteGattServiceChromeOS( GattCharacteristicAdded(*iter); } -BluetoothRemoteGattServiceChromeOS::~BluetoothRemoteGattServiceChromeOS() { +BluetoothRemoteGattServiceBlueZ::~BluetoothRemoteGattServiceBlueZ() { bluez::BluezDBusManager::Get() ->GetBluetoothGattServiceClient() ->RemoveObserver(this); @@ -79,11 +79,11 @@ BluetoothRemoteGattServiceChromeOS::~BluetoothRemoteGattServiceChromeOS() { } } -std::string BluetoothRemoteGattServiceChromeOS::GetIdentifier() const { +std::string BluetoothRemoteGattServiceBlueZ::GetIdentifier() const { return object_path_.value(); } -device::BluetoothUUID BluetoothRemoteGattServiceChromeOS::GetUUID() const { +device::BluetoothUUID BluetoothRemoteGattServiceBlueZ::GetUUID() const { bluez::BluetoothGattServiceClient::Properties* properties = bluez::BluezDBusManager::Get() ->GetBluetoothGattServiceClient() @@ -92,11 +92,11 @@ device::BluetoothUUID BluetoothRemoteGattServiceChromeOS::GetUUID() const { return device::BluetoothUUID(properties->uuid.value()); } -bool BluetoothRemoteGattServiceChromeOS::IsLocal() const { +bool BluetoothRemoteGattServiceBlueZ::IsLocal() const { return false; } -bool BluetoothRemoteGattServiceChromeOS::IsPrimary() const { +bool BluetoothRemoteGattServiceBlueZ::IsPrimary() const { bluez::BluetoothGattServiceClient::Properties* properties = bluez::BluezDBusManager::Get() ->GetBluetoothGattServiceClient() @@ -105,12 +105,12 @@ bool BluetoothRemoteGattServiceChromeOS::IsPrimary() const { return properties->primary.value(); } -device::BluetoothDevice* BluetoothRemoteGattServiceChromeOS::GetDevice() const { +device::BluetoothDevice* BluetoothRemoteGattServiceBlueZ::GetDevice() const { return device_; } std::vector<device::BluetoothGattCharacteristic*> -BluetoothRemoteGattServiceChromeOS::GetCharacteristics() const { +BluetoothRemoteGattServiceBlueZ::GetCharacteristics() const { std::vector<device::BluetoothGattCharacteristic*> characteristics; for (CharacteristicMap::const_iterator iter = characteristics_.begin(); iter != characteristics_.end(); ++iter) { @@ -120,13 +120,13 @@ BluetoothRemoteGattServiceChromeOS::GetCharacteristics() const { } std::vector<device::BluetoothGattService*> -BluetoothRemoteGattServiceChromeOS::GetIncludedServices() const { +BluetoothRemoteGattServiceBlueZ::GetIncludedServices() const { // TODO(armansito): Return the actual included services here. return std::vector<device::BluetoothGattService*>(); } device::BluetoothGattCharacteristic* -BluetoothRemoteGattServiceChromeOS::GetCharacteristic( +BluetoothRemoteGattServiceBlueZ::GetCharacteristic( const std::string& identifier) const { CharacteristicMap::const_iterator iter = characteristics_.find(dbus::ObjectPath(identifier)); @@ -135,26 +135,26 @@ BluetoothRemoteGattServiceChromeOS::GetCharacteristic( return iter->second; } -bool BluetoothRemoteGattServiceChromeOS::AddCharacteristic( +bool BluetoothRemoteGattServiceBlueZ::AddCharacteristic( device::BluetoothGattCharacteristic* characteristic) { VLOG(1) << "Characteristics cannot be added to a remote GATT service."; return false; } -bool BluetoothRemoteGattServiceChromeOS::AddIncludedService( +bool BluetoothRemoteGattServiceBlueZ::AddIncludedService( device::BluetoothGattService* service) { VLOG(1) << "Included services cannot be added to a remote GATT service."; return false; } -void BluetoothRemoteGattServiceChromeOS::Register( +void BluetoothRemoteGattServiceBlueZ::Register( const base::Closure& callback, const ErrorCallback& error_callback) { VLOG(1) << "A remote GATT service cannot be registered."; error_callback.Run(); } -void BluetoothRemoteGattServiceChromeOS::Unregister( +void BluetoothRemoteGattServiceBlueZ::Unregister( const base::Closure& callback, const ErrorCallback& error_callback) { VLOG(1) << "A remote GATT service cannot be unregistered."; @@ -163,7 +163,7 @@ void BluetoothRemoteGattServiceChromeOS::Unregister( // static device::BluetoothGattService::GattErrorCode -BluetoothRemoteGattServiceChromeOS::DBusErrorToServiceError( +BluetoothRemoteGattServiceBlueZ::DBusErrorToServiceError( std::string error_name) { device::BluetoothGattService::GattErrorCode code = GATT_ERROR_UNKNOWN; if (error_name == kErrorFailed) { @@ -184,12 +184,11 @@ BluetoothRemoteGattServiceChromeOS::DBusErrorToServiceError( return code; } -BluetoothAdapterChromeOS* -BluetoothRemoteGattServiceChromeOS::GetAdapter() const { +BluetoothAdapterBlueZ* BluetoothRemoteGattServiceBlueZ::GetAdapter() const { return adapter_; } -void BluetoothRemoteGattServiceChromeOS::NotifyServiceChanged() { +void BluetoothRemoteGattServiceBlueZ::NotifyServiceChanged() { // Don't send service changed unless we know that all characteristics have // already been discovered. This is to prevent spammy events before sending // out the first Gatt @@ -200,9 +199,9 @@ void BluetoothRemoteGattServiceChromeOS::NotifyServiceChanged() { adapter_->NotifyGattServiceChanged(this); } -void BluetoothRemoteGattServiceChromeOS::NotifyDescriptorAddedOrRemoved( - BluetoothRemoteGattCharacteristicChromeOS* characteristic, - BluetoothRemoteGattDescriptorChromeOS* descriptor, +void BluetoothRemoteGattServiceBlueZ::NotifyDescriptorAddedOrRemoved( + BluetoothRemoteGattCharacteristicBlueZ* characteristic, + BluetoothRemoteGattDescriptorBlueZ* descriptor, bool added) { DCHECK(characteristic->GetService() == this); DCHECK(descriptor->GetCharacteristic() == characteristic); @@ -216,9 +215,9 @@ void BluetoothRemoteGattServiceChromeOS::NotifyDescriptorAddedOrRemoved( adapter_->NotifyGattDescriptorRemoved(descriptor); } -void BluetoothRemoteGattServiceChromeOS::NotifyDescriptorValueChanged( - BluetoothRemoteGattCharacteristicChromeOS* characteristic, - BluetoothRemoteGattDescriptorChromeOS* descriptor, +void BluetoothRemoteGattServiceBlueZ::NotifyDescriptorValueChanged( + BluetoothRemoteGattCharacteristicBlueZ* characteristic, + BluetoothRemoteGattDescriptorBlueZ* descriptor, const std::vector<uint8>& value) { DCHECK(characteristic->GetService() == this); DCHECK(descriptor->GetCharacteristic() == characteristic); @@ -226,9 +225,9 @@ void BluetoothRemoteGattServiceChromeOS::NotifyDescriptorValueChanged( adapter_->NotifyGattDescriptorValueChanged(descriptor, value); } -void BluetoothRemoteGattServiceChromeOS::GattServicePropertyChanged( +void BluetoothRemoteGattServiceBlueZ::GattServicePropertyChanged( const dbus::ObjectPath& object_path, - const std::string& property_name){ + const std::string& property_name) { if (object_path != object_path_) return; @@ -255,7 +254,7 @@ void BluetoothRemoteGattServiceChromeOS::GattServicePropertyChanged( adapter_->NotifyGattDiscoveryComplete(this); } -void BluetoothRemoteGattServiceChromeOS::GattCharacteristicAdded( +void BluetoothRemoteGattServiceBlueZ::GattCharacteristicAdded( const dbus::ObjectPath& object_path) { if (characteristics_.find(object_path) != characteristics_.end()) { VLOG(1) << "Remote GATT characteristic already exists: " @@ -276,8 +275,8 @@ void BluetoothRemoteGattServiceChromeOS::GattCharacteristicAdded( VLOG(1) << "Adding new remote GATT characteristic for GATT service: " << GetIdentifier() << ", UUID: " << GetUUID().canonical_value(); - BluetoothRemoteGattCharacteristicChromeOS* characteristic = - new BluetoothRemoteGattCharacteristicChromeOS(this, object_path); + BluetoothRemoteGattCharacteristicBlueZ* characteristic = + new BluetoothRemoteGattCharacteristicBlueZ(this, object_path); characteristics_[object_path] = characteristic; DCHECK(characteristic->GetIdentifier() == object_path.value()); DCHECK(characteristic->GetUUID().IsValid()); @@ -286,7 +285,7 @@ void BluetoothRemoteGattServiceChromeOS::GattCharacteristicAdded( adapter_->NotifyGattCharacteristicAdded(characteristic); } -void BluetoothRemoteGattServiceChromeOS::GattCharacteristicRemoved( +void BluetoothRemoteGattServiceBlueZ::GattCharacteristicRemoved( const dbus::ObjectPath& object_path) { CharacteristicMap::iterator iter = characteristics_.find(object_path); if (iter == characteristics_.end()) { @@ -297,7 +296,7 @@ void BluetoothRemoteGattServiceChromeOS::GattCharacteristicRemoved( VLOG(1) << "Removing remote GATT characteristic from service: " << GetIdentifier() << ", UUID: " << GetUUID().canonical_value(); - BluetoothRemoteGattCharacteristicChromeOS* characteristic = iter->second; + BluetoothRemoteGattCharacteristicBlueZ* characteristic = iter->second; DCHECK(characteristic->object_path() == object_path); characteristics_.erase(iter); @@ -307,7 +306,7 @@ void BluetoothRemoteGattServiceChromeOS::GattCharacteristicRemoved( delete characteristic; } -void BluetoothRemoteGattServiceChromeOS::GattCharacteristicPropertyChanged( +void BluetoothRemoteGattServiceBlueZ::GattCharacteristicPropertyChanged( const dbus::ObjectPath& object_path, const std::string& property_name) { CharacteristicMap::iterator iter = characteristics_.find(object_path); @@ -336,4 +335,4 @@ void BluetoothRemoteGattServiceChromeOS::GattCharacteristicPropertyChanged( properties->value.value()); } -} // namespace chromeos +} // namespace bluez diff --git a/device/bluetooth/bluetooth_remote_gatt_service_chromeos.h b/device/bluetooth/bluetooth_remote_gatt_service_bluez.h index bc35cb7..ce525f8 100644 --- a/device/bluetooth/bluetooth_remote_gatt_service_chromeos.h +++ b/device/bluetooth/bluetooth_remote_gatt_service_bluez.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_CHROMEOS_H_ -#define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_CHROMEOS_H_ +#ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_BLUEZ_H_ +#define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_BLUEZ_H_ #include <map> #include <string> @@ -25,16 +25,16 @@ class BluetoothGattCharacteristic; } // namespace device -namespace chromeos { +namespace bluez { -class BluetoothAdapterChromeOS; -class BluetoothDeviceChromeOS; -class BluetoothRemoteGattCharacteristicChromeOS; -class BluetoothRemoteGattDescriptorChromeOS; +class BluetoothAdapterBlueZ; +class BluetoothDeviceBlueZ; +class BluetoothRemoteGattCharacteristicBlueZ; +class BluetoothRemoteGattDescriptorBlueZ; -// The BluetoothRemoteGattServiceChromeOS class implements BluetootGattService +// The BluetoothRemoteGattServiceBlueZ class implements BluetootGattService // for remote GATT services on the Chrome OS platform. -class BluetoothRemoteGattServiceChromeOS +class BluetoothRemoteGattServiceBlueZ : public device::BluetoothGattService, public bluez::BluetoothGattServiceClient::Observer, public bluez::BluetoothGattCharacteristicClient::Observer { @@ -67,42 +67,42 @@ class BluetoothRemoteGattServiceChromeOS const std::string error_name); // Returns the adapter associated with this service. - BluetoothAdapterChromeOS* GetAdapter() const; + BluetoothAdapterBlueZ* GetAdapter() const; // Notifies its observers that the GATT service has changed. This is mainly - // used by BluetoothRemoteGattCharacteristicChromeOS instances to notify + // used by BluetoothRemoteGattCharacteristicBlueZ instances to notify // service observers when characteristic descriptors get added and removed. void NotifyServiceChanged(); // Notifies its observers that a descriptor |descriptor| belonging to // characteristic |characteristic| has been added or removed. This is used - // by BluetoothRemoteGattCharacteristicChromeOS instances to notify service + // by BluetoothRemoteGattCharacteristicBlueZ instances to notify service // observers when characteristic descriptors get added and removed. If |added| // is true, an "Added" event will be sent. Otherwise, a "Removed" event will // be sent. void NotifyDescriptorAddedOrRemoved( - BluetoothRemoteGattCharacteristicChromeOS* characteristic, - BluetoothRemoteGattDescriptorChromeOS* descriptor, + BluetoothRemoteGattCharacteristicBlueZ* characteristic, + BluetoothRemoteGattDescriptorBlueZ* descriptor, bool added); // Notifies its observers that the value of a descriptor has changed. Called - // by BluetoothRemoteGattCharacteristicChromeOS instances to notify service + // by BluetoothRemoteGattCharacteristicBlueZ instances to notify service // observers. void NotifyDescriptorValueChanged( - BluetoothRemoteGattCharacteristicChromeOS* characteristic, - BluetoothRemoteGattDescriptorChromeOS* descriptor, + BluetoothRemoteGattCharacteristicBlueZ* characteristic, + BluetoothRemoteGattDescriptorBlueZ* descriptor, const std::vector<uint8>& value); private: - friend class BluetoothDeviceChromeOS; + friend class BluetoothDeviceBlueZ; - typedef std::map<dbus::ObjectPath, BluetoothRemoteGattCharacteristicChromeOS*> + typedef std::map<dbus::ObjectPath, BluetoothRemoteGattCharacteristicBlueZ*> CharacteristicMap; - BluetoothRemoteGattServiceChromeOS(BluetoothAdapterChromeOS* adapter, - BluetoothDeviceChromeOS* device, - const dbus::ObjectPath& object_path); - ~BluetoothRemoteGattServiceChromeOS() override; + BluetoothRemoteGattServiceBlueZ(BluetoothAdapterBlueZ* adapter, + BluetoothDeviceBlueZ* device, + const dbus::ObjectPath& object_path); + ~BluetoothRemoteGattServiceBlueZ() override; // bluez::BluetoothGattServiceClient::Observer override. void GattServicePropertyChanged(const dbus::ObjectPath& object_path, @@ -120,11 +120,11 @@ class BluetoothRemoteGattServiceChromeOS // The adapter associated with this service. It's ok to store a raw pointer // here since |adapter_| indirectly owns this instance. - BluetoothAdapterChromeOS* adapter_; + BluetoothAdapterBlueZ* adapter_; // The device this GATT service belongs to. It's ok to store a raw pointer // here since |device_| owns this instance. - BluetoothDeviceChromeOS* device_; + BluetoothDeviceBlueZ* device_; // Mapping from GATT characteristic object paths to characteristic objects. // owned by this service. Since the Chrome OS implementation uses object @@ -138,11 +138,11 @@ class BluetoothRemoteGattServiceChromeOS // Note: This should remain the last member so it'll be destroyed and // invalidate its weak pointers before any other members are destroyed. - base::WeakPtrFactory<BluetoothRemoteGattServiceChromeOS> weak_ptr_factory_; + base::WeakPtrFactory<BluetoothRemoteGattServiceBlueZ> weak_ptr_factory_; - DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattServiceChromeOS); + DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattServiceBlueZ); }; -} // namespace chromeos +} // namespace bluez -#endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_CHROMEOS_H_ +#endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_BLUEZ_H_ diff --git a/device/bluetooth/bluetooth_socket_chromeos.cc b/device/bluetooth/bluetooth_socket_bluez.cc index b3e357d..46269c9 100644 --- a/device/bluetooth/bluetooth_socket_chromeos.cc +++ b/device/bluetooth/bluetooth_socket_bluez.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "device/bluetooth/bluetooth_socket_chromeos.h" +#include "device/bluetooth/bluetooth_socket_bluez.h" #include <queue> #include <string> @@ -24,10 +24,10 @@ #include "dbus/file_descriptor.h" #include "dbus/object_path.h" #include "device/bluetooth/bluetooth_adapter.h" -#include "device/bluetooth/bluetooth_adapter_chromeos.h" -#include "device/bluetooth/bluetooth_adapter_profile_chromeos.h" +#include "device/bluetooth/bluetooth_adapter_bluez.h" +#include "device/bluetooth/bluetooth_adapter_profile_bluez.h" #include "device/bluetooth/bluetooth_device.h" -#include "device/bluetooth/bluetooth_device_chromeos.h" +#include "device/bluetooth/bluetooth_device_bluez.h" #include "device/bluetooth/bluetooth_socket.h" #include "device/bluetooth/bluetooth_socket_net.h" #include "device/bluetooth/bluetooth_socket_thread.h" @@ -52,36 +52,33 @@ const char kSocketNotListening[] = "Socket is not listening."; } // namespace -namespace chromeos { +namespace bluez { // static -scoped_refptr<BluetoothSocketChromeOS> -BluetoothSocketChromeOS::CreateBluetoothSocket( +scoped_refptr<BluetoothSocketBlueZ> BluetoothSocketBlueZ::CreateBluetoothSocket( scoped_refptr<base::SequencedTaskRunner> ui_task_runner, scoped_refptr<BluetoothSocketThread> socket_thread) { DCHECK(ui_task_runner->RunsTasksOnCurrentThread()); return make_scoped_refptr( - new BluetoothSocketChromeOS(ui_task_runner, socket_thread)); + new BluetoothSocketBlueZ(ui_task_runner, socket_thread)); } -BluetoothSocketChromeOS::AcceptRequest::AcceptRequest() {} +BluetoothSocketBlueZ::AcceptRequest::AcceptRequest() {} -BluetoothSocketChromeOS::AcceptRequest::~AcceptRequest() {} +BluetoothSocketBlueZ::AcceptRequest::~AcceptRequest() {} -BluetoothSocketChromeOS::ConnectionRequest::ConnectionRequest() - : accepting(false), - cancelled(false) {} +BluetoothSocketBlueZ::ConnectionRequest::ConnectionRequest() + : accepting(false), cancelled(false) {} -BluetoothSocketChromeOS::ConnectionRequest::~ConnectionRequest() {} +BluetoothSocketBlueZ::ConnectionRequest::~ConnectionRequest() {} -BluetoothSocketChromeOS::BluetoothSocketChromeOS( +BluetoothSocketBlueZ::BluetoothSocketBlueZ( scoped_refptr<base::SequencedTaskRunner> ui_task_runner, scoped_refptr<BluetoothSocketThread> socket_thread) - : BluetoothSocketNet(ui_task_runner, socket_thread), profile_(nullptr) { -} + : BluetoothSocketNet(ui_task_runner, socket_thread), profile_(nullptr) {} -BluetoothSocketChromeOS::~BluetoothSocketChromeOS() { +BluetoothSocketBlueZ::~BluetoothSocketBlueZ() { DCHECK(!profile_); if (adapter_.get()) { @@ -90,8 +87,8 @@ BluetoothSocketChromeOS::~BluetoothSocketChromeOS() { } } -void BluetoothSocketChromeOS::Connect( - const BluetoothDeviceChromeOS* device, +void BluetoothSocketBlueZ::Connect( + const BluetoothDeviceBlueZ* device, const BluetoothUUID& uuid, SecurityLevel security_level, const base::Closure& success_callback, @@ -116,7 +113,7 @@ void BluetoothSocketChromeOS::Connect( RegisterProfile(device->adapter(), success_callback, error_callback); } -void BluetoothSocketChromeOS::Listen( +void BluetoothSocketBlueZ::Listen( scoped_refptr<BluetoothAdapter> adapter, SocketType socket_type, const BluetoothUUID& uuid, @@ -152,11 +149,11 @@ void BluetoothSocketChromeOS::Listen( NOTREACHED(); } - RegisterProfile(static_cast<BluetoothAdapterChromeOS*>(adapter.get()), + RegisterProfile(static_cast<BluetoothAdapterBlueZ*>(adapter.get()), success_callback, error_callback); } -void BluetoothSocketChromeOS::Close() { +void BluetoothSocketBlueZ::Close() { DCHECK(ui_task_runner()->RunsTasksOnCurrentThread()); if (profile_) @@ -178,7 +175,7 @@ void BluetoothSocketChromeOS::Close() { } } -void BluetoothSocketChromeOS::Disconnect(const base::Closure& callback) { +void BluetoothSocketBlueZ::Disconnect(const base::Closure& callback) { DCHECK(ui_task_runner()->RunsTasksOnCurrentThread()); if (profile_) @@ -192,7 +189,7 @@ void BluetoothSocketChromeOS::Disconnect(const base::Closure& callback) { } } -void BluetoothSocketChromeOS::Accept( +void BluetoothSocketBlueZ::Accept( const AcceptCompletionCallback& success_callback, const ErrorCompletionCallback& error_callback) { DCHECK(ui_task_runner()->RunsTasksOnCurrentThread()); @@ -217,8 +214,8 @@ void BluetoothSocketChromeOS::Accept( } } -void BluetoothSocketChromeOS::RegisterProfile( - BluetoothAdapterChromeOS* adapter, +void BluetoothSocketBlueZ::RegisterProfile( + BluetoothAdapterBlueZ* adapter, const base::Closure& success_callback, const ErrorCompletionCallback& error_callback) { DCHECK(ui_task_runner()->RunsTasksOnCurrentThread()); @@ -238,18 +235,17 @@ void BluetoothSocketChromeOS::RegisterProfile( VLOG(1) << uuid_.canonical_value() << " on " << device_path_.value() << ": Acquiring profile."; - adapter->UseProfile( - uuid_, device_path_, *options_, this, - base::Bind(&BluetoothSocketChromeOS::OnRegisterProfile, this, - success_callback, error_callback), - base::Bind(&BluetoothSocketChromeOS::OnRegisterProfileError, this, - error_callback)); + adapter->UseProfile(uuid_, device_path_, *options_, this, + base::Bind(&BluetoothSocketBlueZ::OnRegisterProfile, this, + success_callback, error_callback), + base::Bind(&BluetoothSocketBlueZ::OnRegisterProfileError, + this, error_callback)); } -void BluetoothSocketChromeOS::OnRegisterProfile( +void BluetoothSocketBlueZ::OnRegisterProfile( const base::Closure& success_callback, const ErrorCompletionCallback& error_callback, - BluetoothAdapterProfileChromeOS* profile) { + BluetoothAdapterProfileBlueZ* profile) { DCHECK(ui_task_runner()->RunsTasksOnCurrentThread()); DCHECK(!profile_); @@ -266,13 +262,13 @@ void BluetoothSocketChromeOS::OnRegisterProfile( bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->ConnectProfile( device_path_, uuid_.canonical_value(), - base::Bind(&BluetoothSocketChromeOS::OnConnectProfile, this, + base::Bind(&BluetoothSocketBlueZ::OnConnectProfile, this, success_callback), - base::Bind(&BluetoothSocketChromeOS::OnConnectProfileError, this, + base::Bind(&BluetoothSocketBlueZ::OnConnectProfileError, this, error_callback)); } -void BluetoothSocketChromeOS::OnRegisterProfileError( +void BluetoothSocketBlueZ::OnRegisterProfileError( const ErrorCompletionCallback& error_callback, const std::string& error_message) { DCHECK(ui_task_runner()->RunsTasksOnCurrentThread()); @@ -282,7 +278,7 @@ void BluetoothSocketChromeOS::OnRegisterProfileError( error_callback.Run(error_message); } -void BluetoothSocketChromeOS::OnConnectProfile( +void BluetoothSocketBlueZ::OnConnectProfile( const base::Closure& success_callback) { DCHECK(ui_task_runner()->RunsTasksOnCurrentThread()); DCHECK(profile_); @@ -292,7 +288,7 @@ void BluetoothSocketChromeOS::OnConnectProfile( success_callback.Run(); } -void BluetoothSocketChromeOS::OnConnectProfileError( +void BluetoothSocketBlueZ::OnConnectProfileError( const ErrorCompletionCallback& error_callback, const std::string& error_name, const std::string& error_message) { @@ -306,8 +302,8 @@ void BluetoothSocketChromeOS::OnConnectProfileError( error_callback.Run(error_message); } -void BluetoothSocketChromeOS::AdapterPresentChanged(BluetoothAdapter* adapter, - bool present) { +void BluetoothSocketBlueZ::AdapterPresentChanged(BluetoothAdapter* adapter, + bool present) { DCHECK(ui_task_runner()->RunsTasksOnCurrentThread()); if (!present) { @@ -321,15 +317,14 @@ void BluetoothSocketChromeOS::AdapterPresentChanged(BluetoothAdapter* adapter, VLOG(1) << uuid_.canonical_value() << " on " << device_path_.value() << ": Acquiring profile."; - static_cast<BluetoothAdapterChromeOS*>(adapter)->UseProfile( + static_cast<BluetoothAdapterBlueZ*>(adapter)->UseProfile( uuid_, device_path_, *options_, this, - base::Bind(&BluetoothSocketChromeOS::OnInternalRegisterProfile, this), - base::Bind(&BluetoothSocketChromeOS::OnInternalRegisterProfileError, - this)); + base::Bind(&BluetoothSocketBlueZ::OnInternalRegisterProfile, this), + base::Bind(&BluetoothSocketBlueZ::OnInternalRegisterProfileError, this)); } -void BluetoothSocketChromeOS::OnInternalRegisterProfile( - BluetoothAdapterProfileChromeOS* profile) { +void BluetoothSocketBlueZ::OnInternalRegisterProfile( + BluetoothAdapterProfileBlueZ* profile) { DCHECK(ui_task_runner()->RunsTasksOnCurrentThread()); DCHECK(!profile_); @@ -338,21 +333,21 @@ void BluetoothSocketChromeOS::OnInternalRegisterProfile( VLOG(1) << uuid_.canonical_value() << ": Profile re-registered"; } -void BluetoothSocketChromeOS::OnInternalRegisterProfileError( +void BluetoothSocketBlueZ::OnInternalRegisterProfileError( const std::string& error_message) { DCHECK(ui_task_runner()->RunsTasksOnCurrentThread()); LOG(WARNING) << "Failed to re-register profile: " << error_message; } -void BluetoothSocketChromeOS::Released() { +void BluetoothSocketBlueZ::Released() { DCHECK(ui_task_runner()->RunsTasksOnCurrentThread()); DCHECK(profile_); VLOG(1) << profile_->object_path().value() << ": Release"; } -void BluetoothSocketChromeOS::NewConnection( +void BluetoothSocketBlueZ::NewConnection( const dbus::ObjectPath& device_path, scoped_ptr<dbus::FileDescriptor> fd, const bluez::BluetoothProfileServiceProvider::Delegate::Options& options, @@ -367,13 +362,8 @@ void BluetoothSocketChromeOS::NewConnection( socket_thread()->task_runner()->PostTask( FROM_HERE, - base::Bind( - &BluetoothSocketChromeOS::DoNewConnection, - this, - device_path_, - base::Passed(&fd), - options, - callback)); + base::Bind(&BluetoothSocketBlueZ::DoNewConnection, this, device_path_, + base::Passed(&fd), options, callback)); } else { linked_ptr<ConnectionRequest> request(new ConnectionRequest()); request->device_path = device_path; @@ -389,7 +379,7 @@ void BluetoothSocketChromeOS::NewConnection( } } -void BluetoothSocketChromeOS::RequestDisconnection( +void BluetoothSocketBlueZ::RequestDisconnection( const dbus::ObjectPath& device_path, const ConfirmationCallback& callback) { DCHECK(ui_task_runner()->RunsTasksOnCurrentThread()); @@ -399,7 +389,7 @@ void BluetoothSocketChromeOS::RequestDisconnection( callback.Run(SUCCESS); } -void BluetoothSocketChromeOS::Cancel() { +void BluetoothSocketBlueZ::Cancel() { DCHECK(ui_task_runner()->RunsTasksOnCurrentThread()); DCHECK(profile_); @@ -418,7 +408,7 @@ void BluetoothSocketChromeOS::Cancel() { } } -void BluetoothSocketChromeOS::AcceptConnectionRequest() { +void BluetoothSocketBlueZ::AcceptConnectionRequest() { DCHECK(ui_task_runner()->RunsTasksOnCurrentThread()); DCHECK(accept_request_.get()); DCHECK(connection_request_queue_.size() >= 1); @@ -430,14 +420,14 @@ void BluetoothSocketChromeOS::AcceptConnectionRequest() { linked_ptr<ConnectionRequest> request = connection_request_queue_.front(); request->accepting = true; - BluetoothDeviceChromeOS* device = - static_cast<BluetoothAdapterChromeOS*>(adapter_.get())-> - GetDeviceWithPath(request->device_path); + BluetoothDeviceBlueZ* device = + static_cast<BluetoothAdapterBlueZ*>(adapter_.get()) + ->GetDeviceWithPath(request->device_path); DCHECK(device); - scoped_refptr<BluetoothSocketChromeOS> client_socket = - BluetoothSocketChromeOS::CreateBluetoothSocket( - ui_task_runner(), socket_thread()); + scoped_refptr<BluetoothSocketBlueZ> client_socket = + BluetoothSocketBlueZ::CreateBluetoothSocket(ui_task_runner(), + socket_thread()); client_socket->device_address_ = device->GetAddress(); client_socket->device_path_ = request->device_path; @@ -445,19 +435,14 @@ void BluetoothSocketChromeOS::AcceptConnectionRequest() { socket_thread()->task_runner()->PostTask( FROM_HERE, - base::Bind( - &BluetoothSocketChromeOS::DoNewConnection, - client_socket, - request->device_path, - base::Passed(&request->fd), - request->options, - base::Bind(&BluetoothSocketChromeOS::OnNewConnection, - this, - client_socket, - request->callback))); + base::Bind(&BluetoothSocketBlueZ::DoNewConnection, client_socket, + request->device_path, base::Passed(&request->fd), + request->options, + base::Bind(&BluetoothSocketBlueZ::OnNewConnection, this, + client_socket, request->callback))); } -void BluetoothSocketChromeOS::DoNewConnection( +void BluetoothSocketBlueZ::DoNewConnection( const dbus::ObjectPath& device_path, scoped_ptr<dbus::FileDescriptor> fd, const bluez::BluetoothProfileServiceProvider::Delegate::Options& options, @@ -470,15 +455,15 @@ void BluetoothSocketChromeOS::DoNewConnection( if (!fd->is_valid()) { LOG(WARNING) << uuid_.canonical_value() << " :" << fd->value() << ": Invalid file descriptor received from Bluetooth Daemon."; - ui_task_runner()->PostTask(FROM_HERE, - base::Bind(callback, REJECTED));; + ui_task_runner()->PostTask(FROM_HERE, base::Bind(callback, REJECTED)); + ; return; } if (tcp_socket()) { LOG(WARNING) << uuid_.canonical_value() << ": Already connected"; - ui_task_runner()->PostTask(FROM_HERE, - base::Bind(callback, REJECTED));; + ui_task_runner()->PostTask(FROM_HERE, base::Bind(callback, REJECTED)); + ; return; } @@ -486,24 +471,24 @@ void BluetoothSocketChromeOS::DoNewConnection( // Note: We don't have a meaningful |IPEndPoint|, but that is ok since the // TCPSocket implementation does not actually require one. - int net_result = tcp_socket()->AdoptConnectedSocket(fd->value(), - net::IPEndPoint()); + int net_result = + tcp_socket()->AdoptConnectedSocket(fd->value(), net::IPEndPoint()); if (net_result != net::OK) { LOG(WARNING) << uuid_.canonical_value() << ": Error adopting socket: " << std::string(net::ErrorToString(net_result)); - ui_task_runner()->PostTask(FROM_HERE, - base::Bind(callback, REJECTED));; + ui_task_runner()->PostTask(FROM_HERE, base::Bind(callback, REJECTED)); + ; return; } VLOG(2) << uuid_.canonical_value() << ": Taking descriptor, confirming success."; fd->TakeValue(); - ui_task_runner()->PostTask(FROM_HERE, - base::Bind(callback, SUCCESS));; + ui_task_runner()->PostTask(FROM_HERE, base::Bind(callback, SUCCESS)); + ; } -void BluetoothSocketChromeOS::OnNewConnection( +void BluetoothSocketBlueZ::OnNewConnection( scoped_refptr<BluetoothSocket> socket, const ConfirmationCallback& callback, Status status) { @@ -513,9 +498,9 @@ void BluetoothSocketChromeOS::OnNewConnection( linked_ptr<ConnectionRequest> request = connection_request_queue_.front(); if (status == SUCCESS && !request->cancelled) { - BluetoothDeviceChromeOS* device = - static_cast<BluetoothAdapterChromeOS*>(adapter_.get())-> - GetDeviceWithPath(request->device_path); + BluetoothDeviceBlueZ* device = + static_cast<BluetoothAdapterBlueZ*>(adapter_.get()) + ->GetDeviceWithPath(request->device_path); DCHECK(device); accept_request_->success_callback.Run(device, socket); @@ -529,7 +514,7 @@ void BluetoothSocketChromeOS::OnNewConnection( callback.Run(status); } -void BluetoothSocketChromeOS::DoCloseListening() { +void BluetoothSocketBlueZ::DoCloseListening() { DCHECK(ui_task_runner()->RunsTasksOnCurrentThread()); if (accept_request_) { @@ -545,15 +530,15 @@ void BluetoothSocketChromeOS::DoCloseListening() { } } -void BluetoothSocketChromeOS::UnregisterProfile() { +void BluetoothSocketBlueZ::UnregisterProfile() { DCHECK(ui_task_runner()->RunsTasksOnCurrentThread()); DCHECK(profile_); VLOG(1) << profile_->object_path().value() << ": Release profile"; - static_cast<BluetoothAdapterChromeOS*>(adapter_.get()) + static_cast<BluetoothAdapterBlueZ*>(adapter_.get()) ->ReleaseProfile(device_path_, profile_); profile_ = nullptr; } -} // namespace chromeos +} // namespace bluez diff --git a/device/bluetooth/bluetooth_socket_chromeos.h b/device/bluetooth/bluetooth_socket_bluez.h index a1c76ee2..7ba23839 100644 --- a/device/bluetooth/bluetooth_socket_chromeos.h +++ b/device/bluetooth/bluetooth_socket_bluez.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_CHROMEOS_H_ -#define DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_CHROMEOS_H_ +#ifndef DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_BLUEZ_H_ +#define DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_BLUEZ_H_ #include <queue> #include <string> @@ -23,27 +23,24 @@ namespace dbus { class FileDescriptor; } // namespace dbus -namespace chromeos { +namespace bluez { -class BluetoothDeviceChromeOS; -class BluetoothAdapterChromeOS; -class BluetoothAdapterProfileChromeOS; +class BluetoothDeviceBlueZ; +class BluetoothAdapterBlueZ; +class BluetoothAdapterProfileBlueZ; -// The BluetoothSocketChromeOS class implements BluetoothSocket for the +// The BluetoothSocketBlueZ class implements BluetoothSocket for the // Chrome OS platform. // // This class is not thread-safe, but is only called from the UI thread. -class DEVICE_BLUETOOTH_EXPORT BluetoothSocketChromeOS +class DEVICE_BLUETOOTH_EXPORT BluetoothSocketBlueZ : public device::BluetoothSocketNet, public device::BluetoothAdapter::Observer, public bluez::BluetoothProfileServiceProvider::Delegate { public: - enum SecurityLevel { - SECURITY_LEVEL_LOW, - SECURITY_LEVEL_MEDIUM - }; + enum SecurityLevel { SECURITY_LEVEL_LOW, SECURITY_LEVEL_MEDIUM }; - static scoped_refptr<BluetoothSocketChromeOS> CreateBluetoothSocket( + static scoped_refptr<BluetoothSocketBlueZ> CreateBluetoothSocket( scoped_refptr<base::SequencedTaskRunner> ui_task_runner, scoped_refptr<device::BluetoothSocketThread> socket_thread); @@ -52,7 +49,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothSocketChromeOS // discovery. On a successful connection the socket properties will be updated // and |success_callback| called. On failure |error_callback| will be called // with a message explaining the cause of the failure. - virtual void Connect(const BluetoothDeviceChromeOS* device, + virtual void Connect(const BluetoothDeviceBlueZ* device, const device::BluetoothUUID& uuid, SecurityLevel security_level, const base::Closure& success_callback, @@ -80,20 +77,20 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothSocketChromeOS const ErrorCompletionCallback& error_callback) override; protected: - ~BluetoothSocketChromeOS() override; + ~BluetoothSocketBlueZ() override; private: - BluetoothSocketChromeOS( + BluetoothSocketBlueZ( scoped_refptr<base::SequencedTaskRunner> ui_task_runner, scoped_refptr<device::BluetoothSocketThread> socket_thread); // Register the underlying profile client object with the Bluetooth Daemon. - void RegisterProfile(BluetoothAdapterChromeOS* adapter, + void RegisterProfile(BluetoothAdapterBlueZ* adapter, const base::Closure& success_callback, const ErrorCompletionCallback& error_callback); void OnRegisterProfile(const base::Closure& success_callback, const ErrorCompletionCallback& error_callback, - BluetoothAdapterProfileChromeOS* profile); + BluetoothAdapterProfileBlueZ* profile); void OnRegisterProfileError(const ErrorCompletionCallback& error_callback, const std::string& error_message); @@ -109,7 +106,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothSocketChromeOS // Called by dbus:: on completion of the RegisterProfile() method call // triggered as a result of the adapter becoming present again. - void OnInternalRegisterProfile(BluetoothAdapterProfileChromeOS* profile); + void OnInternalRegisterProfile(BluetoothAdapterProfileBlueZ* profile); void OnInternalRegisterProfileError(const std::string& error_message); // bluez::BluetoothProfileServiceProvider::Delegate: @@ -169,7 +166,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothSocketChromeOS scoped_ptr<bluez::BluetoothProfileManagerClient::Options> options_; // The profile registered with the adapter for this socket. - BluetoothAdapterProfileChromeOS* profile_; + BluetoothAdapterProfileBlueZ* profile_; // Pending request to an Accept() call. struct AcceptRequest { @@ -193,11 +190,11 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothSocketChromeOS bool accepting; bool cancelled; }; - std::queue<linked_ptr<ConnectionRequest> > connection_request_queue_; + std::queue<linked_ptr<ConnectionRequest>> connection_request_queue_; - DISALLOW_COPY_AND_ASSIGN(BluetoothSocketChromeOS); + DISALLOW_COPY_AND_ASSIGN(BluetoothSocketBlueZ); }; -} // namespace chromeos +} // namespace bluez -#endif // DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_CHROMEOS_H_ +#endif // DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_BLUEZ_H_ diff --git a/device/bluetooth/bluetooth_socket_chromeos_unittest.cc b/device/bluetooth/bluetooth_socket_bluez_unittest.cc index 0bdc3be..e72468f 100644 --- a/device/bluetooth/bluetooth_socket_chromeos_unittest.cc +++ b/device/bluetooth/bluetooth_socket_bluez_unittest.cc @@ -6,12 +6,12 @@ #include "base/memory/ref_counted.h" #include "base/message_loop/message_loop.h" #include "device/bluetooth/bluetooth_adapter.h" -#include "device/bluetooth/bluetooth_adapter_chromeos.h" +#include "device/bluetooth/bluetooth_adapter_bluez.h" #include "device/bluetooth/bluetooth_adapter_factory.h" #include "device/bluetooth/bluetooth_device.h" -#include "device/bluetooth/bluetooth_device_chromeos.h" +#include "device/bluetooth/bluetooth_device_bluez.h" #include "device/bluetooth/bluetooth_socket.h" -#include "device/bluetooth/bluetooth_socket_chromeos.h" +#include "device/bluetooth/bluetooth_socket_bluez.h" #include "device/bluetooth/bluetooth_socket_thread.h" #include "device/bluetooth/bluetooth_uuid.h" #include "device/bluetooth/dbus/bluez_dbus_manager.h" @@ -39,11 +39,11 @@ void DoNothingDBusErrorCallback(const std::string& error_name, } // namespace -namespace chromeos { +namespace bluez { -class BluetoothSocketChromeOSTest : public testing::Test { +class BluetoothSocketBlueZTest : public testing::Test { public: - BluetoothSocketChromeOSTest() + BluetoothSocketBlueZTest() : success_callback_count_(0), error_callback_count_(0), last_bytes_sent_(0), @@ -76,18 +76,15 @@ class BluetoothSocketChromeOSTest : public testing::Test { BluetoothSocketThread::Get(); // Grab a pointer to the adapter. - device::BluetoothAdapterFactory::GetAdapter( - base::Bind(&BluetoothSocketChromeOSTest::AdapterCallback, - base::Unretained(this))); + device::BluetoothAdapterFactory::GetAdapter(base::Bind( + &BluetoothSocketBlueZTest::AdapterCallback, base::Unretained(this))); ASSERT_TRUE(adapter_.get() != nullptr); ASSERT_TRUE(adapter_->IsInitialized()); ASSERT_TRUE(adapter_->IsPresent()); // Turn on the adapter. - adapter_->SetPowered( - true, - base::Bind(&base::DoNothing), - base::Bind(&base::DoNothing)); + adapter_->SetPowered(true, base::Bind(&base::DoNothing), + base::Bind(&base::DoNothing)); ASSERT_TRUE(adapter_->IsPowered()); } @@ -163,9 +160,7 @@ class BluetoothSocketChromeOSTest : public testing::Test { message_loop_.Quit(); } - void ImmediateSuccessCallback() { - ++success_callback_count_; - } + void ImmediateSuccessCallback() { ++success_callback_count_; } protected: base::MessageLoop message_loop_; @@ -184,16 +179,16 @@ class BluetoothSocketChromeOSTest : public testing::Test { const BluetoothDevice* last_device_; }; -TEST_F(BluetoothSocketChromeOSTest, Connect) { +TEST_F(BluetoothSocketBlueZTest, Connect) { BluetoothDevice* device = adapter_->GetDevice( bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); ASSERT_TRUE(device != nullptr); device->ConnectToService( BluetoothUUID(bluez::FakeBluetoothProfileManagerClient::kRfcommUuid), - base::Bind(&BluetoothSocketChromeOSTest::ConnectToServiceSuccessCallback, + base::Bind(&BluetoothSocketBlueZTest::ConnectToServiceSuccessCallback, base::Unretained(this)), - base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, + base::Bind(&BluetoothSocketBlueZTest::ErrorCallback, base::Unretained(this))); message_loop_.Run(); @@ -212,9 +207,9 @@ TEST_F(BluetoothSocketChromeOSTest, Connect) { new net::StringIOBuffer("test")); socket->Send(write_buffer.get(), write_buffer->size(), - base::Bind(&BluetoothSocketChromeOSTest::SendSuccessCallback, + base::Bind(&BluetoothSocketBlueZTest::SendSuccessCallback, base::Unretained(this)), - base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, + base::Bind(&BluetoothSocketBlueZTest::ErrorCallback, base::Unretained(this))); message_loop_.Run(); @@ -227,12 +222,11 @@ TEST_F(BluetoothSocketChromeOSTest, Connect) { // Receive data from the socket, and fetch the buffer from the callback; since // the fake is an echo server, we expect to receive what we wrote. - socket->Receive( - 4096, - base::Bind(&BluetoothSocketChromeOSTest::ReceiveSuccessCallback, - base::Unretained(this)), - base::Bind(&BluetoothSocketChromeOSTest::ReceiveErrorCallback, - base::Unretained(this))); + socket->Receive(4096, + base::Bind(&BluetoothSocketBlueZTest::ReceiveSuccessCallback, + base::Unretained(this)), + base::Bind(&BluetoothSocketBlueZTest::ReceiveErrorCallback, + base::Unretained(this))); message_loop_.Run(); EXPECT_EQ(1U, success_callback_count_); @@ -253,12 +247,11 @@ TEST_F(BluetoothSocketChromeOSTest, Connect) { // Receive data again; the socket will have been closed, this should cause a // disconnected error to be returned via the error callback. - socket->Receive( - 4096, - base::Bind(&BluetoothSocketChromeOSTest::ReceiveSuccessCallback, - base::Unretained(this)), - base::Bind(&BluetoothSocketChromeOSTest::ReceiveErrorCallback, - base::Unretained(this))); + socket->Receive(4096, + base::Bind(&BluetoothSocketBlueZTest::ReceiveSuccessCallback, + base::Unretained(this)), + base::Bind(&BluetoothSocketBlueZTest::ReceiveErrorCallback, + base::Unretained(this))); message_loop_.Run(); EXPECT_EQ(0U, success_callback_count_); @@ -274,9 +267,9 @@ TEST_F(BluetoothSocketChromeOSTest, Connect) { write_buffer = new net::StringIOBuffer("second test"); socket->Send(write_buffer.get(), write_buffer->size(), - base::Bind(&BluetoothSocketChromeOSTest::SendSuccessCallback, + base::Bind(&BluetoothSocketBlueZTest::SendSuccessCallback, base::Unretained(this)), - base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, + base::Bind(&BluetoothSocketBlueZTest::ErrorCallback, base::Unretained(this))); message_loop_.Run(); @@ -288,20 +281,20 @@ TEST_F(BluetoothSocketChromeOSTest, Connect) { error_callback_count_ = 0; // Close our end of the socket. - socket->Disconnect(base::Bind(&BluetoothSocketChromeOSTest::SuccessCallback, + socket->Disconnect(base::Bind(&BluetoothSocketBlueZTest::SuccessCallback, base::Unretained(this))); message_loop_.Run(); EXPECT_EQ(1U, success_callback_count_); } -TEST_F(BluetoothSocketChromeOSTest, Listen) { +TEST_F(BluetoothSocketBlueZTest, Listen) { adapter_->CreateRfcommService( BluetoothUUID(bluez::FakeBluetoothProfileManagerClient::kRfcommUuid), BluetoothAdapter::ServiceOptions(), - base::Bind(&BluetoothSocketChromeOSTest::CreateServiceSuccessCallback, + base::Bind(&BluetoothSocketBlueZTest::CreateServiceSuccessCallback, base::Unretained(this)), - base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, + base::Bind(&BluetoothSocketBlueZTest::ErrorCallback, base::Unretained(this))); message_loop_.Run(); @@ -329,16 +322,16 @@ TEST_F(BluetoothSocketChromeOSTest, Listen) { bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); ASSERT_TRUE(device != nullptr); fake_bluetooth_device_client->ConnectProfile( - static_cast<BluetoothDeviceChromeOS*>(device)->object_path(), + static_cast<BluetoothDeviceBlueZ*>(device)->object_path(), bluez::FakeBluetoothProfileManagerClient::kRfcommUuid, base::Bind(&base::DoNothing), base::Bind(&DoNothingDBusErrorCallback)); message_loop_.RunUntilIdle(); server_socket->Accept( - base::Bind(&BluetoothSocketChromeOSTest::AcceptSuccessCallback, + base::Bind(&BluetoothSocketBlueZTest::AcceptSuccessCallback, base::Unretained(this)), - base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, + base::Bind(&BluetoothSocketBlueZTest::ErrorCallback, base::Unretained(this))); message_loop_.Run(); @@ -354,9 +347,8 @@ TEST_F(BluetoothSocketChromeOSTest, Listen) { error_callback_count_ = 0; // Close our end of the client socket. - client_socket->Disconnect( - base::Bind(&BluetoothSocketChromeOSTest::SuccessCallback, - base::Unretained(this))); + client_socket->Disconnect(base::Bind( + &BluetoothSocketBlueZTest::SuccessCallback, base::Unretained(this))); message_loop_.Run(); @@ -368,15 +360,15 @@ TEST_F(BluetoothSocketChromeOSTest, Listen) { // Run a second connection test, this time calling Accept() before the // incoming connection comes in. server_socket->Accept( - base::Bind(&BluetoothSocketChromeOSTest::AcceptSuccessCallback, + base::Bind(&BluetoothSocketBlueZTest::AcceptSuccessCallback, base::Unretained(this)), - base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, + base::Bind(&BluetoothSocketBlueZTest::ErrorCallback, base::Unretained(this))); message_loop_.RunUntilIdle(); fake_bluetooth_device_client->ConnectProfile( - static_cast<BluetoothDeviceChromeOS*>(device)->object_path(), + static_cast<BluetoothDeviceBlueZ*>(device)->object_path(), bluez::FakeBluetoothProfileManagerClient::kRfcommUuid, base::Bind(&base::DoNothing), base::Bind(&DoNothingDBusErrorCallback)); @@ -393,9 +385,8 @@ TEST_F(BluetoothSocketChromeOSTest, Listen) { error_callback_count_ = 0; // Close our end of the client socket. - client_socket->Disconnect( - base::Bind(&BluetoothSocketChromeOSTest::SuccessCallback, - base::Unretained(this))); + client_socket->Disconnect(base::Bind( + &BluetoothSocketBlueZTest::SuccessCallback, base::Unretained(this))); message_loop_.Run(); @@ -406,7 +397,7 @@ TEST_F(BluetoothSocketChromeOSTest, Listen) { // Now close the server socket. server_socket->Disconnect( - base::Bind(&BluetoothSocketChromeOSTest::ImmediateSuccessCallback, + base::Bind(&BluetoothSocketBlueZTest::ImmediateSuccessCallback, base::Unretained(this))); message_loop_.RunUntilIdle(); @@ -414,7 +405,7 @@ TEST_F(BluetoothSocketChromeOSTest, Listen) { EXPECT_EQ(1U, success_callback_count_); } -TEST_F(BluetoothSocketChromeOSTest, ListenBeforeAdapterStart) { +TEST_F(BluetoothSocketBlueZTest, ListenBeforeAdapterStart) { // Start off with an invisible adapter, register the profile, then make // the adapter visible. bluez::FakeBluetoothAdapterClient* fake_bluetooth_adapter_client = @@ -425,9 +416,9 @@ TEST_F(BluetoothSocketChromeOSTest, ListenBeforeAdapterStart) { adapter_->CreateRfcommService( BluetoothUUID(bluez::FakeBluetoothProfileManagerClient::kRfcommUuid), BluetoothAdapter::ServiceOptions(), - base::Bind(&BluetoothSocketChromeOSTest::CreateServiceSuccessCallback, + base::Bind(&BluetoothSocketBlueZTest::CreateServiceSuccessCallback, base::Unretained(this)), - base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, + base::Bind(&BluetoothSocketBlueZTest::ErrorCallback, base::Unretained(this))); message_loop_.Run(); @@ -464,7 +455,7 @@ TEST_F(BluetoothSocketChromeOSTest, ListenBeforeAdapterStart) { // Cleanup the socket. socket->Disconnect( - base::Bind(&BluetoothSocketChromeOSTest::ImmediateSuccessCallback, + base::Bind(&BluetoothSocketBlueZTest::ImmediateSuccessCallback, base::Unretained(this))); message_loop_.RunUntilIdle(); @@ -472,7 +463,7 @@ TEST_F(BluetoothSocketChromeOSTest, ListenBeforeAdapterStart) { EXPECT_EQ(1U, success_callback_count_); } -TEST_F(BluetoothSocketChromeOSTest, ListenAcrossAdapterRestart) { +TEST_F(BluetoothSocketBlueZTest, ListenAcrossAdapterRestart) { // The fake adapter starts off visible by default. bluez::FakeBluetoothAdapterClient* fake_bluetooth_adapter_client = static_cast<bluez::FakeBluetoothAdapterClient*>( @@ -481,9 +472,9 @@ TEST_F(BluetoothSocketChromeOSTest, ListenAcrossAdapterRestart) { adapter_->CreateRfcommService( BluetoothUUID(bluez::FakeBluetoothProfileManagerClient::kRfcommUuid), BluetoothAdapter::ServiceOptions(), - base::Bind(&BluetoothSocketChromeOSTest::CreateServiceSuccessCallback, + base::Bind(&BluetoothSocketBlueZTest::CreateServiceSuccessCallback, base::Unretained(this)), - base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, + base::Bind(&BluetoothSocketBlueZTest::ErrorCallback, base::Unretained(this))); message_loop_.Run(); @@ -526,7 +517,7 @@ TEST_F(BluetoothSocketChromeOSTest, ListenAcrossAdapterRestart) { // Cleanup the socket. socket->Disconnect( - base::Bind(&BluetoothSocketChromeOSTest::ImmediateSuccessCallback, + base::Bind(&BluetoothSocketBlueZTest::ImmediateSuccessCallback, base::Unretained(this))); message_loop_.RunUntilIdle(); @@ -534,16 +525,16 @@ TEST_F(BluetoothSocketChromeOSTest, ListenAcrossAdapterRestart) { EXPECT_EQ(1U, success_callback_count_); } -TEST_F(BluetoothSocketChromeOSTest, PairedConnectFails) { +TEST_F(BluetoothSocketBlueZTest, PairedConnectFails) { BluetoothDevice* device = adapter_->GetDevice( bluez::FakeBluetoothDeviceClient::kPairedUnconnectableDeviceAddress); ASSERT_TRUE(device != nullptr); device->ConnectToService( BluetoothUUID(bluez::FakeBluetoothProfileManagerClient::kRfcommUuid), - base::Bind(&BluetoothSocketChromeOSTest::ConnectToServiceSuccessCallback, + base::Bind(&BluetoothSocketBlueZTest::ConnectToServiceSuccessCallback, base::Unretained(this)), - base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, + base::Bind(&BluetoothSocketBlueZTest::ErrorCallback, base::Unretained(this))); message_loop_.Run(); @@ -553,9 +544,9 @@ TEST_F(BluetoothSocketChromeOSTest, PairedConnectFails) { device->ConnectToService( BluetoothUUID(bluez::FakeBluetoothProfileManagerClient::kRfcommUuid), - base::Bind(&BluetoothSocketChromeOSTest::ConnectToServiceSuccessCallback, + base::Bind(&BluetoothSocketBlueZTest::ConnectToServiceSuccessCallback, base::Unretained(this)), - base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, + base::Bind(&BluetoothSocketBlueZTest::ErrorCallback, base::Unretained(this))); message_loop_.Run(); @@ -564,13 +555,13 @@ TEST_F(BluetoothSocketChromeOSTest, PairedConnectFails) { EXPECT_TRUE(last_socket_.get() == nullptr); } -TEST_F(BluetoothSocketChromeOSTest, SocketListenTwice) { +TEST_F(BluetoothSocketBlueZTest, SocketListenTwice) { adapter_->CreateRfcommService( BluetoothUUID(bluez::FakeBluetoothProfileManagerClient::kRfcommUuid), BluetoothAdapter::ServiceOptions(), - base::Bind(&BluetoothSocketChromeOSTest::CreateServiceSuccessCallback, + base::Bind(&BluetoothSocketBlueZTest::CreateServiceSuccessCallback, base::Unretained(this)), - base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, + base::Bind(&BluetoothSocketBlueZTest::ErrorCallback, base::Unretained(this))); message_loop_.Run(); @@ -584,9 +575,9 @@ TEST_F(BluetoothSocketChromeOSTest, SocketListenTwice) { server_socket.swap(last_socket_); server_socket->Accept( - base::Bind(&BluetoothSocketChromeOSTest::AcceptSuccessCallback, + base::Bind(&BluetoothSocketBlueZTest::AcceptSuccessCallback, base::Unretained(this)), - base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, + base::Bind(&BluetoothSocketBlueZTest::ErrorCallback, base::Unretained(this))); server_socket->Close(); @@ -601,9 +592,9 @@ TEST_F(BluetoothSocketChromeOSTest, SocketListenTwice) { adapter_->CreateRfcommService( BluetoothUUID(bluez::FakeBluetoothProfileManagerClient::kRfcommUuid), BluetoothAdapter::ServiceOptions(), - base::Bind(&BluetoothSocketChromeOSTest::CreateServiceSuccessCallback, + base::Bind(&BluetoothSocketBlueZTest::CreateServiceSuccessCallback, base::Unretained(this)), - base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, + base::Bind(&BluetoothSocketBlueZTest::ErrorCallback, base::Unretained(this))); message_loop_.Run(); @@ -616,9 +607,9 @@ TEST_F(BluetoothSocketChromeOSTest, SocketListenTwice) { server_socket.swap(last_socket_); server_socket->Accept( - base::Bind(&BluetoothSocketChromeOSTest::AcceptSuccessCallback, + base::Bind(&BluetoothSocketBlueZTest::AcceptSuccessCallback, base::Unretained(this)), - base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, + base::Bind(&BluetoothSocketBlueZTest::ErrorCallback, base::Unretained(this))); server_socket->Close(); @@ -631,4 +622,4 @@ TEST_F(BluetoothSocketChromeOSTest, SocketListenTwice) { EXPECT_EQ(2U, error_callback_count_); } -} // namespace chromeos +} // namespace bluez diff --git a/device/bluetooth/bluetooth_socket_thread.h b/device/bluetooth/bluetooth_socket_thread.h index 244640f..0c7b65c 100644 --- a/device/bluetooth/bluetooth_socket_thread.h +++ b/device/bluetooth/bluetooth_socket_thread.h @@ -17,7 +17,7 @@ class Thread; namespace device { -// Thread abstraction used by |BluetoothSocketChromeOS| and |BluetoothSocketWin| +// Thread abstraction used by |BluetoothSocketBlueZ| and |BluetoothSocketWin| // to perform IO operations on the underlying platform sockets. An instance of // this class can be shared by many active sockets. class DEVICE_BLUETOOTH_EXPORT BluetoothSocketThread diff --git a/device/bluetooth/dbus/bluetooth_agent_service_provider.h b/device/bluetooth/dbus/bluetooth_agent_service_provider.h index e31ef8f..162cf7e 100644 --- a/device/bluetooth/dbus/bluetooth_agent_service_provider.h +++ b/device/bluetooth/dbus/bluetooth_agent_service_provider.h @@ -21,10 +21,10 @@ namespace bluez { // // Instantiate with a chosen D-Bus object path and delegate object, and pass // the D-Bus object path as the |agent_path| argument to the -// chromeos::BluetoothAgentManagerClient::RegisterAgent() method. +// bluez::BluetoothAgentManagerClient::RegisterAgent() method. // // After initiating the pairing process with a device, using the -// chromeos::BluetoothDeviceClient::Pair() method, the Bluetooth daemon will +// bluez::BluetoothDeviceClient::Pair() method, the Bluetooth daemon will // make calls to this agent object and they will be passed on to your Delegate // object for handling. Responses should be returned using the callbacks // supplied to those methods. diff --git a/device/bluetooth/dbus/bluetooth_dbus_client_bundle.cc b/device/bluetooth/dbus/bluetooth_dbus_client_bundle.cc index 29a4ce8..1d53d8a 100644 --- a/device/bluetooth/dbus/bluetooth_dbus_client_bundle.cc +++ b/device/bluetooth/dbus/bluetooth_dbus_client_bundle.cc @@ -9,7 +9,6 @@ #include "base/command_line.h" #include "base/strings/string_split.h" #include "base/strings/string_util.h" -#include "chromeos/chromeos_switches.h" #include "device/bluetooth/dbus/bluetooth_adapter_client.h" #include "device/bluetooth/dbus/bluetooth_agent_manager_client.h" #include "device/bluetooth/dbus/bluetooth_device_client.h" diff --git a/device/bluetooth/dbus/bluetooth_gatt_characteristic_client.cc b/device/bluetooth/dbus/bluetooth_gatt_characteristic_client.cc index 6000a52..d6229a3a 100644 --- a/device/bluetooth/dbus/bluetooth_gatt_characteristic_client.cc +++ b/device/bluetooth/dbus/bluetooth_gatt_characteristic_client.cc @@ -210,7 +210,7 @@ class BluetoothGattCharacteristicClientImpl } protected: - // chromeos::DBusClient override. + // bluez::DBusClient override. void Init(dbus::Bus* bus) override { object_manager_ = bus->GetObjectManager( bluetooth_object_manager::kBluetoothObjectManagerServiceName, diff --git a/device/bluetooth/dbus/bluetooth_gatt_descriptor_client.cc b/device/bluetooth/dbus/bluetooth_gatt_descriptor_client.cc index f3ba343..d3f9e5f 100644 --- a/device/bluetooth/dbus/bluetooth_gatt_descriptor_client.cc +++ b/device/bluetooth/dbus/bluetooth_gatt_descriptor_client.cc @@ -159,7 +159,7 @@ class BluetoothGattDescriptorClientImpl } protected: - // chromeos::DBusClient override. + // bluez::DBusClient override. void Init(dbus::Bus* bus) override { object_manager_ = bus->GetObjectManager( bluetooth_object_manager::kBluetoothObjectManagerServiceName, diff --git a/device/bluetooth/dbus/bluetooth_gatt_manager_client.cc b/device/bluetooth/dbus/bluetooth_gatt_manager_client.cc index 7e471a5..94f79f5 100644 --- a/device/bluetooth/dbus/bluetooth_gatt_manager_client.cc +++ b/device/bluetooth/dbus/bluetooth_gatt_manager_client.cc @@ -73,7 +73,7 @@ class BluetoothGattManagerClientImpl : public BluetoothGattManagerClient { } protected: - // chromeos::DBusClient override. + // bluez::DBusClient override. void Init(dbus::Bus* bus) override { DCHECK(bus); object_proxy_ = bus->GetObjectProxy( diff --git a/device/bluetooth/dbus/bluetooth_gatt_service_client.cc b/device/bluetooth/dbus/bluetooth_gatt_service_client.cc index dc3ef5a..b13e5fb 100644 --- a/device/bluetooth/dbus/bluetooth_gatt_service_client.cc +++ b/device/bluetooth/dbus/bluetooth_gatt_service_client.cc @@ -95,7 +95,7 @@ class BluetoothGattServiceClientImpl : public BluetoothGattServiceClient, } protected: - // chromeos::DBusClient override. + // bluez::DBusClient override. void Init(dbus::Bus* bus) override { object_manager_ = bus->GetObjectManager( bluetooth_object_manager::kBluetoothObjectManagerServiceName, diff --git a/device/bluetooth/dbus/bluetooth_gatt_service_service_provider.h b/device/bluetooth/dbus/bluetooth_gatt_service_service_provider.h index 828f096..16460ce 100644 --- a/device/bluetooth/dbus/bluetooth_gatt_service_service_provider.h +++ b/device/bluetooth/dbus/bluetooth_gatt_service_service_provider.h @@ -21,7 +21,7 @@ namespace bluez { // Instantiate with a chosen D-Bus object path (that conforms to the BlueZ GATT // service specification), service UUID, and the list of included services, and // pass the D-Bus object path as the |service_path| argument to the -// chromeos::BluetoothGattManagerClient::RegisterService method. Make sure to +// bluez::BluetoothGattManagerClient::RegisterService method. Make sure to // create characteristic and descriptor objects using the appropriate service // providers before registering a GATT service with the Bluetooth daemon. class DEVICE_BLUETOOTH_EXPORT BluetoothGattServiceServiceProvider { diff --git a/device/bluetooth/dbus/bluetooth_media_endpoint_service_provider.h b/device/bluetooth/dbus/bluetooth_media_endpoint_service_provider.h index df17f09..d42cd94 100644 --- a/device/bluetooth/dbus/bluetooth_media_endpoint_service_provider.h +++ b/device/bluetooth/dbus/bluetooth_media_endpoint_service_provider.h @@ -21,7 +21,7 @@ namespace bluez { // // Instantiate with a chosen D-Bus object path and a delegate object, and pass // the D-Bus object path as |endpoint_path| argument to the -// chromeos::BluetoothMediaClient::RegisterEndoint() method. +// bluez::BluetoothMediaClient::RegisterEndoint() method. // // After initiating a connection between an audio source and an audio sink, the // Bluetooth daemon will make calls to this endpoint object and they will be diff --git a/device/bluetooth/dbus/bluetooth_profile_service_provider.h b/device/bluetooth/dbus/bluetooth_profile_service_provider.h index f2db22c..109bcaf 100644 --- a/device/bluetooth/dbus/bluetooth_profile_service_provider.h +++ b/device/bluetooth/dbus/bluetooth_profile_service_provider.h @@ -22,10 +22,10 @@ namespace bluez { // // Instantiate with a chosen D-Bus object path and delegate object, and pass // the D-Bus object path as the |agent_path| argument to the -// chromeos::BluetoothProfileManagerClient::RegisterProfile() method. +// bluez::BluetoothProfileManagerClient::RegisterProfile() method. // // When an incoming profile connection occurs, or after initiating a connection -// using the chromeos::BluetoothDeviceClient::ConnectProfile() method, the +// using the bluez::BluetoothDeviceClient::ConnectProfile() method, the // Bluetooth daemon will make calls to this profile object and they will be // passed on to your Delegate object for handling. Responses should be returned // using the callbacks supplied to those methods. diff --git a/device/bluetooth/dbus/bluez_dbus_manager.h b/device/bluetooth/dbus/bluez_dbus_manager.h index 6f75f96..d59dddb 100644 --- a/device/bluetooth/dbus/bluez_dbus_manager.h +++ b/device/bluetooth/dbus/bluez_dbus_manager.h @@ -56,7 +56,7 @@ class DEVICE_BLUETOOTH_EXPORT BluezDBusManager { // We explicitly initialize and shut down the global object, rather than // making it a Singleton, to ensure clean startup and shutdown. // This will initialize real or stub DBusClients depending on command-line - // arguments and whether this process runs in a ChromeOS environment. + // arguments and whether this process runs in a real or test environment. static void Initialize(dbus::Bus* bus, bool use_dbus_stub); // Returns a BluezDBusManagerSetter instance that allows tests to diff --git a/device/bluetooth/dbus/dbus_thread_manager_linux.cc b/device/bluetooth/dbus/dbus_thread_manager_linux.cc new file mode 100644 index 0000000..adffe9b --- /dev/null +++ b/device/bluetooth/dbus/dbus_thread_manager_linux.cc @@ -0,0 +1,72 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "device/bluetooth/dbus/dbus_thread_manager_linux.h" + +#include "base/threading/thread.h" +#include "dbus/bus.h" + +namespace bluez { + +static DBusThreadManagerLinux* g_linux_dbus_manager = NULL; + +DBusThreadManagerLinux::DBusThreadManagerLinux() { + base::Thread::Options thread_options; + thread_options.message_loop_type = base::MessageLoop::TYPE_IO; + dbus_thread_.reset(new base::Thread("D-Bus thread")); + dbus_thread_->StartWithOptions(thread_options); + + // Create the connection to the system bus. + dbus::Bus::Options system_bus_options; + system_bus_options.bus_type = dbus::Bus::SYSTEM; + system_bus_options.connection_type = dbus::Bus::PRIVATE; + system_bus_options.dbus_task_runner = dbus_thread_->task_runner(); + system_bus_ = new dbus::Bus(system_bus_options); +} + +DBusThreadManagerLinux::~DBusThreadManagerLinux() { + // Shut down the bus. During the browser shutdown, it's ok to shut down + // the bus synchronously. + if (system_bus_.get()) + system_bus_->ShutdownOnDBusThreadAndBlock(); + + // Stop the D-Bus thread. + if (dbus_thread_) + dbus_thread_->Stop(); + + if (!g_linux_dbus_manager) + return; // Called form Shutdown() or local test instance. + + // There should never be both a global instance and a local instance. + CHECK(this == g_linux_dbus_manager); +} + +dbus::Bus* DBusThreadManagerLinux::GetSystemBus() { + return system_bus_.get(); +} + +// static +void DBusThreadManagerLinux::Initialize() { + CHECK(!g_linux_dbus_manager); + g_linux_dbus_manager = new DBusThreadManagerLinux(); +} + +// static +void DBusThreadManagerLinux::Shutdown() { + // Ensure that we only shutdown LinuxDBusManager once. + CHECK(g_linux_dbus_manager); + DBusThreadManagerLinux* dbus_thread_manager = g_linux_dbus_manager; + g_linux_dbus_manager = NULL; + delete dbus_thread_manager; + VLOG(1) << "LinuxDBusManager Shutdown completed"; +} + +// static +DBusThreadManagerLinux* DBusThreadManagerLinux::Get() { + CHECK(g_linux_dbus_manager) + << "LinuxDBusManager::Get() called before Initialize()"; + return g_linux_dbus_manager; +} + +} // namespace bluez diff --git a/device/bluetooth/dbus/dbus_thread_manager_linux.h b/device/bluetooth/dbus/dbus_thread_manager_linux.h new file mode 100644 index 0000000..56fdb1c --- /dev/null +++ b/device/bluetooth/dbus/dbus_thread_manager_linux.h @@ -0,0 +1,59 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef DEVICE_BLUETOOTH_DBUS_LINUX_DBUS_MANAGER_H_ +#define DEVICE_BLUETOOTH_DBUS_LINUX_DBUS_MANAGER_H_ + +#include "base/callback.h" +#include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" +#include "device/bluetooth/bluetooth_export.h" + +namespace base { +class Thread; +} // namespace base + +namespace dbus { +class Bus; +} // namespace dbus + +namespace bluez { + +// LinuxDBusManager manages the D-Bus thread, the thread dedicated to +// handling asynchronous D-Bus operations. +class DEVICE_BLUETOOTH_EXPORT DBusThreadManagerLinux { + public: + // Sets the global instance. Must be called before any calls to Get(). + // We explicitly initialize and shut down the global object, rather than + // making it a Singleton, to ensure clean startup and shutdown. + static void Initialize(); + + // Destroys the global instance. + static void Shutdown(); + + // Gets the global instance. Initialize() must be called first. + static DBusThreadManagerLinux* Get(); + + // Returns various D-Bus bus instances, owned by LinuxDBusManager. + dbus::Bus* GetSystemBus(); + + private: + explicit DBusThreadManagerLinux(); + ~DBusThreadManagerLinux(); + + // Creates a global instance of LinuxDBusManager with the real + // implementations for all clients that are listed in |unstub_client_mask| and + // stub implementations for all clients that are not included. Cannot be + // called more than once. + static void CreateGlobalInstance(); + + scoped_ptr<base::Thread> dbus_thread_; + scoped_refptr<dbus::Bus> system_bus_; + + DISALLOW_COPY_AND_ASSIGN(DBusThreadManagerLinux); +}; + +} // namespace bluez + +#endif // DEVICE_BLUETOOTH_DBUS_LINUX_DBUS_MANAGER_H_ diff --git a/device/bluetooth/dbus/fake_bluetooth_adapter_client.h b/device/bluetooth/dbus/fake_bluetooth_adapter_client.h index 51cd808..0dced89 100644 --- a/device/bluetooth/dbus/fake_bluetooth_adapter_client.h +++ b/device/bluetooth/dbus/fake_bluetooth_adapter_client.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_ADAPTER_CLIENT_H_ -#define CHROMEOS_DBUS_FAKE_BLUETOOTH_ADAPTER_CLIENT_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_ADAPTER_CLIENT_H_ +#define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_ADAPTER_CLIENT_H_ #include <vector> @@ -115,4 +115,4 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothAdapterClient } // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_ADAPTER_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_ADAPTER_CLIENT_H_ diff --git a/device/bluetooth/dbus/fake_bluetooth_agent_manager_client.h b/device/bluetooth/dbus/fake_bluetooth_agent_manager_client.h index 8d7e30c..d5c83cf 100644 --- a/device/bluetooth/dbus/fake_bluetooth_agent_manager_client.h +++ b/device/bluetooth/dbus/fake_bluetooth_agent_manager_client.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_AGENT_MANAGER_CLIENT_H_ -#define CHROMEOS_DBUS_FAKE_BLUETOOTH_AGENT_MANAGER_CLIENT_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_AGENT_MANAGER_CLIENT_H_ +#define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_AGENT_MANAGER_CLIENT_H_ #include "base/bind.h" #include "base/callback.h" @@ -54,4 +54,4 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothAgentManagerClient } // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_AGENT_MANAGER_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_AGENT_MANAGER_CLIENT_H_ diff --git a/device/bluetooth/dbus/fake_bluetooth_agent_service_provider.h b/device/bluetooth/dbus/fake_bluetooth_agent_service_provider.h index 37e1ce6..e3c8cd4 100644 --- a/device/bluetooth/dbus/fake_bluetooth_agent_service_provider.h +++ b/device/bluetooth/dbus/fake_bluetooth_agent_service_provider.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_ -#define CHROMEOS_DBUS_FAKE_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_ +#define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_ #include "base/bind.h" #include "base/callback.h" @@ -65,4 +65,4 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothAgentServiceProvider } // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_ diff --git a/device/bluetooth/dbus/fake_bluetooth_device_client.cc b/device/bluetooth/dbus/fake_bluetooth_device_client.cc index 5dd589b..4af707e 100644 --- a/device/bluetooth/dbus/fake_bluetooth_device_client.cc +++ b/device/bluetooth/dbus/fake_bluetooth_device_client.cc @@ -959,7 +959,7 @@ void FakeBluetoothDeviceClient::RemoveDevice( // Remove the Input interface if it exists. This should be called before the // BluetoothDeviceClient::Observer::DeviceRemoved because it deletes the - // BluetoothDeviceChromeOS object, including the device_path referenced here. + // BluetoothDeviceBlueZ object, including the device_path referenced here. FakeBluetoothInputClient* fake_bluetooth_input_client = static_cast<FakeBluetoothInputClient*>( bluez::BluezDBusManager::Get()->GetBluetoothInputClient()); diff --git a/device/bluetooth/dbus/fake_bluetooth_device_client.h b/device/bluetooth/dbus/fake_bluetooth_device_client.h index edc8ee6..04597e8 100644 --- a/device/bluetooth/dbus/fake_bluetooth_device_client.h +++ b/device/bluetooth/dbus/fake_bluetooth_device_client.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_DEVICE_CLIENT_H_ -#define CHROMEOS_DBUS_FAKE_BLUETOOTH_DEVICE_CLIENT_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_DEVICE_CLIENT_H_ +#define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_DEVICE_CLIENT_H_ #include <map> #include <vector> @@ -313,4 +313,4 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothDeviceClient } // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_DEVICE_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_DEVICE_CLIENT_H_ diff --git a/device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_client.h b/device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_client.h index dc5196d..89fefcc 100644 --- a/device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_client.h +++ b/device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_client.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ -#define CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ +#define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ #include <string> #include <vector> @@ -191,4 +191,4 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothGattCharacteristicClient } // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ diff --git a/device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provider.h b/device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provider.h index a67d6c95..eadde4b 100644 --- a/device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provider.h +++ b/device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provider.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_SERVICE_PROVIDER_H_ -#define CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_SERVICE_PROVIDER_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_SERVICE_PROVIDER_H_ +#define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_SERVICE_PROVIDER_H_ #include <string> #include <vector> @@ -63,4 +63,4 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothGattCharacteristicServiceProvider } // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_SERVICE_PROVIDER_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_SERVICE_PROVIDER_H_ diff --git a/device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.h b/device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.h index e933664..80fdc49 100644 --- a/device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.h +++ b/device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_DESCRIPTOR_CLIENT_H_ -#define CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_DESCRIPTOR_CLIENT_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_DESCRIPTOR_CLIENT_H_ +#define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_DESCRIPTOR_CLIENT_H_ #include <map> #include <string> @@ -100,4 +100,4 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothGattDescriptorClient } // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_DESCRIPTOR_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_DESCRIPTOR_CLIENT_H_ diff --git a/device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_service_provider.h b/device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_service_provider.h index 7e53625..22e3ad2 100644 --- a/device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_service_provider.h +++ b/device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_service_provider.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_DESCRIPTOR_SERVICE_PROVIDER_H_ -#define CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_DESCRIPTOR_SERVICE_PROVIDER_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_DESCRIPTOR_SERVICE_PROVIDER_H_ +#define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_DESCRIPTOR_SERVICE_PROVIDER_H_ #include <string> #include <vector> @@ -64,4 +64,4 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothGattDescriptorServiceProvider } // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_DESCRIPTOR_SERVICE_PROVIDER_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_DESCRIPTOR_SERVICE_PROVIDER_H_ diff --git a/device/bluetooth/dbus/fake_bluetooth_gatt_manager_client.h b/device/bluetooth/dbus/fake_bluetooth_gatt_manager_client.h index 32209df..b181f07 100644 --- a/device/bluetooth/dbus/fake_bluetooth_gatt_manager_client.h +++ b/device/bluetooth/dbus/fake_bluetooth_gatt_manager_client.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_MANAGER_CLIENT_H_ -#define CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_MANAGER_CLIENT_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_MANAGER_CLIENT_H_ +#define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_MANAGER_CLIENT_H_ #include <map> #include <string> @@ -97,4 +97,4 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothGattManagerClient } // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_MANAGER_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_MANAGER_CLIENT_H_ diff --git a/device/bluetooth/dbus/fake_bluetooth_gatt_service_client.h b/device/bluetooth/dbus/fake_bluetooth_gatt_service_client.h index d25e9d2..2950dda 100644 --- a/device/bluetooth/dbus/fake_bluetooth_gatt_service_client.h +++ b/device/bluetooth/dbus/fake_bluetooth_gatt_service_client.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_SERVICE_CLIENT_H_ -#define CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_SERVICE_CLIENT_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_SERVICE_CLIENT_H_ +#define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_SERVICE_CLIENT_H_ #include <string> #include <vector> @@ -103,4 +103,4 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothGattServiceClient } // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_SERVICE_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_SERVICE_CLIENT_H_ diff --git a/device/bluetooth/dbus/fake_bluetooth_gatt_service_service_provider.h b/device/bluetooth/dbus/fake_bluetooth_gatt_service_service_provider.h index 69b71fd..2e9fb2d 100644 --- a/device/bluetooth/dbus/fake_bluetooth_gatt_service_service_provider.h +++ b/device/bluetooth/dbus/fake_bluetooth_gatt_service_service_provider.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_SERVICE_SERVICE_PROVIDER_H_ -#define CHROMEOS_DBUS_FAKE_BLUETOOTH_SERVICE_SERVICE_PROVIDER_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_SERVICE_SERVICE_PROVIDER_H_ +#define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_SERVICE_SERVICE_PROVIDER_H_ #include <string> #include <vector> @@ -44,4 +44,4 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothGattServiceServiceProvider } // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_SERVICE_SERVICE_PROVIDER_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_SERVICE_SERVICE_PROVIDER_H_ diff --git a/device/bluetooth/dbus/fake_bluetooth_input_client.h b/device/bluetooth/dbus/fake_bluetooth_input_client.h index e7a3b0a..a72be52 100644 --- a/device/bluetooth/dbus/fake_bluetooth_input_client.h +++ b/device/bluetooth/dbus/fake_bluetooth_input_client.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_INPUT_CLIENT_H_ -#define CHROMEOS_DBUS_FAKE_BLUETOOTH_INPUT_CLIENT_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_INPUT_CLIENT_H_ +#define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_INPUT_CLIENT_H_ #include "base/callback.h" #include "base/observer_list.h" @@ -62,4 +62,4 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothInputClient } // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_INPUT_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_INPUT_CLIENT_H_ diff --git a/device/bluetooth/dbus/fake_bluetooth_le_advertisement_service_provider.h b/device/bluetooth/dbus/fake_bluetooth_le_advertisement_service_provider.h index 66df2c2..fb5d62c 100644 --- a/device/bluetooth/dbus/fake_bluetooth_le_advertisement_service_provider.h +++ b/device/bluetooth/dbus/fake_bluetooth_le_advertisement_service_provider.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_LE_ADVERTISEMENT_SERVICE_PROVIDER_H_ -#define CHROMEOS_DBUS_FAKE_BLUETOOTH_LE_ADVERTISEMENT_SERVICE_PROVIDER_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_LE_ADVERTISEMENT_SERVICE_PROVIDER_H_ +#define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_LE_ADVERTISEMENT_SERVICE_PROVIDER_H_ #include "base/bind.h" #include "base/callback.h" @@ -46,4 +46,4 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothLEAdvertisementServiceProvider } // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_LE_ADVERTISEMENT_SERVICE_PROVIDER_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_LE_ADVERTISEMENT_SERVICE_PROVIDER_H_ diff --git a/device/bluetooth/dbus/fake_bluetooth_le_advertising_manager_client.h b/device/bluetooth/dbus/fake_bluetooth_le_advertising_manager_client.h index e3090e6..308a703 100644 --- a/device/bluetooth/dbus/fake_bluetooth_le_advertising_manager_client.h +++ b/device/bluetooth/dbus/fake_bluetooth_le_advertising_manager_client.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_LE_ADVERTISING_MANAGER_CLIENT_H_ -#define CHROMEOS_DBUS_FAKE_BLUETOOTH_LE_ADVERTISING_MANAGER_CLIENT_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_LE_ADVERTISING_MANAGER_CLIENT_H_ +#define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_LE_ADVERTISING_MANAGER_CLIENT_H_ #include <map> #include <string> @@ -76,4 +76,4 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothLEAdvertisingManagerClient } // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_LE_ADVERTISING_MANAGER_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_LE_ADVERTISING_MANAGER_CLIENT_H_ diff --git a/device/bluetooth/dbus/fake_bluetooth_media_client.h b/device/bluetooth/dbus/fake_bluetooth_media_client.h index 3d6d84e..ff80b07 100644 --- a/device/bluetooth/dbus/fake_bluetooth_media_client.h +++ b/device/bluetooth/dbus/fake_bluetooth_media_client.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_CLIENT_H_ -#define CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_CLIENT_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_MEDIA_CLIENT_H_ +#define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_MEDIA_CLIENT_H_ #include <map> @@ -74,4 +74,4 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothMediaClient } // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_MEDIA_CLIENT_H_ diff --git a/device/bluetooth/dbus/fake_bluetooth_media_endpoint_service_provider.h b/device/bluetooth/dbus/fake_bluetooth_media_endpoint_service_provider.h index 1f4383f..528a736 100644 --- a/device/bluetooth/dbus/fake_bluetooth_media_endpoint_service_provider.h +++ b/device/bluetooth/dbus/fake_bluetooth_media_endpoint_service_provider.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_ENDPOINT_SERVICE_PROVIDER_H_ -#define CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_ENDPOINT_SERVICE_PROVIDER_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_MEDIA_ENDPOINT_SERVICE_PROVIDER_H_ +#define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_MEDIA_ENDPOINT_SERVICE_PROVIDER_H_ #include <vector> @@ -54,4 +54,4 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothMediaEndpointServiceProvider } // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_ENDPOINT_SERVICE_PROVIDER_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_MEDIA_ENDPOINT_SERVICE_PROVIDER_H_ diff --git a/device/bluetooth/dbus/fake_bluetooth_media_transport_client.h b/device/bluetooth/dbus/fake_bluetooth_media_transport_client.h index 8403c36..0a0af40 100644 --- a/device/bluetooth/dbus/fake_bluetooth_media_transport_client.h +++ b/device/bluetooth/dbus/fake_bluetooth_media_transport_client.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ -#define CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ +#define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ #include <map> #include <string> @@ -144,4 +144,4 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothMediaTransportClient } // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ diff --git a/device/bluetooth/dbus/fake_bluetooth_profile_manager_client.h b/device/bluetooth/dbus/fake_bluetooth_profile_manager_client.h index 62af0f1..8ed7826 100644 --- a/device/bluetooth/dbus/fake_bluetooth_profile_manager_client.h +++ b/device/bluetooth/dbus/fake_bluetooth_profile_manager_client.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_ -#define CHROMEOS_DBUS_FAKE_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_ +#define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_ #include <map> #include <string> @@ -71,4 +71,4 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothProfileManagerClient } // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_ diff --git a/device/bluetooth/dbus/fake_bluetooth_profile_service_provider.h b/device/bluetooth/dbus/fake_bluetooth_profile_service_provider.h index 1259927..6eefb80 100644 --- a/device/bluetooth/dbus/fake_bluetooth_profile_service_provider.h +++ b/device/bluetooth/dbus/fake_bluetooth_profile_service_provider.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ -#define CHROMEOS_DBUS_FAKE_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ +#define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ #include "base/bind.h" #include "base/callback.h" @@ -57,4 +57,4 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothProfileServiceProvider } // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ diff --git a/device/bluetooth/test/mock_bluetooth_adapter.cc b/device/bluetooth/test/mock_bluetooth_adapter.cc index 26ae68b..4b060e5 100644 --- a/device/bluetooth/test/mock_bluetooth_adapter.cc +++ b/device/bluetooth/test/mock_bluetooth_adapter.cc @@ -27,7 +27,7 @@ MockBluetoothAdapter::MockBluetoothAdapter() { MockBluetoothAdapter::~MockBluetoothAdapter() {} -#if defined(OS_CHROMEOS) +#if defined(OS_CHROMEOS) || defined(OS_LINUX) void MockBluetoothAdapter::Shutdown() { } #endif diff --git a/device/bluetooth/test/mock_bluetooth_adapter.h b/device/bluetooth/test/mock_bluetooth_adapter.h index 775adee..c5427c2 100644 --- a/device/bluetooth/test/mock_bluetooth_adapter.h +++ b/device/bluetooth/test/mock_bluetooth_adapter.h @@ -37,7 +37,7 @@ class MockBluetoothAdapter : public BluetoothAdapter { virtual bool IsInitialized() const { return true; } -#if defined(OS_CHROMEOS) +#if defined(OS_CHROMEOS) || defined(OS_LINUX) void Shutdown() override; #endif MOCK_METHOD1(AddObserver, void(BluetoothAdapter::Observer*)); diff --git a/device/bluetooth/test/mock_bluetooth_advertisement.cc b/device/bluetooth/test/mock_bluetooth_advertisement.cc index ddba516..746108a 100644 --- a/device/bluetooth/test/mock_bluetooth_advertisement.cc +++ b/device/bluetooth/test/mock_bluetooth_advertisement.cc @@ -18,4 +18,4 @@ void MockBluetoothAdvertisement::Unregister( success_callback.Run(); } -} // namespace chromeos +} // namespace device diff --git a/device/bluetooth/test/mock_bluetooth_advertisement.h b/device/bluetooth/test/mock_bluetooth_advertisement.h index ddaeef4..2079cf0 100644 --- a/device/bluetooth/test/mock_bluetooth_advertisement.h +++ b/device/bluetooth/test/mock_bluetooth_advertisement.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADVERTISEMENT_CHROMEOS_H_ -#define DEVICE_BLUETOOTH_BLUETOOTH_ADVERTISEMENT_CHROMEOS_H_ +#ifndef DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_ADVERTISEMENT_H_ +#define DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_ADVERTISEMENT_H_ #include "base/macros.h" #include "device/bluetooth/bluetooth_advertisement.h" @@ -24,6 +24,6 @@ class MockBluetoothAdvertisement : public device::BluetoothAdvertisement { DISALLOW_COPY_AND_ASSIGN(MockBluetoothAdvertisement); }; -} // namespace chromeos +} // namespace device -#endif // DEVICE_BLUETOOTH_BLUETOOTH_ADVERTISEMENT_CHROMEOS_H_ +#endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_ADVERTISEMENT_H_ diff --git a/device/device_tests.gyp b/device/device_tests.gyp index 864a320..126fada 100644 --- a/device/device_tests.gyp +++ b/device/device_tests.gyp @@ -36,20 +36,14 @@ 'battery/battery_status_manager_win_unittest.cc', 'battery/battery_status_service_unittest.cc', 'bluetooth/bluetooth_adapter_mac_unittest.mm', - 'bluetooth/bluetooth_adapter_profile_chromeos_unittest.cc', 'bluetooth/bluetooth_adapter_unittest.cc', 'bluetooth/bluetooth_adapter_win_unittest.cc', - 'bluetooth/bluetooth_advertisement_chromeos_unittest.cc', 'bluetooth/bluetooth_advertisement_unittest.cc', - 'bluetooth/bluetooth_audio_sink_chromeos_unittest.cc', - 'bluetooth/bluetooth_chromeos_unittest.cc', 'bluetooth/bluetooth_device_unittest.cc', 'bluetooth/bluetooth_device_win_unittest.cc', 'bluetooth/bluetooth_discovery_filter_unittest.cc', - 'bluetooth/bluetooth_gatt_chromeos_unittest.cc', 'bluetooth/bluetooth_low_energy_win_unittest.cc', 'bluetooth/bluetooth_service_record_win_unittest.cc', - 'bluetooth/bluetooth_socket_chromeos_unittest.cc', 'bluetooth/bluetooth_task_manager_win_unittest.cc', 'bluetooth/bluetooth_uuid_unittest.cc', 'bluetooth/test/bluetooth_test.cc', @@ -90,15 +84,27 @@ 'conditions': [ ['chromeos==1', { 'dependencies': [ - '../build/linux/system.gyp:dbus', '../chromeos/chromeos.gyp:chromeos_test_support', '../chromeos/chromeos.gyp:chromeos_test_support_without_gmock', - '../dbus/dbus.gyp:dbus', ], 'sources!': [ 'battery/battery_status_manager_linux_unittest.cc', ], }], + ['chromeos==1 or OS=="linux"', { + 'dependencies': [ + '../build/linux/system.gyp:dbus', + '../dbus/dbus.gyp:dbus', + ], + 'sources': [ + 'bluetooth/bluetooth_adapter_profile_bluez_unittest.cc', + 'bluetooth/bluetooth_advertisement_bluez_unittest.cc', + 'bluetooth/bluetooth_audio_sink_bluez_unittest.cc', + 'bluetooth/bluetooth_bluez_unittest.cc', + 'bluetooth/bluetooth_gatt_bluez_unittest.cc', + 'bluetooth/bluetooth_socket_bluez_unittest.cc', + ], + }], ['OS=="android"', { 'dependencies!': [ '../tools/usb_gadget/usb_gadget.gyp:usb_gadget', |