diff options
author | rkc <rkc@chromium.org> | 2015-11-04 17:55:40 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-05 01:56:30 +0000 |
commit | 06c92c041f3b7b62bcddec714fb886b431865057 (patch) | |
tree | 1745f16086c453e1671e6b02df73626cded2f295 | |
parent | a9ed17edd6831510d2d50680824740a485ae25d6 (diff) | |
download | chromium_src-06c92c041f3b7b62bcddec714fb886b431865057.zip chromium_src-06c92c041f3b7b62bcddec714fb886b431865057.tar.gz chromium_src-06c92c041f3b7b62bcddec714fb886b431865057.tar.bz2 |
Reland: Refactor DBusThreadManager to split away BT clients.
This is a reland of
This CL doesn't change any of the code except for merge and lint changes.
The original CL was triggering a test crash in Valgrind. On this patch,
I've run Valgrind multiple times locally and also additionally run TSan.
Since I am seeing no failures, after talking to glider@ (who works on
Valgrind), I'm attempting to re-land this CL.
TBR=armansito@chromium.org, glider@chromium.org, isherman@chromium.org, oshima@chromium.org, sky@chromium.org, stevenjb@chromium.org
BUG=None.
Committed: c56b94daaf6513891e7da3094ab5054ffbd6262
Cr-Commit-Position: refs/heads/master@{#357707}
Review URL: https://codereview.chromium.org/1411793010
Cr-Commit-Position: refs/heads/master@{#357976}
127 files changed, 2488 insertions, 1888 deletions
diff --git a/ash/test/ash_test_helper.cc b/ash/test/ash_test_helper.cc index 995b9f5..560f8ef 100644 --- a/ash/test/ash_test_helper.cc +++ b/ash/test/ash_test_helper.cc @@ -32,6 +32,7 @@ #if defined(OS_CHROMEOS) #include "chromeos/audio/cras_audio_handler.h" #include "chromeos/dbus/dbus_thread_manager.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" #endif #if defined(OS_WIN) @@ -54,6 +55,7 @@ AshTestHelper::AshTestHelper(base::MessageLoopForUI* message_loop) CHECK(message_loop_); #if defined(OS_CHROMEOS) dbus_thread_manager_initialized_ = false; + bluez_dbus_manager_initialized_ = false; #endif #if defined(USE_X11) aura::test::SetUseOverrideRedirectWindowByDefault(true); @@ -91,6 +93,15 @@ void AshTestHelper::SetUp(bool start_session) { chromeos::DBusThreadManager::Initialize(); dbus_thread_manager_initialized_ = true; } + + if (!bluez::BluezDBusManager::IsInitialized()) { + bluez::BluezDBusManager::Initialize( + chromeos::DBusThreadManager::Get()->GetSystemBus(), + chromeos::DBusThreadManager::Get()->IsUsingStub( + chromeos::DBusClientBundle::BLUETOOTH)); + bluez_dbus_manager_initialized_ = true; + } + // Create CrasAudioHandler for testing since g_browser_process is not // created in AshTestBase tests. chromeos::CrasAudioHandler::InitializeForTesting(); @@ -136,6 +147,10 @@ void AshTestHelper::TearDown() { #if defined(OS_CHROMEOS) chromeos::CrasAudioHandler::Shutdown(); + if (bluez_dbus_manager_initialized_) { + bluez::BluezDBusManager::Shutdown(); + bluez_dbus_manager_initialized_ = false; + } if (dbus_thread_manager_initialized_) { chromeos::DBusThreadManager::Shutdown(); dbus_thread_manager_initialized_ = false; diff --git a/ash/test/ash_test_helper.h b/ash/test/ash_test_helper.h index daa3316..e324fe4 100644 --- a/ash/test/ash_test_helper.h +++ b/ash/test/ash_test_helper.h @@ -101,6 +101,8 @@ class AshTestHelper { #if defined(OS_CHROMEOS) // Check if DBus Thread Manager was initialized here. bool dbus_thread_manager_initialized_; + // Check if Bluez DBus Manager was initialized here. + bool bluez_dbus_manager_initialized_; #endif DISALLOW_COPY_AND_ASSIGN(AshTestHelper); diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc index f88e8b8..0f1fd63 100644 --- a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc +++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc @@ -121,6 +121,7 @@ #include "content/public/common/content_switches.h" #include "content/public/common/main_function_params.h" #include "device/bluetooth/bluetooth_adapter_factory.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" #include "media/audio/sounds/sounds_manager.h" #include "net/base/network_change_notifier.h" #include "net/socket/ssl_server_socket.h" @@ -186,6 +187,12 @@ class DBusServices { // Initialize DBusThreadManager for the browser. This must be done after // the main message loop is started, as it uses the message loop. DBusThreadManager::Initialize(); + + bluez::BluezDBusManager::Initialize( + DBusThreadManager::Get()->GetSystemBus(), + chromeos::DBusThreadManager::Get()->IsUsingStub( + chromeos::DBusClientBundle::BLUETOOTH)); + PowerPolicyController::Initialize( DBusThreadManager::Get()->GetPowerManagerClient()); @@ -252,6 +259,7 @@ class DBusServices { PowerDataCollector::Shutdown(); PowerPolicyController::Shutdown(); device::BluetoothAdapterFactory::Shutdown(); + bluez::BluezDBusManager::Shutdown(); // NOTE: This must only be called if Initialize() was called. DBusThreadManager::Shutdown(); diff --git a/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api_chromeos_unittest.cc b/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api_chromeos_unittest.cc index 912bd70..fc1c8c8 100644 --- a/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api_chromeos_unittest.cc +++ b/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api_chromeos_unittest.cc @@ -26,6 +26,7 @@ #include "chromeos/dbus/fake_easy_unlock_client.h" #include "components/proximity_auth/cryptauth/proto/cryptauth_api.pb.h" #include "components/proximity_auth/switches.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" #include "extensions/browser/api_test_utils.h" #include "extensions/browser/event_router.h" #include "extensions/browser/event_router_factory.h" @@ -127,6 +128,10 @@ class EasyUnlockPrivateApiTest : public extensions::ExtensionApiUnittest { protected: void SetUp() override { chromeos::DBusThreadManager::Initialize(); + bluez::BluezDBusManager::Initialize( + chromeos::DBusThreadManager::Get()->GetSystemBus(), + chromeos::DBusThreadManager::Get()->IsUsingStub( + chromeos::DBusClientBundle::BLUETOOTH)); client_ = chromeos::DBusThreadManager::Get()->GetEasyUnlockClient(); extensions::ExtensionApiUnittest::SetUp(); @@ -135,6 +140,7 @@ class EasyUnlockPrivateApiTest : public extensions::ExtensionApiUnittest { void TearDown() override { extensions::ExtensionApiUnittest::TearDown(); + bluez::BluezDBusManager::Shutdown(); chromeos::DBusThreadManager::Shutdown(); } diff --git a/chrome/browser/metrics/chromeos_metrics_provider_unittest.cc b/chrome/browser/metrics/chromeos_metrics_provider_unittest.cc index f0fc27d..4801acc 100644 --- a/chrome/browser/metrics/chromeos_metrics_provider_unittest.cc +++ b/chrome/browser/metrics/chromeos_metrics_provider_unittest.cc @@ -11,41 +11,44 @@ #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" #include "chrome/browser/metrics/chromeos_metrics_provider.h" #include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_adapter_client.h" -#include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" -#include "chromeos/dbus/fake_bluetooth_device_client.h" -#include "chromeos/dbus/fake_bluetooth_gatt_characteristic_client.h" -#include "chromeos/dbus/fake_bluetooth_gatt_descriptor_client.h" -#include "chromeos/dbus/fake_bluetooth_gatt_service_client.h" -#include "chromeos/dbus/fake_bluetooth_input_client.h" #include "chromeos/dbus/power_manager_client.h" #include "chromeos/login/login_state.h" #include "components/metrics/proto/system_profile.pb.h" #include "components/user_manager/user_manager.h" #include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_utils.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" +#include "device/bluetooth/dbus/fake_bluetooth_device_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_service_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_input_client.h" #include "testing/gtest/include/gtest/gtest.h" #if defined(USE_X11) #include "ui/events/devices/x11/device_data_manager_x11.h" #endif +using bluez::BluetoothAdapterClient; +using bluez::BluetoothAgentManagerClient; +using bluez::BluetoothDeviceClient; +using bluez::BluetoothGattCharacteristicClient; +using bluez::BluetoothGattDescriptorClient; +using bluez::BluetoothGattServiceClient; +using bluez::BluetoothInputClient; +using bluez::BluezDBusManager; +using bluez::BluezDBusManagerSetter; +using bluez::FakeBluetoothAdapterClient; +using bluez::FakeBluetoothAgentManagerClient; +using bluez::FakeBluetoothDeviceClient; +using bluez::FakeBluetoothGattCharacteristicClient; +using bluez::FakeBluetoothGattDescriptorClient; +using bluez::FakeBluetoothGattServiceClient; +using bluez::FakeBluetoothInputClient; using chromeos::DBusThreadManager; using chromeos::DBusThreadManagerSetter; -using chromeos::BluetoothAdapterClient; -using chromeos::BluetoothAgentManagerClient; -using chromeos::BluetoothDeviceClient; -using chromeos::BluetoothGattCharacteristicClient; -using chromeos::BluetoothGattDescriptorClient; -using chromeos::BluetoothGattServiceClient; -using chromeos::BluetoothInputClient; -using chromeos::FakeBluetoothAdapterClient; -using chromeos::FakeBluetoothAgentManagerClient; -using chromeos::FakeBluetoothDeviceClient; -using chromeos::FakeBluetoothGattCharacteristicClient; -using chromeos::FakeBluetoothGattDescriptorClient; -using chromeos::FakeBluetoothGattServiceClient; -using chromeos::FakeBluetoothInputClient; using chromeos::PowerManagerClient; using chromeos::STUB_DBUS_CLIENT_IMPLEMENTATION; @@ -60,37 +63,39 @@ class ChromeOSMetricsProviderTest : public testing::Test { #endif // Set up the fake Bluetooth environment, - scoped_ptr<DBusThreadManagerSetter> dbus_setter = - DBusThreadManager::GetSetterForTesting(); - dbus_setter->SetBluetoothAdapterClient( + scoped_ptr<BluezDBusManagerSetter> bluez_dbus_setter = + BluezDBusManager::GetSetterForTesting(); + bluez_dbus_setter->SetBluetoothAdapterClient( scoped_ptr<BluetoothAdapterClient>(new FakeBluetoothAdapterClient)); - dbus_setter->SetBluetoothDeviceClient( + bluez_dbus_setter->SetBluetoothDeviceClient( scoped_ptr<BluetoothDeviceClient>(new FakeBluetoothDeviceClient)); - dbus_setter->SetBluetoothGattCharacteristicClient( + bluez_dbus_setter->SetBluetoothGattCharacteristicClient( scoped_ptr<BluetoothGattCharacteristicClient>( new FakeBluetoothGattCharacteristicClient)); - dbus_setter->SetBluetoothGattDescriptorClient( + bluez_dbus_setter->SetBluetoothGattDescriptorClient( scoped_ptr<BluetoothGattDescriptorClient>( new FakeBluetoothGattDescriptorClient)); - dbus_setter->SetBluetoothGattServiceClient( + bluez_dbus_setter->SetBluetoothGattServiceClient( scoped_ptr<BluetoothGattServiceClient>( new FakeBluetoothGattServiceClient)); - dbus_setter->SetBluetoothInputClient( + bluez_dbus_setter->SetBluetoothInputClient( scoped_ptr<BluetoothInputClient>(new FakeBluetoothInputClient)); - dbus_setter->SetBluetoothAgentManagerClient( + bluez_dbus_setter->SetBluetoothAgentManagerClient( scoped_ptr<BluetoothAgentManagerClient>( new FakeBluetoothAgentManagerClient)); // Set up a PowerManagerClient instance for PerfProvider. + scoped_ptr<DBusThreadManagerSetter> dbus_setter = + DBusThreadManager::GetSetterForTesting(); dbus_setter->SetPowerManagerClient( scoped_ptr<PowerManagerClient>( PowerManagerClient::Create(STUB_DBUS_CLIENT_IMPLEMENTATION))); // Grab pointers to members of the thread manager for easier testing. fake_bluetooth_adapter_client_ = static_cast<FakeBluetoothAdapterClient*>( - DBusThreadManager::Get()->GetBluetoothAdapterClient()); + BluezDBusManager::Get()->GetBluetoothAdapterClient()); fake_bluetooth_device_client_ = static_cast<FakeBluetoothDeviceClient*>( - DBusThreadManager::Get()->GetBluetoothDeviceClient()); + BluezDBusManager::Get()->GetBluetoothDeviceClient()); // Initialize the login state trackers. if (!chromeos::LoginState::IsInitialized()) diff --git a/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc b/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc index 260b2f6..932d7a9 100644 --- a/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc +++ b/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc @@ -10,12 +10,13 @@ #include "base/strings/string_number_conversions.h" #include "base/values.h" #include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_adapter_client.h" -#include "chromeos/dbus/fake_bluetooth_device_client.h" #include "chromeos/dbus/fake_cras_audio_client.h" #include "chromeos/dbus/fake_power_manager_client.h" #include "content/public/browser/web_ui.h" #include "device/bluetooth/bluetooth_device_chromeos.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" +#include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_device_client.h" namespace { @@ -63,7 +64,7 @@ const char kPairedPropertyName[] = "Paired"; namespace chromeos { class DeviceEmulatorMessageHandler::BluetoothObserver - : public BluetoothDeviceClient::Observer { + : public bluez::BluetoothDeviceClient::Observer { public: explicit BluetoothObserver(DeviceEmulatorMessageHandler* owner) : owner_(owner) { @@ -179,8 +180,8 @@ void DeviceEmulatorMessageHandler::PowerObserver::PowerChanged( DeviceEmulatorMessageHandler::DeviceEmulatorMessageHandler() : fake_bluetooth_device_client_( - static_cast<chromeos::FakeBluetoothDeviceClient*>( - chromeos::DBusThreadManager::Get() + static_cast<bluez::FakeBluetoothDeviceClient*>( + bluez::BluezDBusManager::Get() ->GetBluetoothDeviceClient())), fake_cras_audio_client_(static_cast<chromeos::FakeCrasAudioClient*>( chromeos::DBusThreadManager::Get() @@ -208,7 +209,7 @@ void DeviceEmulatorMessageHandler::HandleRemoveBluetoothDevice( std::string path; CHECK(args->GetString(0, &path)); fake_bluetooth_device_client_->RemoveDevice( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), dbus::ObjectPath(path)); } @@ -223,7 +224,7 @@ void DeviceEmulatorMessageHandler::HandleRequestBluetoothInfo( // the main adapter. std::vector<dbus::ObjectPath> paths = fake_bluetooth_device_client_->GetDevicesForAdapter( - dbus::ObjectPath(chromeos::FakeBluetoothAdapterClient::kAdapterPath)); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath)); base::ListValue devices; // Get each device's properties. @@ -237,21 +238,21 @@ void DeviceEmulatorMessageHandler::HandleRequestBluetoothInfo( base::ListValue pairing_method_options; pairing_method_options.AppendString( - FakeBluetoothDeviceClient::kPairingMethodNone); + bluez::FakeBluetoothDeviceClient::kPairingMethodNone); pairing_method_options.AppendString( - FakeBluetoothDeviceClient::kPairingMethodPinCode); + bluez::FakeBluetoothDeviceClient::kPairingMethodPinCode); pairing_method_options.AppendString( - FakeBluetoothDeviceClient::kPairingMethodPassKey); + bluez::FakeBluetoothDeviceClient::kPairingMethodPassKey); base::ListValue pairing_action_options; pairing_action_options.AppendString( - FakeBluetoothDeviceClient::kPairingActionDisplay); + bluez::FakeBluetoothDeviceClient::kPairingActionDisplay); pairing_action_options.AppendString( - FakeBluetoothDeviceClient::kPairingActionRequest); + bluez::FakeBluetoothDeviceClient::kPairingActionRequest); pairing_action_options.AppendString( - FakeBluetoothDeviceClient::kPairingActionConfirmation); + bluez::FakeBluetoothDeviceClient::kPairingActionConfirmation); pairing_action_options.AppendString( - FakeBluetoothDeviceClient::kPairingActionFail); + bluez::FakeBluetoothDeviceClient::kPairingActionFail); // Send the list of devices to the view. web_ui()->CallJavascriptFunction(kUpdateBluetoothInfoJSCallback, @@ -263,7 +264,7 @@ void DeviceEmulatorMessageHandler::HandleRequestBluetoothPair( const base::ListValue* args) { // Create the device if it does not already exist. std::string path = CreateBluetoothDeviceFromListValue(args); - chromeos::FakeBluetoothDeviceClient::Properties* props = + bluez::FakeBluetoothDeviceClient::Properties* props = fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath(path)); // Try to pair the device with the main adapter. The device is identified @@ -442,7 +443,7 @@ void DeviceEmulatorMessageHandler::RegisterMessages() { std::string DeviceEmulatorMessageHandler::CreateBluetoothDeviceFromListValue( const base::ListValue* args) { const base::DictionaryValue* device_dict = nullptr; - FakeBluetoothDeviceClient::IncomingDeviceProperties props; + bluez::FakeBluetoothDeviceClient::IncomingDeviceProperties props; CHECK(args->GetDictionary(0, &device_dict)); CHECK(device_dict->GetString("path", &props.device_path)); @@ -459,8 +460,7 @@ std::string DeviceEmulatorMessageHandler::CreateBluetoothDeviceFromListValue( // Create the device and store it in the FakeBluetoothDeviceClient's observed // list of devices. fake_bluetooth_device_client_->CreateDeviceWithProperties( - dbus::ObjectPath(chromeos::FakeBluetoothAdapterClient::kAdapterPath), - props); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), props); return props.device_path; } @@ -468,11 +468,11 @@ std::string DeviceEmulatorMessageHandler::CreateBluetoothDeviceFromListValue( scoped_ptr<base::DictionaryValue> DeviceEmulatorMessageHandler::GetDeviceInfo( const dbus::ObjectPath& object_path) { // Get the device's properties. - chromeos::FakeBluetoothDeviceClient::Properties* props = + bluez::FakeBluetoothDeviceClient::Properties* props = fake_bluetooth_device_client_->GetProperties(object_path); scoped_ptr<base::DictionaryValue> device(new base::DictionaryValue()); scoped_ptr<base::ListValue> uuids(new base::ListValue); - chromeos::FakeBluetoothDeviceClient::SimulatedPairingOptions* options = + bluez::FakeBluetoothDeviceClient::SimulatedPairingOptions* options = fake_bluetooth_device_client_->GetPairingOptions(object_path); device->SetString("path", object_path.value()); diff --git a/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.h b/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.h index 840111b..882af77 100644 --- a/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.h +++ b/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.h @@ -17,9 +17,12 @@ namespace dbus { class ObjectPath; } // namespace dbus +namespace bluez { +class FakeBluetoothDeviceClient; +} + namespace chromeos { -class FakeBluetoothDeviceClient; class FakeCrasAudioClient; class FakePowerManagerClient; @@ -99,7 +102,7 @@ class DeviceEmulatorMessageHandler scoped_ptr<base::DictionaryValue> GetDeviceInfo( const dbus::ObjectPath& object_path); - FakeBluetoothDeviceClient* fake_bluetooth_device_client_; + bluez::FakeBluetoothDeviceClient* fake_bluetooth_device_client_; scoped_ptr<BluetoothObserver> bluetooth_observer_; FakeCrasAudioClient* fake_cras_audio_client_; diff --git a/chrome/test/DEPS b/chrome/test/DEPS index 2d596c8..2167a41 100644 --- a/chrome/test/DEPS +++ b/chrome/test/DEPS @@ -6,6 +6,7 @@ include_rules = [ "+chrome/grit", # For generated headers "+chromeos", "+components", + "+device/bluetooth/dbus", "+extensions", # Tests under chrome/ shouldn't need to access the internals of content/ and diff --git a/chrome/test/base/testing_io_thread_state.cc b/chrome/test/base/testing_io_thread_state.cc index 8ebd202..09b07f2 100644 --- a/chrome/test/base/testing_io_thread_state.cc +++ b/chrome/test/base/testing_io_thread_state.cc @@ -16,6 +16,7 @@ #if defined(OS_CHROMEOS) #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/network/network_handler.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" #endif using content::BrowserThread; @@ -42,6 +43,10 @@ TestingIOThreadState::TestingIOThreadState() { #if defined(OS_CHROMEOS) // Needed by IOThread constructor. chromeos::DBusThreadManager::Initialize(); + bluez::BluezDBusManager::Initialize( + chromeos::DBusThreadManager::Get()->GetSystemBus(), + chromeos::DBusThreadManager::Get()->IsUsingStub( + chromeos::DBusClientBundle::BLUETOOTH)); chromeos::NetworkHandler::Initialize(); #endif @@ -75,6 +80,7 @@ TestingIOThreadState::~TestingIOThreadState() { #if defined(OS_CHROMEOS) chromeos::NetworkHandler::Shutdown(); + bluez::BluezDBusManager::Shutdown(); chromeos::DBusThreadManager::Shutdown(); #endif } diff --git a/chrome/test/base/view_event_test_platform_part_chromeos.cc b/chrome/test/base/view_event_test_platform_part_chromeos.cc index 2cf14ef..16a678e 100644 --- a/chrome/test/base/view_event_test_platform_part_chromeos.cc +++ b/chrome/test/base/view_event_test_platform_part_chromeos.cc @@ -15,6 +15,7 @@ #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/network/network_handler.h" #include "content/public/browser/browser_thread.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" #include "ui/aura/env.h" #include "ui/aura/window_tree_host.h" #include "ui/message_center/message_center.h" @@ -46,6 +47,10 @@ ViewEventTestPlatformPartChromeOS::ViewEventTestPlatformPartChromeOS( // also create the message center. message_center::MessageCenter::Initialize(); chromeos::DBusThreadManager::Initialize(); + bluez::BluezDBusManager::Initialize( + chromeos::DBusThreadManager::Get()->GetSystemBus(), + chromeos::DBusThreadManager::Get()->IsUsingStub( + chromeos::DBusClientBundle::BLUETOOTH)); chromeos::CrasAudioHandler::InitializeForTesting(); chromeos::NetworkHandler::Initialize(); @@ -70,6 +75,7 @@ ViewEventTestPlatformPartChromeOS::~ViewEventTestPlatformPartChromeOS() { chromeos::NetworkHandler::Shutdown(); chromeos::CrasAudioHandler::Shutdown(); + bluez::BluezDBusManager::Shutdown(); chromeos::DBusThreadManager::Shutdown(); // Ash Shell can't just live on its own without a browser process, we need to // also shut down the message center. diff --git a/chromeos/chromeos.gyp b/chromeos/chromeos.gyp index bce686c..d2f0511 100644 --- a/chromeos/chromeos.gyp +++ b/chromeos/chromeos.gyp @@ -61,44 +61,6 @@ 'dbus/audio_node.h', 'dbus/blocking_method_caller.cc', 'dbus/blocking_method_caller.h', - 'dbus/bluetooth_adapter_client.cc', - 'dbus/bluetooth_adapter_client.h', - 'dbus/bluetooth_le_advertising_manager_client.cc', - 'dbus/bluetooth_le_advertising_manager_client.h', - 'dbus/bluetooth_le_advertisement_service_provider.cc', - 'dbus/bluetooth_le_advertisement_service_provider.h', - 'dbus/bluetooth_agent_manager_client.cc', - 'dbus/bluetooth_agent_manager_client.h', - 'dbus/bluetooth_agent_service_provider.cc', - 'dbus/bluetooth_agent_service_provider.h', - 'dbus/bluetooth_device_client.cc', - 'dbus/bluetooth_device_client.h', - 'dbus/bluetooth_gatt_characteristic_client.cc', - 'dbus/bluetooth_gatt_characteristic_client.h', - 'dbus/bluetooth_gatt_characteristic_service_provider.cc', - 'dbus/bluetooth_gatt_characteristic_service_provider.h', - 'dbus/bluetooth_gatt_descriptor_client.cc', - 'dbus/bluetooth_gatt_descriptor_client.h', - 'dbus/bluetooth_gatt_descriptor_service_provider.cc', - 'dbus/bluetooth_gatt_descriptor_service_provider.h', - 'dbus/bluetooth_gatt_manager_client.cc', - 'dbus/bluetooth_gatt_manager_client.h', - 'dbus/bluetooth_gatt_service_client.cc', - 'dbus/bluetooth_gatt_service_client.h', - 'dbus/bluetooth_gatt_service_service_provider.cc', - 'dbus/bluetooth_gatt_service_service_provider.h', - 'dbus/bluetooth_input_client.cc', - 'dbus/bluetooth_input_client.h', - 'dbus/bluetooth_media_client.cc', - 'dbus/bluetooth_media_client.h', - 'dbus/bluetooth_media_endpoint_service_provider.cc', - 'dbus/bluetooth_media_endpoint_service_provider.h', - 'dbus/bluetooth_media_transport_client.cc', - 'dbus/bluetooth_media_transport_client.h', - 'dbus/bluetooth_profile_manager_client.cc', - 'dbus/bluetooth_profile_manager_client.h', - 'dbus/bluetooth_profile_service_provider.cc', - 'dbus/bluetooth_profile_service_provider.h', 'dbus/cras_audio_client.cc', 'dbus/cras_audio_client.h', 'dbus/cros_disks_client.cc', @@ -124,44 +86,6 @@ 'dbus/fake_arc_bridge_client.h', 'dbus/fake_audio_dsp_client.cc', 'dbus/fake_audio_dsp_client.h', - 'dbus/fake_bluetooth_adapter_client.cc', - 'dbus/fake_bluetooth_adapter_client.h', - 'dbus/fake_bluetooth_le_advertising_manager_client.cc', - 'dbus/fake_bluetooth_le_advertising_manager_client.h', - 'dbus/fake_bluetooth_le_advertisement_service_provider.cc', - 'dbus/fake_bluetooth_le_advertisement_service_provider.h', - 'dbus/fake_bluetooth_agent_manager_client.cc', - 'dbus/fake_bluetooth_agent_manager_client.h', - 'dbus/fake_bluetooth_agent_service_provider.cc', - 'dbus/fake_bluetooth_agent_service_provider.h', - 'dbus/fake_bluetooth_device_client.cc', - 'dbus/fake_bluetooth_device_client.h', - 'dbus/fake_bluetooth_gatt_characteristic_client.cc', - 'dbus/fake_bluetooth_gatt_characteristic_client.h', - 'dbus/fake_bluetooth_gatt_characteristic_service_provider.cc', - 'dbus/fake_bluetooth_gatt_characteristic_service_provider.h', - 'dbus/fake_bluetooth_gatt_descriptor_client.cc', - 'dbus/fake_bluetooth_gatt_descriptor_client.h', - 'dbus/fake_bluetooth_gatt_descriptor_service_provider.cc', - 'dbus/fake_bluetooth_gatt_descriptor_service_provider.h', - 'dbus/fake_bluetooth_gatt_manager_client.cc', - 'dbus/fake_bluetooth_gatt_manager_client.h', - 'dbus/fake_bluetooth_gatt_service_client.cc', - 'dbus/fake_bluetooth_gatt_service_client.h', - 'dbus/fake_bluetooth_gatt_service_service_provider.cc', - 'dbus/fake_bluetooth_gatt_service_service_provider.h', - 'dbus/fake_bluetooth_input_client.cc', - 'dbus/fake_bluetooth_input_client.h', - 'dbus/fake_bluetooth_media_client.cc', - 'dbus/fake_bluetooth_media_client.h', - 'dbus/fake_bluetooth_media_endpoint_service_provider.cc', - 'dbus/fake_bluetooth_media_endpoint_service_provider.h', - 'dbus/fake_bluetooth_media_transport_client.cc', - 'dbus/fake_bluetooth_media_transport_client.h', - 'dbus/fake_bluetooth_profile_manager_client.cc', - 'dbus/fake_bluetooth_profile_manager_client.h', - 'dbus/fake_bluetooth_profile_service_provider.cc', - 'dbus/fake_bluetooth_profile_service_provider.h', 'dbus/fake_cras_audio_client.cc', 'dbus/fake_cras_audio_client.h', 'dbus/fake_cros_disks_client.cc', diff --git a/chromeos/dbus/dbus_client_bundle.cc b/chromeos/dbus/dbus_client_bundle.cc index 941bec6..0397ff6 100644 --- a/chromeos/dbus/dbus_client_bundle.cc +++ b/chromeos/dbus/dbus_client_bundle.cc @@ -14,18 +14,6 @@ #include "chromeos/dbus/ap_manager_client.h" #include "chromeos/dbus/arc_bridge_client.h" #include "chromeos/dbus/audio_dsp_client.h" -#include "chromeos/dbus/bluetooth_adapter_client.h" -#include "chromeos/dbus/bluetooth_agent_manager_client.h" -#include "chromeos/dbus/bluetooth_device_client.h" -#include "chromeos/dbus/bluetooth_gatt_characteristic_client.h" -#include "chromeos/dbus/bluetooth_gatt_descriptor_client.h" -#include "chromeos/dbus/bluetooth_gatt_manager_client.h" -#include "chromeos/dbus/bluetooth_gatt_service_client.h" -#include "chromeos/dbus/bluetooth_input_client.h" -#include "chromeos/dbus/bluetooth_le_advertising_manager_client.h" -#include "chromeos/dbus/bluetooth_media_client.h" -#include "chromeos/dbus/bluetooth_media_transport_client.h" -#include "chromeos/dbus/bluetooth_profile_manager_client.h" #include "chromeos/dbus/cras_audio_client.h" #include "chromeos/dbus/cros_disks_client.h" #include "chromeos/dbus/cryptohome_client.h" @@ -35,18 +23,6 @@ #include "chromeos/dbus/fake_ap_manager_client.h" #include "chromeos/dbus/fake_arc_bridge_client.h" #include "chromeos/dbus/fake_audio_dsp_client.h" -#include "chromeos/dbus/fake_bluetooth_adapter_client.h" -#include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" -#include "chromeos/dbus/fake_bluetooth_device_client.h" -#include "chromeos/dbus/fake_bluetooth_gatt_characteristic_client.h" -#include "chromeos/dbus/fake_bluetooth_gatt_descriptor_client.h" -#include "chromeos/dbus/fake_bluetooth_gatt_manager_client.h" -#include "chromeos/dbus/fake_bluetooth_gatt_service_client.h" -#include "chromeos/dbus/fake_bluetooth_input_client.h" -#include "chromeos/dbus/fake_bluetooth_le_advertising_manager_client.h" -#include "chromeos/dbus/fake_bluetooth_media_client.h" -#include "chromeos/dbus/fake_bluetooth_media_transport_client.h" -#include "chromeos/dbus/fake_bluetooth_profile_manager_client.h" #include "chromeos/dbus/fake_cras_audio_client.h" #include "chromeos/dbus/fake_cryptohome_client.h" #include "chromeos/dbus/fake_debug_daemon_client.h" @@ -165,45 +141,6 @@ DBusClientBundle::DBusClientBundle(DBusClientTypeMask unstub_client_mask) else audio_dsp_client_.reset(new FakeAudioDspClient); - if (!IsUsingStub(BLUETOOTH)) { - bluetooth_adapter_client_.reset(BluetoothAdapterClient::Create()); - bluetooth_le_advertising_manager_client_.reset( - BluetoothLEAdvertisingManagerClient::Create()); - bluetooth_agent_manager_client_.reset( - BluetoothAgentManagerClient::Create()); - bluetooth_device_client_.reset(BluetoothDeviceClient::Create()); - bluetooth_input_client_.reset(BluetoothInputClient::Create()); - bluetooth_media_client_.reset(BluetoothMediaClient::Create()); - bluetooth_media_transport_client_.reset( - BluetoothMediaTransportClient::Create()); - bluetooth_profile_manager_client_.reset( - BluetoothProfileManagerClient::Create()); - bluetooth_gatt_characteristic_client_.reset( - BluetoothGattCharacteristicClient::Create()); - bluetooth_gatt_descriptor_client_.reset( - BluetoothGattDescriptorClient::Create()); - bluetooth_gatt_manager_client_.reset(BluetoothGattManagerClient::Create()); - bluetooth_gatt_service_client_.reset(BluetoothGattServiceClient::Create()); - } else { - bluetooth_adapter_client_.reset(new FakeBluetoothAdapterClient); - bluetooth_le_advertising_manager_client_.reset( - new FakeBluetoothLEAdvertisingManagerClient); - bluetooth_agent_manager_client_.reset(new FakeBluetoothAgentManagerClient); - bluetooth_device_client_.reset(new FakeBluetoothDeviceClient); - bluetooth_input_client_.reset(new FakeBluetoothInputClient); - bluetooth_media_client_.reset(new FakeBluetoothMediaClient); - bluetooth_media_transport_client_.reset( - new FakeBluetoothMediaTransportClient); - bluetooth_profile_manager_client_.reset( - new FakeBluetoothProfileManagerClient); - bluetooth_gatt_characteristic_client_.reset( - new FakeBluetoothGattCharacteristicClient); - bluetooth_gatt_descriptor_client_.reset( - new FakeBluetoothGattDescriptorClient); - bluetooth_gatt_manager_client_.reset(new FakeBluetoothGattManagerClient); - bluetooth_gatt_service_client_.reset(new FakeBluetoothGattServiceClient); - } - if (!IsUsingStub(CRAS)) cras_audio_client_.reset(CrasAudioClient::Create()); else diff --git a/chromeos/dbus/dbus_client_bundle.h b/chromeos/dbus/dbus_client_bundle.h index 536eb4d..2fd9e58 100644 --- a/chromeos/dbus/dbus_client_bundle.h +++ b/chromeos/dbus/dbus_client_bundle.h @@ -16,18 +16,6 @@ class AmplifierClient; class ApManagerClient; class ArcBridgeClient; class AudioDspClient; -class BluetoothAdapterClient; -class BluetoothAgentManagerClient; -class BluetoothDeviceClient; -class BluetoothGattCharacteristicClient; -class BluetoothGattDescriptorClient; -class BluetoothGattManagerClient; -class BluetoothGattServiceClient; -class BluetoothInputClient; -class BluetoothLEAdvertisingManagerClient; -class BluetoothMediaClient; -class BluetoothMediaTransportClient; -class BluetoothProfileManagerClient; class CrasAudioClient; class CrosDisksClient; class CryptohomeClient; @@ -120,55 +108,6 @@ class CHROMEOS_EXPORT DBusClientBundle { AudioDspClient* audio_dsp_client() { return audio_dsp_client_.get(); } - BluetoothAdapterClient* bluetooth_adapter_client() { - return bluetooth_adapter_client_.get(); - } - - BluetoothLEAdvertisingManagerClient* - bluetooth_le_advertising_manager_client() { - return bluetooth_le_advertising_manager_client_.get(); - } - - BluetoothAgentManagerClient* bluetooth_agent_manager_client() { - return bluetooth_agent_manager_client_.get(); - } - - BluetoothDeviceClient* bluetooth_device_client() { - return bluetooth_device_client_.get(); - } - - BluetoothGattCharacteristicClient* bluetooth_gatt_characteristic_client() { - return bluetooth_gatt_characteristic_client_.get(); - } - - BluetoothGattDescriptorClient* bluetooth_gatt_descriptor_client() { - return bluetooth_gatt_descriptor_client_.get(); - } - - BluetoothGattManagerClient* bluetooth_gatt_manager_client() { - return bluetooth_gatt_manager_client_.get(); - } - - BluetoothGattServiceClient* bluetooth_gatt_service_client() { - return bluetooth_gatt_service_client_.get(); - } - - BluetoothInputClient* bluetooth_input_client() { - return bluetooth_input_client_.get(); - } - - BluetoothMediaClient* bluetooth_media_client() { - return bluetooth_media_client_.get(); - } - - BluetoothMediaTransportClient* bluetooth_media_transport_client() { - return bluetooth_media_transport_client_.get(); - } - - BluetoothProfileManagerClient* bluetooth_profile_manager_client() { - return bluetooth_profile_manager_client_.get(); - } - CrasAudioClient* cras_audio_client() { return cras_audio_client_.get(); } @@ -296,20 +235,6 @@ class CHROMEOS_EXPORT DBusClientBundle { scoped_ptr<ApManagerClient> ap_manager_client_; scoped_ptr<ArcBridgeClient> arc_bridge_client_; scoped_ptr<AudioDspClient> audio_dsp_client_; - scoped_ptr<BluetoothAdapterClient> bluetooth_adapter_client_; - scoped_ptr<BluetoothLEAdvertisingManagerClient> - bluetooth_le_advertising_manager_client_; - scoped_ptr<BluetoothAgentManagerClient> bluetooth_agent_manager_client_; - scoped_ptr<BluetoothDeviceClient> bluetooth_device_client_; - scoped_ptr<BluetoothGattCharacteristicClient> - bluetooth_gatt_characteristic_client_; - scoped_ptr<BluetoothGattDescriptorClient> bluetooth_gatt_descriptor_client_; - scoped_ptr<BluetoothGattManagerClient> bluetooth_gatt_manager_client_; - scoped_ptr<BluetoothGattServiceClient> bluetooth_gatt_service_client_; - scoped_ptr<BluetoothInputClient> bluetooth_input_client_; - scoped_ptr<BluetoothMediaClient> bluetooth_media_client_; - scoped_ptr<BluetoothMediaTransportClient> bluetooth_media_transport_client_; - scoped_ptr<BluetoothProfileManagerClient> bluetooth_profile_manager_client_; scoped_ptr<CrasAudioClient> cras_audio_client_; scoped_ptr<CrosDisksClient> cros_disks_client_; scoped_ptr<CryptohomeClient> cryptohome_client_; diff --git a/chromeos/dbus/dbus_thread_manager.cc b/chromeos/dbus/dbus_thread_manager.cc index af03c1f..ab8db4f 100644 --- a/chromeos/dbus/dbus_thread_manager.cc +++ b/chromeos/dbus/dbus_thread_manager.cc @@ -12,18 +12,6 @@ #include "chromeos/dbus/ap_manager_client.h" #include "chromeos/dbus/arc_bridge_client.h" #include "chromeos/dbus/audio_dsp_client.h" -#include "chromeos/dbus/bluetooth_adapter_client.h" -#include "chromeos/dbus/bluetooth_agent_manager_client.h" -#include "chromeos/dbus/bluetooth_device_client.h" -#include "chromeos/dbus/bluetooth_gatt_characteristic_client.h" -#include "chromeos/dbus/bluetooth_gatt_descriptor_client.h" -#include "chromeos/dbus/bluetooth_gatt_manager_client.h" -#include "chromeos/dbus/bluetooth_gatt_service_client.h" -#include "chromeos/dbus/bluetooth_input_client.h" -#include "chromeos/dbus/bluetooth_le_advertising_manager_client.h" -#include "chromeos/dbus/bluetooth_media_client.h" -#include "chromeos/dbus/bluetooth_media_transport_client.h" -#include "chromeos/dbus/bluetooth_profile_manager_client.h" #include "chromeos/dbus/cras_audio_client.h" #include "chromeos/dbus/cros_disks_client.h" #include "chromeos/dbus/cryptohome_client.h" @@ -132,60 +120,6 @@ AudioDspClient* DBusThreadManager::GetAudioDspClient() { return client_bundle_->audio_dsp_client(); } -BluetoothAdapterClient* DBusThreadManager::GetBluetoothAdapterClient() { - return client_bundle_->bluetooth_adapter_client(); -} - -BluetoothLEAdvertisingManagerClient* -DBusThreadManager::GetBluetoothLEAdvertisingManagerClient() { - return client_bundle_->bluetooth_le_advertising_manager_client(); -} - -BluetoothAgentManagerClient* -DBusThreadManager::GetBluetoothAgentManagerClient() { - return client_bundle_->bluetooth_agent_manager_client(); -} - -BluetoothDeviceClient* DBusThreadManager::GetBluetoothDeviceClient() { - return client_bundle_->bluetooth_device_client(); -} - -BluetoothGattCharacteristicClient* -DBusThreadManager::GetBluetoothGattCharacteristicClient() { - return client_bundle_->bluetooth_gatt_characteristic_client(); -} - -BluetoothGattDescriptorClient* -DBusThreadManager::GetBluetoothGattDescriptorClient() { - return client_bundle_->bluetooth_gatt_descriptor_client(); -} - -BluetoothGattManagerClient* DBusThreadManager::GetBluetoothGattManagerClient() { - return client_bundle_->bluetooth_gatt_manager_client(); -} - -BluetoothGattServiceClient* DBusThreadManager::GetBluetoothGattServiceClient() { - return client_bundle_->bluetooth_gatt_service_client(); -} - -BluetoothInputClient* DBusThreadManager::GetBluetoothInputClient() { - return client_bundle_->bluetooth_input_client(); -} - -BluetoothMediaClient* DBusThreadManager::GetBluetoothMediaClient() { - return client_bundle_->bluetooth_media_client(); -} - -BluetoothMediaTransportClient* -DBusThreadManager::GetBluetoothMediaTransportClient() { - return client_bundle_->bluetooth_media_transport_client(); -} - -BluetoothProfileManagerClient* -DBusThreadManager::GetBluetoothProfileManagerClient() { - return client_bundle_->bluetooth_profile_manager_client(); -} - CrasAudioClient* DBusThreadManager::GetCrasAudioClient() { return client_bundle_->cras_audio_client(); } @@ -314,18 +248,6 @@ void DBusThreadManager::InitializeClients() { GetApManagerClient()->Init(GetSystemBus()); GetArcBridgeClient()->Init(GetSystemBus()); GetAudioDspClient()->Init(GetSystemBus()); - GetBluetoothAdapterClient()->Init(GetSystemBus()); - GetBluetoothAgentManagerClient()->Init(GetSystemBus()); - GetBluetoothDeviceClient()->Init(GetSystemBus()); - GetBluetoothGattCharacteristicClient()->Init(GetSystemBus()); - GetBluetoothGattDescriptorClient()->Init(GetSystemBus()); - GetBluetoothGattManagerClient()->Init(GetSystemBus()); - GetBluetoothGattServiceClient()->Init(GetSystemBus()); - GetBluetoothInputClient()->Init(GetSystemBus()); - GetBluetoothLEAdvertisingManagerClient()->Init(GetSystemBus()); - GetBluetoothMediaClient()->Init(GetSystemBus()); - GetBluetoothMediaTransportClient()->Init(GetSystemBus()); - GetBluetoothProfileManagerClient()->Init(GetSystemBus()); GetCrasAudioClient()->Init(GetSystemBus()); GetCrosDisksClient()->Init(GetSystemBus()); GetCryptohomeClient()->Init(GetSystemBus()); @@ -485,79 +407,6 @@ void DBusThreadManagerSetter::SetAudioDspClient( DBusThreadManager::Get()->client_bundle_->audio_dsp_client_ = client.Pass(); } -void DBusThreadManagerSetter::SetBluetoothAdapterClient( - scoped_ptr<BluetoothAdapterClient> client) { - DBusThreadManager::Get()->client_bundle_->bluetooth_adapter_client_ = - client.Pass(); -} - -void DBusThreadManagerSetter::SetBluetoothLEAdvertisingManagerClient( - scoped_ptr<BluetoothLEAdvertisingManagerClient> client) { - DBusThreadManager::Get() - ->client_bundle_->bluetooth_le_advertising_manager_client_ = - client.Pass(); -} - -void DBusThreadManagerSetter::SetBluetoothAgentManagerClient( - scoped_ptr<BluetoothAgentManagerClient> client) { - DBusThreadManager::Get()->client_bundle_->bluetooth_agent_manager_client_ = - client.Pass(); -} - -void DBusThreadManagerSetter::SetBluetoothDeviceClient( - scoped_ptr<BluetoothDeviceClient> client) { - DBusThreadManager::Get()->client_bundle_->bluetooth_device_client_ = - client.Pass(); -} - -void DBusThreadManagerSetter::SetBluetoothGattCharacteristicClient( - scoped_ptr<BluetoothGattCharacteristicClient> client) { - DBusThreadManager::Get() - ->client_bundle_->bluetooth_gatt_characteristic_client_ = client.Pass(); -} - -void DBusThreadManagerSetter::SetBluetoothGattDescriptorClient( - scoped_ptr<BluetoothGattDescriptorClient> client) { - DBusThreadManager::Get()->client_bundle_->bluetooth_gatt_descriptor_client_ = - client.Pass(); -} - -void DBusThreadManagerSetter::SetBluetoothGattManagerClient( - scoped_ptr<BluetoothGattManagerClient> client) { - DBusThreadManager::Get()->client_bundle_->bluetooth_gatt_manager_client_ = - client.Pass(); -} - -void DBusThreadManagerSetter::SetBluetoothGattServiceClient( - scoped_ptr<BluetoothGattServiceClient> client) { - DBusThreadManager::Get()->client_bundle_->bluetooth_gatt_service_client_ = - client.Pass(); -} - -void DBusThreadManagerSetter::SetBluetoothInputClient( - scoped_ptr<BluetoothInputClient> client) { - DBusThreadManager::Get()->client_bundle_->bluetooth_input_client_ = - client.Pass(); -} - -void DBusThreadManagerSetter::SetBluetoothMediaClient( - scoped_ptr<BluetoothMediaClient> client) { - DBusThreadManager::Get()->client_bundle_->bluetooth_media_client_ = - client.Pass(); -} - -void DBusThreadManagerSetter::SetBluetoothMediaTransportClient( - scoped_ptr<BluetoothMediaTransportClient> client) { - DBusThreadManager::Get()->client_bundle_->bluetooth_media_transport_client_ = - client.Pass(); -} - -void DBusThreadManagerSetter::SetBluetoothProfileManagerClient( - scoped_ptr<BluetoothProfileManagerClient> client) { - DBusThreadManager::Get()->client_bundle_->bluetooth_profile_manager_client_ = - client.Pass(); -} - void DBusThreadManagerSetter::SetCrasAudioClient( scoped_ptr<CrasAudioClient> client) { DBusThreadManager::Get()->client_bundle_->cras_audio_client_ = client.Pass(); diff --git a/chromeos/dbus/dbus_thread_manager.h b/chromeos/dbus/dbus_thread_manager.h index b002c9f..eaf9109 100644 --- a/chromeos/dbus/dbus_thread_manager.h +++ b/chromeos/dbus/dbus_thread_manager.h @@ -29,18 +29,6 @@ class AmplifierClient; class ApManagerClient; class ArcBridgeClient; class AudioDspClient; -class BluetoothAdapterClient; -class BluetoothLEAdvertisingManagerClient; -class BluetoothAgentManagerClient; -class BluetoothDeviceClient; -class BluetoothGattCharacteristicClient; -class BluetoothGattDescriptorClient; -class BluetoothGattManagerClient; -class BluetoothGattServiceClient; -class BluetoothInputClient; -class BluetoothMediaClient; -class BluetoothMediaTransportClient; -class BluetoothProfileManagerClient; class CrasAudioClient; class CrosDisksClient; class CryptohomeClient; @@ -126,18 +114,6 @@ class CHROMEOS_EXPORT DBusThreadManager { ApManagerClient* GetApManagerClient(); ArcBridgeClient* GetArcBridgeClient(); AudioDspClient* GetAudioDspClient(); - BluetoothAdapterClient* GetBluetoothAdapterClient(); - BluetoothLEAdvertisingManagerClient* GetBluetoothLEAdvertisingManagerClient(); - BluetoothAgentManagerClient* GetBluetoothAgentManagerClient(); - BluetoothDeviceClient* GetBluetoothDeviceClient(); - BluetoothGattCharacteristicClient* GetBluetoothGattCharacteristicClient(); - BluetoothGattDescriptorClient* GetBluetoothGattDescriptorClient(); - BluetoothGattManagerClient* GetBluetoothGattManagerClient(); - BluetoothGattServiceClient* GetBluetoothGattServiceClient(); - BluetoothInputClient* GetBluetoothInputClient(); - BluetoothMediaClient* GetBluetoothMediaClient(); - BluetoothMediaTransportClient* GetBluetoothMediaTransportClient(); - BluetoothProfileManagerClient* GetBluetoothProfileManagerClient(); CrasAudioClient* GetCrasAudioClient(); CrosDisksClient* GetCrosDisksClient(); CryptohomeClient* GetCryptohomeClient(); @@ -213,26 +189,6 @@ class CHROMEOS_EXPORT DBusThreadManagerSetter { void SetAmplifierClient(scoped_ptr<AmplifierClient> client); void SetArcBridgeClient(scoped_ptr<ArcBridgeClient> client); void SetAudioDspClient(scoped_ptr<AudioDspClient> client); - void SetBluetoothAdapterClient(scoped_ptr<BluetoothAdapterClient> client); - void SetBluetoothLEAdvertisingManagerClient( - scoped_ptr<BluetoothLEAdvertisingManagerClient> client); - void SetBluetoothAgentManagerClient( - scoped_ptr<BluetoothAgentManagerClient> client); - void SetBluetoothDeviceClient(scoped_ptr<BluetoothDeviceClient> client); - void SetBluetoothGattCharacteristicClient( - scoped_ptr<BluetoothGattCharacteristicClient> client); - void SetBluetoothGattDescriptorClient( - scoped_ptr<BluetoothGattDescriptorClient> client); - void SetBluetoothGattManagerClient( - scoped_ptr<BluetoothGattManagerClient> client); - void SetBluetoothGattServiceClient( - scoped_ptr<BluetoothGattServiceClient> client); - void SetBluetoothInputClient(scoped_ptr<BluetoothInputClient> client); - void SetBluetoothMediaClient(scoped_ptr<BluetoothMediaClient> client); - void SetBluetoothMediaTransportClient( - scoped_ptr<BluetoothMediaTransportClient> client); - void SetBluetoothProfileManagerClient( - scoped_ptr<BluetoothProfileManagerClient> client); void SetCrasAudioClient(scoped_ptr<CrasAudioClient> client); void SetCrosDisksClient(scoped_ptr<CrosDisksClient> client); void SetCryptohomeClient(scoped_ptr<CryptohomeClient> client); diff --git a/device/bluetooth/BUILD.gn b/device/bluetooth/BUILD.gn index 25dfc44..5edb17c 100644 --- a/device/bluetooth/BUILD.gn +++ b/device/bluetooth/BUILD.gn @@ -161,6 +161,95 @@ component("bluetooth") { if (is_win) { 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" ] + sources += [ + "dbus/bluetooth_adapter_client.cc", + "dbus/bluetooth_adapter_client.h", + "dbus/bluetooth_agent_manager_client.cc", + "dbus/bluetooth_agent_manager_client.h", + "dbus/bluetooth_agent_service_provider.cc", + "dbus/bluetooth_agent_service_provider.h", + "dbus/bluetooth_dbus_client_bundle.cc", + "dbus/bluetooth_dbus_client_bundle.h", + "dbus/bluetooth_device_client.cc", + "dbus/bluetooth_device_client.h", + "dbus/bluetooth_gatt_characteristic_client.cc", + "dbus/bluetooth_gatt_characteristic_client.h", + "dbus/bluetooth_gatt_characteristic_service_provider.cc", + "dbus/bluetooth_gatt_characteristic_service_provider.h", + "dbus/bluetooth_gatt_descriptor_client.cc", + "dbus/bluetooth_gatt_descriptor_client.h", + "dbus/bluetooth_gatt_descriptor_service_provider.cc", + "dbus/bluetooth_gatt_descriptor_service_provider.h", + "dbus/bluetooth_gatt_manager_client.cc", + "dbus/bluetooth_gatt_manager_client.h", + "dbus/bluetooth_gatt_service_client.cc", + "dbus/bluetooth_gatt_service_client.h", + "dbus/bluetooth_gatt_service_service_provider.cc", + "dbus/bluetooth_gatt_service_service_provider.h", + "dbus/bluetooth_input_client.cc", + "dbus/bluetooth_input_client.h", + "dbus/bluetooth_le_advertisement_service_provider.cc", + "dbus/bluetooth_le_advertisement_service_provider.h", + "dbus/bluetooth_le_advertising_manager_client.cc", + "dbus/bluetooth_le_advertising_manager_client.h", + "dbus/bluetooth_media_client.cc", + "dbus/bluetooth_media_client.h", + "dbus/bluetooth_media_endpoint_service_provider.cc", + "dbus/bluetooth_media_endpoint_service_provider.h", + "dbus/bluetooth_media_transport_client.cc", + "dbus/bluetooth_media_transport_client.h", + "dbus/bluetooth_profile_manager_client.cc", + "dbus/bluetooth_profile_manager_client.h", + "dbus/bluetooth_profile_service_provider.cc", + "dbus/bluetooth_profile_service_provider.h", + "dbus/bluez_dbus_client.h", + "dbus/bluez_dbus_manager.cc", + "dbus/bluez_dbus_manager.h", + "dbus/fake_bluetooth_adapter_client.cc", + "dbus/fake_bluetooth_adapter_client.h", + "dbus/fake_bluetooth_agent_manager_client.cc", + "dbus/fake_bluetooth_agent_manager_client.h", + "dbus/fake_bluetooth_agent_service_provider.cc", + "dbus/fake_bluetooth_agent_service_provider.h", + "dbus/fake_bluetooth_device_client.cc", + "dbus/fake_bluetooth_device_client.h", + "dbus/fake_bluetooth_gatt_characteristic_client.cc", + "dbus/fake_bluetooth_gatt_characteristic_client.h", + "dbus/fake_bluetooth_gatt_characteristic_service_provider.cc", + "dbus/fake_bluetooth_gatt_characteristic_service_provider.h", + "dbus/fake_bluetooth_gatt_descriptor_client.cc", + "dbus/fake_bluetooth_gatt_descriptor_client.h", + "dbus/fake_bluetooth_gatt_descriptor_service_provider.cc", + "dbus/fake_bluetooth_gatt_descriptor_service_provider.h", + "dbus/fake_bluetooth_gatt_manager_client.cc", + "dbus/fake_bluetooth_gatt_manager_client.h", + "dbus/fake_bluetooth_gatt_service_client.cc", + "dbus/fake_bluetooth_gatt_service_client.h", + "dbus/fake_bluetooth_gatt_service_service_provider.cc", + "dbus/fake_bluetooth_gatt_service_service_provider.h", + "dbus/fake_bluetooth_input_client.cc", + "dbus/fake_bluetooth_input_client.h", + "dbus/fake_bluetooth_le_advertisement_service_provider.cc", + "dbus/fake_bluetooth_le_advertisement_service_provider.h", + "dbus/fake_bluetooth_le_advertising_manager_client.cc", + "dbus/fake_bluetooth_le_advertising_manager_client.h", + "dbus/fake_bluetooth_media_client.cc", + "dbus/fake_bluetooth_media_client.h", + "dbus/fake_bluetooth_media_endpoint_service_provider.cc", + "dbus/fake_bluetooth_media_endpoint_service_provider.h", + "dbus/fake_bluetooth_media_transport_client.cc", + "dbus/fake_bluetooth_media_transport_client.h", + "dbus/fake_bluetooth_profile_manager_client.cc", + "dbus/fake_bluetooth_profile_manager_client.h", + "dbus/fake_bluetooth_profile_service_provider.cc", + "dbus/fake_bluetooth_profile_service_provider.h", + ] + } } static_library("mocks") { diff --git a/device/bluetooth/bluetooth.gyp b/device/bluetooth/bluetooth.gyp index f862660..90306d1 100644 --- a/device/bluetooth/bluetooth.gyp +++ b/device/bluetooth/bluetooth.gyp @@ -133,6 +133,96 @@ 'bluetooth_uuid.h', ], 'conditions': [ + # This block will also build for Linux once we write the linux + # implementation of BluezDbusManager. + ['chromeos==1', { + 'defines': [ + 'DEVICE_BLUETOOTH_IMPLEMENTATION', + ], + 'sources': [ + 'dbus/bluetooth_adapter_client.cc', + 'dbus/bluetooth_adapter_client.h', + 'dbus/bluetooth_le_advertising_manager_client.cc', + 'dbus/bluetooth_le_advertising_manager_client.h', + 'dbus/bluetooth_le_advertisement_service_provider.cc', + 'dbus/bluetooth_le_advertisement_service_provider.h', + 'dbus/bluetooth_agent_manager_client.cc', + 'dbus/bluetooth_agent_manager_client.h', + 'dbus/bluetooth_agent_service_provider.cc', + 'dbus/bluetooth_agent_service_provider.h', + 'dbus/bluetooth_dbus_client_bundle.cc', + 'dbus/bluetooth_dbus_client_bundle.h', + 'dbus/bluetooth_device_client.cc', + 'dbus/bluetooth_device_client.h', + 'dbus/bluetooth_gatt_characteristic_client.cc', + 'dbus/bluetooth_gatt_characteristic_client.h', + 'dbus/bluetooth_gatt_characteristic_service_provider.cc', + 'dbus/bluetooth_gatt_characteristic_service_provider.h', + 'dbus/bluetooth_gatt_descriptor_client.cc', + 'dbus/bluetooth_gatt_descriptor_client.h', + 'dbus/bluetooth_gatt_descriptor_service_provider.cc', + 'dbus/bluetooth_gatt_descriptor_service_provider.h', + 'dbus/bluetooth_gatt_manager_client.cc', + 'dbus/bluetooth_gatt_manager_client.h', + 'dbus/bluetooth_gatt_service_client.cc', + 'dbus/bluetooth_gatt_service_client.h', + 'dbus/bluetooth_gatt_service_service_provider.cc', + 'dbus/bluetooth_gatt_service_service_provider.h', + 'dbus/bluetooth_input_client.cc', + 'dbus/bluetooth_input_client.h', + 'dbus/bluetooth_media_client.cc', + 'dbus/bluetooth_media_client.h', + 'dbus/bluetooth_media_endpoint_service_provider.cc', + 'dbus/bluetooth_media_endpoint_service_provider.h', + 'dbus/bluetooth_media_transport_client.cc', + 'dbus/bluetooth_media_transport_client.h', + 'dbus/bluetooth_profile_manager_client.cc', + 'dbus/bluetooth_profile_manager_client.h', + 'dbus/bluetooth_profile_service_provider.cc', + 'dbus/bluetooth_profile_service_provider.h', + 'dbus/bluez_dbus_client.h', + 'dbus/bluez_dbus_manager.cc', + 'dbus/bluez_dbus_manager.h', + 'dbus/fake_bluetooth_adapter_client.cc', + 'dbus/fake_bluetooth_adapter_client.h', + 'dbus/fake_bluetooth_le_advertising_manager_client.cc', + 'dbus/fake_bluetooth_le_advertising_manager_client.h', + 'dbus/fake_bluetooth_le_advertisement_service_provider.cc', + 'dbus/fake_bluetooth_le_advertisement_service_provider.h', + 'dbus/fake_bluetooth_agent_manager_client.cc', + 'dbus/fake_bluetooth_agent_manager_client.h', + 'dbus/fake_bluetooth_agent_service_provider.cc', + 'dbus/fake_bluetooth_agent_service_provider.h', + 'dbus/fake_bluetooth_device_client.cc', + 'dbus/fake_bluetooth_device_client.h', + 'dbus/fake_bluetooth_gatt_characteristic_client.cc', + 'dbus/fake_bluetooth_gatt_characteristic_client.h', + 'dbus/fake_bluetooth_gatt_characteristic_service_provider.cc', + 'dbus/fake_bluetooth_gatt_characteristic_service_provider.h', + 'dbus/fake_bluetooth_gatt_descriptor_client.cc', + 'dbus/fake_bluetooth_gatt_descriptor_client.h', + 'dbus/fake_bluetooth_gatt_descriptor_service_provider.cc', + 'dbus/fake_bluetooth_gatt_descriptor_service_provider.h', + 'dbus/fake_bluetooth_gatt_manager_client.cc', + 'dbus/fake_bluetooth_gatt_manager_client.h', + 'dbus/fake_bluetooth_gatt_service_client.cc', + 'dbus/fake_bluetooth_gatt_service_client.h', + 'dbus/fake_bluetooth_gatt_service_service_provider.cc', + 'dbus/fake_bluetooth_gatt_service_service_provider.h', + 'dbus/fake_bluetooth_input_client.cc', + 'dbus/fake_bluetooth_input_client.h', + 'dbus/fake_bluetooth_media_client.cc', + 'dbus/fake_bluetooth_media_client.h', + 'dbus/fake_bluetooth_media_endpoint_service_provider.cc', + 'dbus/fake_bluetooth_media_endpoint_service_provider.h', + 'dbus/fake_bluetooth_media_transport_client.cc', + 'dbus/fake_bluetooth_media_transport_client.h', + 'dbus/fake_bluetooth_profile_manager_client.cc', + 'dbus/fake_bluetooth_profile_manager_client.h', + 'dbus/fake_bluetooth_profile_service_provider.cc', + 'dbus/fake_bluetooth_profile_service_provider.h', + ], + }], ['chromeos==1', { 'dependencies': [ '../../build/linux/system.gyp:dbus', diff --git a/device/bluetooth/bluetooth_adapter_chromeos.cc b/device/bluetooth/bluetooth_adapter_chromeos.cc index 70ec7fb..55d0bef 100644 --- a/device/bluetooth/bluetooth_adapter_chromeos.cc +++ b/device/bluetooth/bluetooth_adapter_chromeos.cc @@ -13,12 +13,6 @@ #include "base/sequenced_task_runner.h" #include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" -#include "chromeos/dbus/bluetooth_adapter_client.h" -#include "chromeos/dbus/bluetooth_agent_manager_client.h" -#include "chromeos/dbus/bluetooth_agent_service_provider.h" -#include "chromeos/dbus/bluetooth_device_client.h" -#include "chromeos/dbus/bluetooth_input_client.h" -#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/system/devicetype.h" #include "device/bluetooth/bluetooth_adapter_profile_chromeos.h" #include "device/bluetooth/bluetooth_advertisement_chromeos.h" @@ -33,6 +27,12 @@ #include "device/bluetooth/bluetooth_socket_chromeos.h" #include "device/bluetooth/bluetooth_socket_thread.h" #include "device/bluetooth/bluetooth_uuid.h" +#include "device/bluetooth/dbus/bluetooth_adapter_client.h" +#include "device/bluetooth/dbus/bluetooth_agent_manager_client.h" +#include "device/bluetooth/dbus/bluetooth_agent_service_provider.h" +#include "device/bluetooth/dbus/bluetooth_device_client.h" +#include "device/bluetooth/dbus/bluetooth_input_client.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" #include "third_party/cros_system_api/dbus/service_constants.h" using device::BluetoothAdapter; @@ -61,9 +61,9 @@ void OnUnregisterAgentError(const std::string& error_name, UMABluetoothDiscoverySessionOutcome TranslateDiscoveryErrorToUMA( const std::string& error_name) { - if (error_name == chromeos::BluetoothAdapterClient::kUnknownAdapterError) { + if (error_name == bluez::BluetoothAdapterClient::kUnknownAdapterError) { return UMABluetoothDiscoverySessionOutcome::CHROMEOS_DBUS_UNKNOWN_ADAPTER; - } else if (error_name == chromeos::BluetoothAdapterClient::kNoResponseError) { + } else if (error_name == bluez::BluetoothAdapterClient::kNoResponseError) { return UMABluetoothDiscoverySessionOutcome::CHROMEOS_DBUS_NO_RESPONSE; } else if (error_name == bluetooth_device::kErrorInProgress) { return UMABluetoothDiscoverySessionOutcome::CHROMEOS_DBUS_IN_PROGRESS; @@ -100,9 +100,9 @@ base::WeakPtr<BluetoothAdapter> BluetoothAdapterChromeOS::CreateAdapter() { void BluetoothAdapterChromeOS::Shutdown() { if (dbus_is_shutdown_) return; - DCHECK(DBusThreadManager::IsInitialized()) + DCHECK(bluez::BluezDBusManager::IsInitialized()) << "Call BluetoothAdapterFactory::Shutdown() before " - "DBusThreadManager::Shutdown()."; + "BluezDBusManager::Shutdown()."; if (IsPresent()) RemoveAdapter(); // Also deletes devices_. @@ -115,14 +115,19 @@ void BluetoothAdapterChromeOS::Shutdown() { delete it.second; profile_queues_.clear(); - DBusThreadManager::Get()->GetBluetoothAdapterClient()->RemoveObserver(this); - DBusThreadManager::Get()->GetBluetoothDeviceClient()->RemoveObserver(this); - DBusThreadManager::Get()->GetBluetoothInputClient()->RemoveObserver(this); + bluez::BluezDBusManager::Get()->GetBluetoothAdapterClient()->RemoveObserver( + this); + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->RemoveObserver( + this); + bluez::BluezDBusManager::Get()->GetBluetoothInputClient()->RemoveObserver( + this); VLOG(1) << "Unregistering pairing agent"; - DBusThreadManager::Get()->GetBluetoothAgentManagerClient()->UnregisterAgent( - dbus::ObjectPath(kAgentPath), base::Bind(&base::DoNothing), - base::Bind(&OnUnregisterAgentError)); + bluez::BluezDBusManager::Get() + ->GetBluetoothAgentManagerClient() + ->UnregisterAgent(dbus::ObjectPath(kAgentPath), + base::Bind(&base::DoNothing), + base::Bind(&OnUnregisterAgentError)); agent_.reset(); dbus_is_shutdown_ = true; @@ -136,18 +141,20 @@ BluetoothAdapterChromeOS::BluetoothAdapterChromeOS() ui_task_runner_ = base::ThreadTaskRunnerHandle::Get(); socket_thread_ = device::BluetoothSocketThread::Get(); - DBusThreadManager::Get()->GetBluetoothAdapterClient()->AddObserver(this); - DBusThreadManager::Get()->GetBluetoothDeviceClient()->AddObserver(this); - DBusThreadManager::Get()->GetBluetoothInputClient()->AddObserver(this); + bluez::BluezDBusManager::Get()->GetBluetoothAdapterClient()->AddObserver( + this); + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->AddObserver(this); + bluez::BluezDBusManager::Get()->GetBluetoothInputClient()->AddObserver(this); // Register the pairing agent. - dbus::Bus* system_bus = DBusThreadManager::Get()->GetSystemBus(); - agent_.reset(BluetoothAgentServiceProvider::Create( + dbus::Bus* system_bus = bluez::BluezDBusManager::Get()->GetSystemBus(); + agent_.reset(bluez::BluetoothAgentServiceProvider::Create( system_bus, dbus::ObjectPath(kAgentPath), this)); DCHECK(agent_.get()); - std::vector<dbus::ObjectPath> object_paths = - DBusThreadManager::Get()->GetBluetoothAdapterClient()->GetAdapters(); + std::vector<dbus::ObjectPath> object_paths = bluez::BluezDBusManager::Get() + ->GetBluetoothAdapterClient() + ->GetAdapters(); if (!object_paths.empty()) { VLOG(1) << object_paths.size() << " Bluetooth adapter(s) available."; @@ -163,9 +170,10 @@ std::string BluetoothAdapterChromeOS::GetAddress() const { if (!IsPresent()) return std::string(); - BluetoothAdapterClient::Properties* properties = - DBusThreadManager::Get()->GetBluetoothAdapterClient()->GetProperties( - object_path_); + bluez::BluetoothAdapterClient::Properties* properties = + bluez::BluezDBusManager::Get() + ->GetBluetoothAdapterClient() + ->GetProperties(object_path_); DCHECK(properties); return BluetoothDevice::CanonicalizeAddress(properties->address.value()); @@ -175,9 +183,10 @@ std::string BluetoothAdapterChromeOS::GetName() const { if (!IsPresent()) return std::string(); - BluetoothAdapterClient::Properties* properties = - DBusThreadManager::Get()->GetBluetoothAdapterClient()->GetProperties( - object_path_); + bluez::BluetoothAdapterClient::Properties* properties = + bluez::BluezDBusManager::Get() + ->GetBluetoothAdapterClient() + ->GetProperties(object_path_); DCHECK(properties); return properties->alias.value(); @@ -191,7 +200,7 @@ void BluetoothAdapterChromeOS::SetName(const std::string& name, return; } - DBusThreadManager::Get() + bluez::BluezDBusManager::Get() ->GetBluetoothAdapterClient() ->GetProperties(object_path_) ->alias.Set( @@ -212,9 +221,10 @@ bool BluetoothAdapterChromeOS::IsPowered() const { if (!IsPresent()) return false; - BluetoothAdapterClient::Properties* properties = - DBusThreadManager::Get()->GetBluetoothAdapterClient()->GetProperties( - object_path_); + bluez::BluetoothAdapterClient::Properties* properties = + bluez::BluezDBusManager::Get() + ->GetBluetoothAdapterClient() + ->GetProperties(object_path_); return properties->powered.value(); } @@ -228,7 +238,7 @@ void BluetoothAdapterChromeOS::SetPowered( return; } - DBusThreadManager::Get() + bluez::BluezDBusManager::Get() ->GetBluetoothAdapterClient() ->GetProperties(object_path_) ->powered.Set( @@ -241,9 +251,10 @@ bool BluetoothAdapterChromeOS::IsDiscoverable() const { if (!IsPresent()) return false; - BluetoothAdapterClient::Properties* properties = - DBusThreadManager::Get()->GetBluetoothAdapterClient()->GetProperties( - object_path_); + bluez::BluetoothAdapterClient::Properties* properties = + bluez::BluezDBusManager::Get() + ->GetBluetoothAdapterClient() + ->GetProperties(object_path_); return properties->discoverable.value(); } @@ -257,7 +268,7 @@ void BluetoothAdapterChromeOS::SetDiscoverable( return; } - DBusThreadManager::Get() + bluez::BluezDBusManager::Get() ->GetBluetoothAdapterClient() ->GetProperties(object_path_) ->discoverable.Set( @@ -270,9 +281,10 @@ bool BluetoothAdapterChromeOS::IsDiscovering() const { if (!IsPresent()) return false; - BluetoothAdapterClient::Properties* properties = - DBusThreadManager::Get()->GetBluetoothAdapterClient()->GetProperties( - object_path_); + bluez::BluetoothAdapterClient::Properties* properties = + bluez::BluezDBusManager::Get() + ->GetBluetoothAdapterClient() + ->GetProperties(object_path_); return properties->discovering.value(); } @@ -377,9 +389,10 @@ void BluetoothAdapterChromeOS::AdapterPropertyChanged( return; DCHECK(IsPresent()); - BluetoothAdapterClient::Properties* properties = - DBusThreadManager::Get()->GetBluetoothAdapterClient()->GetProperties( - object_path_); + bluez::BluetoothAdapterClient::Properties* properties = + bluez::BluezDBusManager::Get() + ->GetBluetoothAdapterClient() + ->GetProperties(object_path_); if (property_name == properties->powered.name()) { PoweredChanged(properties->powered.value()); @@ -392,9 +405,9 @@ void BluetoothAdapterChromeOS::AdapterPropertyChanged( void BluetoothAdapterChromeOS::DeviceAdded( const dbus::ObjectPath& object_path) { - DCHECK(DBusThreadManager::Get()); - BluetoothDeviceClient::Properties* properties = - DBusThreadManager::Get()->GetBluetoothDeviceClient()->GetProperties( + DCHECK(bluez::BluezDBusManager::Get()); + bluez::BluetoothDeviceClient::Properties* properties = + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( object_path); if (!properties || properties->adapter.value() != object_path_) return; @@ -438,8 +451,8 @@ void BluetoothAdapterChromeOS::DevicePropertyChanged( if (!device_chromeos) return; - BluetoothDeviceClient::Properties* properties = - DBusThreadManager::Get()->GetBluetoothDeviceClient()->GetProperties( + bluez::BluetoothDeviceClient::Properties* properties = + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( object_path); if (property_name == properties->address.name()) { @@ -513,8 +526,8 @@ void BluetoothAdapterChromeOS::InputPropertyChanged( if (!device_chromeos) return; - BluetoothInputClient::Properties* properties = - DBusThreadManager::Get()->GetBluetoothInputClient()->GetProperties( + bluez::BluetoothInputClient::Properties* properties = + bluez::BluezDBusManager::Get()->GetBluetoothInputClient()->GetProperties( object_path); // Properties structure can be removed, which triggers a change in the @@ -672,7 +685,7 @@ void BluetoothAdapterChromeOS::Cancel() { void BluetoothAdapterChromeOS::OnRegisterAgent() { VLOG(1) << "Pairing agent registered, requesting to be made default"; - DBusThreadManager::Get() + bluez::BluezDBusManager::Get() ->GetBluetoothAgentManagerClient() ->RequestDefaultAgent( dbus::ObjectPath(kAgentPath), @@ -765,19 +778,22 @@ void BluetoothAdapterChromeOS::SetAdapter(const dbus::ObjectPath& object_path) { VLOG(1) << object_path_.value() << ": using adapter."; VLOG(1) << "Registering pairing agent"; - DBusThreadManager::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())); + 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())); SetDefaultAdapterName(); - BluetoothAdapterClient::Properties* properties = - DBusThreadManager::Get()->GetBluetoothAdapterClient()->GetProperties( - object_path_); + bluez::BluetoothAdapterClient::Properties* properties = + bluez::BluezDBusManager::Get() + ->GetBluetoothAdapterClient() + ->GetProperties(object_path_); PresentChanged(true); @@ -789,7 +805,7 @@ void BluetoothAdapterChromeOS::SetAdapter(const dbus::ObjectPath& object_path) { DiscoveringChanged(true); std::vector<dbus::ObjectPath> device_paths = - DBusThreadManager::Get() + bluez::BluezDBusManager::Get() ->GetBluetoothDeviceClient() ->GetDevicesForAdapter(object_path_); @@ -828,9 +844,10 @@ void BluetoothAdapterChromeOS::RemoveAdapter() { DCHECK(IsPresent()); VLOG(1) << object_path_.value() << ": adapter removed."; - BluetoothAdapterClient::Properties* properties = - DBusThreadManager::Get()->GetBluetoothAdapterClient()->GetProperties( - object_path_); + bluez::BluetoothAdapterClient::Properties* properties = + bluez::BluezDBusManager::Get() + ->GetBluetoothAdapterClient() + ->GetProperties(object_path_); object_path_ = dbus::ObjectPath(""); @@ -1025,8 +1042,8 @@ void BluetoothAdapterChromeOS::NotifyGattDescriptorValueChanged( void BluetoothAdapterChromeOS::UseProfile( const BluetoothUUID& uuid, const dbus::ObjectPath& device_path, - const BluetoothProfileManagerClient::Options& options, - BluetoothProfileServiceProvider::Delegate* delegate, + const bluez::BluetoothProfileManagerClient::Options& options, + bluez::BluetoothProfileServiceProvider::Delegate* delegate, const ProfileRegisteredCallback& success_callback, const ErrorCompletionCallback& error_callback) { DCHECK(delegate); @@ -1097,7 +1114,7 @@ void BluetoothAdapterChromeOS::OnRegisterProfile( void BluetoothAdapterChromeOS::SetProfileDelegate( const BluetoothUUID& uuid, const dbus::ObjectPath& device_path, - BluetoothProfileServiceProvider::Delegate* delegate, + bluez::BluetoothProfileServiceProvider::Delegate* delegate, const ProfileRegisteredCallback& success_callback, const ErrorCompletionCallback& error_callback) { if (profiles_.find(uuid) == profiles_.end()) { @@ -1140,7 +1157,7 @@ void BluetoothAdapterChromeOS::OnSetDiscoverable( // Set the discoverable_timeout property to zero so the adapter remains // discoverable forever. - DBusThreadManager::Get() + bluez::BluezDBusManager::Get() ->GetBluetoothAdapterClient() ->GetProperties(object_path_) ->discoverable_timeout.Set( @@ -1214,7 +1231,7 @@ void BluetoothAdapterChromeOS::AddDiscoverySession( // This is the first request to start device discovery. discovery_request_pending_ = true; - DBusThreadManager::Get()->GetBluetoothAdapterClient()->StartDiscovery( + bluez::BluezDBusManager::Get()->GetBluetoothAdapterClient()->StartDiscovery( object_path_, base::Bind(&BluetoothAdapterChromeOS::OnStartDiscovery, weak_ptr_factory_.GetWeakPtr(), callback, error_callback), @@ -1268,7 +1285,7 @@ void BluetoothAdapterChromeOS::RemoveDiscoverySession( // discovery. DCHECK_EQ(num_discovery_sessions_, 1); discovery_request_pending_ = true; - DBusThreadManager::Get()->GetBluetoothAdapterClient()->StopDiscovery( + bluez::BluezDBusManager::Get()->GetBluetoothAdapterClient()->StopDiscovery( object_path_, base::Bind(&BluetoothAdapterChromeOS::OnStopDiscovery, weak_ptr_factory_.GetWeakPtr(), callback), base::Bind(&BluetoothAdapterChromeOS::OnStopDiscoveryError, @@ -1301,7 +1318,7 @@ void BluetoothAdapterChromeOS::SetDiscoveryFilter( current_filter_.reset(discovery_filter.release()); - chromeos::BluetoothAdapterClient::DiscoveryFilter dbus_discovery_filter; + bluez::BluetoothAdapterClient::DiscoveryFilter dbus_discovery_filter; if (current_filter_.get()) { uint16_t pathloss; @@ -1336,12 +1353,14 @@ void BluetoothAdapterChromeOS::SetDiscoveryFilter( } } - DBusThreadManager::Get()->GetBluetoothAdapterClient()->SetDiscoveryFilter( - object_path_, dbus_discovery_filter, - base::Bind(&BluetoothAdapterChromeOS::OnSetDiscoveryFilter, - weak_ptr_factory_.GetWeakPtr(), callback, error_callback), - base::Bind(&BluetoothAdapterChromeOS::OnSetDiscoveryFilterError, - weak_ptr_factory_.GetWeakPtr(), callback, error_callback)); + bluez::BluezDBusManager::Get() + ->GetBluetoothAdapterClient() + ->SetDiscoveryFilter( + object_path_, dbus_discovery_filter, + base::Bind(&BluetoothAdapterChromeOS::OnSetDiscoveryFilter, + weak_ptr_factory_.GetWeakPtr(), callback, error_callback), + base::Bind(&BluetoothAdapterChromeOS::OnSetDiscoveryFilterError, + weak_ptr_factory_.GetWeakPtr(), callback, error_callback)); } void BluetoothAdapterChromeOS::OnStartDiscovery( @@ -1431,7 +1450,7 @@ void BluetoothAdapterChromeOS::OnPreSetDiscoveryFilter( DCHECK(discovery_request_pending_); DCHECK_EQ(num_discovery_sessions_, 0); - DBusThreadManager::Get()->GetBluetoothAdapterClient()->StartDiscovery( + bluez::BluezDBusManager::Get()->GetBluetoothAdapterClient()->StartDiscovery( object_path_, base::Bind(&BluetoothAdapterChromeOS::OnStartDiscovery, weak_ptr_factory_.GetWeakPtr(), callback, error_callback), diff --git a/device/bluetooth/bluetooth_adapter_chromeos.h b/device/bluetooth/bluetooth_adapter_chromeos.h index 46c634f..53b271f 100644 --- a/device/bluetooth/bluetooth_adapter_chromeos.h +++ b/device/bluetooth/bluetooth_adapter_chromeos.h @@ -12,18 +12,18 @@ #include <vector> #include "base/memory/weak_ptr.h" -#include "chromeos/dbus/bluetooth_adapter_client.h" -#include "chromeos/dbus/bluetooth_agent_service_provider.h" -#include "chromeos/dbus/bluetooth_device_client.h" -#include "chromeos/dbus/bluetooth_input_client.h" -#include "chromeos/dbus/bluetooth_profile_manager_client.h" -#include "chromeos/dbus/bluetooth_profile_service_provider.h" #include "dbus/object_path.h" #include "device/bluetooth/bluetooth_adapter.h" #include "device/bluetooth/bluetooth_audio_sink.h" #include "device/bluetooth/bluetooth_device.h" #include "device/bluetooth/bluetooth_discovery_session.h" #include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluetooth_adapter_client.h" +#include "device/bluetooth/dbus/bluetooth_agent_service_provider.h" +#include "device/bluetooth/dbus/bluetooth_device_client.h" +#include "device/bluetooth/dbus/bluetooth_input_client.h" +#include "device/bluetooth/dbus/bluetooth_profile_manager_client.h" +#include "device/bluetooth/dbus/bluetooth_profile_service_provider.h" namespace base { class SequencedTaskRunner; @@ -60,10 +60,10 @@ class BluetoothRemoteGattServiceChromeOS; // BluetoothChromeOSTest, Shutdown. class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterChromeOS : public device::BluetoothAdapter, - public chromeos::BluetoothAdapterClient::Observer, - public chromeos::BluetoothDeviceClient::Observer, - public chromeos::BluetoothInputClient::Observer, - public chromeos::BluetoothAgentServiceProvider::Delegate { + public bluez::BluetoothAdapterClient::Observer, + public bluez::BluetoothDeviceClient::Observer, + public bluez::BluetoothInputClient::Observer, + public bluez::BluetoothAgentServiceProvider::Delegate { public: typedef base::Callback<void(const std::string& error_message)> ErrorCompletionCallback; @@ -157,8 +157,8 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterChromeOS // |error_callback| will be called. void UseProfile(const device::BluetoothUUID& uuid, const dbus::ObjectPath& device_path, - const BluetoothProfileManagerClient::Options& options, - BluetoothProfileServiceProvider::Delegate* delegate, + const bluez::BluetoothProfileManagerClient::Options& options, + bluez::BluetoothProfileServiceProvider::Delegate* delegate, const ProfileRegisteredCallback& success_callback, const ErrorCompletionCallback& error_callback); @@ -194,23 +194,23 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterChromeOS BluetoothAdapterChromeOS(); ~BluetoothAdapterChromeOS() override; - // BluetoothAdapterClient::Observer override. + // bluez::BluetoothAdapterClient::Observer override. void AdapterAdded(const dbus::ObjectPath& object_path) override; void AdapterRemoved(const dbus::ObjectPath& object_path) override; void AdapterPropertyChanged(const dbus::ObjectPath& object_path, const std::string& property_name) override; - // BluetoothDeviceClient::Observer override. + // bluez::BluetoothDeviceClient::Observer override. void DeviceAdded(const dbus::ObjectPath& object_path) override; void DeviceRemoved(const dbus::ObjectPath& object_path) override; void DevicePropertyChanged(const dbus::ObjectPath& object_path, const std::string& property_name) override; - // BluetoothInputClient::Observer override. + // bluez::BluetoothInputClient::Observer override. void InputPropertyChanged(const dbus::ObjectPath& object_path, const std::string& property_name) override; - // BluetoothAgentServiceProvider::Delegate override. + // bluez::BluetoothAgentServiceProvider::Delegate override. void Released() override; void RequestPinCode(const dbus::ObjectPath& device_path, const PinCodeCallback& callback) override; @@ -333,11 +333,12 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterChromeOS void OnRegisterProfile(const device::BluetoothUUID& uuid, scoped_ptr<BluetoothAdapterProfileChromeOS> profile); - void SetProfileDelegate(const device::BluetoothUUID& uuid, - const dbus::ObjectPath& device_path, - BluetoothProfileServiceProvider::Delegate* delegate, - const ProfileRegisteredCallback& success_callback, - const ErrorCompletionCallback& error_callback); + void SetProfileDelegate( + const device::BluetoothUUID& uuid, + const dbus::ObjectPath& device_path, + bluez::BluetoothProfileServiceProvider::Delegate* delegate, + const ProfileRegisteredCallback& success_callback, + const ErrorCompletionCallback& error_callback); void OnRegisterProfileError(const device::BluetoothUUID& uuid, const std::string& error_name, const std::string& error_message); @@ -377,7 +378,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterChromeOS // Instance of the D-Bus agent object used for pairing, initialized with // our own class as its delegate. - scoped_ptr<BluetoothAgentServiceProvider> agent_; + scoped_ptr<bluez::BluetoothAgentServiceProvider> agent_; // UI thread task runner and socket thread object used to create sockets. scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; diff --git a/device/bluetooth/bluetooth_adapter_profile_chromeos.cc b/device/bluetooth/bluetooth_adapter_profile_chromeos.cc index aeab2ae..27779f2 100644 --- a/device/bluetooth/bluetooth_adapter_profile_chromeos.cc +++ b/device/bluetooth/bluetooth_adapter_profile_chromeos.cc @@ -9,29 +9,31 @@ #include "base/bind.h" #include "base/logging.h" #include "base/strings/string_util.h" -#include "chromeos/dbus/bluetooth_profile_service_provider.h" -#include "chromeos/dbus/dbus_thread_manager.h" #include "dbus/bus.h" #include "dbus/object_path.h" #include "device/bluetooth/bluetooth_adapter_chromeos.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 { // static void BluetoothAdapterProfileChromeOS::Register( const device::BluetoothUUID& uuid, - const BluetoothProfileManagerClient::Options& options, + const bluez::BluetoothProfileManagerClient::Options& options, const ProfileRegisteredCallback& success_callback, - const BluetoothProfileManagerClient::ErrorCallback& error_callback) { + const bluez::BluetoothProfileManagerClient::ErrorCallback& error_callback) { scoped_ptr<BluetoothAdapterProfileChromeOS> profile( new BluetoothAdapterProfileChromeOS(uuid)); VLOG(1) << "Registering profile: " << profile->object_path().value(); const dbus::ObjectPath& object_path = profile->object_path(); - DBusThreadManager::Get()->GetBluetoothProfileManagerClient()->RegisterProfile( - object_path, uuid.canonical_value(), options, - base::Bind(success_callback, base::Passed(&profile)), error_callback); + bluez::BluezDBusManager::Get() + ->GetBluetoothProfileManagerClient() + ->RegisterProfile(object_path, uuid.canonical_value(), options, + base::Bind(success_callback, base::Passed(&profile)), + error_callback); } BluetoothAdapterProfileChromeOS::BluetoothAdapterProfileChromeOS( @@ -42,9 +44,9 @@ BluetoothAdapterProfileChromeOS::BluetoothAdapterProfileChromeOS( object_path_ = dbus::ObjectPath("/org/chromium/bluetooth_profile/" + uuid_path); - dbus::Bus* system_bus = DBusThreadManager::Get()->GetSystemBus(); - profile_.reset( - BluetoothProfileServiceProvider::Create(system_bus, object_path_, this)); + dbus::Bus* system_bus = bluez::BluezDBusManager::Get()->GetSystemBus(); + profile_.reset(bluez::BluetoothProfileServiceProvider::Create( + system_bus, object_path_, this)); DCHECK(profile_.get()); } @@ -53,7 +55,7 @@ BluetoothAdapterProfileChromeOS::~BluetoothAdapterProfileChromeOS() { bool BluetoothAdapterProfileChromeOS::SetDelegate( const dbus::ObjectPath& device_path, - BluetoothProfileServiceProvider::Delegate* delegate) { + bluez::BluetoothProfileServiceProvider::Delegate* delegate) { DCHECK(delegate); VLOG(1) << "SetDelegate: " << object_path_.value() << " dev " << device_path.value(); @@ -83,7 +85,7 @@ void BluetoothAdapterProfileChromeOS::RemoveDelegate( VLOG(1) << device_path.value() << " No delegates left, unregistering."; // No users left, release the profile. - DBusThreadManager::Get() + bluez::BluezDBusManager::Get() ->GetBluetoothProfileManagerClient() ->UnregisterProfile( object_path_, unregistered_callback, @@ -102,7 +104,7 @@ void BluetoothAdapterProfileChromeOS::OnUnregisterProfileError( unregistered_callback.Run(); } -// BluetoothProfileServiceProvider::Delegate: +// bluez::BluetoothProfileServiceProvider::Delegate: void BluetoothAdapterProfileChromeOS::Released() { VLOG(1) << object_path_.value() << ": Release"; } @@ -110,7 +112,7 @@ void BluetoothAdapterProfileChromeOS::Released() { void BluetoothAdapterProfileChromeOS::NewConnection( const dbus::ObjectPath& device_path, scoped_ptr<dbus::FileDescriptor> fd, - const BluetoothProfileServiceProvider::Delegate::Options& options, + const bluez::BluetoothProfileServiceProvider::Delegate::Options& options, const ConfirmationCallback& callback) { dbus::ObjectPath delegate_path = device_path; diff --git a/device/bluetooth/bluetooth_adapter_profile_chromeos.h b/device/bluetooth/bluetooth_adapter_profile_chromeos.h index 85e2ffe..35971e8 100644 --- a/device/bluetooth/bluetooth_adapter_profile_chromeos.h +++ b/device/bluetooth/bluetooth_adapter_profile_chromeos.h @@ -6,10 +6,10 @@ #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_PROFILE_CHROMEOS_H_ #include "base/memory/weak_ptr.h" -#include "chromeos/dbus/bluetooth_profile_manager_client.h" -#include "chromeos/dbus/bluetooth_profile_service_provider.h" #include "device/bluetooth/bluetooth_adapter_chromeos.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" namespace device { class BluetoothUUID; @@ -28,7 +28,7 @@ namespace chromeos { // BluetoothAdapterProfileChromeOS objects are owned by the // BluetoothAdapterChromeOS and allocated through Register() class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterProfileChromeOS - : public chromeos::BluetoothProfileServiceProvider::Delegate { + : public bluez::BluetoothProfileServiceProvider::Delegate { public: typedef base::Callback<void(scoped_ptr<BluetoothAdapterProfileChromeOS> profile)> ProfileRegisteredCallback; @@ -39,9 +39,10 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterProfileChromeOS // will be called. static void Register( const device::BluetoothUUID& uuid, - const BluetoothProfileManagerClient::Options& options, + const bluez::BluetoothProfileManagerClient::Options& options, const ProfileRegisteredCallback& success_callback, - const BluetoothProfileManagerClient::ErrorCallback& error_callback); + const bluez::BluetoothProfileManagerClient::ErrorCallback& + error_callback); ~BluetoothAdapterProfileChromeOS() override; @@ -56,7 +57,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterProfileChromeOS // Returns true if the delegate was set, and false if the |device_path| // already had a delegate set. bool SetDelegate(const dbus::ObjectPath& device_path, - BluetoothProfileServiceProvider::Delegate* delegate); + bluez::BluetoothProfileServiceProvider::Delegate* delegate); // Remove the delegate for a device. |unregistered_callback| will be called // if this unregisters the profile. @@ -69,12 +70,12 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterProfileChromeOS private: BluetoothAdapterProfileChromeOS(const device::BluetoothUUID& uuid); - // BluetoothProfileServiceProvider::Delegate: + // bluez::BluetoothProfileServiceProvider::Delegate: void Released() override; void NewConnection( const dbus::ObjectPath& device_path, scoped_ptr<dbus::FileDescriptor> fd, - const BluetoothProfileServiceProvider::Delegate::Options& options, + const bluez::BluetoothProfileServiceProvider::Delegate::Options& options, const ConfirmationCallback& callback) override; void RequestDisconnection(const dbus::ObjectPath& device_path, const ConfirmationCallback& callback) override; @@ -86,7 +87,8 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterProfileChromeOS const std::string& error_message); // List of delegates which this profile is multiplexing to. - std::map<std::string, BluetoothProfileServiceProvider::Delegate*> delegates_; + std::map<std::string, bluez::BluetoothProfileServiceProvider::Delegate*> + delegates_; // The UUID that this profile represents. const device::BluetoothUUID& uuid_; @@ -95,7 +97,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterProfileChromeOS dbus::ObjectPath object_path_; // Profile dbus object for receiving profile method calls from BlueZ - scoped_ptr<BluetoothProfileServiceProvider> profile_; + scoped_ptr<bluez::BluetoothProfileServiceProvider> profile_; // Note: This should remain the last member so it'll be destroyed and // invalidate its weak pointers before any other members are destroyed. diff --git a/device/bluetooth/bluetooth_adapter_profile_chromeos_unittest.cc b/device/bluetooth/bluetooth_adapter_profile_chromeos_unittest.cc index 1b9c0b3..be99901 100644 --- a/device/bluetooth/bluetooth_adapter_profile_chromeos_unittest.cc +++ b/device/bluetooth/bluetooth_adapter_profile_chromeos_unittest.cc @@ -4,17 +4,17 @@ #include "base/bind.h" #include "base/message_loop/message_loop.h" -#include "chromeos/dbus/bluetooth_profile_service_provider.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_adapter_client.h" -#include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" -#include "chromeos/dbus/fake_bluetooth_device_client.h" -#include "chromeos/dbus/fake_bluetooth_profile_manager_client.h" #include "device/bluetooth/bluetooth_adapter.h" #include "device/bluetooth/bluetooth_adapter_chromeos.h" #include "device/bluetooth/bluetooth_adapter_factory.h" #include "device/bluetooth/bluetooth_adapter_profile_chromeos.h" #include "device/bluetooth/bluetooth_uuid.h" +#include "device/bluetooth/dbus/bluetooth_profile_service_provider.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" +#include "device/bluetooth/dbus/fake_bluetooth_device_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_profile_manager_client.h" #include "testing/gtest/include/gtest/gtest.h" using device::BluetoothAdapter; @@ -27,25 +27,29 @@ class BluetoothAdapterProfileChromeOSTest : public testing::Test { BluetoothAdapterProfileChromeOSTest() : success_callback_count_(0), error_callback_count_(0), - fake_delegate_paired_(FakeBluetoothDeviceClient::kPairedDevicePath), - fake_delegate_autopair_(FakeBluetoothDeviceClient::kLegacyAutopairPath), + fake_delegate_paired_( + bluez::FakeBluetoothDeviceClient::kPairedDevicePath), + fake_delegate_autopair_( + bluez::FakeBluetoothDeviceClient::kLegacyAutopairPath), fake_delegate_listen_(""), profile_user_ptr_(nullptr) {} void SetUp() override { - scoped_ptr<DBusThreadManagerSetter> dbus_setter = - DBusThreadManager::GetSetterForTesting(); + scoped_ptr<bluez::BluezDBusManagerSetter> dbus_setter = + bluez::BluezDBusManager::GetSetterForTesting(); dbus_setter->SetBluetoothAdapterClient( - scoped_ptr<BluetoothAdapterClient>(new FakeBluetoothAdapterClient)); + scoped_ptr<bluez::BluetoothAdapterClient>( + new bluez::FakeBluetoothAdapterClient)); dbus_setter->SetBluetoothAgentManagerClient( - scoped_ptr<BluetoothAgentManagerClient>( - new FakeBluetoothAgentManagerClient)); + scoped_ptr<bluez::BluetoothAgentManagerClient>( + new bluez::FakeBluetoothAgentManagerClient)); dbus_setter->SetBluetoothDeviceClient( - scoped_ptr<BluetoothDeviceClient>(new FakeBluetoothDeviceClient)); + scoped_ptr<bluez::BluetoothDeviceClient>( + new bluez::FakeBluetoothDeviceClient)); dbus_setter->SetBluetoothProfileManagerClient( - scoped_ptr<BluetoothProfileManagerClient>( - new FakeBluetoothProfileManagerClient)); + scoped_ptr<bluez::BluetoothProfileManagerClient>( + new bluez::FakeBluetoothProfileManagerClient)); // Grab a pointer to the adapter. device::BluetoothAdapterFactory::GetAdapter( @@ -64,21 +68,20 @@ class BluetoothAdapterProfileChromeOSTest : public testing::Test { void TearDown() override { profile_.reset(); adapter_ = nullptr; - DBusThreadManager::Shutdown(); + bluez::BluezDBusManager::Shutdown(); } void AdapterCallback(scoped_refptr<BluetoothAdapter> adapter) { adapter_ = adapter; } - class FakeDelegate - : public chromeos::BluetoothProfileServiceProvider::Delegate { + class FakeDelegate : public bluez::BluetoothProfileServiceProvider::Delegate { public: FakeDelegate(const std::string& device_path) : connections_(0) { device_path_ = dbus::ObjectPath(device_path); } - // BluetoothProfileServiceProvider::Delegate: + // bluez::BluetoothProfileServiceProvider::Delegate: void Released() override { // noop } @@ -86,7 +89,8 @@ class BluetoothAdapterProfileChromeOSTest : public testing::Test { void NewConnection( const dbus::ObjectPath& device_path, scoped_ptr<dbus::FileDescriptor> fd, - const BluetoothProfileServiceProvider::Delegate::Options& options, + const bluez::BluetoothProfileServiceProvider::Delegate::Options& + options, const ConfirmationCallback& callback) override { ++connections_; fd->CheckValidity(); @@ -157,8 +161,8 @@ class BluetoothAdapterProfileChromeOSTest : public testing::Test { }; TEST_F(BluetoothAdapterProfileChromeOSTest, DelegateCount) { - BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); - BluetoothProfileManagerClient::Options options; + BluetoothUUID uuid(bluez::FakeBluetoothProfileManagerClient::kRfcommUuid); + bluez::BluetoothProfileManagerClient::Options options; options.require_authentication.reset(new bool(false)); @@ -194,8 +198,8 @@ TEST_F(BluetoothAdapterProfileChromeOSTest, DelegateCount) { } TEST_F(BluetoothAdapterProfileChromeOSTest, BlackHole) { - BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); - BluetoothProfileManagerClient::Options options; + BluetoothUUID uuid(bluez::FakeBluetoothProfileManagerClient::kRfcommUuid); + bluez::BluetoothProfileManagerClient::Options options; options.require_authentication.reset(new bool(false)); @@ -212,9 +216,9 @@ TEST_F(BluetoothAdapterProfileChromeOSTest, BlackHole) { EXPECT_EQ(1U, success_callback_count_); EXPECT_EQ(0U, error_callback_count_); - DBusThreadManager::Get()->GetBluetoothDeviceClient()->ConnectProfile( - dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath), - FakeBluetoothProfileManagerClient::kRfcommUuid, + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->ConnectProfile( + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kPairedDevicePath), + bluez::FakeBluetoothProfileManagerClient::kRfcommUuid, base::Bind( &BluetoothAdapterProfileChromeOSTest::DBusConnectSuccessCallback, base::Unretained(this)), @@ -230,8 +234,8 @@ TEST_F(BluetoothAdapterProfileChromeOSTest, BlackHole) { } TEST_F(BluetoothAdapterProfileChromeOSTest, Routing) { - BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); - BluetoothProfileManagerClient::Options options; + BluetoothUUID uuid(bluez::FakeBluetoothProfileManagerClient::kRfcommUuid); + bluez::BluetoothProfileManagerClient::Options options; options.require_authentication.reset(new bool(false)); @@ -255,9 +259,9 @@ TEST_F(BluetoothAdapterProfileChromeOSTest, Routing) { profile_->SetDelegate(fake_delegate_listen_.device_path_, &fake_delegate_listen_); - DBusThreadManager::Get()->GetBluetoothDeviceClient()->ConnectProfile( - dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath), - FakeBluetoothProfileManagerClient::kRfcommUuid, + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->ConnectProfile( + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kPairedDevicePath), + bluez::FakeBluetoothProfileManagerClient::kRfcommUuid, base::Bind( &BluetoothAdapterProfileChromeOSTest::DBusConnectSuccessCallback, base::Unretained(this)), @@ -271,9 +275,9 @@ TEST_F(BluetoothAdapterProfileChromeOSTest, Routing) { EXPECT_EQ(1U, fake_delegate_paired_.connections_); - DBusThreadManager::Get()->GetBluetoothDeviceClient()->ConnectProfile( - dbus::ObjectPath(FakeBluetoothDeviceClient::kLegacyAutopairPath), - FakeBluetoothProfileManagerClient::kRfcommUuid, + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->ConnectProfile( + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLegacyAutopairPath), + bluez::FakeBluetoothProfileManagerClient::kRfcommUuid, base::Bind( &BluetoothAdapterProfileChromeOSTest::DBusConnectSuccessCallback, base::Unretained(this)), @@ -288,9 +292,9 @@ TEST_F(BluetoothAdapterProfileChromeOSTest, Routing) { EXPECT_EQ(1U, fake_delegate_autopair_.connections_); // Incoming connections look the same from BlueZ. - DBusThreadManager::Get()->GetBluetoothDeviceClient()->ConnectProfile( - dbus::ObjectPath(FakeBluetoothDeviceClient::kDisplayPinCodePath), - FakeBluetoothProfileManagerClient::kRfcommUuid, + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->ConnectProfile( + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kDisplayPinCodePath), + bluez::FakeBluetoothProfileManagerClient::kRfcommUuid, base::Bind( &BluetoothAdapterProfileChromeOSTest::DBusConnectSuccessCallback, base::Unretained(this)), @@ -306,8 +310,8 @@ TEST_F(BluetoothAdapterProfileChromeOSTest, Routing) { } TEST_F(BluetoothAdapterProfileChromeOSTest, SimultaneousRegister) { - BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kRfcommUuid); - BluetoothProfileManagerClient::Options options; + BluetoothUUID uuid(bluez::FakeBluetoothProfileManagerClient::kRfcommUuid); + bluez::BluetoothProfileManagerClient::Options options; BluetoothAdapterChromeOS* adapter = static_cast<BluetoothAdapterChromeOS*>(adapter_.get()); @@ -347,8 +351,9 @@ TEST_F(BluetoothAdapterProfileChromeOSTest, SimultaneousRegister) { } TEST_F(BluetoothAdapterProfileChromeOSTest, SimultaneousRegisterFail) { - BluetoothUUID uuid(FakeBluetoothProfileManagerClient::kUnregisterableUuid); - BluetoothProfileManagerClient::Options options; + BluetoothUUID uuid( + bluez::FakeBluetoothProfileManagerClient::kUnregisterableUuid); + bluez::BluetoothProfileManagerClient::Options options; BluetoothAdapterChromeOS* adapter = static_cast<BluetoothAdapterChromeOS*>(adapter_.get()); diff --git a/device/bluetooth/bluetooth_advertisement_chromeos.cc b/device/bluetooth/bluetooth_advertisement_chromeos.cc index 8cdfe90..671977d 100644 --- a/device/bluetooth/bluetooth_advertisement_chromeos.cc +++ b/device/bluetooth/bluetooth_advertisement_chromeos.cc @@ -12,11 +12,11 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/strings/string_util.h" -#include "chromeos/dbus/bluetooth_le_advertising_manager_client.h" -#include "chromeos/dbus/dbus_thread_manager.h" #include "dbus/bus.h" #include "dbus/object_path.h" #include "device/bluetooth/bluetooth_adapter_chromeos.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" namespace { @@ -82,10 +82,12 @@ BluetoothAdvertisementChromeOS::BluetoothAdvertisementChromeOS( dbus::ObjectPath advertisement_object_path = dbus::ObjectPath("/org/chromium/bluetooth_advertisement/" + GuidString); - DCHECK(DBusThreadManager::Get()); - provider_ = BluetoothLEAdvertisementServiceProvider::Create( - DBusThreadManager::Get()->GetSystemBus(), advertisement_object_path, this, - static_cast<BluetoothLEAdvertisementServiceProvider::AdvertisementType>( + DCHECK(bluez::BluezDBusManager::Get()); + provider_ = bluez::BluetoothLEAdvertisementServiceProvider::Create( + bluez::BluezDBusManager::Get()->GetSystemBus(), advertisement_object_path, + this, + static_cast< + bluez::BluetoothLEAdvertisementServiceProvider::AdvertisementType>( data->type()), data->service_uuids().Pass(), data->manufacturer_data().Pass(), data->solicit_uuids().Pass(), data->service_data().Pass()); @@ -95,8 +97,8 @@ void BluetoothAdvertisementChromeOS::Register( const base::Closure& success_callback, const device::BluetoothAdapter::CreateAdvertisementErrorCallback& error_callback) { - DCHECK(DBusThreadManager::Get()); - DBusThreadManager::Get() + DCHECK(bluez::BluezDBusManager::Get()); + bluez::BluezDBusManager::Get() ->GetBluetoothLEAdvertisingManagerClient() ->RegisterAdvertisement( adapter_->object_path(), provider_->object_path(), success_callback, @@ -118,8 +120,8 @@ void BluetoothAdvertisementChromeOS::Unregister( return; } - DCHECK(DBusThreadManager::Get()); - DBusThreadManager::Get() + DCHECK(bluez::BluezDBusManager::Get()); + bluez::BluezDBusManager::Get() ->GetBluetoothLEAdvertisingManagerClient() ->UnregisterAdvertisement( adapter_->object_path(), provider_->object_path(), success_callback, diff --git a/device/bluetooth/bluetooth_advertisement_chromeos.h b/device/bluetooth/bluetooth_advertisement_chromeos.h index aeb59b7..44abec2 100644 --- a/device/bluetooth/bluetooth_advertisement_chromeos.h +++ b/device/bluetooth/bluetooth_advertisement_chromeos.h @@ -6,21 +6,24 @@ #define DEVICE_BLUETOOTH_BLUETOOTH_ADVERTISEMENT_CHROMEOS_H_ #include "base/macros.h" -#include "chromeos/dbus/bluetooth_le_advertisement_service_provider.h" #include "device/bluetooth/bluetooth_adapter.h" #include "device/bluetooth/bluetooth_advertisement.h" #include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluetooth_le_advertisement_service_provider.h" + +namespace bluez { +class BluetoothLEAdvertisementServiceProvider; +} namespace chromeos { -class BluetoothLEAdvertisementServiceProvider; class BluetoothAdapterChromeOS; // The BluetoothAdvertisementChromeOS class implements BluetoothAdvertisement // for the Chrome OS platform. class DEVICE_BLUETOOTH_EXPORT BluetoothAdvertisementChromeOS : public device::BluetoothAdvertisement, - public BluetoothLEAdvertisementServiceProvider::Delegate { + public bluez::BluetoothLEAdvertisementServiceProvider::Delegate { public: BluetoothAdvertisementChromeOS( scoped_ptr<device::BluetoothAdvertisement::Data> data, @@ -30,7 +33,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdvertisementChromeOS void Unregister(const SuccessCallback& success_callback, const ErrorCallback& error_callback) override; - // BluetoothLEAdvertisementServiceProvider::Delegate overrides: + // bluez::BluetoothLEAdvertisementServiceProvider::Delegate overrides: void Released() override; void Register( @@ -40,7 +43,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdvertisementChromeOS // Used from tests to be able to trigger events on the fake advertisement // provider. - BluetoothLEAdvertisementServiceProvider* provider() { + bluez::BluetoothLEAdvertisementServiceProvider* provider() { return provider_.get(); } @@ -49,7 +52,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdvertisementChromeOS // Adapter this advertisement is advertising on. scoped_refptr<BluetoothAdapterChromeOS> adapter_; - scoped_ptr<BluetoothLEAdvertisementServiceProvider> provider_; + scoped_ptr<bluez::BluetoothLEAdvertisementServiceProvider> provider_; DISALLOW_COPY_AND_ASSIGN(BluetoothAdvertisementChromeOS); }; diff --git a/device/bluetooth/bluetooth_advertisement_chromeos_unittest.cc b/device/bluetooth/bluetooth_advertisement_chromeos_unittest.cc index 02fe1e4..165dc8d 100644 --- a/device/bluetooth/bluetooth_advertisement_chromeos_unittest.cc +++ b/device/bluetooth/bluetooth_advertisement_chromeos_unittest.cc @@ -9,12 +9,12 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_le_advertisement_service_provider.h" #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/dbus/bluez_dbus_manager.h" +#include "device/bluetooth/dbus/fake_bluetooth_le_advertisement_service_provider.h" #include "testing/gtest/include/gtest/gtest.h" using device::BluetoothAdapter; @@ -52,7 +52,7 @@ class TestAdvertisementObserver : public BluetoothAdvertisement::Observer { class BluetoothAdvertisementChromeOSTest : public testing::Test { public: void SetUp() override { - DBusThreadManager::Initialize(); + bluez::BluezDBusManager::Initialize(NULL, true); callback_count_ = 0; error_callback_count_ = 0; @@ -70,7 +70,7 @@ class BluetoothAdvertisementChromeOSTest : public testing::Test { // The adapter should outlive the advertisement. advertisement_ = nullptr; adapter_ = nullptr; - DBusThreadManager::Shutdown(); + bluez::BluezDBusManager::Shutdown(); } // Gets the existing Bluetooth adapter. @@ -134,8 +134,8 @@ class BluetoothAdvertisementChromeOSTest : public testing::Test { void TriggerReleased(scoped_refptr<BluetoothAdvertisement> advertisement) { BluetoothAdvertisementChromeOS* adv = static_cast<BluetoothAdvertisementChromeOS*>(advertisement.get()); - FakeBluetoothLEAdvertisementServiceProvider* provider = - static_cast<FakeBluetoothLEAdvertisementServiceProvider*>( + bluez::FakeBluetoothLEAdvertisementServiceProvider* provider = + static_cast<bluez::FakeBluetoothLEAdvertisementServiceProvider*>( adv->provider()); provider->Release(); } diff --git a/device/bluetooth/bluetooth_audio_sink_chromeos.cc b/device/bluetooth/bluetooth_audio_sink_chromeos.cc index 18ab219..9bb4b60 100644 --- a/device/bluetooth/bluetooth_audio_sink_chromeos.cc +++ b/device/bluetooth/bluetooth_audio_sink_chromeos.cc @@ -14,9 +14,9 @@ #include "base/debug/stack_trace.h" #include "base/files/file_util.h" #include "base/logging.h" -#include "chromeos/dbus/dbus_thread_manager.h" #include "dbus/message.h" #include "device/bluetooth/bluetooth_adapter_chromeos.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" using dbus::ObjectPath; using device::BluetoothAudioSink; @@ -94,17 +94,17 @@ BluetoothAudioSinkChromeOS::BluetoothAudioSinkChromeOS( CHECK(adapter_.get()); CHECK(adapter_->IsPresent()); - CHECK(DBusThreadManager::IsInitialized()); + CHECK(bluez::BluezDBusManager::IsInitialized()); adapter_->AddObserver(this); - BluetoothMediaClient* media = - DBusThreadManager::Get()->GetBluetoothMediaClient(); + bluez::BluetoothMediaClient* media = + bluez::BluezDBusManager::Get()->GetBluetoothMediaClient(); CHECK(media); media->AddObserver(this); - BluetoothMediaTransportClient* transport = - DBusThreadManager::Get()->GetBluetoothMediaTransportClient(); + bluez::BluetoothMediaTransportClient* transport = + bluez::BluezDBusManager::Get()->GetBluetoothMediaTransportClient(); CHECK(transport); transport->AddObserver(this); @@ -123,13 +123,13 @@ BluetoothAudioSinkChromeOS::~BluetoothAudioSinkChromeOS() { adapter_->RemoveObserver(this); - BluetoothMediaClient* media = - DBusThreadManager::Get()->GetBluetoothMediaClient(); + bluez::BluetoothMediaClient* media = + bluez::BluezDBusManager::Get()->GetBluetoothMediaClient(); CHECK(media); media->RemoveObserver(this); - BluetoothMediaTransportClient* transport = - DBusThreadManager::Get()->GetBluetoothMediaTransportClient(); + bluez::BluetoothMediaTransportClient* transport = + bluez::BluezDBusManager::Get()->GetBluetoothMediaTransportClient(); CHECK(transport); transport->RemoveObserver(this); } @@ -139,11 +139,11 @@ void BluetoothAudioSinkChromeOS::Unregister( const device::BluetoothAudioSink::ErrorCallback& error_callback) { VLOG(1) << "Unregister"; - if (!DBusThreadManager::IsInitialized()) + if (!bluez::BluezDBusManager::IsInitialized()) error_callback.Run(BluetoothAudioSink::ERROR_NOT_UNREGISTERED); - BluetoothMediaClient* media = - DBusThreadManager::Get()->GetBluetoothMediaClient(); + bluez::BluetoothMediaClient* media = + bluez::BluezDBusManager::Get()->GetBluetoothMediaClient(); CHECK(media); media->UnregisterEndpoint( @@ -185,27 +185,28 @@ void BluetoothAudioSinkChromeOS::Register( DCHECK_EQ(state_, BluetoothAudioSink::STATE_DISCONNECTED); // Gets system bus. - dbus::Bus* system_bus = DBusThreadManager::Get()->GetSystemBus(); + dbus::Bus* system_bus = bluez::BluezDBusManager::Get()->GetSystemBus(); // Creates a Media Endpoint with newly-generated path. endpoint_path_ = GenerateEndpointPath(); - media_endpoint_.reset(BluetoothMediaEndpointServiceProvider::Create( + media_endpoint_.reset(bluez::BluetoothMediaEndpointServiceProvider::Create( system_bus, endpoint_path_, this)); DCHECK(media_endpoint_.get()); // Creates endpoint properties with |options|. options_ = options; - chromeos::BluetoothMediaClient::EndpointProperties endpoint_properties; - endpoint_properties.uuid = BluetoothMediaClient::kBluetoothAudioSinkUUID; + bluez::BluetoothMediaClient::EndpointProperties endpoint_properties; + endpoint_properties.uuid = + bluez::BluetoothMediaClient::kBluetoothAudioSinkUUID; endpoint_properties.codec = options_.codec; endpoint_properties.capabilities = options_.capabilities; media_path_ = static_cast<BluetoothAdapterChromeOS*>( adapter_.get())->object_path(); - BluetoothMediaClient* media = - DBusThreadManager::Get()->GetBluetoothMediaClient(); + bluez::BluetoothMediaClient* media = + bluez::BluezDBusManager::Get()->GetBluetoothMediaClient(); CHECK(media); media->RegisterEndpoint( media_path_, @@ -217,7 +218,7 @@ void BluetoothAudioSinkChromeOS::Register( weak_ptr_factory_.GetWeakPtr(), error_callback)); } -BluetoothMediaEndpointServiceProvider* +bluez::BluetoothMediaEndpointServiceProvider* BluetoothAudioSinkChromeOS::GetEndpointServiceProvider() { return media_endpoint_.get(); } @@ -279,21 +280,21 @@ void BluetoothAudioSinkChromeOS::MediaTransportPropertyChanged( VLOG(1) << "MediaTransportPropertyChanged: " << property_name; // Retrieves the property set of the transport object with |object_path|. - BluetoothMediaTransportClient::Properties* properties = - DBusThreadManager::Get() + bluez::BluetoothMediaTransportClient::Properties* properties = + bluez::BluezDBusManager::Get() ->GetBluetoothMediaTransportClient() ->GetProperties(object_path); // Dispatches a property changed event to the corresponding handler. if (property_name == properties->state.name()) { if (properties->state.value() == - BluetoothMediaTransportClient::kStateIdle) { + bluez::BluetoothMediaTransportClient::kStateIdle) { StateChanged(BluetoothAudioSink::STATE_IDLE); } else if (properties->state.value() == - BluetoothMediaTransportClient::kStatePending) { + bluez::BluetoothMediaTransportClient::kStatePending) { StateChanged(BluetoothAudioSink::STATE_PENDING); } else if (properties->state.value() == - BluetoothMediaTransportClient::kStateActive) { + bluez::BluetoothMediaTransportClient::kStateActive) { StateChanged(BluetoothAudioSink::STATE_ACTIVE); } } else if (property_name == properties->volume.name()) { @@ -308,7 +309,7 @@ void BluetoothAudioSinkChromeOS::SetConfiguration( transport_path_ = transport_path; // The initial state for a connection should be "idle". - if (properties.state != BluetoothMediaTransportClient::kStateIdle) { + if (properties.state != bluez::BluetoothMediaTransportClient::kStateIdle) { VLOG(1) << "SetConfiugration - unexpected state :" << properties.state; return; } @@ -355,7 +356,7 @@ void BluetoothAudioSinkChromeOS::AcquireFD() { read_has_failed_ = false; - DBusThreadManager::Get()->GetBluetoothMediaTransportClient()->Acquire( + bluez::BluezDBusManager::Get()->GetBluetoothMediaTransportClient()->Acquire( transport_path_, base::Bind(&BluetoothAudioSinkChromeOS::OnAcquireSucceeded, weak_ptr_factory_.GetWeakPtr()), diff --git a/device/bluetooth/bluetooth_audio_sink_chromeos.h b/device/bluetooth/bluetooth_audio_sink_chromeos.h index 6261ace..750b31d 100644 --- a/device/bluetooth/bluetooth_audio_sink_chromeos.h +++ b/device/bluetooth/bluetooth_audio_sink_chromeos.h @@ -14,14 +14,14 @@ #include "base/memory/weak_ptr.h" #include "base/message_loop/message_loop.h" #include "base/observer_list.h" -#include "chromeos/dbus/bluetooth_media_client.h" -#include "chromeos/dbus/bluetooth_media_endpoint_service_provider.h" -#include "chromeos/dbus/bluetooth_media_transport_client.h" #include "dbus/file_descriptor.h" #include "dbus/object_path.h" #include "device/bluetooth/bluetooth_adapter.h" #include "device/bluetooth/bluetooth_audio_sink.h" #include "device/bluetooth/bluetooth_export.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" namespace chromeos { @@ -30,9 +30,9 @@ class BluetoothAudioSinkChromeOSTest; class DEVICE_BLUETOOTH_EXPORT BluetoothAudioSinkChromeOS : public device::BluetoothAudioSink, public device::BluetoothAdapter::Observer, - public BluetoothMediaClient::Observer, - public BluetoothMediaTransportClient::Observer, - public BluetoothMediaEndpointServiceProvider::Delegate, + public bluez::BluetoothMediaClient::Observer, + public bluez::BluetoothMediaTransportClient::Observer, + public bluez::BluetoothMediaEndpointServiceProvider::Delegate, public base::MessageLoopForIO::Watcher { public: explicit BluetoothAudioSinkChromeOS( @@ -61,7 +61,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAudioSinkChromeOS // Returns a pointer to the media endpoint object. This function should be // used for testing purpose only. - BluetoothMediaEndpointServiceProvider* GetEndpointServiceProvider(); + bluez::BluetoothMediaEndpointServiceProvider* GetEndpointServiceProvider(); private: ~BluetoothAudioSinkChromeOS() override; @@ -72,15 +72,15 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAudioSinkChromeOS void AdapterPoweredChanged(device::BluetoothAdapter* adapter, bool powered) override; - // BluetoothMediaClient::Observer overrides. + // bluez::BluetoothMediaClient::Observer overrides. void MediaRemoved(const dbus::ObjectPath& object_path) override; - // BluetoothMediaTransportClient::Observer overrides. + // bluez::BluetoothMediaTransportClient::Observer overrides. void MediaTransportRemoved(const dbus::ObjectPath& object_path) override; void MediaTransportPropertyChanged(const dbus::ObjectPath& object_path, const std::string& property_name) override; - // BluetoothMediaEndpointServiceProvider::Delegate overrides. + // bluez::BluetoothMediaEndpointServiceProvider::Delegate overrides. void SetConfiguration(const dbus::ObjectPath& transport_path, const TransportProperties& properties) override; void SelectConfiguration( @@ -204,7 +204,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAudioSinkChromeOS device::BluetoothAudioSink::Options options_; // Media Endpoint object owned by the audio sink object. - scoped_ptr<BluetoothMediaEndpointServiceProvider> media_endpoint_; + 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. diff --git a/device/bluetooth/bluetooth_audio_sink_chromeos_unittest.cc b/device/bluetooth/bluetooth_audio_sink_chromeos_unittest.cc index a585f3d..5f51cb8 100644 --- a/device/bluetooth/bluetooth_audio_sink_chromeos_unittest.cc +++ b/device/bluetooth/bluetooth_audio_sink_chromeos_unittest.cc @@ -8,20 +8,21 @@ #include "base/logging.h" #include "base/memory/ref_counted.h" #include "base/message_loop/message_loop.h" -#include "chromeos/dbus/bluetooth_media_client.h" -#include "chromeos/dbus/bluetooth_media_endpoint_service_provider.h" -#include "chromeos/dbus/bluetooth_media_transport_client.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_media_client.h" -#include "chromeos/dbus/fake_bluetooth_media_endpoint_service_provider.h" -#include "chromeos/dbus/fake_bluetooth_media_transport_client.h" #include "dbus/object_path.h" #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/dbus/bluetooth_media_client.h" +#include "device/bluetooth/dbus/bluetooth_media_endpoint_service_provider.h" +#include "device/bluetooth/dbus/bluetooth_media_transport_client.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" +#include "device/bluetooth/dbus/fake_bluetooth_media_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_media_endpoint_service_provider.h" +#include "device/bluetooth/dbus/fake_bluetooth_media_transport_client.h" #include "testing/gtest/include/gtest/gtest.h" +using bluez::FakeBluetoothMediaTransportClient; using dbus::ObjectPath; using device::BluetoothAdapter; using device::BluetoothAdapterFactory; @@ -81,26 +82,26 @@ class TestAudioSinkObserver : public BluetoothAudioSink::Observer { class BluetoothAudioSinkChromeOSTest : public testing::Test { public: void SetUp() override { - DBusThreadManager::Initialize(); + bluez::BluezDBusManager::Initialize(NULL, true); callback_count_ = 0; error_callback_count_ = 0; - fake_media_ = static_cast<FakeBluetoothMediaClient*>( - DBusThreadManager::Get()->GetBluetoothMediaClient()); + fake_media_ = static_cast<bluez::FakeBluetoothMediaClient*>( + bluez::BluezDBusManager::Get()->GetBluetoothMediaClient()); fake_transport_ = static_cast<FakeBluetoothMediaTransportClient*>( - DBusThreadManager::Get()->GetBluetoothMediaTransportClient()); + bluez::BluezDBusManager::Get()->GetBluetoothMediaTransportClient()); // Initiates Delegate::TransportProperties with default values. properties_.device = ObjectPath(FakeBluetoothMediaTransportClient::kTransportDevicePath); - properties_.uuid = BluetoothMediaClient::kBluetoothAudioSinkUUID; + properties_.uuid = bluez::BluetoothMediaClient::kBluetoothAudioSinkUUID; properties_.codec = FakeBluetoothMediaTransportClient::kTransportCodec; properties_.configuration = std::vector<uint8_t>( FakeBluetoothMediaTransportClient::kTransportConfiguration, FakeBluetoothMediaTransportClient::kTransportConfiguration + FakeBluetoothMediaTransportClient::kTransportConfigurationLength); - properties_.state = BluetoothMediaTransportClient::kStateIdle; + properties_.state = bluez::BluetoothMediaTransportClient::kStateIdle; properties_.delay.reset( new uint16_t(FakeBluetoothMediaTransportClient::kTransportDelay)); properties_.volume.reset( @@ -119,7 +120,7 @@ class BluetoothAudioSinkChromeOSTest : public testing::Test { // The adapter should outlive audio sink. audio_sink_ = nullptr; adapter_ = nullptr; - DBusThreadManager::Shutdown(); + bluez::BluezDBusManager::Shutdown(); } // Gets the existing Bluetooth adapter. @@ -180,8 +181,9 @@ class BluetoothAudioSinkChromeOSTest : public testing::Test { static_cast<BluetoothAudioSinkChromeOS*>(audio_sink_.get()); ASSERT_NE(audio_sink_chromeos, nullptr); - media_endpoint_ = static_cast<FakeBluetoothMediaEndpointServiceProvider*>( - audio_sink_chromeos->GetEndpointServiceProvider()); + media_endpoint_ = + static_cast<bluez::FakeBluetoothMediaEndpointServiceProvider*>( + audio_sink_chromeos->GetEndpointServiceProvider()); } // Called whenever RegisterAudioSink is completed successfully. @@ -233,16 +235,16 @@ class BluetoothAudioSinkChromeOSTest : public testing::Test { base::MessageLoopForIO message_loop_; - FakeBluetoothMediaClient* fake_media_; + bluez::FakeBluetoothMediaClient* fake_media_; FakeBluetoothMediaTransportClient* fake_transport_; - FakeBluetoothMediaEndpointServiceProvider* media_endpoint_; + bluez::FakeBluetoothMediaEndpointServiceProvider* media_endpoint_; scoped_ptr<TestAudioSinkObserver> observer_; scoped_refptr<BluetoothAdapter> adapter_; scoped_refptr<BluetoothAudioSink> audio_sink_; // The default property set used while calling SetConfiguration on a media // endpoint object. - BluetoothMediaEndpointServiceProvider::Delegate::TransportProperties + bluez::BluetoothMediaEndpointServiceProvider::Delegate::TransportProperties properties_; }; diff --git a/device/bluetooth/bluetooth_chromeos_unittest.cc b/device/bluetooth/bluetooth_chromeos_unittest.cc index 49b5b59..cea92d9 100644 --- a/device/bluetooth/bluetooth_chromeos_unittest.cc +++ b/device/bluetooth/bluetooth_chromeos_unittest.cc @@ -6,12 +6,6 @@ #include "base/message_loop/message_loop.h" #include "base/run_loop.h" #include "base/strings/utf_string_conversions.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_adapter_client.h" -#include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" -#include "chromeos/dbus/fake_bluetooth_device_client.h" -#include "chromeos/dbus/fake_bluetooth_gatt_service_client.h" -#include "chromeos/dbus/fake_bluetooth_input_client.h" #include "dbus/object_path.h" #include "device/bluetooth/bluetooth_adapter.h" #include "device/bluetooth/bluetooth_adapter_chromeos.h" @@ -20,6 +14,12 @@ #include "device/bluetooth/bluetooth_device_chromeos.h" #include "device/bluetooth/bluetooth_discovery_session.h" #include "device/bluetooth/bluetooth_pairing_chromeos.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" +#include "device/bluetooth/dbus/fake_bluetooth_device_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_service_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_input_client.h" #include "device/bluetooth/test/test_bluetooth_adapter_observer.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/cros_system_api/dbus/service_constants.h" @@ -57,17 +57,18 @@ int GetDeviceIndexByAddress(BluetoothAdapter::DeviceList& devices, } class FakeBluetoothProfileServiceProviderDelegate - : public chromeos::BluetoothProfileServiceProvider::Delegate { + : public bluez::BluetoothProfileServiceProvider::Delegate { public: FakeBluetoothProfileServiceProviderDelegate() {} - // BluetoothProfileServiceProvider::Delegate: + // bluez::BluetoothProfileServiceProvider::Delegate: void Released() override {} - void NewConnection(const dbus::ObjectPath&, - scoped_ptr<dbus::FileDescriptor>, - const BluetoothProfileServiceProvider::Delegate::Options&, - const ConfirmationCallback&) override {} + void NewConnection( + const dbus::ObjectPath&, + scoped_ptr<dbus::FileDescriptor>, + const bluez::BluetoothProfileServiceProvider::Delegate::Options&, + const ConfirmationCallback&) override {} void RequestDisconnection(const dbus::ObjectPath&, const ConfirmationCallback&) override {} @@ -165,25 +166,28 @@ class TestPairingDelegate : public BluetoothDevice::PairingDelegate { class BluetoothChromeOSTest : public testing::Test { public: void SetUp() override { - scoped_ptr<DBusThreadManagerSetter> dbus_setter = - chromeos::DBusThreadManager::GetSetterForTesting(); - // We need to initialize DBusThreadManager early to prevent + scoped_ptr<bluez::BluezDBusManagerSetter> dbus_setter = + bluez::BluezDBusManager::GetSetterForTesting(); + // We need to initialize BluezDBusManager early to prevent // Bluetooth*::Create() methods from picking the real instead of fake // implementations. - fake_bluetooth_adapter_client_ = new FakeBluetoothAdapterClient; + fake_bluetooth_adapter_client_ = new bluez::FakeBluetoothAdapterClient; dbus_setter->SetBluetoothAdapterClient( - scoped_ptr<BluetoothAdapterClient>(fake_bluetooth_adapter_client_)); - fake_bluetooth_device_client_ = new FakeBluetoothDeviceClient; + scoped_ptr<bluez::BluetoothAdapterClient>( + fake_bluetooth_adapter_client_)); + fake_bluetooth_device_client_ = new bluez::FakeBluetoothDeviceClient; dbus_setter->SetBluetoothDeviceClient( - scoped_ptr<BluetoothDeviceClient>(fake_bluetooth_device_client_)); + scoped_ptr<bluez::BluetoothDeviceClient>( + fake_bluetooth_device_client_)); dbus_setter->SetBluetoothInputClient( - scoped_ptr<BluetoothInputClient>(new FakeBluetoothInputClient)); + scoped_ptr<bluez::BluetoothInputClient>( + new bluez::FakeBluetoothInputClient)); dbus_setter->SetBluetoothAgentManagerClient( - scoped_ptr<BluetoothAgentManagerClient>( - new FakeBluetoothAgentManagerClient)); + scoped_ptr<bluez::BluetoothAgentManagerClient>( + new bluez::FakeBluetoothAgentManagerClient)); dbus_setter->SetBluetoothGattServiceClient( - scoped_ptr<BluetoothGattServiceClient>( - new FakeBluetoothGattServiceClient)); + scoped_ptr<bluez::BluetoothGattServiceClient>( + new bluez::FakeBluetoothGattServiceClient)); fake_bluetooth_adapter_client_->SetSimulationIntervalMs(10); @@ -208,7 +212,7 @@ class BluetoothChromeOSTest : public testing::Test { } discovery_sessions_.clear(); adapter_ = nullptr; - DBusThreadManager::Shutdown(); + bluez::BluezDBusManager::Shutdown(); } // Generic callbacks @@ -337,8 +341,8 @@ class BluetoothChromeOSTest : public testing::Test { protected: base::MessageLoop message_loop_; - FakeBluetoothAdapterClient* fake_bluetooth_adapter_client_; - FakeBluetoothDeviceClient* fake_bluetooth_device_client_; + bluez::FakeBluetoothAdapterClient* fake_bluetooth_adapter_client_; + bluez::FakeBluetoothDeviceClient* fake_bluetooth_device_client_; scoped_refptr<BluetoothAdapter> adapter_; int callback_count_; @@ -366,7 +370,7 @@ TEST_F(BluetoothChromeOSTest, AlreadyPresent) { // and initializes with an existing adapter if there is one. EXPECT_TRUE(adapter_->IsPresent()); EXPECT_FALSE(adapter_->IsPowered()); - EXPECT_EQ(FakeBluetoothAdapterClient::kAdapterAddress, + EXPECT_EQ(bluez::FakeBluetoothAdapterClient::kAdapterAddress, adapter_->GetAddress()); EXPECT_FALSE(adapter_->IsDiscovering()); @@ -375,12 +379,14 @@ TEST_F(BluetoothChromeOSTest, AlreadyPresent) { EXPECT_EQ(2U, devices.size()); // |devices| are not ordered, verify it contains the 2 device addresses. - EXPECT_NE(-1, GetDeviceIndexByAddress( - devices, FakeBluetoothDeviceClient::kPairedDeviceAddress)); - EXPECT_NE(-1, - GetDeviceIndexByAddress( - devices, - FakeBluetoothDeviceClient::kPairedUnconnectableDeviceAddress)); + EXPECT_NE( + -1, GetDeviceIndexByAddress( + devices, bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress)); + EXPECT_NE( + -1, + GetDeviceIndexByAddress( + devices, + bluez::FakeBluetoothDeviceClient::kPairedUnconnectableDeviceAddress)); } TEST_F(BluetoothChromeOSTest, BecomePresent) { @@ -401,7 +407,7 @@ TEST_F(BluetoothChromeOSTest, BecomePresent) { // We should have had a device announced. EXPECT_EQ(2, observer.device_added_count()); - EXPECT_EQ(FakeBluetoothDeviceClient::kPairedUnconnectableDeviceAddress, + EXPECT_EQ(bluez::FakeBluetoothDeviceClient::kPairedUnconnectableDeviceAddress, observer.last_device_address()); // Other callbacks shouldn't be called if the values are false. @@ -430,10 +436,10 @@ TEST_F(BluetoothChromeOSTest, BecomeNotPresent) { EXPECT_EQ(2, observer.device_removed_count()); // 2 possibilities for the last device here. std::string address = observer.last_device_address(); - EXPECT_TRUE( - address.compare( - FakeBluetoothDeviceClient::kPairedUnconnectableDeviceAddress) == 0 || - address.compare(FakeBluetoothDeviceClient::kPairedDeviceAddress) == 0); + EXPECT_TRUE(address.compare(bluez::FakeBluetoothDeviceClient:: + kPairedUnconnectableDeviceAddress) == 0 || + address.compare( + bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress) == 0); // Other callbacks shouldn't be called since the values are false. EXPECT_EQ(0, observer.powered_changed_count()); @@ -455,7 +461,7 @@ TEST_F(BluetoothChromeOSTest, SecondAdapter) { EXPECT_EQ(0, observer.present_changed_count()); EXPECT_TRUE(adapter_->IsPresent()); - EXPECT_EQ(FakeBluetoothAdapterClient::kAdapterAddress, + EXPECT_EQ(bluez::FakeBluetoothAdapterClient::kAdapterAddress, adapter_->GetAddress()); // Try removing the first adapter, we should now act as if the adapter @@ -472,10 +478,10 @@ TEST_F(BluetoothChromeOSTest, SecondAdapter) { // As BluetoothAdapter devices removal does not keep the order of adding them, // 2 possibilities for the last device here. std::string address = observer.last_device_address(); - EXPECT_TRUE( - address.compare( - FakeBluetoothDeviceClient::kPairedUnconnectableDeviceAddress) == 0 || - address.compare(FakeBluetoothDeviceClient::kPairedDeviceAddress) == 0); + EXPECT_TRUE(address.compare(bluez::FakeBluetoothDeviceClient:: + kPairedUnconnectableDeviceAddress) == 0 || + address.compare( + bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress) == 0); // Other callbacks shouldn't be called since the values are false. EXPECT_EQ(0, observer.powered_changed_count()); @@ -745,7 +751,7 @@ TEST_F(BluetoothChromeOSTest, Discovery) { message_loop_.Run(); EXPECT_EQ(2, observer.device_added_count()); - EXPECT_EQ(FakeBluetoothDeviceClient::kLowEnergyAddress, + EXPECT_EQ(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress, observer.last_device_address()); // Next we should get another two devices... @@ -757,7 +763,7 @@ TEST_F(BluetoothChromeOSTest, Discovery) { message_loop_.Run(); EXPECT_EQ(1, observer.device_removed_count()); - EXPECT_EQ(FakeBluetoothDeviceClient::kVanishingDeviceAddress, + EXPECT_EQ(bluez::FakeBluetoothDeviceClient::kVanishingDeviceAddress, observer.last_device_address()); } @@ -777,7 +783,7 @@ TEST_F(BluetoothChromeOSTest, PoweredAndDiscovering) { // Stop the timers that the simulation uses fake_bluetooth_device_client_->EndDiscoverySimulation( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath)); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath)); ASSERT_TRUE(adapter_->IsPowered()); ASSERT_TRUE(adapter_->IsDiscovering()); @@ -971,21 +977,23 @@ TEST_F(BluetoothChromeOSTest, // Stop the timers that the simulation uses fake_bluetooth_device_client_->EndDiscoverySimulation( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath)); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath)); ASSERT_TRUE(adapter_->IsPowered()); ASSERT_TRUE(adapter_->IsDiscovering()); // Stop device discovery behind the adapter. The adapter and the observer // should be notified of the change and the reference count should be reset. - // Even though FakeBluetoothAdapterClient does its own reference counting and + // Even though bluez::FakeBluetoothAdapterClient does its own reference + // counting and // we called 3 BluetoothAdapter::StartDiscoverySession 3 times, the - // FakeBluetoothAdapterClient's count should be only 1 and a single call to - // FakeBluetoothAdapterClient::StopDiscovery should work. + // bluez::FakeBluetoothAdapterClient's count should be only 1 and a single + // call to + // bluez::FakeBluetoothAdapterClient::StopDiscovery should work. fake_bluetooth_adapter_client_->StopDiscovery( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), GetCallback(), - base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, - base::Unretained(this))); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), + GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, + base::Unretained(this))); message_loop_.Run(); EXPECT_EQ(2, observer.discovering_changed_count()); EXPECT_EQ(4, callback_count_); @@ -1018,7 +1026,7 @@ TEST_F(BluetoothChromeOSTest, EXPECT_TRUE(discovery_sessions_[i]->IsActive()); fake_bluetooth_device_client_->EndDiscoverySimulation( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath)); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath)); // Make the adapter disappear and appear. This will make it come back as // discovering. When this happens, the reference count should become and @@ -1043,7 +1051,8 @@ TEST_F(BluetoothChromeOSTest, EXPECT_TRUE(observer.last_discovering()); EXPECT_TRUE(adapter_->IsDiscovering()); - // Start and stop discovery. At this point, FakeBluetoothAdapterClient has + // Start and stop discovery. At this point, bluez::FakeBluetoothAdapterClient + // has // a reference count that is equal to 1. Pretend that this was done by an // application other than us. Starting and stopping discovery will succeed // but it won't cause the discovery state to change. @@ -1088,9 +1097,9 @@ TEST_F(BluetoothChromeOSTest, // the discovery state won't change since our BluetoothAdapter also just // requested it via D-Bus. fake_bluetooth_adapter_client_->StopDiscovery( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), GetCallback(), - base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, - base::Unretained(this))); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), + GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, + base::Unretained(this))); message_loop_.Run(); EXPECT_EQ(5, observer.discovering_changed_count()); EXPECT_EQ(10, callback_count_); @@ -1149,7 +1158,7 @@ TEST_F(BluetoothChromeOSTest, InvalidatedDiscoverySessions) { // Stop the timers that the simulation uses fake_bluetooth_device_client_->EndDiscoverySimulation( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath)); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath)); ASSERT_TRUE(adapter_->IsPowered()); ASSERT_TRUE(adapter_->IsDiscovering()); @@ -1166,9 +1175,9 @@ TEST_F(BluetoothChromeOSTest, InvalidatedDiscoverySessions) { // memory errors as the sessions that we explicitly deleted should get // cleaned up. fake_bluetooth_adapter_client_->StopDiscovery( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), GetCallback(), - base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, - base::Unretained(this))); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), + GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, + base::Unretained(this))); message_loop_.Run(); EXPECT_EQ(2, observer.discovering_changed_count()); EXPECT_EQ(4, callback_count_); @@ -1201,7 +1210,7 @@ TEST_F(BluetoothChromeOSTest, QueuedDiscoveryRequests) { EXPECT_EQ(0, callback_count_); fake_bluetooth_device_client_->EndDiscoverySimulation( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath)); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath)); // The underlying adapter has started discovery, but our call hasn't returned // yet. @@ -2119,14 +2128,15 @@ TEST_F(BluetoothChromeOSTest, DeviceProperties) { ASSERT_EQ(2U, devices.size()); int idx = GetDeviceIndexByAddress( - devices, FakeBluetoothDeviceClient::kPairedDeviceAddress); + devices, bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); ASSERT_NE(-1, idx); - ASSERT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress, + ASSERT_EQ(bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress, devices[idx]->GetAddress()); // Verify the other device properties. - EXPECT_EQ(base::UTF8ToUTF16(FakeBluetoothDeviceClient::kPairedDeviceName), - devices[idx]->GetName()); + EXPECT_EQ( + base::UTF8ToUTF16(bluez::FakeBluetoothDeviceClient::kPairedDeviceName), + devices[idx]->GetName()); EXPECT_EQ(BluetoothDevice::DEVICE_COMPUTER, devices[idx]->GetDeviceType()); EXPECT_TRUE(devices[idx]->IsPaired()); EXPECT_FALSE(devices[idx]->IsConnected()); @@ -2155,7 +2165,7 @@ TEST_F(BluetoothChromeOSTest, DeviceClassChanged) { ASSERT_EQ(2U, devices.size()); int idx = GetDeviceIndexByAddress( - devices, FakeBluetoothDeviceClient::kPairedDeviceAddress); + devices, bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); ASSERT_NE(-1, idx); ASSERT_EQ(BluetoothDevice::DEVICE_COMPUTER, devices[idx]->GetDeviceType()); @@ -2163,9 +2173,9 @@ TEST_F(BluetoothChromeOSTest, DeviceClassChanged) { // we change the class of the device. TestBluetoothAdapterObserver observer(adapter_); - FakeBluetoothDeviceClient::Properties* properties = - fake_bluetooth_device_client_->GetProperties( - dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath)); + bluez::FakeBluetoothDeviceClient::Properties* properties = + fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath( + bluez::FakeBluetoothDeviceClient::kPairedDevicePath)); properties->bluetooth_class.ReplaceValue(0x002580); @@ -2183,20 +2193,21 @@ TEST_F(BluetoothChromeOSTest, DeviceNameChanged) { ASSERT_EQ(2U, devices.size()); int idx = GetDeviceIndexByAddress( - devices, FakeBluetoothDeviceClient::kPairedDeviceAddress); + devices, bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); ASSERT_NE(-1, idx); - ASSERT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress, + ASSERT_EQ(bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress, devices[idx]->GetAddress()); - ASSERT_EQ(base::UTF8ToUTF16(FakeBluetoothDeviceClient::kPairedDeviceName), - devices[idx]->GetName()); + ASSERT_EQ( + base::UTF8ToUTF16(bluez::FakeBluetoothDeviceClient::kPairedDeviceName), + devices[idx]->GetName()); // Install an observer; expect the DeviceChanged method to be called when // we change the alias of the device. TestBluetoothAdapterObserver observer(adapter_); - FakeBluetoothDeviceClient::Properties* properties = - fake_bluetooth_device_client_->GetProperties( - dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath)); + bluez::FakeBluetoothDeviceClient::Properties* properties = + fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath( + bluez::FakeBluetoothDeviceClient::kPairedDevicePath)); static const std::string new_name("New Device Name"); properties->alias.ReplaceValue(new_name); @@ -2215,20 +2226,21 @@ TEST_F(BluetoothChromeOSTest, DeviceAddressChanged) { ASSERT_EQ(2U, devices.size()); int idx = GetDeviceIndexByAddress( - devices, FakeBluetoothDeviceClient::kPairedDeviceAddress); + devices, bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); ASSERT_NE(-1, idx); - ASSERT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress, + ASSERT_EQ(bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress, devices[idx]->GetAddress()); - ASSERT_EQ(base::UTF8ToUTF16(FakeBluetoothDeviceClient::kPairedDeviceName), - devices[idx]->GetName()); + ASSERT_EQ( + base::UTF8ToUTF16(bluez::FakeBluetoothDeviceClient::kPairedDeviceName), + devices[idx]->GetName()); // Install an observer; expect the DeviceAddressChanged method to be called // when we change the alias of the device. TestBluetoothAdapterObserver observer(adapter_); - FakeBluetoothDeviceClient::Properties* properties = - fake_bluetooth_device_client_->GetProperties( - dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath)); + bluez::FakeBluetoothDeviceClient::Properties* properties = + fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath( + bluez::FakeBluetoothDeviceClient::kPairedDevicePath)); static const char* kNewAddress = "D9:1F:FC:11:22:33"; properties->address.ReplaceValue(kNewAddress); @@ -2248,9 +2260,9 @@ TEST_F(BluetoothChromeOSTest, DeviceUuidsChanged) { ASSERT_EQ(2U, devices.size()); int idx = GetDeviceIndexByAddress( - devices, FakeBluetoothDeviceClient::kPairedDeviceAddress); + devices, bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); ASSERT_NE(-1, idx); - ASSERT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress, + ASSERT_EQ(bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress, devices[idx]->GetAddress()); BluetoothDevice::UUIDList uuids = devices[idx]->GetUUIDs(); @@ -2262,9 +2274,9 @@ TEST_F(BluetoothChromeOSTest, DeviceUuidsChanged) { // we change the class of the device. TestBluetoothAdapterObserver observer(adapter_); - FakeBluetoothDeviceClient::Properties* properties = - fake_bluetooth_device_client_->GetProperties( - dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath)); + bluez::FakeBluetoothDeviceClient::Properties* properties = + fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath( + bluez::FakeBluetoothDeviceClient::kPairedDevicePath)); std::vector<std::string> new_uuids; new_uuids.push_back(uuids[0].canonical_value()); @@ -2297,12 +2309,12 @@ TEST_F(BluetoothChromeOSTest, DeviceInquiryRSSIInvalidated) { ASSERT_EQ(2U, devices.size()); int idx = GetDeviceIndexByAddress( - devices, FakeBluetoothDeviceClient::kPairedDeviceAddress); + devices, bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); ASSERT_NE(-1, idx); - FakeBluetoothDeviceClient::Properties* properties = - fake_bluetooth_device_client_->GetProperties( - dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath)); + bluez::FakeBluetoothDeviceClient::Properties* properties = + fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath( + bluez::FakeBluetoothDeviceClient::kPairedDevicePath)); // During discovery, rssi is a valid value (-75) properties->rssi.ReplaceValue(-75); @@ -2334,12 +2346,12 @@ TEST_F(BluetoothChromeOSTest, DeviceInquiryTxPowerInvalidated) { ASSERT_EQ(2U, devices.size()); int idx = GetDeviceIndexByAddress( - devices, FakeBluetoothDeviceClient::kPairedDeviceAddress); + devices, bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); ASSERT_NE(-1, idx); - FakeBluetoothDeviceClient::Properties* properties = - fake_bluetooth_device_client_->GetProperties( - dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath)); + bluez::FakeBluetoothDeviceClient::Properties* properties = + fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath( + bluez::FakeBluetoothDeviceClient::kPairedDevicePath)); // During discovery, tx_power is a valid value (0) properties->tx_power.ReplaceValue(0); @@ -2369,9 +2381,9 @@ TEST_F(BluetoothChromeOSTest, ForgetDevice) { ASSERT_EQ(2U, devices.size()); int idx = GetDeviceIndexByAddress( - devices, FakeBluetoothDeviceClient::kPairedDeviceAddress); + devices, bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); ASSERT_NE(-1, idx); - ASSERT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress, + ASSERT_EQ(bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress, devices[idx]->GetAddress()); std::string address = devices[idx]->GetAddress(); @@ -2395,8 +2407,8 @@ TEST_F(BluetoothChromeOSTest, ForgetUnpairedDevice) { GetAdapter(); DiscoverDevices(); - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kConnectUnpairableAddress); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kConnectUnpairableAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); @@ -2413,9 +2425,9 @@ TEST_F(BluetoothChromeOSTest, ForgetUnpairedDevice) { ASSERT_FALSE(device->IsConnecting()); // Make sure the trusted property has been set to true. - FakeBluetoothDeviceClient::Properties* properties = - fake_bluetooth_device_client_->GetProperties( - dbus::ObjectPath(FakeBluetoothDeviceClient::kConnectUnpairablePath)); + bluez::FakeBluetoothDeviceClient::Properties* properties = + fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath( + bluez::FakeBluetoothDeviceClient::kConnectUnpairablePath)); ASSERT_TRUE(properties->trusted.value()); // Install an observer; expect the DeviceRemoved method to be called @@ -2426,20 +2438,20 @@ TEST_F(BluetoothChromeOSTest, ForgetUnpairedDevice) { EXPECT_EQ(0, error_callback_count_); EXPECT_EQ(1, observer.device_removed_count()); - EXPECT_EQ(FakeBluetoothDeviceClient::kConnectUnpairableAddress, + EXPECT_EQ(bluez::FakeBluetoothDeviceClient::kConnectUnpairableAddress, observer.last_device_address()); // GetDevices shouldn't return the device either. - device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kConnectUnpairableAddress); + device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kConnectUnpairableAddress); EXPECT_FALSE(device != nullptr); } TEST_F(BluetoothChromeOSTest, ConnectPairedDevice) { GetAdapter(); - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kPairedDeviceAddress); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); ASSERT_TRUE(device != nullptr); ASSERT_TRUE(device->IsPaired()); @@ -2467,8 +2479,8 @@ TEST_F(BluetoothChromeOSTest, ConnectUnpairableDevice) { GetAdapter(); DiscoverDevices(); - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kConnectUnpairableAddress); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kConnectUnpairableAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); @@ -2492,9 +2504,9 @@ TEST_F(BluetoothChromeOSTest, ConnectUnpairableDevice) { EXPECT_FALSE(device->IsConnecting()); // Make sure the trusted property has been set to true. - FakeBluetoothDeviceClient::Properties* properties = - fake_bluetooth_device_client_->GetProperties( - dbus::ObjectPath(FakeBluetoothDeviceClient::kConnectUnpairablePath)); + bluez::FakeBluetoothDeviceClient::Properties* properties = + fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath( + bluez::FakeBluetoothDeviceClient::kConnectUnpairablePath)); EXPECT_TRUE(properties->trusted.value()); // Verify is a HID device and is not connectable. @@ -2507,8 +2519,8 @@ TEST_F(BluetoothChromeOSTest, ConnectUnpairableDevice) { TEST_F(BluetoothChromeOSTest, ConnectConnectedDevice) { GetAdapter(); - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kPairedDeviceAddress); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); ASSERT_TRUE(device != nullptr); ASSERT_TRUE(device->IsPaired()); @@ -2545,8 +2557,8 @@ TEST_F(BluetoothChromeOSTest, ConnectDeviceFails) { GetAdapter(); DiscoverDevices(); - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kLegacyAutopairAddress); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kLegacyAutopairAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); @@ -2571,8 +2583,8 @@ TEST_F(BluetoothChromeOSTest, ConnectDeviceFails) { TEST_F(BluetoothChromeOSTest, DisconnectDevice) { GetAdapter(); - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kPairedDeviceAddress); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); ASSERT_TRUE(device != nullptr); ASSERT_TRUE(device->IsPaired()); @@ -2605,8 +2617,8 @@ TEST_F(BluetoothChromeOSTest, DisconnectDevice) { TEST_F(BluetoothChromeOSTest, DisconnectUnconnectedDevice) { GetAdapter(); - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kPairedDeviceAddress); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); ASSERT_TRUE(device != nullptr); ASSERT_TRUE(device->IsPaired()); ASSERT_FALSE(device->IsConnected()); @@ -2630,18 +2642,20 @@ TEST_F(BluetoothChromeOSTest, PairTrustedDevice) { GetAdapter(); fake_bluetooth_device_client_->CreateDevice( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), - dbus::ObjectPath( - FakeBluetoothDeviceClient::kConnectedTrustedNotPairedDevicePath)); - BluetoothDevice* device = adapter_->GetDevice( - FakeBluetoothDeviceClient::kConnectedTrustedNotPairedDeviceAddress); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient:: + kConnectedTrustedNotPairedDevicePath)); + BluetoothDevice* device = + adapter_->GetDevice(bluez::FakeBluetoothDeviceClient:: + kConnectedTrustedNotPairedDeviceAddress); ASSERT_TRUE(device != nullptr); // On the DBus level the device is trusted but not paired. But the current // implementation of |BluetoothDevice::IsPaired()| returns true in this case. - FakeBluetoothDeviceClient::Properties* properties = - fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath( - FakeBluetoothDeviceClient::kConnectedTrustedNotPairedDevicePath)); + bluez::FakeBluetoothDeviceClient::Properties* properties = + fake_bluetooth_device_client_->GetProperties( + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient:: + kConnectedTrustedNotPairedDevicePath)); EXPECT_FALSE(properties->paired.value()); EXPECT_TRUE(properties->trusted.value()); ASSERT_TRUE(device->IsPaired()); @@ -2667,7 +2681,7 @@ TEST_F(BluetoothChromeOSTest, PairTrustedDevice) { // Make sure the paired property has been set to true. properties = fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath( - FakeBluetoothDeviceClient::kConnectedTrustedNotPairedDevicePath)); + bluez::FakeBluetoothDeviceClient::kConnectedTrustedNotPairedDevicePath)); EXPECT_TRUE(properties->paired.value()); } @@ -2675,16 +2689,16 @@ TEST_F(BluetoothChromeOSTest, PairAlreadyPairedDevice) { GetAdapter(); fake_bluetooth_device_client_->CreateDevice( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), - dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath)); - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kPairedDeviceAddress); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kPairedDevicePath)); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); ASSERT_TRUE(device != nullptr); // On the DBus level a device can be trusted but not paired. - FakeBluetoothDeviceClient::Properties* properties = - fake_bluetooth_device_client_->GetProperties( - dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath)); + bluez::FakeBluetoothDeviceClient::Properties* properties = + fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath( + bluez::FakeBluetoothDeviceClient::kPairedDevicePath)); EXPECT_TRUE(properties->paired.value()); EXPECT_TRUE(properties->trusted.value()); ASSERT_TRUE(device->IsPaired()); @@ -2712,8 +2726,8 @@ TEST_F(BluetoothChromeOSTest, PairLegacyAutopair) { // The Legacy Autopair device requires no PIN or Passkey to pair because // the daemon provides 0000 to the device for us. - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kLegacyAutopairAddress); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kLegacyAutopairAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); @@ -2750,9 +2764,9 @@ TEST_F(BluetoothChromeOSTest, PairLegacyAutopair) { EXPECT_TRUE(device->IsConnectable()); // Make sure the trusted property has been set to true. - FakeBluetoothDeviceClient::Properties* properties = - fake_bluetooth_device_client_->GetProperties( - dbus::ObjectPath(FakeBluetoothDeviceClient::kLegacyAutopairPath)); + bluez::FakeBluetoothDeviceClient::Properties* properties = + fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath( + bluez::FakeBluetoothDeviceClient::kLegacyAutopairPath)); EXPECT_TRUE(properties->trusted.value()); } @@ -2763,8 +2777,8 @@ TEST_F(BluetoothChromeOSTest, PairDisplayPinCode) { DiscoverDevices(); // Requires that we display a randomly generated PIN on the screen. - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kDisplayPinCodeAddress); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kDisplayPinCodeAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); @@ -2803,9 +2817,9 @@ TEST_F(BluetoothChromeOSTest, PairDisplayPinCode) { EXPECT_TRUE(device->IsConnectable()); // Make sure the trusted property has been set to true. - FakeBluetoothDeviceClient::Properties* properties = - fake_bluetooth_device_client_->GetProperties( - dbus::ObjectPath(FakeBluetoothDeviceClient::kDisplayPinCodePath)); + bluez::FakeBluetoothDeviceClient::Properties* properties = + fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath( + bluez::FakeBluetoothDeviceClient::kDisplayPinCodePath)); EXPECT_TRUE(properties->trusted.value()); } @@ -2817,8 +2831,8 @@ TEST_F(BluetoothChromeOSTest, PairDisplayPasskey) { // Requires that we display a randomly generated Passkey on the screen, // and notifies us as it's typed in. - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kDisplayPasskeyAddress); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kDisplayPasskeyAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); @@ -2878,9 +2892,9 @@ TEST_F(BluetoothChromeOSTest, PairDisplayPasskey) { EXPECT_FALSE(device->IsConnectable()); // Make sure the trusted property has been set to true. - FakeBluetoothDeviceClient::Properties* properties = - fake_bluetooth_device_client_->GetProperties( - dbus::ObjectPath(FakeBluetoothDeviceClient::kDisplayPasskeyPath)); + bluez::FakeBluetoothDeviceClient::Properties* properties = + fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath( + bluez::FakeBluetoothDeviceClient::kDisplayPasskeyPath)); EXPECT_TRUE(properties->trusted.value()); } @@ -2891,8 +2905,8 @@ TEST_F(BluetoothChromeOSTest, PairRequestPinCode) { DiscoverDevices(); // Requires that the user enters a PIN for them. - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kRequestPinCodeAddress); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kRequestPinCodeAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); @@ -2932,9 +2946,9 @@ TEST_F(BluetoothChromeOSTest, PairRequestPinCode) { EXPECT_TRUE(device->IsConnectable()); // Make sure the trusted property has been set to true. - FakeBluetoothDeviceClient::Properties* properties = - fake_bluetooth_device_client_->GetProperties( - dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath)); + bluez::FakeBluetoothDeviceClient::Properties* properties = + fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath( + bluez::FakeBluetoothDeviceClient::kRequestPinCodePath)); EXPECT_TRUE(properties->trusted.value()); } @@ -2945,8 +2959,8 @@ TEST_F(BluetoothChromeOSTest, PairConfirmPasskey) { DiscoverDevices(); // Requests that we confirm a displayed passkey. - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kConfirmPasskeyAddress); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kConfirmPasskeyAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); @@ -2983,9 +2997,9 @@ TEST_F(BluetoothChromeOSTest, PairConfirmPasskey) { EXPECT_TRUE(device->IsConnectable()); // Make sure the trusted property has been set to true. - FakeBluetoothDeviceClient::Properties* properties = - fake_bluetooth_device_client_->GetProperties( - dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); + bluez::FakeBluetoothDeviceClient::Properties* properties = + fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath( + bluez::FakeBluetoothDeviceClient::kConfirmPasskeyPath)); EXPECT_TRUE(properties->trusted.value()); } @@ -2997,8 +3011,8 @@ TEST_F(BluetoothChromeOSTest, PairRequestPasskey) { // Requires that the user enters a Passkey, this would be some kind of // device that has a display, but doesn't use "just works" - maybe a car? - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kRequestPasskeyAddress); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kRequestPasskeyAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); @@ -3034,9 +3048,9 @@ TEST_F(BluetoothChromeOSTest, PairRequestPasskey) { EXPECT_TRUE(device->IsConnectable()); // Make sure the trusted property has been set to true. - FakeBluetoothDeviceClient::Properties* properties = - fake_bluetooth_device_client_->GetProperties( - dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath)); + bluez::FakeBluetoothDeviceClient::Properties* properties = + fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath( + bluez::FakeBluetoothDeviceClient::kRequestPasskeyPath)); EXPECT_TRUE(properties->trusted.value()); } @@ -3049,7 +3063,7 @@ TEST_F(BluetoothChromeOSTest, PairJustWorks) { // Uses just-works pairing, since this is an outgoing pairing, no delegate // interaction is required. BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kJustWorksAddress); + adapter_->GetDevice(bluez::FakeBluetoothDeviceClient::kJustWorksAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); @@ -3081,9 +3095,9 @@ TEST_F(BluetoothChromeOSTest, PairJustWorks) { EXPECT_TRUE(device->IsConnectable()); // Make sure the trusted property has been set to true. - FakeBluetoothDeviceClient::Properties* properties = + bluez::FakeBluetoothDeviceClient::Properties* properties = fake_bluetooth_device_client_->GetProperties( - dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath)); + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kJustWorksPath)); EXPECT_TRUE(properties->trusted.value()); } @@ -3091,10 +3105,10 @@ TEST_F(BluetoothChromeOSTest, PairUnpairableDeviceFails) { fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); - DiscoverDevice(FakeBluetoothDeviceClient::kUnconnectableDeviceAddress); + DiscoverDevice(bluez::FakeBluetoothDeviceClient::kUnconnectableDeviceAddress); - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kUnpairableDeviceAddress); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kUnpairableDeviceAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); @@ -3125,11 +3139,11 @@ TEST_F(BluetoothChromeOSTest, PairingFails) { fake_bluetooth_device_client_->SetSimulationIntervalMs(10); GetAdapter(); - DiscoverDevice(FakeBluetoothDeviceClient::kVanishingDeviceAddress); + DiscoverDevice(bluez::FakeBluetoothDeviceClient::kVanishingDeviceAddress); // The vanishing device times out during pairing - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kVanishingDeviceAddress); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kVanishingDeviceAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); @@ -3165,7 +3179,7 @@ TEST_F(BluetoothChromeOSTest, PairingFailsAtConnection) { // Everything seems to go according to plan with the unconnectable device; // it pairs, but then you can't make connections to it after. BluetoothDevice* device = adapter_->GetDevice( - FakeBluetoothDeviceClient::kUnconnectableDeviceAddress); + bluez::FakeBluetoothDeviceClient::kUnconnectableDeviceAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); @@ -3197,9 +3211,9 @@ TEST_F(BluetoothChromeOSTest, PairingFailsAtConnection) { // Make sure the trusted property has been set to true still (since pairing // worked). - FakeBluetoothDeviceClient::Properties* properties = + bluez::FakeBluetoothDeviceClient::Properties* properties = fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath( - FakeBluetoothDeviceClient::kUnconnectableDevicePath)); + bluez::FakeBluetoothDeviceClient::kUnconnectableDevicePath)); EXPECT_TRUE(properties->trusted.value()); } @@ -3210,8 +3224,8 @@ TEST_F(BluetoothChromeOSTest, PairingRejectedAtPinCode) { DiscoverDevices(); // Reject the pairing after we receive a request for the PIN code. - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kRequestPinCodeAddress); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kRequestPinCodeAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); @@ -3248,8 +3262,8 @@ TEST_F(BluetoothChromeOSTest, PairingCancelledAtPinCode) { DiscoverDevices(); // Cancel the pairing after we receive a request for the PIN code. - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kRequestPinCodeAddress); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kRequestPinCodeAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); @@ -3286,8 +3300,8 @@ TEST_F(BluetoothChromeOSTest, PairingRejectedAtPasskey) { DiscoverDevices(); // Reject the pairing after we receive a request for the passkey. - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kRequestPasskeyAddress); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kRequestPasskeyAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); @@ -3324,8 +3338,8 @@ TEST_F(BluetoothChromeOSTest, PairingCancelledAtPasskey) { DiscoverDevices(); // Cancel the pairing after we receive a request for the passkey. - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kRequestPasskeyAddress); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kRequestPasskeyAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); @@ -3362,8 +3376,8 @@ TEST_F(BluetoothChromeOSTest, PairingRejectedAtConfirmation) { DiscoverDevices(); // Reject the pairing after we receive a request for passkey confirmation. - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kConfirmPasskeyAddress); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kConfirmPasskeyAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); @@ -3400,8 +3414,8 @@ TEST_F(BluetoothChromeOSTest, PairingCancelledAtConfirmation) { DiscoverDevices(); // Cancel the pairing after we receive a request for the passkey. - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kConfirmPasskeyAddress); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kConfirmPasskeyAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); @@ -3438,8 +3452,8 @@ TEST_F(BluetoothChromeOSTest, PairingCancelledInFlight) { DiscoverDevices(); // Cancel the pairing while we're waiting for the remote host. - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kLegacyAutopairAddress); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kLegacyAutopairAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); @@ -3480,19 +3494,19 @@ TEST_F(BluetoothChromeOSTest, IncomingPairRequestPinCode) { // Requires that we provide a PIN code. fake_bluetooth_device_client_->CreateDevice( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), - dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath)); - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kRequestPinCodeAddress); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kRequestPinCodePath)); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kRequestPinCodeAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); fake_bluetooth_device_client_->SimulatePairing( - dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath), true, - GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, - base::Unretained(this))); + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kRequestPinCodePath), + true, GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, + base::Unretained(this))); EXPECT_EQ(1, pairing_delegate.call_count_); EXPECT_EQ(1, pairing_delegate.request_pincode_count_); @@ -3511,9 +3525,9 @@ TEST_F(BluetoothChromeOSTest, IncomingPairRequestPinCode) { EXPECT_TRUE(device->IsPaired()); // Make sure the trusted property has been set to true. - FakeBluetoothDeviceClient::Properties* properties = - fake_bluetooth_device_client_->GetProperties( - dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath)); + bluez::FakeBluetoothDeviceClient::Properties* properties = + fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath( + bluez::FakeBluetoothDeviceClient::kRequestPinCodePath)); ASSERT_TRUE(properties->trusted.value()); // No pairing context should remain on the device. @@ -3534,19 +3548,19 @@ TEST_F(BluetoothChromeOSTest, IncomingPairConfirmPasskey) { // Requests that we confirm a displayed passkey. fake_bluetooth_device_client_->CreateDevice( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), - dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kConfirmPasskeyAddress); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kConfirmPasskeyPath)); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kConfirmPasskeyAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); fake_bluetooth_device_client_->SimulatePairing( - dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath), true, - GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, - base::Unretained(this))); + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kConfirmPasskeyPath), + true, GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, + base::Unretained(this))); EXPECT_EQ(1, pairing_delegate.call_count_); EXPECT_EQ(1, pairing_delegate.confirm_passkey_count_); @@ -3566,9 +3580,9 @@ TEST_F(BluetoothChromeOSTest, IncomingPairConfirmPasskey) { EXPECT_TRUE(device->IsPaired()); // Make sure the trusted property has been set to true. - FakeBluetoothDeviceClient::Properties* properties = - fake_bluetooth_device_client_->GetProperties( - dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); + bluez::FakeBluetoothDeviceClient::Properties* properties = + fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath( + bluez::FakeBluetoothDeviceClient::kConfirmPasskeyPath)); ASSERT_TRUE(properties->trusted.value()); // No pairing context should remain on the device. @@ -3589,19 +3603,19 @@ TEST_F(BluetoothChromeOSTest, IncomingPairRequestPasskey) { // Requests that we provide a Passkey. fake_bluetooth_device_client_->CreateDevice( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), - dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath)); - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kRequestPasskeyAddress); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kRequestPasskeyPath)); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kRequestPasskeyAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); fake_bluetooth_device_client_->SimulatePairing( - dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath), true, - GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, - base::Unretained(this))); + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kRequestPasskeyPath), + true, GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, + base::Unretained(this))); EXPECT_EQ(1, pairing_delegate.call_count_); EXPECT_EQ(1, pairing_delegate.request_passkey_count_); @@ -3620,9 +3634,9 @@ TEST_F(BluetoothChromeOSTest, IncomingPairRequestPasskey) { EXPECT_TRUE(device->IsPaired()); // Make sure the trusted property has been set to true. - FakeBluetoothDeviceClient::Properties* properties = - fake_bluetooth_device_client_->GetProperties( - dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath)); + bluez::FakeBluetoothDeviceClient::Properties* properties = + fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath( + bluez::FakeBluetoothDeviceClient::kRequestPasskeyPath)); ASSERT_TRUE(properties->trusted.value()); // No pairing context should remain on the device. @@ -3644,17 +3658,17 @@ TEST_F(BluetoothChromeOSTest, IncomingPairJustWorks) { // Uses just-works pairing so, sinec this an incoming pairing, require // authorization from the user. fake_bluetooth_device_client_->CreateDevice( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), - dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath)); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kJustWorksPath)); BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kJustWorksAddress); + adapter_->GetDevice(bluez::FakeBluetoothDeviceClient::kJustWorksAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); fake_bluetooth_device_client_->SimulatePairing( - dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath), true, + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kJustWorksPath), true, GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, base::Unretained(this))); @@ -3675,9 +3689,9 @@ TEST_F(BluetoothChromeOSTest, IncomingPairJustWorks) { EXPECT_TRUE(device->IsPaired()); // Make sure the trusted property has been set to true. - FakeBluetoothDeviceClient::Properties* properties = + bluez::FakeBluetoothDeviceClient::Properties* properties = fake_bluetooth_device_client_->GetProperties( - dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath)); + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kJustWorksPath)); ASSERT_TRUE(properties->trusted.value()); // No pairing context should remain on the device. @@ -3694,19 +3708,19 @@ TEST_F(BluetoothChromeOSTest, IncomingPairRequestPinCodeWithoutDelegate) { // Requires that we provide a PIN Code, without a pairing delegate, // that will be rejected. fake_bluetooth_device_client_->CreateDevice( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), - dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath)); - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kRequestPinCodeAddress); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kRequestPinCodePath)); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kRequestPinCodeAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); fake_bluetooth_device_client_->SimulatePairing( - dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath), true, - GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, - base::Unretained(this))); + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kRequestPinCodePath), + true, GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, + base::Unretained(this))); message_loop_.Run(); @@ -3733,19 +3747,19 @@ TEST_F(BluetoothChromeOSTest, IncomingPairConfirmPasskeyWithoutDelegate) { // Requests that we confirm a displayed passkey, without a pairing delegate, // that will be rejected. fake_bluetooth_device_client_->CreateDevice( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), - dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kConfirmPasskeyAddress); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kConfirmPasskeyPath)); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kConfirmPasskeyAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); fake_bluetooth_device_client_->SimulatePairing( - dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath), true, - GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, - base::Unretained(this))); + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kConfirmPasskeyPath), + true, GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, + base::Unretained(this))); message_loop_.Run(); @@ -3772,19 +3786,19 @@ TEST_F(BluetoothChromeOSTest, IncomingPairRequestPasskeyWithoutDelegate) { // Requests that we provide a displayed passkey, without a pairing delegate, // that will be rejected. fake_bluetooth_device_client_->CreateDevice( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), - dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath)); - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kRequestPasskeyAddress); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kRequestPasskeyPath)); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kRequestPasskeyAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); fake_bluetooth_device_client_->SimulatePairing( - dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath), true, - GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, - base::Unretained(this))); + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kRequestPasskeyPath), + true, GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, + base::Unretained(this))); message_loop_.Run(); @@ -3811,17 +3825,17 @@ TEST_F(BluetoothChromeOSTest, IncomingPairJustWorksWithoutDelegate) { // Uses just-works pairing and thus requires authorization for incoming // pairings, without a pairing delegate, that will be rejected. fake_bluetooth_device_client_->CreateDevice( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), - dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath)); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kJustWorksPath)); BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kJustWorksAddress); + adapter_->GetDevice(bluez::FakeBluetoothDeviceClient::kJustWorksAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); fake_bluetooth_device_client_->SimulatePairing( - dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath), true, + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kJustWorksPath), true, GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, base::Unretained(this))); @@ -3854,19 +3868,19 @@ TEST_F(BluetoothChromeOSTest, RemovePairingDelegateDuringPairing) { // Requests that we provide a Passkey. fake_bluetooth_device_client_->CreateDevice( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), - dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath)); - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kRequestPasskeyAddress); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kRequestPasskeyPath)); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kRequestPasskeyAddress); ASSERT_TRUE(device != nullptr); ASSERT_FALSE(device->IsPaired()); TestBluetoothAdapterObserver observer(adapter_); fake_bluetooth_device_client_->SimulatePairing( - dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath), true, - GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, - base::Unretained(this))); + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kRequestPasskeyPath), + true, GetCallback(), base::Bind(&BluetoothChromeOSTest::DBusErrorCallback, + base::Unretained(this))); EXPECT_EQ(1, pairing_delegate.call_count_); EXPECT_EQ(1, pairing_delegate.request_passkey_count_); @@ -3897,11 +3911,11 @@ TEST_F(BluetoothChromeOSTest, DeviceId) { // Use the built-in paired device for this test, grab its Properties // structure so we can adjust the underlying modalias property. - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kPairedDeviceAddress); - FakeBluetoothDeviceClient::Properties* properties = - fake_bluetooth_device_client_->GetProperties( - dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath)); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); + bluez::FakeBluetoothDeviceClient::Properties* properties = + fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath( + bluez::FakeBluetoothDeviceClient::kPairedDevicePath)); ASSERT_TRUE(device != nullptr); ASSERT_TRUE(properties != nullptr); @@ -3949,8 +3963,8 @@ TEST_F(BluetoothChromeOSTest, DeviceId) { TEST_F(BluetoothChromeOSTest, GetConnectionInfoForDisconnectedDevice) { GetAdapter(); - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kPairedDeviceAddress); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); // Calling GetConnectionInfo for an unconnected device should return a result // in which all fields are filled with BluetoothDevice::kUnknownPower. @@ -3965,8 +3979,8 @@ TEST_F(BluetoothChromeOSTest, GetConnectionInfoForDisconnectedDevice) { TEST_F(BluetoothChromeOSTest, GetConnectionInfoForConnectedDevice) { GetAdapter(); - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kPairedDeviceAddress); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); device->Connect(nullptr, GetCallback(), base::Bind(&BluetoothChromeOSTest::ConnectErrorCallback, @@ -4011,8 +4025,9 @@ TEST_F(BluetoothChromeOSTest, Shutdown) { EXPECT_TRUE(adapter_->IsDiscoverable()); EXPECT_TRUE(adapter_->IsDiscovering()); EXPECT_EQ(2U, adapter_->GetDevices().size()); - EXPECT_NE(nullptr, adapter_->GetDevice( - FakeBluetoothDeviceClient::kPairedDeviceAddress)); + EXPECT_NE(nullptr, + adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress)); EXPECT_NE(dbus::ObjectPath(""), static_cast<BluetoothAdapterChromeOS*>( adapter_.get())->object_path()); @@ -4089,7 +4104,7 @@ TEST_F(BluetoothChromeOSTest, Shutdown) { FakeBluetoothProfileServiceProviderDelegate profile_delegate; adapter_chrome_os->UseProfile( BluetoothUUID(), dbus::ObjectPath(""), - BluetoothProfileManagerClient::Options(), &profile_delegate, + bluez::BluetoothProfileManagerClient::Options(), &profile_delegate, base::Bind(&BluetoothChromeOSTest::ProfileRegisteredCallback, base::Unretained(this)), base::Bind(&BluetoothChromeOSTest::ErrorCompletionCallback, @@ -4109,7 +4124,8 @@ TEST_F(BluetoothChromeOSTest, Shutdown) { adapter_chrome_os->DeviceRemoved(dbus::ObjectPath("")); adapter_chrome_os->DevicePropertyChanged(dbus::ObjectPath(""), ""); adapter_chrome_os->InputPropertyChanged(dbus::ObjectPath(""), ""); - // BluetoothAgentServiceProvider::Delegate omitted, dbus will be shutdown, + // bluez::BluetoothAgentServiceProvider::Delegate omitted, dbus will be + // shutdown, // with the exception of Released. adapter_chrome_os->Released(); @@ -4166,7 +4182,7 @@ TEST_F(BluetoothChromeOSTest, Shutdown) { // UseProfile to be set first, do so again here just before calling them. adapter_chrome_os->UseProfile( BluetoothUUID(), dbus::ObjectPath(""), - BluetoothProfileManagerClient::Options(), &profile_delegate, + bluez::BluetoothProfileManagerClient::Options(), &profile_delegate, base::Bind(&BluetoothChromeOSTest::ProfileRegisteredCallback, base::Unretained(this)), base::Bind(&BluetoothChromeOSTest::ErrorCompletionCallback, @@ -4201,8 +4217,9 @@ TEST_F(BluetoothChromeOSTest, Shutdown) { EXPECT_EQ(1, error_callback_count_--) << "StartDiscoverySession error"; EXPECT_EQ(0U, adapter_->GetDevices().size()); - EXPECT_EQ(nullptr, adapter_->GetDevice( - FakeBluetoothDeviceClient::kPairedDeviceAddress)); + EXPECT_EQ(nullptr, + adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress)); TestPairingDelegate pairing_delegate2; adapter_->AddPairingDelegate( &pairing_delegate2, BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH); diff --git a/device/bluetooth/bluetooth_device_chromeos.cc b/device/bluetooth/bluetooth_device_chromeos.cc index 898fd51..ea4a168 100644 --- a/device/bluetooth/bluetooth_device_chromeos.cc +++ b/device/bluetooth/bluetooth_device_chromeos.cc @@ -11,11 +11,6 @@ #include "base/metrics/histogram.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" -#include "chromeos/dbus/bluetooth_adapter_client.h" -#include "chromeos/dbus/bluetooth_device_client.h" -#include "chromeos/dbus/bluetooth_gatt_service_client.h" -#include "chromeos/dbus/bluetooth_input_client.h" -#include "chromeos/dbus/dbus_thread_manager.h" #include "dbus/bus.h" #include "device/bluetooth/bluetooth_adapter_chromeos.h" #include "device/bluetooth/bluetooth_gatt_connection_chromeos.h" @@ -25,6 +20,11 @@ #include "device/bluetooth/bluetooth_socket_chromeos.h" #include "device/bluetooth/bluetooth_socket_thread.h" #include "device/bluetooth/bluetooth_uuid.h" +#include "device/bluetooth/dbus/bluetooth_adapter_client.h" +#include "device/bluetooth/dbus/bluetooth_device_client.h" +#include "device/bluetooth/dbus/bluetooth_gatt_service_client.h" +#include "device/bluetooth/dbus/bluetooth_input_client.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" #include "third_party/cros_system_api/dbus/service_constants.h" using device::BluetoothDevice; @@ -55,10 +55,9 @@ void ParseModalias(const dbus::ObjectPath& object_path, uint16* vendor_id, uint16* product_id, uint16* device_id) { - chromeos::BluetoothDeviceClient::Properties* properties = - chromeos::DBusThreadManager::Get() - ->GetBluetoothDeviceClient() - ->GetProperties(object_path); + bluez::BluetoothDeviceClient::Properties* properties = + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( + object_path); DCHECK(properties); std::string modalias = properties->modalias.value(); @@ -153,11 +152,14 @@ BluetoothDeviceChromeOS::BluetoothDeviceChromeOS( ui_task_runner_(ui_task_runner), socket_thread_(socket_thread), weak_ptr_factory_(this) { - DBusThreadManager::Get()->GetBluetoothGattServiceClient()->AddObserver(this); + bluez::BluezDBusManager::Get()->GetBluetoothGattServiceClient()->AddObserver( + this); // Add all known GATT services. const std::vector<dbus::ObjectPath> gatt_services = - DBusThreadManager::Get()->GetBluetoothGattServiceClient()->GetServices(); + bluez::BluezDBusManager::Get() + ->GetBluetoothGattServiceClient() + ->GetServices(); for (std::vector<dbus::ObjectPath>::const_iterator it = gatt_services.begin(); it != gatt_services.end(); ++it) { GattServiceAdded(*it); @@ -165,8 +167,9 @@ BluetoothDeviceChromeOS::BluetoothDeviceChromeOS( } BluetoothDeviceChromeOS::~BluetoothDeviceChromeOS() { - DBusThreadManager::Get()->GetBluetoothGattServiceClient()->RemoveObserver( - this); + bluez::BluezDBusManager::Get() + ->GetBluetoothGattServiceClient() + ->RemoveObserver(this); // Copy the GATT services list here and clear the original so that when we // send GattServiceRemoved(), GetGattServices() returns no services. @@ -180,8 +183,8 @@ BluetoothDeviceChromeOS::~BluetoothDeviceChromeOS() { } uint32 BluetoothDeviceChromeOS::GetBluetoothClass() const { - BluetoothDeviceClient::Properties* properties = - DBusThreadManager::Get()->GetBluetoothDeviceClient()->GetProperties( + bluez::BluetoothDeviceClient::Properties* properties = + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( object_path_); DCHECK(properties); @@ -189,8 +192,8 @@ uint32 BluetoothDeviceChromeOS::GetBluetoothClass() const { } std::string BluetoothDeviceChromeOS::GetDeviceName() const { - BluetoothDeviceClient::Properties* properties = - DBusThreadManager::Get()->GetBluetoothDeviceClient()->GetProperties( + bluez::BluetoothDeviceClient::Properties* properties = + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( object_path_); DCHECK(properties); @@ -210,8 +213,8 @@ void BluetoothDeviceChromeOS::DisconnectGatt() { } std::string BluetoothDeviceChromeOS::GetAddress() const { - BluetoothDeviceClient::Properties* properties = - DBusThreadManager::Get()->GetBluetoothDeviceClient()->GetProperties( + bluez::BluetoothDeviceClient::Properties* properties = + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( object_path_); DCHECK(properties); @@ -244,8 +247,8 @@ uint16 BluetoothDeviceChromeOS::GetDeviceID() const { } bool BluetoothDeviceChromeOS::IsPaired() const { - BluetoothDeviceClient::Properties* properties = - DBusThreadManager::Get()->GetBluetoothDeviceClient()->GetProperties( + bluez::BluetoothDeviceClient::Properties* properties = + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( object_path_); DCHECK(properties); @@ -256,8 +259,8 @@ bool BluetoothDeviceChromeOS::IsPaired() const { } bool BluetoothDeviceChromeOS::IsConnected() const { - BluetoothDeviceClient::Properties* properties = - DBusThreadManager::Get()->GetBluetoothDeviceClient()->GetProperties( + bluez::BluetoothDeviceClient::Properties* properties = + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( object_path_); DCHECK(properties); @@ -270,8 +273,8 @@ bool BluetoothDeviceChromeOS::IsGattConnected() const { } bool BluetoothDeviceChromeOS::IsConnectable() const { - BluetoothInputClient::Properties* input_properties = - DBusThreadManager::Get()->GetBluetoothInputClient()->GetProperties( + bluez::BluetoothInputClient::Properties* input_properties = + bluez::BluezDBusManager::Get()->GetBluetoothInputClient()->GetProperties( object_path_); // GetProperties returns NULL when the device does not implement the given // interface. Non HID devices are normally connectable. @@ -286,8 +289,8 @@ bool BluetoothDeviceChromeOS::IsConnecting() const { } BluetoothDeviceChromeOS::UUIDList BluetoothDeviceChromeOS::GetUUIDs() const { - BluetoothDeviceClient::Properties* properties = - DBusThreadManager::Get()->GetBluetoothDeviceClient()->GetProperties( + bluez::BluetoothDeviceClient::Properties* properties = + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( object_path_); DCHECK(properties); @@ -303,8 +306,8 @@ BluetoothDeviceChromeOS::UUIDList BluetoothDeviceChromeOS::GetUUIDs() const { } int16 BluetoothDeviceChromeOS::GetInquiryRSSI() const { - BluetoothDeviceClient::Properties* properties = - DBusThreadManager::Get()->GetBluetoothDeviceClient()->GetProperties( + bluez::BluetoothDeviceClient::Properties* properties = + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( object_path_); DCHECK(properties); @@ -315,8 +318,8 @@ int16 BluetoothDeviceChromeOS::GetInquiryRSSI() const { } int16 BluetoothDeviceChromeOS::GetInquiryTxPower() const { - BluetoothDeviceClient::Properties* properties = - DBusThreadManager::Get()->GetBluetoothDeviceClient()->GetProperties( + bluez::BluetoothDeviceClient::Properties* properties = + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( object_path_); DCHECK(properties); @@ -342,7 +345,7 @@ void BluetoothDeviceChromeOS::GetConnectionInfo( const ConnectionInfoCallback& callback) { // DBus method call should gracefully return an error if the device is not // currently connected. - DBusThreadManager::Get()->GetBluetoothDeviceClient()->GetConnInfo( + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetConnInfo( object_path_, base::Bind(&BluetoothDeviceChromeOS::OnGetConnInfo, weak_ptr_factory_.GetWeakPtr(), callback), base::Bind(&BluetoothDeviceChromeOS::OnGetConnInfoError, @@ -366,7 +369,7 @@ void BluetoothDeviceChromeOS::Connect( // Initiate high-security connection with pairing. BeginPairing(pairing_delegate); - DBusThreadManager::Get()->GetBluetoothDeviceClient()->Pair( + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->Pair( object_path_, base::Bind(&BluetoothDeviceChromeOS::OnPairDuringConnect, weak_ptr_factory_.GetWeakPtr(), callback, error_callback), @@ -382,7 +385,7 @@ void BluetoothDeviceChromeOS::Pair( DCHECK(pairing_delegate); BeginPairing(pairing_delegate); - DBusThreadManager::Get()->GetBluetoothDeviceClient()->Pair( + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->Pair( object_path_, base::Bind(&BluetoothDeviceChromeOS::OnPair, weak_ptr_factory_.GetWeakPtr(), callback), base::Bind(&BluetoothDeviceChromeOS::OnPairError, @@ -429,7 +432,7 @@ void BluetoothDeviceChromeOS::CancelPairing() { if (!canceled) { VLOG(1) << object_path_.value() << ": No pairing context or callback. " << "Sending explicit cancel"; - DBusThreadManager::Get()->GetBluetoothDeviceClient()->CancelPairing( + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->CancelPairing( object_path_, base::Bind(&base::DoNothing), base::Bind(&BluetoothDeviceChromeOS::OnCancelPairingError, weak_ptr_factory_.GetWeakPtr())); @@ -445,7 +448,7 @@ void BluetoothDeviceChromeOS::CancelPairing() { void BluetoothDeviceChromeOS::Disconnect(const base::Closure& callback, const ErrorCallback& error_callback) { VLOG(1) << object_path_.value() << ": Disconnecting"; - DBusThreadManager::Get()->GetBluetoothDeviceClient()->Disconnect( + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->Disconnect( object_path_, base::Bind(&BluetoothDeviceChromeOS::OnDisconnect, weak_ptr_factory_.GetWeakPtr(), callback), base::Bind(&BluetoothDeviceChromeOS::OnDisconnectError, @@ -454,7 +457,7 @@ void BluetoothDeviceChromeOS::Disconnect(const base::Closure& callback, void BluetoothDeviceChromeOS::Forget(const ErrorCallback& error_callback) { VLOG(1) << object_path_.value() << ": Removing device"; - DBusThreadManager::Get()->GetBluetoothAdapterClient()->RemoveDevice( + bluez::BluezDBusManager::Get()->GetBluetoothAdapterClient()->RemoveDevice( adapter()->object_path(), object_path_, base::Bind(&base::DoNothing), base::Bind(&BluetoothDeviceChromeOS::OnForgetError, weak_ptr_factory_.GetWeakPtr(), error_callback)); @@ -533,9 +536,10 @@ void BluetoothDeviceChromeOS::GattServiceAdded( return; } - BluetoothGattServiceClient::Properties* properties = - DBusThreadManager::Get()->GetBluetoothGattServiceClient()->GetProperties( - object_path); + bluez::BluetoothGattServiceClient::Properties* properties = + bluez::BluezDBusManager::Get() + ->GetBluetoothGattServiceClient() + ->GetProperties(object_path); DCHECK(properties); if (properties->device.value() != object_path_) { VLOG(2) << "Remote GATT service does not belong to this device."; @@ -603,7 +607,7 @@ void BluetoothDeviceChromeOS::ConnectInternal( const base::Closure& callback, const ConnectErrorCallback& error_callback) { VLOG(1) << object_path_.value() << ": Connecting"; - DBusThreadManager::Get()->GetBluetoothDeviceClient()->Connect( + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->Connect( object_path_, base::Bind(&BluetoothDeviceChromeOS::OnConnect, weak_ptr_factory_.GetWeakPtr(), after_pairing, callback), @@ -731,7 +735,7 @@ void BluetoothDeviceChromeOS::SetTrusted() { // 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 // we get the D-Bus signal about the earlier change. - DBusThreadManager::Get() + bluez::BluezDBusManager::Get() ->GetBluetoothDeviceClient() ->GetProperties(object_path_) ->trusted.Set(true, base::Bind(&BluetoothDeviceChromeOS::OnSetTrusted, diff --git a/device/bluetooth/bluetooth_device_chromeos.h b/device/bluetooth/bluetooth_device_chromeos.h index 7f66a43..544fdaf 100644 --- a/device/bluetooth/bluetooth_device_chromeos.h +++ b/device/bluetooth/bluetooth_device_chromeos.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_CHROMEOS_H_ +#define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H_ #include <string> @@ -11,11 +11,11 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/sequenced_task_runner.h" -#include "chromeos/dbus/bluetooth_device_client.h" -#include "chromeos/dbus/bluetooth_gatt_service_client.h" #include "dbus/object_path.h" #include "device/bluetooth/bluetooth_device.h" #include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluetooth_device_client.h" +#include "device/bluetooth/dbus/bluetooth_gatt_service_client.h" namespace device { class BluetoothSocketThread; @@ -35,7 +35,7 @@ class BluetoothPairingChromeOS; // thread. class DEVICE_BLUETOOTH_EXPORT BluetoothDeviceChromeOS : public device::BluetoothDevice, - public BluetoothGattServiceClient::Observer { + public bluez::BluetoothGattServiceClient::Observer { public: // BluetoothDevice override uint32 GetBluetoothClass() const override; @@ -118,7 +118,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothDeviceChromeOS scoped_refptr<device::BluetoothSocketThread> socket_thread); ~BluetoothDeviceChromeOS() override; - // BluetoothGattServiceClient::Observer overrides. + // bluez::BluetoothGattServiceClient::Observer overrides. void GattServiceAdded(const dbus::ObjectPath& object_path) override; void GattServiceRemoved(const dbus::ObjectPath& object_path) override; @@ -215,4 +215,4 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothDeviceChromeOS } // namespace chromeos -#endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H +#endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H_ diff --git a/device/bluetooth/bluetooth_gatt_chromeos_unittest.cc b/device/bluetooth/bluetooth_gatt_chromeos_unittest.cc index 5cf067c..cf9e441 100644 --- a/device/bluetooth/bluetooth_gatt_chromeos_unittest.cc +++ b/device/bluetooth/bluetooth_gatt_chromeos_unittest.cc @@ -5,14 +5,6 @@ #include "base/memory/scoped_vector.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_adapter_client.h" -#include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" -#include "chromeos/dbus/fake_bluetooth_device_client.h" -#include "chromeos/dbus/fake_bluetooth_gatt_characteristic_client.h" -#include "chromeos/dbus/fake_bluetooth_gatt_descriptor_client.h" -#include "chromeos/dbus/fake_bluetooth_gatt_service_client.h" -#include "chromeos/dbus/fake_bluetooth_input_client.h" #include "dbus/object_path.h" #include "device/bluetooth/bluetooth_adapter.h" #include "device/bluetooth/bluetooth_adapter_factory.h" @@ -23,6 +15,14 @@ #include "device/bluetooth/bluetooth_gatt_notify_session.h" #include "device/bluetooth/bluetooth_gatt_service.h" #include "device/bluetooth/bluetooth_uuid.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" +#include "device/bluetooth/dbus/fake_bluetooth_device_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_service_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_input_client.h" #include "device/bluetooth/test/test_bluetooth_adapter_observer.h" #include "testing/gtest/include/gtest/gtest.h" @@ -41,11 +41,11 @@ namespace chromeos { namespace { const BluetoothUUID kHeartRateMeasurementUUID( - FakeBluetoothGattCharacteristicClient::kHeartRateMeasurementUUID); + bluez::FakeBluetoothGattCharacteristicClient::kHeartRateMeasurementUUID); const BluetoothUUID kBodySensorLocationUUID( - FakeBluetoothGattCharacteristicClient::kBodySensorLocationUUID); + bluez::FakeBluetoothGattCharacteristicClient::kBodySensorLocationUUID); const BluetoothUUID kHeartRateControlPointUUID( - FakeBluetoothGattCharacteristicClient::kHeartRateControlPointUUID); + bluez::FakeBluetoothGattCharacteristicClient::kHeartRateControlPointUUID); // Compares GATT characteristic/descriptor values. Returns true, if the values // are equal. @@ -70,32 +70,36 @@ class BluetoothGattChromeOSTest : public testing::Test { } void SetUp() override { - scoped_ptr<DBusThreadManagerSetter> dbus_setter = - chromeos::DBusThreadManager::GetSetterForTesting(); - fake_bluetooth_device_client_ = new FakeBluetoothDeviceClient; - fake_bluetooth_gatt_service_client_ = new FakeBluetoothGattServiceClient; + scoped_ptr<bluez::BluezDBusManagerSetter> dbus_setter = + bluez::BluezDBusManager::GetSetterForTesting(); + fake_bluetooth_device_client_ = new bluez::FakeBluetoothDeviceClient; + fake_bluetooth_gatt_service_client_ = + new bluez::FakeBluetoothGattServiceClient; fake_bluetooth_gatt_characteristic_client_ = - new FakeBluetoothGattCharacteristicClient; + new bluez::FakeBluetoothGattCharacteristicClient; fake_bluetooth_gatt_descriptor_client_ = - new FakeBluetoothGattDescriptorClient; + new bluez::FakeBluetoothGattDescriptorClient; dbus_setter->SetBluetoothDeviceClient( - scoped_ptr<BluetoothDeviceClient>(fake_bluetooth_device_client_)); + scoped_ptr<bluez::BluetoothDeviceClient>( + fake_bluetooth_device_client_)); dbus_setter->SetBluetoothGattServiceClient( - scoped_ptr<BluetoothGattServiceClient>( + scoped_ptr<bluez::BluetoothGattServiceClient>( fake_bluetooth_gatt_service_client_)); dbus_setter->SetBluetoothGattCharacteristicClient( - scoped_ptr<BluetoothGattCharacteristicClient>( + scoped_ptr<bluez::BluetoothGattCharacteristicClient>( fake_bluetooth_gatt_characteristic_client_)); dbus_setter->SetBluetoothGattDescriptorClient( - scoped_ptr<BluetoothGattDescriptorClient>( + scoped_ptr<bluez::BluetoothGattDescriptorClient>( fake_bluetooth_gatt_descriptor_client_)); dbus_setter->SetBluetoothAdapterClient( - scoped_ptr<BluetoothAdapterClient>(new FakeBluetoothAdapterClient)); + scoped_ptr<bluez::BluetoothAdapterClient>( + new bluez::FakeBluetoothAdapterClient)); dbus_setter->SetBluetoothInputClient( - scoped_ptr<BluetoothInputClient>(new FakeBluetoothInputClient)); + scoped_ptr<bluez::BluetoothInputClient>( + new bluez::FakeBluetoothInputClient)); dbus_setter->SetBluetoothAgentManagerClient( - scoped_ptr<BluetoothAgentManagerClient>( - new FakeBluetoothAgentManagerClient)); + scoped_ptr<bluez::BluetoothAgentManagerClient>( + new bluez::FakeBluetoothAgentManagerClient)); GetAdapter(); @@ -110,7 +114,7 @@ class BluetoothGattChromeOSTest : public testing::Test { adapter_ = NULL; update_sessions_.clear(); gatt_conn_.reset(); - DBusThreadManager::Shutdown(); + bluez::BluezDBusManager::Shutdown(); } void GetAdapter() { @@ -173,11 +177,12 @@ class BluetoothGattChromeOSTest : public testing::Test { base::MessageLoop message_loop_; - FakeBluetoothDeviceClient* fake_bluetooth_device_client_; - FakeBluetoothGattServiceClient* fake_bluetooth_gatt_service_client_; - FakeBluetoothGattCharacteristicClient* + bluez::FakeBluetoothDeviceClient* fake_bluetooth_device_client_; + bluez::FakeBluetoothGattServiceClient* fake_bluetooth_gatt_service_client_; + bluez::FakeBluetoothGattCharacteristicClient* fake_bluetooth_gatt_characteristic_client_; - FakeBluetoothGattDescriptorClient* fake_bluetooth_gatt_descriptor_client_; + bluez::FakeBluetoothGattDescriptorClient* + fake_bluetooth_gatt_descriptor_client_; scoped_ptr<device::BluetoothGattConnection> gatt_conn_; ScopedVector<BluetoothGattNotifySession> update_sessions_; scoped_refptr<BluetoothAdapter> adapter_; @@ -190,10 +195,10 @@ class BluetoothGattChromeOSTest : public testing::Test { TEST_F(BluetoothGattChromeOSTest, GattConnection) { fake_bluetooth_device_client_->CreateDevice( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), - dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath)); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kLowEnergyAddress); + adapter_->GetDevice(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress); ASSERT_TRUE(device); ASSERT_FALSE(device->IsConnected()); ASSERT_FALSE(gatt_conn_.get()); @@ -211,7 +216,7 @@ TEST_F(BluetoothGattChromeOSTest, GattConnection) { EXPECT_TRUE(device->IsConnected()); ASSERT_TRUE(gatt_conn_.get()); EXPECT_TRUE(gatt_conn_->IsConnected()); - EXPECT_EQ(FakeBluetoothDeviceClient::kLowEnergyAddress, + EXPECT_EQ(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress, gatt_conn_->GetDeviceAddress()); gatt_conn_->Disconnect(); @@ -253,8 +258,8 @@ TEST_F(BluetoothGattChromeOSTest, GattConnection) { EXPECT_TRUE(gatt_conn_->IsConnected()); fake_bluetooth_device_client_->RemoveDevice( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), - dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath)); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); ASSERT_TRUE(gatt_conn_.get()); EXPECT_FALSE(gatt_conn_->IsConnected()); } @@ -263,10 +268,10 @@ TEST_F(BluetoothGattChromeOSTest, 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( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), - dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath)); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kLowEnergyAddress); + adapter_->GetDevice(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress); ASSERT_TRUE(device); TestBluetoothAdapterObserver observer(adapter_); @@ -279,14 +284,14 @@ TEST_F(BluetoothGattChromeOSTest, GattServiceAddedAndRemoved) { // Expose the fake Heart Rate Service. fake_bluetooth_gatt_service_client_->ExposeHeartRateService( - dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath)); + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); EXPECT_EQ(1, observer.gatt_service_added_count()); EXPECT_EQ(0, observer.gatt_service_removed_count()); EXPECT_FALSE(observer.last_gatt_service_id().empty()); EXPECT_EQ(1U, device->GetGattServices().size()); - EXPECT_EQ( - BluetoothUUID(FakeBluetoothGattServiceClient::kHeartRateServiceUUID), - observer.last_gatt_service_uuid()); + EXPECT_EQ(BluetoothUUID( + bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID), + observer.last_gatt_service_uuid()); BluetoothGattService* service = device->GetGattService(observer.last_gatt_service_id()); @@ -306,9 +311,9 @@ TEST_F(BluetoothGattChromeOSTest, GattServiceAddedAndRemoved) { EXPECT_EQ(1, observer.gatt_service_removed_count()); EXPECT_FALSE(observer.last_gatt_service_id().empty()); EXPECT_TRUE(device->GetGattServices().empty()); - EXPECT_EQ( - BluetoothUUID(FakeBluetoothGattServiceClient::kHeartRateServiceUUID), - observer.last_gatt_service_uuid()); + EXPECT_EQ(BluetoothUUID( + bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID), + observer.last_gatt_service_uuid()); EXPECT_EQ(NULL, device->GetGattService(observer.last_gatt_service_id())); @@ -316,14 +321,14 @@ TEST_F(BluetoothGattChromeOSTest, GattServiceAddedAndRemoved) { observer.last_gatt_service_uuid() = BluetoothUUID(); observer.last_gatt_service_id().clear(); fake_bluetooth_gatt_service_client_->ExposeHeartRateService( - dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath)); + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); EXPECT_EQ(2, observer.gatt_service_added_count()); EXPECT_EQ(1, observer.gatt_service_removed_count()); EXPECT_FALSE(observer.last_gatt_service_id().empty()); EXPECT_EQ(1U, device->GetGattServices().size()); - EXPECT_EQ( - BluetoothUUID(FakeBluetoothGattServiceClient::kHeartRateServiceUUID), - observer.last_gatt_service_uuid()); + EXPECT_EQ(BluetoothUUID( + bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID), + observer.last_gatt_service_uuid()); // The object |service| points to should have been deallocated. |device| // should contain a brand new instance. @@ -339,30 +344,30 @@ TEST_F(BluetoothGattChromeOSTest, GattServiceAddedAndRemoved) { observer.last_gatt_service_uuid() = BluetoothUUID(); observer.last_gatt_service_id().clear(); fake_bluetooth_device_client_->RemoveDevice( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), - dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath)); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); EXPECT_EQ(2, observer.gatt_service_added_count()); EXPECT_EQ(2, observer.gatt_service_removed_count()); EXPECT_FALSE(observer.last_gatt_service_id().empty()); - EXPECT_EQ( - BluetoothUUID(FakeBluetoothGattServiceClient::kHeartRateServiceUUID), - observer.last_gatt_service_uuid()); - EXPECT_EQ(NULL, - adapter_->GetDevice(FakeBluetoothDeviceClient::kLowEnergyAddress)); + EXPECT_EQ(BluetoothUUID( + bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID), + observer.last_gatt_service_uuid()); + EXPECT_EQ(NULL, adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kLowEnergyAddress)); } TEST_F(BluetoothGattChromeOSTest, ServicesDiscovered) { // 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( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), - dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath)); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kLowEnergyAddress); - FakeBluetoothDeviceClient::Properties* properties = + adapter_->GetDevice(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress); + bluez::FakeBluetoothDeviceClient::Properties* properties = fake_bluetooth_device_client_->GetProperties( - dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath)); + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); ASSERT_TRUE(device); @@ -372,23 +377,23 @@ TEST_F(BluetoothGattChromeOSTest, ServicesDiscovered) { // Expose the fake Heart Rate Service. fake_bluetooth_gatt_service_client_->ExposeHeartRateService( - dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath)); + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); // Notify that all services have been discovered. properties->gatt_services.ReplaceValue( fake_bluetooth_gatt_service_client_->GetServices()); EXPECT_EQ(1, observer.gatt_services_discovered_count()); EXPECT_EQ(device, observer.last_device()); - EXPECT_EQ(FakeBluetoothDeviceClient::kLowEnergyAddress, + EXPECT_EQ(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress, observer.last_device_address()); } TEST_F(BluetoothGattChromeOSTest, GattCharacteristicAddedAndRemoved) { fake_bluetooth_device_client_->CreateDevice( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), - dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath)); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kLowEnergyAddress); + adapter_->GetDevice(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress); ASSERT_TRUE(device); TestBluetoothAdapterObserver observer(adapter_); @@ -396,7 +401,7 @@ TEST_F(BluetoothGattChromeOSTest, GattCharacteristicAddedAndRemoved) { // Expose the fake Heart Rate service. This will asynchronously expose // characteristics. fake_bluetooth_gatt_service_client_->ExposeHeartRateService( - dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath)); + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); ASSERT_EQ(1, observer.gatt_service_added_count()); BluetoothGattService* service = @@ -453,10 +458,10 @@ TEST_F(BluetoothGattChromeOSTest, GattCharacteristicAddedAndRemoved) { TEST_F(BluetoothGattChromeOSTest, GattDescriptorAddedAndRemoved) { fake_bluetooth_device_client_->CreateDevice( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), - dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath)); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kLowEnergyAddress); + adapter_->GetDevice(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress); ASSERT_TRUE(device); TestBluetoothAdapterObserver observer(adapter_); @@ -464,7 +469,7 @@ TEST_F(BluetoothGattChromeOSTest, GattDescriptorAddedAndRemoved) { // Expose the fake Heart Rate service. This will asynchronously expose // characteristics. fake_bluetooth_gatt_service_client_->ExposeHeartRateService( - dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath)); + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); ASSERT_EQ(1, observer.gatt_service_added_count()); BluetoothGattService* service = @@ -525,7 +530,7 @@ TEST_F(BluetoothGattChromeOSTest, GattDescriptorAddedAndRemoved) { observer.last_gatt_descriptor_uuid() = BluetoothUUID(); fake_bluetooth_gatt_descriptor_client_->ExposeDescriptor( dbus::ObjectPath(characteristic->GetIdentifier()), - FakeBluetoothGattDescriptorClient:: + bluez::FakeBluetoothGattDescriptorClient:: kClientCharacteristicConfigurationUUID); EXPECT_EQ(0, observer.gatt_service_changed_count()); EXPECT_EQ(1U, characteristic->GetDescriptors().size()); @@ -549,10 +554,10 @@ TEST_F(BluetoothGattChromeOSTest, AdapterAddedAfterGattService) { // Create the fake D-Bus objects. fake_bluetooth_device_client_->CreateDevice( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), - dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath)); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); fake_bluetooth_gatt_service_client_->ExposeHeartRateService( - dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath)); + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); while (!fake_bluetooth_gatt_characteristic_client_->IsHeartRateVisible()) base::RunLoop().RunUntilIdle(); ASSERT_TRUE(fake_bluetooth_gatt_service_client_->IsHeartRateVisible()); @@ -561,7 +566,7 @@ TEST_F(BluetoothGattChromeOSTest, AdapterAddedAfterGattService) { // Create the adapter. This should create all the GATT objects. GetAdapter(); BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kLowEnergyAddress); + adapter_->GetDevice(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress); ASSERT_TRUE(device); EXPECT_EQ(1U, device->GetGattServices().size()); @@ -569,9 +574,9 @@ TEST_F(BluetoothGattChromeOSTest, AdapterAddedAfterGattService) { ASSERT_TRUE(service); EXPECT_FALSE(service->IsLocal()); EXPECT_TRUE(service->IsPrimary()); - EXPECT_EQ( - BluetoothUUID(FakeBluetoothGattServiceClient::kHeartRateServiceUUID), - service->GetUUID()); + EXPECT_EQ(BluetoothUUID( + bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID), + service->GetUUID()); EXPECT_EQ(service, device->GetGattServices()[0]); EXPECT_EQ(service, device->GetGattService(service->GetIdentifier())); EXPECT_FALSE(service->IsLocal()); @@ -581,8 +586,8 @@ TEST_F(BluetoothGattChromeOSTest, AdapterAddedAfterGattService) { fake_bluetooth_gatt_characteristic_client_-> GetBodySensorLocationPath().value()); ASSERT_TRUE(characteristic); - EXPECT_EQ(BluetoothUUID( - FakeBluetoothGattCharacteristicClient::kBodySensorLocationUUID), + EXPECT_EQ(BluetoothUUID(bluez::FakeBluetoothGattCharacteristicClient:: + kBodySensorLocationUUID), characteristic->GetUUID()); EXPECT_FALSE(characteristic->IsLocal()); EXPECT_TRUE(characteristic->GetDescriptors().empty()); @@ -591,10 +596,9 @@ TEST_F(BluetoothGattChromeOSTest, AdapterAddedAfterGattService) { fake_bluetooth_gatt_characteristic_client_-> GetHeartRateControlPointPath().value()); ASSERT_TRUE(characteristic); - EXPECT_EQ( - BluetoothUUID( - FakeBluetoothGattCharacteristicClient::kHeartRateControlPointUUID), - characteristic->GetUUID()); + EXPECT_EQ(BluetoothUUID(bluez::FakeBluetoothGattCharacteristicClient:: + kHeartRateControlPointUUID), + characteristic->GetUUID()); EXPECT_FALSE(characteristic->IsLocal()); EXPECT_TRUE(characteristic->GetDescriptors().empty()); @@ -602,10 +606,9 @@ TEST_F(BluetoothGattChromeOSTest, AdapterAddedAfterGattService) { fake_bluetooth_gatt_characteristic_client_-> GetHeartRateMeasurementPath().value()); ASSERT_TRUE(characteristic); - EXPECT_EQ( - BluetoothUUID( - FakeBluetoothGattCharacteristicClient::kHeartRateMeasurementUUID), - characteristic->GetUUID()); + EXPECT_EQ(BluetoothUUID(bluez::FakeBluetoothGattCharacteristicClient:: + kHeartRateMeasurementUUID), + characteristic->GetUUID()); EXPECT_FALSE(characteristic->IsLocal()); EXPECT_EQ(1U, characteristic->GetDescriptors().size()); @@ -618,10 +621,10 @@ TEST_F(BluetoothGattChromeOSTest, AdapterAddedAfterGattService) { TEST_F(BluetoothGattChromeOSTest, GattCharacteristicValue) { fake_bluetooth_device_client_->CreateDevice( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), - dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath)); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kLowEnergyAddress); + adapter_->GetDevice(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress); ASSERT_TRUE(device); TestBluetoothAdapterObserver observer(adapter_); @@ -629,7 +632,7 @@ TEST_F(BluetoothGattChromeOSTest, GattCharacteristicValue) { // Expose the fake Heart Rate service. This will asynchronously expose // characteristics. fake_bluetooth_gatt_service_client_->ExposeHeartRateService( - dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath)); + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); ASSERT_EQ(1, observer.gatt_service_added_count()); BluetoothGattService* service = @@ -833,10 +836,10 @@ TEST_F(BluetoothGattChromeOSTest, GattCharacteristicValue) { TEST_F(BluetoothGattChromeOSTest, GattCharacteristicProperties) { fake_bluetooth_device_client_->CreateDevice( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), - dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath)); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kLowEnergyAddress); + adapter_->GetDevice(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress); ASSERT_TRUE(device); TestBluetoothAdapterObserver observer(adapter_); @@ -844,7 +847,7 @@ TEST_F(BluetoothGattChromeOSTest, GattCharacteristicProperties) { // Expose the fake Heart Rate service. This will asynchronously expose // characteristics. fake_bluetooth_gatt_service_client_->ExposeHeartRateService( - dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath)); + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); BluetoothGattService* service = device->GetGattService(observer.last_gatt_service_id()); @@ -875,10 +878,10 @@ TEST_F(BluetoothGattChromeOSTest, GattCharacteristicProperties) { TEST_F(BluetoothGattChromeOSTest, GattDescriptorValue) { fake_bluetooth_device_client_->CreateDevice( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), - dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath)); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kLowEnergyAddress); + adapter_->GetDevice(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress); ASSERT_TRUE(device); TestBluetoothAdapterObserver observer(adapter_); @@ -886,7 +889,7 @@ TEST_F(BluetoothGattChromeOSTest, GattDescriptorValue) { // Expose the fake Heart Rate service. This will asynchronously expose // characteristics. fake_bluetooth_gatt_service_client_->ExposeHeartRateService( - dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath)); + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); ASSERT_EQ(1, observer.gatt_service_added_count()); BluetoothGattService* service = @@ -998,10 +1001,10 @@ TEST_F(BluetoothGattChromeOSTest, GattDescriptorValue) { TEST_F(BluetoothGattChromeOSTest, NotifySessions) { fake_bluetooth_device_client_->CreateDevice( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), - dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath)); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kLowEnergyAddress); + adapter_->GetDevice(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress); ASSERT_TRUE(device); TestBluetoothAdapterObserver observer(adapter_); @@ -1009,7 +1012,7 @@ TEST_F(BluetoothGattChromeOSTest, NotifySessions) { // Expose the fake Heart Rate service. This will asynchronously expose // characteristics. fake_bluetooth_gatt_service_client_->ExposeHeartRateService( - dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath)); + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); ASSERT_EQ(1, observer.gatt_service_added_count()); BluetoothGattService* service = @@ -1147,10 +1150,10 @@ TEST_F(BluetoothGattChromeOSTest, NotifySessions) { TEST_F(BluetoothGattChromeOSTest, NotifySessionsMadeInactive) { fake_bluetooth_device_client_->CreateDevice( - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), - dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath)); + dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kLowEnergyAddress); + adapter_->GetDevice(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress); ASSERT_TRUE(device); TestBluetoothAdapterObserver observer(adapter_); @@ -1158,7 +1161,7 @@ TEST_F(BluetoothGattChromeOSTest, NotifySessionsMadeInactive) { // Expose the fake Heart Rate service. This will asynchronously expose // characteristics. fake_bluetooth_gatt_service_client_->ExposeHeartRateService( - dbus::ObjectPath(FakeBluetoothDeviceClient::kLowEnergyPath)); + dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); ASSERT_EQ(1, observer.gatt_service_added_count()); BluetoothGattService* service = diff --git a/device/bluetooth/bluetooth_gatt_connection_chromeos.cc b/device/bluetooth/bluetooth_gatt_connection_chromeos.cc index 6c16db8..57aaa4d 100644 --- a/device/bluetooth/bluetooth_gatt_connection_chromeos.cc +++ b/device/bluetooth/bluetooth_gatt_connection_chromeos.cc @@ -6,9 +6,9 @@ #include "base/bind.h" #include "base/logging.h" -#include "chromeos/dbus/dbus_thread_manager.h" #include "device/bluetooth/bluetooth_adapter.h" #include "device/bluetooth/bluetooth_device.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" namespace chromeos { @@ -23,11 +23,12 @@ BluetoothGattConnectionChromeOS::BluetoothGattConnectionChromeOS( DCHECK(!device_address_.empty()); DCHECK(object_path_.IsValid()); - DBusThreadManager::Get()->GetBluetoothDeviceClient()->AddObserver(this); + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->AddObserver(this); } BluetoothGattConnectionChromeOS::~BluetoothGattConnectionChromeOS() { - DBusThreadManager::Get()->GetBluetoothDeviceClient()->RemoveObserver(this); + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->RemoveObserver( + this); Disconnect(); } @@ -40,8 +41,8 @@ bool BluetoothGattConnectionChromeOS::IsConnected() { if (!connected_) return false; - BluetoothDeviceClient::Properties* properties = - DBusThreadManager::Get()->GetBluetoothDeviceClient()->GetProperties( + bluez::BluetoothDeviceClient::Properties* properties = + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( object_path_); if (!properties || !properties->connected.value()) connected_ = false; @@ -82,8 +83,8 @@ void BluetoothGattConnectionChromeOS::DevicePropertyChanged( if (!connected_) return; - BluetoothDeviceClient::Properties* properties = - DBusThreadManager::Get()->GetBluetoothDeviceClient()->GetProperties( + bluez::BluetoothDeviceClient::Properties* properties = + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( object_path_); if (!properties) { diff --git a/device/bluetooth/bluetooth_gatt_connection_chromeos.h b/device/bluetooth/bluetooth_gatt_connection_chromeos.h index 66c1a1a..6e40283 100644 --- a/device/bluetooth/bluetooth_gatt_connection_chromeos.h +++ b/device/bluetooth/bluetooth_gatt_connection_chromeos.h @@ -9,9 +9,9 @@ #include "base/callback.h" #include "base/memory/weak_ptr.h" -#include "chromeos/dbus/bluetooth_device_client.h" #include "dbus/object_path.h" #include "device/bluetooth/bluetooth_gatt_connection.h" +#include "device/bluetooth/dbus/bluetooth_device_client.h" namespace device { @@ -23,8 +23,9 @@ namespace chromeos { // BluetoothGattConnectionChromeOS implements BluetoothGattConnection for the // Chrome OS platform. -class BluetoothGattConnectionChromeOS : public device::BluetoothGattConnection, - public BluetoothDeviceClient::Observer { +class BluetoothGattConnectionChromeOS + : public device::BluetoothGattConnection, + public bluez::BluetoothDeviceClient::Observer { public: explicit BluetoothGattConnectionChromeOS( scoped_refptr<device::BluetoothAdapter> adapter, @@ -37,7 +38,7 @@ class BluetoothGattConnectionChromeOS : public device::BluetoothGattConnection, void Disconnect() override; private: - // chromeos::BluetoothDeviceClient::Observer overrides. + // bluez::Bluetooth$1Client::Observer overrides. void DeviceRemoved(const dbus::ObjectPath& object_path) override; void DevicePropertyChanged(const dbus::ObjectPath& object_path, const std::string& property_name) override; diff --git a/device/bluetooth/bluetooth_gatt_notify_session_chromeos.cc b/device/bluetooth/bluetooth_gatt_notify_session_chromeos.cc index ba7b843..02f7ed8 100644 --- a/device/bluetooth/bluetooth_gatt_notify_session_chromeos.cc +++ b/device/bluetooth/bluetooth_gatt_notify_session_chromeos.cc @@ -6,11 +6,11 @@ #include "base/bind.h" #include "base/logging.h" -#include "chromeos/dbus/dbus_thread_manager.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/dbus/bluez_dbus_manager.h" namespace chromeos { @@ -32,12 +32,13 @@ BluetoothGattNotifySessionChromeOS::BluetoothGattNotifySessionChromeOS( DCHECK(!characteristic_id_.empty()); DCHECK(object_path_.IsValid()); - DBusThreadManager::Get()->GetBluetoothGattCharacteristicClient()->AddObserver( - this); + bluez::BluezDBusManager::Get() + ->GetBluetoothGattCharacteristicClient() + ->AddObserver(this); } BluetoothGattNotifySessionChromeOS::~BluetoothGattNotifySessionChromeOS() { - DBusThreadManager::Get() + bluez::BluezDBusManager::Get() ->GetBluetoothGattCharacteristicClient() ->RemoveObserver(this); Stop(base::Bind(&base::DoNothing)); @@ -58,11 +59,12 @@ bool BluetoothGattNotifySessionChromeOS::IsActive() { // actually active, since the characteristic might have stopped sending // notifications yet this method was called before we processed the // observer event (e.g. because somebody else called this method in their - // BluetoothGattCharacteristicClient::Observer implementation, which was + // bluez::BluetoothGattCharacteristicClient::Observer implementation, which + // was // called before ours). Check the client to see if notifications are still // being sent. - BluetoothGattCharacteristicClient::Properties* properties = - DBusThreadManager::Get() + bluez::BluetoothGattCharacteristicClient::Properties* properties = + bluez::BluezDBusManager::Get() ->GetBluetoothGattCharacteristicClient() ->GetProperties(object_path_); if (!properties || !properties->notifying.value()) @@ -115,8 +117,8 @@ void BluetoothGattNotifySessionChromeOS::GattCharacteristicPropertyChanged( if (!active_) return; - BluetoothGattCharacteristicClient::Properties* properties = - DBusThreadManager::Get() + bluez::BluetoothGattCharacteristicClient::Properties* properties = + bluez::BluezDBusManager::Get() ->GetBluetoothGattCharacteristicClient() ->GetProperties(object_path_); if (!properties) { diff --git a/device/bluetooth/bluetooth_gatt_notify_session_chromeos.h b/device/bluetooth/bluetooth_gatt_notify_session_chromeos.h index 245a72f..ef6e8da 100644 --- a/device/bluetooth/bluetooth_gatt_notify_session_chromeos.h +++ b/device/bluetooth/bluetooth_gatt_notify_session_chromeos.h @@ -8,8 +8,8 @@ #include <string> #include "base/callback.h" -#include "chromeos/dbus/bluetooth_gatt_characteristic_client.h" #include "device/bluetooth/bluetooth_gatt_notify_session.h" +#include "device/bluetooth/dbus/bluetooth_gatt_characteristic_client.h" namespace device { @@ -25,7 +25,7 @@ class BluetoothRemoteGattCharacteristicChromeOS; // BluetoothGattNotifySession for the Chrome OS platform. class BluetoothGattNotifySessionChromeOS : public device::BluetoothGattNotifySession, - public BluetoothGattCharacteristicClient::Observer { + public bluez::BluetoothGattCharacteristicClient::Observer { public: ~BluetoothGattNotifySessionChromeOS() override; @@ -44,7 +44,7 @@ class BluetoothGattNotifySessionChromeOS const std::string& characteristic_identifier, const dbus::ObjectPath& characteristic_path); - // BluetoothGattCharacteristicClient::Observer overrides. + // bluez::BluetoothGattCharacteristicClient::Observer overrides. void GattCharacteristicRemoved(const dbus::ObjectPath& object_path) override; void GattCharacteristicPropertyChanged( const dbus::ObjectPath& object_path, diff --git a/device/bluetooth/bluetooth_pairing_chromeos.cc b/device/bluetooth/bluetooth_pairing_chromeos.cc index 2bc67cb..4541fb3 100644 --- a/device/bluetooth/bluetooth_pairing_chromeos.cc +++ b/device/bluetooth/bluetooth_pairing_chromeos.cc @@ -55,25 +55,26 @@ BluetoothPairingChromeOS::~BluetoothPairingChromeOS() { } if (!pincode_callback_.is_null()) { - pincode_callback_.Run(BluetoothAgentServiceProvider::Delegate::CANCELLED, - ""); + pincode_callback_.Run( + bluez::BluetoothAgentServiceProvider::Delegate::CANCELLED, ""); } if (!passkey_callback_.is_null()) { - passkey_callback_.Run(BluetoothAgentServiceProvider::Delegate::CANCELLED, - 0); + passkey_callback_.Run( + bluez::BluetoothAgentServiceProvider::Delegate::CANCELLED, 0); } if (!confirmation_callback_.is_null()) { confirmation_callback_.Run( - BluetoothAgentServiceProvider::Delegate::CANCELLED); + bluez::BluetoothAgentServiceProvider::Delegate::CANCELLED); } pairing_delegate_ = NULL; } void BluetoothPairingChromeOS::RequestPinCode( - const BluetoothAgentServiceProvider::Delegate::PinCodeCallback& callback) { + const bluez::BluetoothAgentServiceProvider::Delegate::PinCodeCallback& + callback) { UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod", UMA_PAIRING_METHOD_REQUEST_PINCODE, UMA_PAIRING_METHOD_COUNT); @@ -92,7 +93,7 @@ void BluetoothPairingChromeOS::SetPinCode(const std::string& pincode) { if (pincode_callback_.is_null()) return; - pincode_callback_.Run(BluetoothAgentServiceProvider::Delegate::SUCCESS, + pincode_callback_.Run(bluez::BluetoothAgentServiceProvider::Delegate::SUCCESS, pincode); pincode_callback_.Reset(); @@ -120,7 +121,8 @@ void BluetoothPairingChromeOS::DisplayPinCode(const std::string& pincode) { } void BluetoothPairingChromeOS::RequestPasskey( - const BluetoothAgentServiceProvider::Delegate::PasskeyCallback& callback) { + const bluez::BluetoothAgentServiceProvider::Delegate::PasskeyCallback& + callback) { UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod", UMA_PAIRING_METHOD_REQUEST_PASSKEY, UMA_PAIRING_METHOD_COUNT); @@ -139,7 +141,7 @@ void BluetoothPairingChromeOS::SetPasskey(uint32 passkey) { if (passkey_callback_.is_null()) return; - passkey_callback_.Run(BluetoothAgentServiceProvider::Delegate::SUCCESS, + passkey_callback_.Run(bluez::BluetoothAgentServiceProvider::Delegate::SUCCESS, passkey); passkey_callback_.Reset(); @@ -158,7 +160,6 @@ void BluetoothPairingChromeOS::DisplayPasskey(uint32 passkey) { ResetCallbacks(); pairing_delegate_used_ = true; pairing_delegate_->DisplayPasskey(device_, passkey); - } void BluetoothPairingChromeOS::KeysEntered(uint16 entered) { @@ -174,7 +175,7 @@ void BluetoothPairingChromeOS::KeysEntered(uint16 entered) { void BluetoothPairingChromeOS::RequestConfirmation( uint32 passkey, - const BluetoothAgentServiceProvider::Delegate::ConfirmationCallback& + const bluez::BluetoothAgentServiceProvider::Delegate::ConfirmationCallback& callback) { UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod", UMA_PAIRING_METHOD_CONFIRM_PASSKEY, @@ -187,7 +188,7 @@ void BluetoothPairingChromeOS::RequestConfirmation( } void BluetoothPairingChromeOS::RequestAuthorization( - const BluetoothAgentServiceProvider::Delegate::ConfirmationCallback& + const bluez::BluetoothAgentServiceProvider::Delegate::ConfirmationCallback& callback) { UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod", UMA_PAIRING_METHOD_NONE, @@ -207,7 +208,8 @@ void BluetoothPairingChromeOS::ConfirmPairing() { if (confirmation_callback_.is_null()) return; - confirmation_callback_.Run(BluetoothAgentServiceProvider::Delegate::SUCCESS); + confirmation_callback_.Run( + bluez::BluetoothAgentServiceProvider::Delegate::SUCCESS); confirmation_callback_.Reset(); // If this is not an outgoing connection to the device, clean up the pairing @@ -218,12 +220,13 @@ void BluetoothPairingChromeOS::ConfirmPairing() { } bool BluetoothPairingChromeOS::RejectPairing() { - return RunPairingCallbacks(BluetoothAgentServiceProvider::Delegate::REJECTED); + return RunPairingCallbacks( + bluez::BluetoothAgentServiceProvider::Delegate::REJECTED); } bool BluetoothPairingChromeOS::CancelPairing() { return RunPairingCallbacks( - BluetoothAgentServiceProvider::Delegate::CANCELLED); + bluez::BluetoothAgentServiceProvider::Delegate::CANCELLED); } BluetoothDevice::PairingDelegate* @@ -238,7 +241,7 @@ void BluetoothPairingChromeOS::ResetCallbacks() { } bool BluetoothPairingChromeOS::RunPairingCallbacks( - BluetoothAgentServiceProvider::Delegate::Status status) { + bluez::BluetoothAgentServiceProvider::Delegate::Status status) { pairing_delegate_used_ = true; bool callback_run = false; diff --git a/device/bluetooth/bluetooth_pairing_chromeos.h b/device/bluetooth/bluetooth_pairing_chromeos.h index b50a328..0a4ddb6 100644 --- a/device/bluetooth/bluetooth_pairing_chromeos.h +++ b/device/bluetooth/bluetooth_pairing_chromeos.h @@ -5,8 +5,8 @@ #ifndef DEVICE_BLUETOOTH_BLUETOOTH_PAIRING_CHROMEOS_H_ #define DEVICE_BLUETOOTH_BLUETOOTH_PAIRING_CHROMEOS_H_ -#include "chromeos/dbus/bluetooth_agent_service_provider.h" #include "device/bluetooth/bluetooth_device.h" +#include "device/bluetooth/dbus/bluetooth_agent_service_provider.h" namespace chromeos { @@ -36,7 +36,8 @@ class BluetoothPairingChromeOS { // calls on this object are translated into the appropriate response to // |callback|. void RequestPinCode( - const BluetoothAgentServiceProvider::Delegate::PinCodeCallback& callback); + const bluez::BluetoothAgentServiceProvider::Delegate::PinCodeCallback& + callback); // Indicates whether the device is currently pairing and expecting a // PIN Code to be returned. @@ -57,7 +58,8 @@ class BluetoothPairingChromeOS { // calls on this object are translated into the appropriate response to // |callback|. void RequestPasskey( - const BluetoothAgentServiceProvider::Delegate::PasskeyCallback& callback); + const bluez::BluetoothAgentServiceProvider::Delegate::PasskeyCallback& + callback); // Sends the Passkey |passkey| to the remote device during pairing. // @@ -79,18 +81,16 @@ class BluetoothPairingChromeOS { // from the current pairing delegate. The ConfirmPairing(), RejectPairing() // and CancelPairing() method calls on this object are translated into the // appropriate response to |callback|. - void RequestConfirmation( - uint32 passkey, - const BluetoothAgentServiceProvider::Delegate::ConfirmationCallback& - callback); + void RequestConfirmation(uint32 passkey, + const bluez::BluetoothAgentServiceProvider:: + Delegate::ConfirmationCallback& callback); // Requests authorization that the current device be allowed to pair with // this device from the current pairing delegate. The ConfirmPairing(), // RejectPairing() and CancelPairing() method calls on this object are // translated into the appropriate response to |callback|. - void RequestAuthorization( - const BluetoothAgentServiceProvider::Delegate::ConfirmationCallback& - callback); + void RequestAuthorization(const bluez::BluetoothAgentServiceProvider:: + Delegate::ConfirmationCallback& callback); // Confirms to the remote device during pairing that a passkey provided by // the ConfirmPasskey() delegate call is displayed on both devices. @@ -115,7 +115,7 @@ class BluetoothPairingChromeOS { // Internal method to respond to the relevant callback for a RejectPairing // or CancelPairing call. bool RunPairingCallbacks( - BluetoothAgentServiceProvider::Delegate::Status status); + bluez::BluetoothAgentServiceProvider::Delegate::Status status); // The underlying BluetoothDeviceChromeOS that owns this pairing context. BluetoothDeviceChromeOS* device_; @@ -131,11 +131,13 @@ class BluetoothPairingChromeOS { // During pairing these callbacks are set to those provided by method calls // made on the BluetoothAdapterChromeOS instance by its respective - // BluetoothAgentServiceProvider instance, and are called by our own + // bluez::BluetoothAgentServiceProvider instance, and are called by our own // method calls such as SetPinCode() and SetPasskey(). - BluetoothAgentServiceProvider::Delegate::PinCodeCallback pincode_callback_; - BluetoothAgentServiceProvider::Delegate::PasskeyCallback passkey_callback_; - BluetoothAgentServiceProvider::Delegate::ConfirmationCallback + bluez::BluetoothAgentServiceProvider::Delegate::PinCodeCallback + pincode_callback_; + bluez::BluetoothAgentServiceProvider::Delegate::PasskeyCallback + passkey_callback_; + bluez::BluetoothAgentServiceProvider::Delegate::ConfirmationCallback confirmation_callback_; DISALLOW_COPY_AND_ASSIGN(BluetoothPairingChromeOS); diff --git a/device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.cc b/device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.cc index 7a0f5e3..7374f16 100644 --- a/device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.cc +++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.cc @@ -8,13 +8,13 @@ #include "base/logging.h" #include "base/strings/stringprintf.h" -#include "chromeos/dbus/dbus_thread_manager.h" #include "device/bluetooth/bluetooth_adapter_chromeos.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/dbus/bluez_dbus_manager.h" #include "third_party/cros_system_api/dbus/service_constants.h" namespace chromeos { @@ -44,12 +44,13 @@ BluetoothRemoteGattCharacteristicChromeOS:: weak_ptr_factory_(this) { VLOG(1) << "Creating remote GATT characteristic with identifier: " << GetIdentifier() << ", UUID: " << GetUUID().canonical_value(); - DBusThreadManager::Get()->GetBluetoothGattDescriptorClient()->AddObserver( - this); + bluez::BluezDBusManager::Get() + ->GetBluetoothGattDescriptorClient() + ->AddObserver(this); // Add all known GATT characteristic descriptors. const std::vector<dbus::ObjectPath>& gatt_descs = - DBusThreadManager::Get() + bluez::BluezDBusManager::Get() ->GetBluetoothGattDescriptorClient() ->GetDescriptors(); for (std::vector<dbus::ObjectPath>::const_iterator iter = gatt_descs.begin(); @@ -59,8 +60,9 @@ BluetoothRemoteGattCharacteristicChromeOS:: BluetoothRemoteGattCharacteristicChromeOS:: ~BluetoothRemoteGattCharacteristicChromeOS() { - DBusThreadManager::Get()->GetBluetoothGattDescriptorClient()->RemoveObserver( - this); + bluez::BluezDBusManager::Get() + ->GetBluetoothGattDescriptorClient() + ->RemoveObserver(this); // Clean up all the descriptors. There isn't much point in notifying service // observers for each descriptor that gets removed, so just delete them. @@ -82,8 +84,8 @@ std::string BluetoothRemoteGattCharacteristicChromeOS::GetIdentifier() const { device::BluetoothUUID BluetoothRemoteGattCharacteristicChromeOS::GetUUID() const { - BluetoothGattCharacteristicClient::Properties* properties = - DBusThreadManager::Get() + bluez::BluetoothGattCharacteristicClient::Properties* properties = + bluez::BluezDBusManager::Get() ->GetBluetoothGattCharacteristicClient() ->GetProperties(object_path_); DCHECK(properties); @@ -96,8 +98,8 @@ bool BluetoothRemoteGattCharacteristicChromeOS::IsLocal() const { const std::vector<uint8>& BluetoothRemoteGattCharacteristicChromeOS::GetValue() const { - BluetoothGattCharacteristicClient::Properties* properties = - DBusThreadManager::Get() + bluez::BluetoothGattCharacteristicClient::Properties* properties = + bluez::BluezDBusManager::Get() ->GetBluetoothGattCharacteristicClient() ->GetProperties(object_path_); @@ -113,8 +115,8 @@ BluetoothRemoteGattCharacteristicChromeOS::GetService() const { device::BluetoothGattCharacteristic::Properties BluetoothRemoteGattCharacteristicChromeOS::GetProperties() const { - BluetoothGattCharacteristicClient::Properties* properties = - DBusThreadManager::Get() + bluez::BluetoothGattCharacteristicClient::Properties* properties = + bluez::BluezDBusManager::Get() ->GetBluetoothGattCharacteristicClient() ->GetProperties(object_path_); DCHECK(properties); @@ -157,8 +159,8 @@ BluetoothRemoteGattCharacteristicChromeOS::GetPermissions() const { } bool BluetoothRemoteGattCharacteristicChromeOS::IsNotifying() const { - BluetoothGattCharacteristicClient::Properties* properties = - DBusThreadManager::Get() + bluez::BluetoothGattCharacteristicClient::Properties* properties = + bluez::BluezDBusManager::Get() ->GetBluetoothGattCharacteristicClient() ->GetProperties(object_path_); DCHECK(properties); @@ -204,10 +206,12 @@ void BluetoothRemoteGattCharacteristicChromeOS::ReadRemoteCharacteristic( << GetIdentifier() << ", UUID: " << GetUUID().canonical_value() << "."; - DBusThreadManager::Get()->GetBluetoothGattCharacteristicClient()->ReadValue( - object_path_, callback, - base::Bind(&BluetoothRemoteGattCharacteristicChromeOS::OnError, - weak_ptr_factory_.GetWeakPtr(), error_callback)); + bluez::BluezDBusManager::Get() + ->GetBluetoothGattCharacteristicClient() + ->ReadValue( + object_path_, callback, + base::Bind(&BluetoothRemoteGattCharacteristicChromeOS::OnError, + weak_ptr_factory_.GetWeakPtr(), error_callback)); } void BluetoothRemoteGattCharacteristicChromeOS::WriteRemoteCharacteristic( @@ -218,10 +222,12 @@ void BluetoothRemoteGattCharacteristicChromeOS::WriteRemoteCharacteristic( << GetIdentifier() << ", UUID: " << GetUUID().canonical_value() << ", with value: " << new_value << "."; - DBusThreadManager::Get()->GetBluetoothGattCharacteristicClient()->WriteValue( - object_path_, new_value, callback, - base::Bind(&BluetoothRemoteGattCharacteristicChromeOS::OnError, - weak_ptr_factory_.GetWeakPtr(), error_callback)); + bluez::BluezDBusManager::Get() + ->GetBluetoothGattCharacteristicClient() + ->WriteValue( + object_path_, new_value, callback, + base::Bind(&BluetoothRemoteGattCharacteristicChromeOS::OnError, + weak_ptr_factory_.GetWeakPtr(), error_callback)); } void BluetoothRemoteGattCharacteristicChromeOS::StartNotifySession( @@ -267,13 +273,16 @@ void BluetoothRemoteGattCharacteristicChromeOS::StartNotifySession( } notify_call_pending_ = true; - DBusThreadManager::Get()->GetBluetoothGattCharacteristicClient()->StartNotify( - object_path_, - base::Bind( - &BluetoothRemoteGattCharacteristicChromeOS::OnStartNotifySuccess, - weak_ptr_factory_.GetWeakPtr(), callback), - base::Bind(&BluetoothRemoteGattCharacteristicChromeOS::OnStartNotifyError, - weak_ptr_factory_.GetWeakPtr(), error_callback)); + bluez::BluezDBusManager::Get() + ->GetBluetoothGattCharacteristicClient() + ->StartNotify( + object_path_, + base::Bind( + &BluetoothRemoteGattCharacteristicChromeOS::OnStartNotifySuccess, + weak_ptr_factory_.GetWeakPtr(), callback), + base::Bind( + &BluetoothRemoteGattCharacteristicChromeOS::OnStartNotifyError, + weak_ptr_factory_.GetWeakPtr(), error_callback)); } void BluetoothRemoteGattCharacteristicChromeOS::RemoveNotifySession( @@ -302,13 +311,16 @@ void BluetoothRemoteGattCharacteristicChromeOS::RemoveNotifySession( DCHECK(num_notify_sessions_ == 1); notify_call_pending_ = true; - DBusThreadManager::Get()->GetBluetoothGattCharacteristicClient()->StopNotify( - object_path_, - base::Bind( - &BluetoothRemoteGattCharacteristicChromeOS::OnStopNotifySuccess, - weak_ptr_factory_.GetWeakPtr(), callback), - base::Bind(&BluetoothRemoteGattCharacteristicChromeOS::OnStopNotifyError, - weak_ptr_factory_.GetWeakPtr(), callback)); + bluez::BluezDBusManager::Get() + ->GetBluetoothGattCharacteristicClient() + ->StopNotify( + object_path_, + base::Bind( + &BluetoothRemoteGattCharacteristicChromeOS::OnStopNotifySuccess, + weak_ptr_factory_.GetWeakPtr(), callback), + base::Bind( + &BluetoothRemoteGattCharacteristicChromeOS::OnStopNotifyError, + weak_ptr_factory_.GetWeakPtr(), callback)); } void BluetoothRemoteGattCharacteristicChromeOS::GattDescriptorAdded( @@ -319,8 +331,8 @@ void BluetoothRemoteGattCharacteristicChromeOS::GattDescriptorAdded( return; } - BluetoothGattDescriptorClient::Properties* properties = - DBusThreadManager::Get() + bluez::BluetoothGattDescriptorClient::Properties* properties = + bluez::BluezDBusManager::Get() ->GetBluetoothGattDescriptorClient() ->GetProperties(object_path); DCHECK(properties); @@ -372,8 +384,8 @@ void BluetoothRemoteGattCharacteristicChromeOS::GattDescriptorPropertyChanged( return; } - BluetoothGattDescriptorClient::Properties* properties = - DBusThreadManager::Get() + bluez::BluetoothGattDescriptorClient::Properties* properties = + bluez::BluezDBusManager::Get() ->GetBluetoothGattDescriptorClient() ->GetProperties(object_path); diff --git a/device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h b/device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h index a23a1178..361b319 100644 --- a/device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h +++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h @@ -12,10 +12,10 @@ #include <vector> #include "base/memory/weak_ptr.h" -#include "chromeos/dbus/bluetooth_gatt_descriptor_client.h" #include "dbus/object_path.h" #include "device/bluetooth/bluetooth_gatt_characteristic.h" #include "device/bluetooth/bluetooth_uuid.h" +#include "device/bluetooth/dbus/bluetooth_gatt_descriptor_client.h" namespace device { @@ -34,7 +34,7 @@ class BluetoothRemoteGattServiceChromeOS; // platform. class BluetoothRemoteGattCharacteristicChromeOS : public device::BluetoothGattCharacteristic, - public BluetoothGattDescriptorClient::Observer { + public bluez::BluetoothGattDescriptorClient::Observer { public: // device::BluetoothGattCharacteristic overrides. std::string GetIdentifier() const override; @@ -78,7 +78,7 @@ class BluetoothRemoteGattCharacteristicChromeOS const dbus::ObjectPath& object_path); ~BluetoothRemoteGattCharacteristicChromeOS() override; - // BluetoothGattDescriptorClient::Observer overrides. + // bluez::BluetoothGattDescriptorClient::Observer overrides. void GattDescriptorAdded(const dbus::ObjectPath& object_path) override; void GattDescriptorRemoved(const dbus::ObjectPath& object_path) override; void GattDescriptorPropertyChanged(const dbus::ObjectPath& object_path, diff --git a/device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.cc b/device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.cc index ab1074f8..f864c3b 100644 --- a/device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.cc +++ b/device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.cc @@ -7,10 +7,10 @@ #include "base/bind.h" #include "base/logging.h" #include "base/strings/stringprintf.h" -#include "chromeos/dbus/bluetooth_gatt_descriptor_client.h" -#include "chromeos/dbus/dbus_thread_manager.h" #include "device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h" #include "device/bluetooth/bluetooth_remote_gatt_service_chromeos.h" +#include "device/bluetooth/dbus/bluetooth_gatt_descriptor_client.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" namespace chromeos { @@ -47,8 +47,8 @@ std::string BluetoothRemoteGattDescriptorChromeOS::GetIdentifier() const { } device::BluetoothUUID BluetoothRemoteGattDescriptorChromeOS::GetUUID() const { - BluetoothGattDescriptorClient::Properties* properties = - DBusThreadManager::Get() + bluez::BluetoothGattDescriptorClient::Properties* properties = + bluez::BluezDBusManager::Get() ->GetBluetoothGattDescriptorClient() ->GetProperties(object_path_); DCHECK(properties); @@ -61,8 +61,8 @@ bool BluetoothRemoteGattDescriptorChromeOS::IsLocal() const { const std::vector<uint8>& BluetoothRemoteGattDescriptorChromeOS::GetValue() const { - BluetoothGattDescriptorClient::Properties* properties = - DBusThreadManager::Get() + bluez::BluetoothGattDescriptorClient::Properties* properties = + bluez::BluezDBusManager::Get() ->GetBluetoothGattDescriptorClient() ->GetProperties(object_path_); @@ -90,7 +90,7 @@ void BluetoothRemoteGattDescriptorChromeOS::ReadRemoteDescriptor( << "descriptor: " << GetIdentifier() << ", UUID: " << GetUUID().canonical_value(); - DBusThreadManager::Get()->GetBluetoothGattDescriptorClient()->ReadValue( + bluez::BluezDBusManager::Get()->GetBluetoothGattDescriptorClient()->ReadValue( object_path_, callback, base::Bind(&BluetoothRemoteGattDescriptorChromeOS::OnError, weak_ptr_factory_.GetWeakPtr(), error_callback)); @@ -105,10 +105,11 @@ void BluetoothRemoteGattDescriptorChromeOS::WriteRemoteDescriptor( << GetUUID().canonical_value() << ", with value: " << new_value << "."; - DBusThreadManager::Get()->GetBluetoothGattDescriptorClient()->WriteValue( - object_path_, new_value, callback, - base::Bind(&BluetoothRemoteGattDescriptorChromeOS::OnError, - weak_ptr_factory_.GetWeakPtr(), error_callback)); + bluez::BluezDBusManager::Get() + ->GetBluetoothGattDescriptorClient() + ->WriteValue(object_path_, new_value, callback, + base::Bind(&BluetoothRemoteGattDescriptorChromeOS::OnError, + weak_ptr_factory_.GetWeakPtr(), error_callback)); } void BluetoothRemoteGattDescriptorChromeOS::OnError( diff --git a/device/bluetooth/bluetooth_remote_gatt_service_chromeos.cc b/device/bluetooth/bluetooth_remote_gatt_service_chromeos.cc index e8176bd..8a57fa2 100644 --- a/device/bluetooth/bluetooth_remote_gatt_service_chromeos.cc +++ b/device/bluetooth/bluetooth_remote_gatt_service_chromeos.cc @@ -6,12 +6,12 @@ #include "base/logging.h" #include "base/strings/stringprintf.h" -#include "chromeos/dbus/bluetooth_gatt_service_client.h" -#include "chromeos/dbus/dbus_thread_manager.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/dbus/bluetooth_gatt_service_client.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" namespace chromeos { @@ -41,13 +41,15 @@ BluetoothRemoteGattServiceChromeOS::BluetoothRemoteGattServiceChromeOS( << object_path.value() << ", UUID: " << GetUUID().canonical_value(); DCHECK(adapter_); - DBusThreadManager::Get()->GetBluetoothGattServiceClient()->AddObserver(this); - DBusThreadManager::Get()->GetBluetoothGattCharacteristicClient()->AddObserver( + bluez::BluezDBusManager::Get()->GetBluetoothGattServiceClient()->AddObserver( this); + bluez::BluezDBusManager::Get() + ->GetBluetoothGattCharacteristicClient() + ->AddObserver(this); // Add all known GATT characteristics. const std::vector<dbus::ObjectPath>& gatt_chars = - DBusThreadManager::Get() + bluez::BluezDBusManager::Get() ->GetBluetoothGattCharacteristicClient() ->GetCharacteristics(); for (std::vector<dbus::ObjectPath>::const_iterator iter = gatt_chars.begin(); @@ -56,9 +58,10 @@ BluetoothRemoteGattServiceChromeOS::BluetoothRemoteGattServiceChromeOS( } BluetoothRemoteGattServiceChromeOS::~BluetoothRemoteGattServiceChromeOS() { - DBusThreadManager::Get()->GetBluetoothGattServiceClient()->RemoveObserver( - this); - DBusThreadManager::Get() + bluez::BluezDBusManager::Get() + ->GetBluetoothGattServiceClient() + ->RemoveObserver(this); + bluez::BluezDBusManager::Get() ->GetBluetoothGattCharacteristicClient() ->RemoveObserver(this); @@ -81,9 +84,10 @@ std::string BluetoothRemoteGattServiceChromeOS::GetIdentifier() const { } device::BluetoothUUID BluetoothRemoteGattServiceChromeOS::GetUUID() const { - BluetoothGattServiceClient::Properties* properties = - DBusThreadManager::Get()->GetBluetoothGattServiceClient()->GetProperties( - object_path_); + bluez::BluetoothGattServiceClient::Properties* properties = + bluez::BluezDBusManager::Get() + ->GetBluetoothGattServiceClient() + ->GetProperties(object_path_); DCHECK(properties); return device::BluetoothUUID(properties->uuid.value()); } @@ -93,9 +97,10 @@ bool BluetoothRemoteGattServiceChromeOS::IsLocal() const { } bool BluetoothRemoteGattServiceChromeOS::IsPrimary() const { - BluetoothGattServiceClient::Properties* properties = - DBusThreadManager::Get()->GetBluetoothGattServiceClient()->GetProperties( - object_path_); + bluez::BluetoothGattServiceClient::Properties* properties = + bluez::BluezDBusManager::Get() + ->GetBluetoothGattServiceClient() + ->GetProperties(object_path_); DCHECK(properties); return properties->primary.value(); } @@ -229,9 +234,10 @@ void BluetoothRemoteGattServiceChromeOS::GattServicePropertyChanged( VLOG(1) << "Service property changed: \"" << property_name << "\", " << object_path.value(); - BluetoothGattServiceClient::Properties* properties = - DBusThreadManager::Get()->GetBluetoothGattServiceClient()->GetProperties( - object_path); + bluez::BluetoothGattServiceClient::Properties* properties = + bluez::BluezDBusManager::Get() + ->GetBluetoothGattServiceClient() + ->GetProperties(object_path); DCHECK(properties); if (property_name != properties->characteristics.name()) { @@ -257,8 +263,8 @@ void BluetoothRemoteGattServiceChromeOS::GattCharacteristicAdded( return; } - BluetoothGattCharacteristicClient::Properties* properties = - DBusThreadManager::Get() + bluez::BluetoothGattCharacteristicClient::Properties* properties = + bluez::BluezDBusManager::Get() ->GetBluetoothGattCharacteristicClient() ->GetProperties(object_path); DCHECK(properties); @@ -315,8 +321,8 @@ void BluetoothRemoteGattServiceChromeOS::GattCharacteristicPropertyChanged( // "Characteristic Extended Properties" descriptor. In this case, kick off // a service changed observer event to let observers refresh the // characteristics. - BluetoothGattCharacteristicClient::Properties* properties = - DBusThreadManager::Get() + bluez::BluetoothGattCharacteristicClient::Properties* properties = + bluez::BluezDBusManager::Get() ->GetBluetoothGattCharacteristicClient() ->GetProperties(object_path); diff --git a/device/bluetooth/bluetooth_remote_gatt_service_chromeos.h b/device/bluetooth/bluetooth_remote_gatt_service_chromeos.h index 9aa8fdd..bc35cb7 100644 --- a/device/bluetooth/bluetooth_remote_gatt_service_chromeos.h +++ b/device/bluetooth/bluetooth_remote_gatt_service_chromeos.h @@ -12,11 +12,11 @@ #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" -#include "chromeos/dbus/bluetooth_gatt_characteristic_client.h" -#include "chromeos/dbus/bluetooth_gatt_service_client.h" #include "dbus/object_path.h" #include "device/bluetooth/bluetooth_gatt_service.h" #include "device/bluetooth/bluetooth_uuid.h" +#include "device/bluetooth/dbus/bluetooth_gatt_characteristic_client.h" +#include "device/bluetooth/dbus/bluetooth_gatt_service_client.h" namespace device { @@ -36,8 +36,8 @@ class BluetoothRemoteGattDescriptorChromeOS; // for remote GATT services on the Chrome OS platform. class BluetoothRemoteGattServiceChromeOS : public device::BluetoothGattService, - public BluetoothGattServiceClient::Observer, - public BluetoothGattCharacteristicClient::Observer { + public bluez::BluetoothGattServiceClient::Observer, + public bluez::BluetoothGattCharacteristicClient::Observer { public: // device::BluetoothGattService overrides. std::string GetIdentifier() const override; @@ -104,11 +104,11 @@ class BluetoothRemoteGattServiceChromeOS const dbus::ObjectPath& object_path); ~BluetoothRemoteGattServiceChromeOS() override; - // BluetoothGattServiceClient::Observer override. + // bluez::BluetoothGattServiceClient::Observer override. void GattServicePropertyChanged(const dbus::ObjectPath& object_path, const std::string& property_name) override; - // BluetoothGattCharacteristicClient::Observer override. + // bluez::BluetoothGattCharacteristicClient::Observer override. void GattCharacteristicAdded(const dbus::ObjectPath& object_path) override; void GattCharacteristicRemoved(const dbus::ObjectPath& object_path) override; void GattCharacteristicPropertyChanged( diff --git a/device/bluetooth/bluetooth_socket_chromeos.cc b/device/bluetooth/bluetooth_socket_chromeos.cc index da15484..b3e357d 100644 --- a/device/bluetooth/bluetooth_socket_chromeos.cc +++ b/device/bluetooth/bluetooth_socket_chromeos.cc @@ -20,10 +20,6 @@ #include "base/task_runner_util.h" #include "base/threading/thread_restrictions.h" #include "base/threading/worker_pool.h" -#include "chromeos/dbus/bluetooth_device_client.h" -#include "chromeos/dbus/bluetooth_profile_manager_client.h" -#include "chromeos/dbus/bluetooth_profile_service_provider.h" -#include "chromeos/dbus/dbus_thread_manager.h" #include "dbus/bus.h" #include "dbus/file_descriptor.h" #include "dbus/object_path.h" @@ -35,6 +31,10 @@ #include "device/bluetooth/bluetooth_socket.h" #include "device/bluetooth/bluetooth_socket_net.h" #include "device/bluetooth/bluetooth_socket_thread.h" +#include "device/bluetooth/dbus/bluetooth_device_client.h" +#include "device/bluetooth/dbus/bluetooth_profile_manager_client.h" +#include "device/bluetooth/dbus/bluetooth_profile_service_provider.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" #include "net/base/ip_endpoint.h" #include "net/base/net_errors.h" #include "third_party/cros_system_api/dbus/service_constants.h" @@ -107,7 +107,7 @@ void BluetoothSocketChromeOS::Connect( device_address_ = device->GetAddress(); device_path_ = device->object_path(); uuid_ = uuid; - options_.reset(new BluetoothProfileManagerClient::Options()); + options_.reset(new bluez::BluetoothProfileManagerClient::Options()); if (security_level == SECURITY_LEVEL_LOW) options_->require_authentication.reset(new bool(false)); @@ -135,7 +135,7 @@ void BluetoothSocketChromeOS::Listen( adapter_->AddObserver(this); uuid_ = uuid; - options_.reset(new BluetoothProfileManagerClient::Options()); + options_.reset(new bluez::BluetoothProfileManagerClient::Options()); if (service_options.name) options_->name.reset(new std::string(*service_options.name)); @@ -165,7 +165,7 @@ void BluetoothSocketChromeOS::Close() { // In the case below, where an asynchronous task gets posted on the socket // thread in BluetoothSocketNet::Close, a reference will be held to this // socket by the callback. This may cause the BluetoothAdapter to outlive - // DBusThreadManager during shutdown if that callback executes too late. + // BluezDBusManager during shutdown if that callback executes too late. if (adapter_.get()) { adapter_->RemoveObserver(this); adapter_ = nullptr; @@ -264,7 +264,7 @@ void BluetoothSocketChromeOS::OnRegisterProfile( VLOG(1) << uuid_.canonical_value() << ": Got profile, connecting to " << device_path_.value(); - DBusThreadManager::Get()->GetBluetoothDeviceClient()->ConnectProfile( + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->ConnectProfile( device_path_, uuid_.canonical_value(), base::Bind(&BluetoothSocketChromeOS::OnConnectProfile, this, success_callback), @@ -355,7 +355,7 @@ void BluetoothSocketChromeOS::Released() { void BluetoothSocketChromeOS::NewConnection( const dbus::ObjectPath& device_path, scoped_ptr<dbus::FileDescriptor> fd, - const BluetoothProfileServiceProvider::Delegate::Options& options, + const bluez::BluetoothProfileServiceProvider::Delegate::Options& options, const ConfirmationCallback& callback) { DCHECK(ui_task_runner()->RunsTasksOnCurrentThread()); @@ -460,7 +460,7 @@ void BluetoothSocketChromeOS::AcceptConnectionRequest() { void BluetoothSocketChromeOS::DoNewConnection( const dbus::ObjectPath& device_path, scoped_ptr<dbus::FileDescriptor> fd, - const BluetoothProfileServiceProvider::Delegate::Options& options, + const bluez::BluetoothProfileServiceProvider::Delegate::Options& options, const ConfirmationCallback& callback) { DCHECK(socket_thread()->task_runner()->RunsTasksOnCurrentThread()); base::ThreadRestrictions::AssertIOAllowed(); diff --git a/device/bluetooth/bluetooth_socket_chromeos.h b/device/bluetooth/bluetooth_socket_chromeos.h index 98d4d02..a1c76ee2 100644 --- a/device/bluetooth/bluetooth_socket_chromeos.h +++ b/device/bluetooth/bluetooth_socket_chromeos.h @@ -10,14 +10,14 @@ #include "base/memory/linked_ptr.h" #include "base/memory/scoped_ptr.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/bluetooth_profile_manager_client.h" -#include "chromeos/dbus/bluetooth_profile_service_provider.h" #include "dbus/object_path.h" #include "device/bluetooth/bluetooth_adapter.h" +#include "device/bluetooth/bluetooth_export.h" #include "device/bluetooth/bluetooth_socket.h" #include "device/bluetooth/bluetooth_socket_net.h" #include "device/bluetooth/bluetooth_uuid.h" +#include "device/bluetooth/dbus/bluetooth_profile_manager_client.h" +#include "device/bluetooth/dbus/bluetooth_profile_service_provider.h" namespace dbus { class FileDescriptor; @@ -33,10 +33,10 @@ class BluetoothAdapterProfileChromeOS; // Chrome OS platform. // // This class is not thread-safe, but is only called from the UI thread. -class CHROMEOS_EXPORT BluetoothSocketChromeOS +class DEVICE_BLUETOOTH_EXPORT BluetoothSocketChromeOS : public device::BluetoothSocketNet, public device::BluetoothAdapter::Observer, - public BluetoothProfileServiceProvider::Delegate { + public bluez::BluetoothProfileServiceProvider::Delegate { public: enum SecurityLevel { SECURITY_LEVEL_LOW, @@ -112,12 +112,12 @@ class CHROMEOS_EXPORT BluetoothSocketChromeOS void OnInternalRegisterProfile(BluetoothAdapterProfileChromeOS* profile); void OnInternalRegisterProfileError(const std::string& error_message); - // BluetoothProfileServiceProvider::Delegate: + // bluez::BluetoothProfileServiceProvider::Delegate: void Released() override; void NewConnection( const dbus::ObjectPath& device_path, scoped_ptr<dbus::FileDescriptor> fd, - const BluetoothProfileServiceProvider::Delegate::Options& options, + const bluez::BluetoothProfileServiceProvider::Delegate::Options& options, const ConfirmationCallback& callback) override; void RequestDisconnection(const dbus::ObjectPath& device_path, const ConfirmationCallback& callback) override; @@ -131,7 +131,7 @@ class CHROMEOS_EXPORT BluetoothSocketChromeOS void DoNewConnection( const dbus::ObjectPath& device_path, scoped_ptr<dbus::FileDescriptor> fd, - const BluetoothProfileServiceProvider::Delegate::Options& options, + const bluez::BluetoothProfileServiceProvider::Delegate::Options& options, const ConfirmationCallback& callback); // Method run on the UI thread after a new connection has been accepted and @@ -166,7 +166,7 @@ class CHROMEOS_EXPORT BluetoothSocketChromeOS device::BluetoothUUID uuid_; // Copy of the profile options used for registering the profile. - scoped_ptr<BluetoothProfileManagerClient::Options> options_; + scoped_ptr<bluez::BluetoothProfileManagerClient::Options> options_; // The profile registered with the adapter for this socket. BluetoothAdapterProfileChromeOS* profile_; @@ -188,7 +188,7 @@ class CHROMEOS_EXPORT BluetoothSocketChromeOS dbus::ObjectPath device_path; scoped_ptr<dbus::FileDescriptor> fd; - BluetoothProfileServiceProvider::Delegate::Options options; + bluez::BluetoothProfileServiceProvider::Delegate::Options options; ConfirmationCallback callback; bool accepting; bool cancelled; diff --git a/device/bluetooth/bluetooth_socket_chromeos_unittest.cc b/device/bluetooth/bluetooth_socket_chromeos_unittest.cc index 477f3a7..b306008 100644 --- a/device/bluetooth/bluetooth_socket_chromeos_unittest.cc +++ b/device/bluetooth/bluetooth_socket_chromeos_unittest.cc @@ -5,14 +5,6 @@ #include "base/bind.h" #include "base/memory/ref_counted.h" #include "base/message_loop/message_loop.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_adapter_client.h" -#include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" -#include "chromeos/dbus/fake_bluetooth_device_client.h" -#include "chromeos/dbus/fake_bluetooth_gatt_service_client.h" -#include "chromeos/dbus/fake_bluetooth_input_client.h" -#include "chromeos/dbus/fake_bluetooth_profile_manager_client.h" -#include "chromeos/dbus/fake_bluetooth_profile_service_provider.h" #include "device/bluetooth/bluetooth_adapter.h" #include "device/bluetooth/bluetooth_adapter_chromeos.h" #include "device/bluetooth/bluetooth_adapter_factory.h" @@ -22,6 +14,14 @@ #include "device/bluetooth/bluetooth_socket_chromeos.h" #include "device/bluetooth/bluetooth_socket_thread.h" #include "device/bluetooth/bluetooth_uuid.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" +#include "device/bluetooth/dbus/fake_bluetooth_device_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_service_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_input_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_profile_manager_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_profile_service_provider.h" #include "net/base/io_buffer.h" #include "net/base/net_errors.h" #include "testing/gtest/include/gtest/gtest.h" @@ -51,24 +51,27 @@ class BluetoothSocketChromeOSTest : public testing::Test { last_reason_(BluetoothSocket::kSystemError) {} void SetUp() override { - scoped_ptr<DBusThreadManagerSetter> dbus_setter = - DBusThreadManager::GetSetterForTesting(); + scoped_ptr<bluez::BluezDBusManagerSetter> dbus_setter = + bluez::BluezDBusManager::GetSetterForTesting(); dbus_setter->SetBluetoothAdapterClient( - scoped_ptr<BluetoothAdapterClient>(new FakeBluetoothAdapterClient)); + scoped_ptr<bluez::BluetoothAdapterClient>( + new bluez::FakeBluetoothAdapterClient)); dbus_setter->SetBluetoothAgentManagerClient( - scoped_ptr<BluetoothAgentManagerClient>( - new FakeBluetoothAgentManagerClient)); + scoped_ptr<bluez::BluetoothAgentManagerClient>( + new bluez::FakeBluetoothAgentManagerClient)); dbus_setter->SetBluetoothDeviceClient( - scoped_ptr<BluetoothDeviceClient>(new FakeBluetoothDeviceClient)); + scoped_ptr<bluez::BluetoothDeviceClient>( + new bluez::FakeBluetoothDeviceClient)); dbus_setter->SetBluetoothGattServiceClient( - scoped_ptr<BluetoothGattServiceClient>( - new FakeBluetoothGattServiceClient)); + scoped_ptr<bluez::BluetoothGattServiceClient>( + new bluez::FakeBluetoothGattServiceClient)); dbus_setter->SetBluetoothInputClient( - scoped_ptr<BluetoothInputClient>(new FakeBluetoothInputClient)); + scoped_ptr<bluez::BluetoothInputClient>( + new bluez::FakeBluetoothInputClient)); dbus_setter->SetBluetoothProfileManagerClient( - scoped_ptr<BluetoothProfileManagerClient>( - new FakeBluetoothProfileManagerClient)); + scoped_ptr<bluez::BluetoothProfileManagerClient>( + new bluez::FakeBluetoothProfileManagerClient)); BluetoothSocketThread::Get(); @@ -91,7 +94,7 @@ class BluetoothSocketChromeOSTest : public testing::Test { void TearDown() override { adapter_ = nullptr; BluetoothSocketThread::CleanupForTesting(); - DBusThreadManager::Shutdown(); + bluez::BluezDBusManager::Shutdown(); } void AdapterCallback(scoped_refptr<BluetoothAdapter> adapter) { @@ -182,12 +185,12 @@ class BluetoothSocketChromeOSTest : public testing::Test { }; TEST_F(BluetoothSocketChromeOSTest, Connect) { - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kPairedDeviceAddress); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); ASSERT_TRUE(device != nullptr); device->ConnectToService( - BluetoothUUID(FakeBluetoothProfileManagerClient::kRfcommUuid), + BluetoothUUID(bluez::FakeBluetoothProfileManagerClient::kRfcommUuid), base::Bind(&BluetoothSocketChromeOSTest::ConnectToServiceSuccessCallback, base::Unretained(this)), base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, @@ -294,7 +297,7 @@ TEST_F(BluetoothSocketChromeOSTest, Connect) { TEST_F(BluetoothSocketChromeOSTest, Listen) { adapter_->CreateRfcommService( - BluetoothUUID(FakeBluetoothProfileManagerClient::kRfcommUuid), + BluetoothUUID(bluez::FakeBluetoothProfileManagerClient::kRfcommUuid), BluetoothAdapter::ServiceOptions(), base::Bind(&BluetoothSocketChromeOSTest::CreateServiceSuccessCallback, base::Unretained(this)), @@ -319,15 +322,15 @@ TEST_F(BluetoothSocketChromeOSTest, Listen) { // // This is done before the Accept() call to simulate a pending call at the // point that Accept() is called. - FakeBluetoothDeviceClient* fake_bluetooth_device_client = - static_cast<FakeBluetoothDeviceClient*>( - DBusThreadManager::Get()->GetBluetoothDeviceClient()); - BluetoothDevice* device = - adapter_->GetDevice(FakeBluetoothDeviceClient::kPairedDeviceAddress); + bluez::FakeBluetoothDeviceClient* fake_bluetooth_device_client = + static_cast<bluez::FakeBluetoothDeviceClient*>( + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()); + BluetoothDevice* device = adapter_->GetDevice( + bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress); ASSERT_TRUE(device != nullptr); fake_bluetooth_device_client->ConnectProfile( static_cast<BluetoothDeviceChromeOS*>(device)->object_path(), - FakeBluetoothProfileManagerClient::kRfcommUuid, + bluez::FakeBluetoothProfileManagerClient::kRfcommUuid, base::Bind(&base::DoNothing), base::Bind(&DoNothingDBusErrorCallback)); message_loop_.RunUntilIdle(); @@ -374,7 +377,7 @@ TEST_F(BluetoothSocketChromeOSTest, Listen) { fake_bluetooth_device_client->ConnectProfile( static_cast<BluetoothDeviceChromeOS*>(device)->object_path(), - FakeBluetoothProfileManagerClient::kRfcommUuid, + bluez::FakeBluetoothProfileManagerClient::kRfcommUuid, base::Bind(&base::DoNothing), base::Bind(&DoNothingDBusErrorCallback)); message_loop_.Run(); @@ -414,13 +417,13 @@ TEST_F(BluetoothSocketChromeOSTest, Listen) { TEST_F(BluetoothSocketChromeOSTest, ListenBeforeAdapterStart) { // Start off with an invisible adapter, register the profile, then make // the adapter visible. - FakeBluetoothAdapterClient* fake_bluetooth_adapter_client = - static_cast<FakeBluetoothAdapterClient*>( - DBusThreadManager::Get()->GetBluetoothAdapterClient()); + bluez::FakeBluetoothAdapterClient* fake_bluetooth_adapter_client = + static_cast<bluez::FakeBluetoothAdapterClient*>( + bluez::BluezDBusManager::Get()->GetBluetoothAdapterClient()); fake_bluetooth_adapter_client->SetVisible(false); adapter_->CreateRfcommService( - BluetoothUUID(FakeBluetoothProfileManagerClient::kRfcommUuid), + BluetoothUUID(bluez::FakeBluetoothProfileManagerClient::kRfcommUuid), BluetoothAdapter::ServiceOptions(), base::Bind(&BluetoothSocketChromeOSTest::CreateServiceSuccessCallback, base::Unretained(this)), @@ -439,12 +442,14 @@ TEST_F(BluetoothSocketChromeOSTest, ListenBeforeAdapterStart) { error_callback_count_ = 0; // But there shouldn't be a profile registered yet. - FakeBluetoothProfileManagerClient* fake_bluetooth_profile_manager_client = - static_cast<FakeBluetoothProfileManagerClient*>( - DBusThreadManager::Get()->GetBluetoothProfileManagerClient()); - FakeBluetoothProfileServiceProvider* profile_service_provider = + bluez::FakeBluetoothProfileManagerClient* + fake_bluetooth_profile_manager_client = + static_cast<bluez::FakeBluetoothProfileManagerClient*>( + bluez::BluezDBusManager::Get() + ->GetBluetoothProfileManagerClient()); + bluez::FakeBluetoothProfileServiceProvider* profile_service_provider = fake_bluetooth_profile_manager_client->GetProfileServiceProvider( - FakeBluetoothProfileManagerClient::kRfcommUuid); + bluez::FakeBluetoothProfileManagerClient::kRfcommUuid); EXPECT_TRUE(profile_service_provider == nullptr); // Make the adapter visible. This should register a profile. @@ -454,7 +459,7 @@ TEST_F(BluetoothSocketChromeOSTest, ListenBeforeAdapterStart) { profile_service_provider = fake_bluetooth_profile_manager_client->GetProfileServiceProvider( - FakeBluetoothProfileManagerClient::kRfcommUuid); + bluez::FakeBluetoothProfileManagerClient::kRfcommUuid); EXPECT_TRUE(profile_service_provider != nullptr); // Cleanup the socket. @@ -469,12 +474,12 @@ TEST_F(BluetoothSocketChromeOSTest, ListenBeforeAdapterStart) { TEST_F(BluetoothSocketChromeOSTest, ListenAcrossAdapterRestart) { // The fake adapter starts off visible by default. - FakeBluetoothAdapterClient* fake_bluetooth_adapter_client = - static_cast<FakeBluetoothAdapterClient*>( - DBusThreadManager::Get()->GetBluetoothAdapterClient()); + bluez::FakeBluetoothAdapterClient* fake_bluetooth_adapter_client = + static_cast<bluez::FakeBluetoothAdapterClient*>( + bluez::BluezDBusManager::Get()->GetBluetoothAdapterClient()); adapter_->CreateRfcommService( - BluetoothUUID(FakeBluetoothProfileManagerClient::kRfcommUuid), + BluetoothUUID(bluez::FakeBluetoothProfileManagerClient::kRfcommUuid), BluetoothAdapter::ServiceOptions(), base::Bind(&BluetoothSocketChromeOSTest::CreateServiceSuccessCallback, base::Unretained(this)), @@ -493,12 +498,14 @@ TEST_F(BluetoothSocketChromeOSTest, ListenAcrossAdapterRestart) { error_callback_count_ = 0; // Make sure the profile was registered with the daemon. - FakeBluetoothProfileManagerClient* fake_bluetooth_profile_manager_client = - static_cast<FakeBluetoothProfileManagerClient*>( - DBusThreadManager::Get()->GetBluetoothProfileManagerClient()); - FakeBluetoothProfileServiceProvider* profile_service_provider = + bluez::FakeBluetoothProfileManagerClient* + fake_bluetooth_profile_manager_client = + static_cast<bluez::FakeBluetoothProfileManagerClient*>( + bluez::BluezDBusManager::Get() + ->GetBluetoothProfileManagerClient()); + bluez::FakeBluetoothProfileServiceProvider* profile_service_provider = fake_bluetooth_profile_manager_client->GetProfileServiceProvider( - FakeBluetoothProfileManagerClient::kRfcommUuid); + bluez::FakeBluetoothProfileManagerClient::kRfcommUuid); EXPECT_TRUE(profile_service_provider != nullptr); // Make the adapter invisible, and fiddle with the profile fake to unregister @@ -514,7 +521,7 @@ TEST_F(BluetoothSocketChromeOSTest, ListenAcrossAdapterRestart) { profile_service_provider = fake_bluetooth_profile_manager_client->GetProfileServiceProvider( - FakeBluetoothProfileManagerClient::kRfcommUuid); + bluez::FakeBluetoothProfileManagerClient::kRfcommUuid); EXPECT_TRUE(profile_service_provider != nullptr); // Cleanup the socket. @@ -529,11 +536,11 @@ TEST_F(BluetoothSocketChromeOSTest, ListenAcrossAdapterRestart) { TEST_F(BluetoothSocketChromeOSTest, PairedConnectFails) { BluetoothDevice* device = adapter_->GetDevice( - FakeBluetoothDeviceClient::kPairedUnconnectableDeviceAddress); + bluez::FakeBluetoothDeviceClient::kPairedUnconnectableDeviceAddress); ASSERT_TRUE(device != nullptr); device->ConnectToService( - BluetoothUUID(FakeBluetoothProfileManagerClient::kRfcommUuid), + BluetoothUUID(bluez::FakeBluetoothProfileManagerClient::kRfcommUuid), base::Bind(&BluetoothSocketChromeOSTest::ConnectToServiceSuccessCallback, base::Unretained(this)), base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, @@ -545,7 +552,7 @@ TEST_F(BluetoothSocketChromeOSTest, PairedConnectFails) { EXPECT_TRUE(last_socket_.get() == nullptr); device->ConnectToService( - BluetoothUUID(FakeBluetoothProfileManagerClient::kRfcommUuid), + BluetoothUUID(bluez::FakeBluetoothProfileManagerClient::kRfcommUuid), base::Bind(&BluetoothSocketChromeOSTest::ConnectToServiceSuccessCallback, base::Unretained(this)), base::Bind(&BluetoothSocketChromeOSTest::ErrorCallback, @@ -559,7 +566,7 @@ TEST_F(BluetoothSocketChromeOSTest, PairedConnectFails) { TEST_F(BluetoothSocketChromeOSTest, SocketListenTwice) { adapter_->CreateRfcommService( - BluetoothUUID(FakeBluetoothProfileManagerClient::kRfcommUuid), + BluetoothUUID(bluez::FakeBluetoothProfileManagerClient::kRfcommUuid), BluetoothAdapter::ServiceOptions(), base::Bind(&BluetoothSocketChromeOSTest::CreateServiceSuccessCallback, base::Unretained(this)), @@ -592,7 +599,7 @@ TEST_F(BluetoothSocketChromeOSTest, SocketListenTwice) { EXPECT_EQ(1U, error_callback_count_); adapter_->CreateRfcommService( - BluetoothUUID(FakeBluetoothProfileManagerClient::kRfcommUuid), + BluetoothUUID(bluez::FakeBluetoothProfileManagerClient::kRfcommUuid), BluetoothAdapter::ServiceOptions(), base::Bind(&BluetoothSocketChromeOSTest::CreateServiceSuccessCallback, base::Unretained(this)), diff --git a/chromeos/dbus/bluetooth_adapter_client.cc b/device/bluetooth/dbus/bluetooth_adapter_client.cc index 064262e..26081ea 100644 --- a/chromeos/dbus/bluetooth_adapter_client.cc +++ b/device/bluetooth/dbus/bluetooth_adapter_client.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 "chromeos/dbus/bluetooth_adapter_client.h" +#include "device/bluetooth/dbus/bluetooth_adapter_client.h" #include "base/bind.h" #include "base/logging.h" @@ -12,7 +12,7 @@ #include "dbus/object_proxy.h" #include "third_party/cros_system_api/dbus/service_constants.h" -namespace chromeos { +namespace bluez { BluetoothAdapterClient::DiscoveryFilter::DiscoveryFilter() {} @@ -347,4 +347,4 @@ BluetoothAdapterClient* BluetoothAdapterClient::Create() { return new BluetoothAdapterClientImpl; } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/bluetooth_adapter_client.h b/device/bluetooth/dbus/bluetooth_adapter_client.h index c7237d7..4af6658 100644 --- a/chromeos/dbus/bluetooth_adapter_client.h +++ b/device/bluetooth/dbus/bluetooth_adapter_client.h @@ -2,25 +2,26 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_BLUETOOTH_ADAPTER_CLIENT_H_ -#define CHROMEOS_DBUS_BLUETOOTH_ADAPTER_CLIENT_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_ADAPTER_CLIENT_H_ +#define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_ADAPTER_CLIENT_H_ #include <string> #include <vector> #include "base/callback.h" +#include "base/macros.h" #include "base/observer_list.h" #include "base/values.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/dbus_client.h" #include "dbus/object_path.h" #include "dbus/property.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluez_dbus_client.h" -namespace chromeos { +namespace bluez { // BluetoothAdapterClient is used to communicate with objects representing // local Bluetooth Adapters. -class CHROMEOS_EXPORT BluetoothAdapterClient : public DBusClient { +class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterClient : public BluezDBusClient { public: // A DiscoveryFilter represents a filter passed to the SetDiscoveryFilter // method. @@ -36,6 +37,7 @@ class CHROMEOS_EXPORT BluetoothAdapterClient : public DBusClient { scoped_ptr<uint16_t> pathloss; scoped_ptr<std::string> transport; + private: DISALLOW_COPY_AND_ASSIGN(DiscoveryFilter); }; @@ -179,6 +181,6 @@ class CHROMEOS_EXPORT BluetoothAdapterClient : public DBusClient { DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterClient); }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_BLUETOOTH_ADAPTER_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_ADAPTER_CLIENT_H_ diff --git a/chromeos/dbus/bluetooth_agent_manager_client.cc b/device/bluetooth/dbus/bluetooth_agent_manager_client.cc index a5606a9..6caee9b 100644 --- a/chromeos/dbus/bluetooth_agent_manager_client.cc +++ b/device/bluetooth/dbus/bluetooth_agent_manager_client.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 "chromeos/dbus/bluetooth_agent_manager_client.h" +#include "device/bluetooth/dbus/bluetooth_agent_manager_client.h" #include "base/bind.h" #include "base/logging.h" @@ -11,7 +11,7 @@ #include "dbus/object_proxy.h" #include "third_party/cros_system_api/dbus/service_constants.h" -namespace chromeos { +namespace bluez { const char BluetoothAgentManagerClient::kNoResponseError[] = "org.chromium.Error.NoResponse"; @@ -134,4 +134,4 @@ BluetoothAgentManagerClient* BluetoothAgentManagerClient::Create() { return new BluetoothAgentManagerClientImpl(); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/bluetooth_agent_manager_client.h b/device/bluetooth/dbus/bluetooth_agent_manager_client.h index f43f4f8..47402dd 100644 --- a/chromeos/dbus/bluetooth_agent_manager_client.h +++ b/device/bluetooth/dbus/bluetooth_agent_manager_client.h @@ -2,23 +2,25 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_BLUETOOTH_AGENT_MANAGER_CLIENT_H_ -#define CHROMEOS_DBUS_BLUETOOTH_AGENT_MANAGER_CLIENT_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_AGENT_MANAGER_CLIENT_H_ +#define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_AGENT_MANAGER_CLIENT_H_ #include <string> #include <vector> #include "base/callback.h" +#include "base/macros.h" #include "base/values.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/dbus_client.h" #include "dbus/object_path.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluez_dbus_client.h" -namespace chromeos { +namespace bluez { // BluetoothAgentManagerClient is used to communicate with the agent manager // object of the Bluetooth daemon. -class CHROMEOS_EXPORT BluetoothAgentManagerClient : public DBusClient { +class DEVICE_BLUETOOTH_EXPORT BluetoothAgentManagerClient + : public BluezDBusClient { public: ~BluetoothAgentManagerClient() override; @@ -63,6 +65,6 @@ class CHROMEOS_EXPORT BluetoothAgentManagerClient : public DBusClient { DISALLOW_COPY_AND_ASSIGN(BluetoothAgentManagerClient); }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_BLUETOOTH_AGENT_MANAGER_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_AGENT_MANAGER_CLIENT_H_ diff --git a/chromeos/dbus/bluetooth_agent_service_provider.cc b/device/bluetooth/dbus/bluetooth_agent_service_provider.cc index 54ebeb3..7392f2b 100644 --- a/chromeos/dbus/bluetooth_agent_service_provider.cc +++ b/device/bluetooth/dbus/bluetooth_agent_service_provider.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 "chromeos/dbus/bluetooth_agent_service_provider.h" +#include "device/bluetooth/dbus/bluetooth_agent_service_provider.h" #include "base/bind.h" #include "base/logging.h" #include "base/memory/ref_counted.h" #include "base/threading/platform_thread.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_agent_service_provider.h" #include "dbus/exported_object.h" #include "dbus/message.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" +#include "device/bluetooth/dbus/fake_bluetooth_agent_service_provider.h" #include "third_party/cros_system_api/dbus/service_constants.h" -namespace chromeos { +namespace bluez { // The BluetoothAgentServiceProvider implementation used in production. class BluetoothAgentServiceProviderImpl : public BluetoothAgentServiceProvider { @@ -434,11 +434,11 @@ BluetoothAgentServiceProvider* BluetoothAgentServiceProvider::Create( dbus::Bus* bus, const dbus::ObjectPath& object_path, Delegate* delegate) { - if (!DBusThreadManager::Get()->IsUsingStub(DBusClientBundle::BLUETOOTH)) { + if (!bluez::BluezDBusManager::Get()->IsUsingStub()) { return new BluetoothAgentServiceProviderImpl(bus, object_path, delegate); } else { return new FakeBluetoothAgentServiceProvider(object_path, delegate); } } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/bluetooth_agent_service_provider.h b/device/bluetooth/dbus/bluetooth_agent_service_provider.h index 8e84fa5..e31ef8f 100644 --- a/chromeos/dbus/bluetooth_agent_service_provider.h +++ b/device/bluetooth/dbus/bluetooth_agent_service_provider.h @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_ -#define CHROMEOS_DBUS_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_ +#define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_ #include <string> #include "base/basictypes.h" #include "base/callback.h" -#include "chromeos/chromeos_export.h" #include "dbus/bus.h" #include "dbus/object_path.h" +#include "device/bluetooth/bluetooth_export.h" -namespace chromeos { +namespace bluez { // BluetoothAgentServiceProvider is used to provide a D-Bus object that // the bluetooth daemon can communicate with during a remote device pairing @@ -28,7 +28,7 @@ namespace chromeos { // 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. -class CHROMEOS_EXPORT BluetoothAgentServiceProvider { +class DEVICE_BLUETOOTH_EXPORT BluetoothAgentServiceProvider { public: // Interface for reacting to agent requests. class Delegate { @@ -173,6 +173,6 @@ class CHROMEOS_EXPORT BluetoothAgentServiceProvider { DISALLOW_COPY_AND_ASSIGN(BluetoothAgentServiceProvider); }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_ +#endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_ diff --git a/device/bluetooth/dbus/bluetooth_dbus_client_bundle.cc b/device/bluetooth/dbus/bluetooth_dbus_client_bundle.cc new file mode 100644 index 0000000..29a4ce8 --- /dev/null +++ b/device/bluetooth/dbus/bluetooth_dbus_client_bundle.cc @@ -0,0 +1,84 @@ +// Copyright 2014 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/bluetooth_dbus_client_bundle.h" + +#include <vector> + +#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" +#include "device/bluetooth/dbus/bluetooth_gatt_characteristic_client.h" +#include "device/bluetooth/dbus/bluetooth_gatt_descriptor_client.h" +#include "device/bluetooth/dbus/bluetooth_gatt_manager_client.h" +#include "device/bluetooth/dbus/bluetooth_gatt_service_client.h" +#include "device/bluetooth/dbus/bluetooth_input_client.h" +#include "device/bluetooth/dbus/bluetooth_le_advertising_manager_client.h" +#include "device/bluetooth/dbus/bluetooth_media_client.h" +#include "device/bluetooth/dbus/bluetooth_media_transport_client.h" +#include "device/bluetooth/dbus/bluetooth_profile_manager_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_agent_manager_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_device_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_manager_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_service_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_input_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_le_advertising_manager_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_media_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_media_transport_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_profile_manager_client.h" + +namespace bluez { + +BluetoothDBusClientBundle::BluetoothDBusClientBundle(bool use_stubs) + : use_stubs_(use_stubs) { + if (!use_stubs) { + bluetooth_adapter_client_.reset(BluetoothAdapterClient::Create()); + bluetooth_le_advertising_manager_client_.reset( + BluetoothLEAdvertisingManagerClient::Create()); + bluetooth_agent_manager_client_.reset( + BluetoothAgentManagerClient::Create()); + bluetooth_device_client_.reset(BluetoothDeviceClient::Create()); + bluetooth_input_client_.reset(BluetoothInputClient::Create()); + bluetooth_media_client_.reset(BluetoothMediaClient::Create()); + bluetooth_media_transport_client_.reset( + BluetoothMediaTransportClient::Create()); + bluetooth_profile_manager_client_.reset( + BluetoothProfileManagerClient::Create()); + bluetooth_gatt_characteristic_client_.reset( + BluetoothGattCharacteristicClient::Create()); + bluetooth_gatt_descriptor_client_.reset( + BluetoothGattDescriptorClient::Create()); + bluetooth_gatt_manager_client_.reset(BluetoothGattManagerClient::Create()); + bluetooth_gatt_service_client_.reset(BluetoothGattServiceClient::Create()); + } else { + bluetooth_adapter_client_.reset(new FakeBluetoothAdapterClient); + bluetooth_le_advertising_manager_client_.reset( + new FakeBluetoothLEAdvertisingManagerClient); + bluetooth_agent_manager_client_.reset(new FakeBluetoothAgentManagerClient); + bluetooth_device_client_.reset(new FakeBluetoothDeviceClient); + bluetooth_input_client_.reset(new FakeBluetoothInputClient); + bluetooth_media_client_.reset(new FakeBluetoothMediaClient); + bluetooth_media_transport_client_.reset( + new FakeBluetoothMediaTransportClient); + bluetooth_profile_manager_client_.reset( + new FakeBluetoothProfileManagerClient); + bluetooth_gatt_characteristic_client_.reset( + new FakeBluetoothGattCharacteristicClient); + bluetooth_gatt_descriptor_client_.reset( + new FakeBluetoothGattDescriptorClient); + bluetooth_gatt_manager_client_.reset(new FakeBluetoothGattManagerClient); + bluetooth_gatt_service_client_.reset(new FakeBluetoothGattServiceClient); + } +} + +BluetoothDBusClientBundle::~BluetoothDBusClientBundle() {} + +} // namespace bluez diff --git a/device/bluetooth/dbus/bluetooth_dbus_client_bundle.h b/device/bluetooth/dbus/bluetooth_dbus_client_bundle.h new file mode 100644 index 0000000..3beef61 --- /dev/null +++ b/device/bluetooth/dbus/bluetooth_dbus_client_bundle.h @@ -0,0 +1,114 @@ +// Copyright 2014 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_BLUETOOTH_DBUS_CLIENT_BUNDLE_H_ +#define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_DBUS_CLIENT_BUNDLE_H_ + +#include <string> + +#include "base/macros.h" +#include "base/memory/scoped_ptr.h" +#include "device/bluetooth/bluetooth_export.h" + +namespace bluez { + +class BluetoothAdapterClient; +class BluetoothAgentManagerClient; +class BluetoothDeviceClient; +class BluetoothGattCharacteristicClient; +class BluetoothGattDescriptorClient; +class BluetoothGattManagerClient; +class BluetoothGattServiceClient; +class BluetoothInputClient; +class BluetoothLEAdvertisingManagerClient; +class BluetoothMediaClient; +class BluetoothMediaTransportClient; +class BluetoothProfileManagerClient; + +// The bundle of all D-Bus clients used in DBusThreadManager. The bundle +// is used to delete them at once in the right order before shutting down the +// system bus. See also the comment in the destructor of DBusThreadManager. +class DEVICE_BLUETOOTH_EXPORT BluetoothDBusClientBundle { + public: + explicit BluetoothDBusClientBundle(bool use_stubs); + ~BluetoothDBusClientBundle(); + + // Returns true if |client| is stubbed. + bool IsUsingStub() { return use_stubs_; } + + BluetoothAdapterClient* bluetooth_adapter_client() { + return bluetooth_adapter_client_.get(); + } + + BluetoothLEAdvertisingManagerClient* + bluetooth_le_advertising_manager_client() { + return bluetooth_le_advertising_manager_client_.get(); + } + + BluetoothAgentManagerClient* bluetooth_agent_manager_client() { + return bluetooth_agent_manager_client_.get(); + } + + BluetoothDeviceClient* bluetooth_device_client() { + return bluetooth_device_client_.get(); + } + + BluetoothGattCharacteristicClient* bluetooth_gatt_characteristic_client() { + return bluetooth_gatt_characteristic_client_.get(); + } + + BluetoothGattDescriptorClient* bluetooth_gatt_descriptor_client() { + return bluetooth_gatt_descriptor_client_.get(); + } + + BluetoothGattManagerClient* bluetooth_gatt_manager_client() { + return bluetooth_gatt_manager_client_.get(); + } + + BluetoothGattServiceClient* bluetooth_gatt_service_client() { + return bluetooth_gatt_service_client_.get(); + } + + BluetoothInputClient* bluetooth_input_client() { + return bluetooth_input_client_.get(); + } + + BluetoothMediaClient* bluetooth_media_client() { + return bluetooth_media_client_.get(); + } + + BluetoothMediaTransportClient* bluetooth_media_transport_client() { + return bluetooth_media_transport_client_.get(); + } + + BluetoothProfileManagerClient* bluetooth_profile_manager_client() { + return bluetooth_profile_manager_client_.get(); + } + + private: + friend class BluezDBusManagerSetter; + + bool use_stubs_; + + scoped_ptr<BluetoothAdapterClient> bluetooth_adapter_client_; + scoped_ptr<BluetoothLEAdvertisingManagerClient> + bluetooth_le_advertising_manager_client_; + scoped_ptr<BluetoothAgentManagerClient> bluetooth_agent_manager_client_; + scoped_ptr<BluetoothDeviceClient> bluetooth_device_client_; + scoped_ptr<BluetoothGattCharacteristicClient> + bluetooth_gatt_characteristic_client_; + scoped_ptr<BluetoothGattDescriptorClient> bluetooth_gatt_descriptor_client_; + scoped_ptr<BluetoothGattManagerClient> bluetooth_gatt_manager_client_; + scoped_ptr<BluetoothGattServiceClient> bluetooth_gatt_service_client_; + scoped_ptr<BluetoothInputClient> bluetooth_input_client_; + scoped_ptr<BluetoothMediaClient> bluetooth_media_client_; + scoped_ptr<BluetoothMediaTransportClient> bluetooth_media_transport_client_; + scoped_ptr<BluetoothProfileManagerClient> bluetooth_profile_manager_client_; + + DISALLOW_COPY_AND_ASSIGN(BluetoothDBusClientBundle); +}; + +} // namespace bluez + +#endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_DBUS_CLIENT_BUNDLE_H_ diff --git a/chromeos/dbus/bluetooth_device_client.cc b/device/bluetooth/dbus/bluetooth_device_client.cc index 8fcf74b..7aaafa2 100644 --- a/chromeos/dbus/bluetooth_device_client.cc +++ b/device/bluetooth/dbus/bluetooth_device_client.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 "chromeos/dbus/bluetooth_device_client.h" +#include "device/bluetooth/dbus/bluetooth_device_client.h" #include "base/bind.h" #include "base/logging.h" @@ -13,7 +13,7 @@ #include "dbus/object_proxy.h" #include "third_party/cros_system_api/dbus/service_constants.h" -namespace chromeos { +namespace bluez { namespace { @@ -376,4 +376,4 @@ BluetoothDeviceClient* BluetoothDeviceClient::Create() { return new BluetoothDeviceClientImpl(); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/bluetooth_device_client.h b/device/bluetooth/dbus/bluetooth_device_client.h index e9c2905..33b3f5d 100644 --- a/chromeos/dbus/bluetooth_device_client.h +++ b/device/bluetooth/dbus/bluetooth_device_client.h @@ -2,25 +2,26 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_BLUETOOTH_DEVICE_CLIENT_H_ -#define CHROMEOS_DBUS_BLUETOOTH_DEVICE_CLIENT_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_DEVICE_CLIENT_H_ +#define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_DEVICE_CLIENT_H_ #include <string> #include <vector> #include "base/callback.h" +#include "base/macros.h" #include "base/observer_list.h" #include "base/values.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/dbus_client.h" #include "dbus/object_path.h" #include "dbus/property.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluez_dbus_client.h" -namespace chromeos { +namespace bluez { // BluetoothDeviceClient is used to communicate with objects representing // remote Bluetooth Devices. -class CHROMEOS_EXPORT BluetoothDeviceClient : public DBusClient { +class DEVICE_BLUETOOTH_EXPORT BluetoothDeviceClient : public BluezDBusClient { public: // Structure of properties associated with bluetooth devices. struct Properties : public dbus::PropertySet { @@ -207,6 +208,6 @@ class CHROMEOS_EXPORT BluetoothDeviceClient : public DBusClient { DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceClient); }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_BLUETOOTH_DEVICE_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_DEVICE_CLIENT_H_ diff --git a/chromeos/dbus/bluetooth_gatt_characteristic_client.cc b/device/bluetooth/dbus/bluetooth_gatt_characteristic_client.cc index 8e241e6..6000a52 100644 --- a/chromeos/dbus/bluetooth_gatt_characteristic_client.cc +++ b/device/bluetooth/dbus/bluetooth_gatt_characteristic_client.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 "chromeos/dbus/bluetooth_gatt_characteristic_client.h" +#include "device/bluetooth/dbus/bluetooth_gatt_characteristic_client.h" #include "base/bind.h" #include "base/memory/weak_ptr.h" @@ -11,7 +11,7 @@ #include "dbus/object_manager.h" #include "third_party/cros_system_api/dbus/service_constants.h" -namespace chromeos { +namespace bluez { namespace { @@ -300,4 +300,4 @@ BluetoothGattCharacteristicClient* BluetoothGattCharacteristicClient::Create() { return new BluetoothGattCharacteristicClientImpl(); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/bluetooth_gatt_characteristic_client.h b/device/bluetooth/dbus/bluetooth_gatt_characteristic_client.h index b040b56..3c476eb 100644 --- a/chromeos/dbus/bluetooth_gatt_characteristic_client.h +++ b/device/bluetooth/dbus/bluetooth_gatt_characteristic_client.h @@ -2,24 +2,25 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ -#define CHROMEOS_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ +#define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ #include <string> #include <vector> #include "base/basictypes.h" #include "base/callback.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/dbus_client.h" #include "dbus/object_path.h" #include "dbus/property.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluez_dbus_client.h" -namespace chromeos { +namespace bluez { // BluetoothGattCharacteristicClient is used to communicate with remote GATT // characteristic objects exposed by the Bluetooth daemon. -class CHROMEOS_EXPORT BluetoothGattCharacteristicClient : public DBusClient { +class DEVICE_BLUETOOTH_EXPORT BluetoothGattCharacteristicClient + : public BluezDBusClient { public: // Structure of properties associated with GATT characteristics. struct Properties : public dbus::PropertySet { @@ -138,6 +139,6 @@ class CHROMEOS_EXPORT BluetoothGattCharacteristicClient : public DBusClient { DISALLOW_COPY_AND_ASSIGN(BluetoothGattCharacteristicClient); }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ diff --git a/chromeos/dbus/bluetooth_gatt_characteristic_service_provider.cc b/device/bluetooth/dbus/bluetooth_gatt_characteristic_service_provider.cc index 856e60d..4decdf0 100644 --- a/chromeos/dbus/bluetooth_gatt_characteristic_service_provider.cc +++ b/device/bluetooth/dbus/bluetooth_gatt_characteristic_service_provider.cc @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/dbus/bluetooth_gatt_characteristic_service_provider.h" +#include "device/bluetooth/dbus/bluetooth_gatt_characteristic_service_provider.h" #include "base/bind.h" #include "base/logging.h" #include "base/memory/weak_ptr.h" #include "base/strings/string_util.h" #include "base/threading/platform_thread.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_gatt_characteristic_service_provider.h" #include "dbus/exported_object.h" #include "dbus/message.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provider.h" #include "third_party/cros_system_api/dbus/service_constants.h" -namespace chromeos { +namespace bluez { namespace { const char kErrorInvalidArgs[] = "org.freedesktop.DBus.Error.InvalidArgs"; const char kErrorPropertyReadOnly[] = @@ -453,7 +453,7 @@ BluetoothGattCharacteristicServiceProvider::Create( const std::vector<std::string>& flags, const std::vector<std::string>& permissions, const dbus::ObjectPath& service_path) { - if (!DBusThreadManager::Get()->IsUsingStub(DBusClientBundle::BLUETOOTH)) { + if (!bluez::BluezDBusManager::Get()->IsUsingStub()) { return new BluetoothGattCharacteristicServiceProviderImpl( bus, object_path, delegate, uuid, flags, permissions, service_path); } @@ -461,4 +461,4 @@ BluetoothGattCharacteristicServiceProvider::Create( object_path, delegate, uuid, flags, permissions, service_path); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/bluetooth_gatt_characteristic_service_provider.h b/device/bluetooth/dbus/bluetooth_gatt_characteristic_service_provider.h index 174a908..ad5d999 100644 --- a/chromeos/dbus/bluetooth_gatt_characteristic_service_provider.h +++ b/device/bluetooth/dbus/bluetooth_gatt_characteristic_service_provider.h @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_SERVICE_PROVIDER_H_ -#define CHROMEOS_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_SERVICE_PROVIDER_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_SERVICE_PROVIDER_H_ +#define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_SERVICE_PROVIDER_H_ #include <string> #include <vector> #include "base/basictypes.h" #include "base/callback.h" -#include "chromeos/chromeos_export.h" #include "dbus/bus.h" #include "dbus/object_path.h" +#include "device/bluetooth/bluetooth_export.h" -namespace chromeos { +namespace bluez { // BluetoothGattCharacteristicServiceProvider is used to provide a D-Bus object // that represents a local GATT characteristic that the Bluetooth daemon can @@ -30,7 +30,7 @@ namespace chromeos { // mandatory during initialization. In addition, a "SendValueChanged" method is // provided, which emits a DBus.Properties.PropertyChanged signal for the // "Value" property. -class CHROMEOS_EXPORT BluetoothGattCharacteristicServiceProvider { +class DEVICE_BLUETOOTH_EXPORT BluetoothGattCharacteristicServiceProvider { public: // Interface for reacting to GATT characteristic value requests. class Delegate { @@ -108,6 +108,6 @@ class CHROMEOS_EXPORT BluetoothGattCharacteristicServiceProvider { DISALLOW_COPY_AND_ASSIGN(BluetoothGattCharacteristicServiceProvider); }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_SERVICE_PROVIDER_H_ +#endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_SERVICE_PROVIDER_H_ diff --git a/chromeos/dbus/bluetooth_gatt_descriptor_client.cc b/device/bluetooth/dbus/bluetooth_gatt_descriptor_client.cc index 4d97415..f3ba343 100644 --- a/chromeos/dbus/bluetooth_gatt_descriptor_client.cc +++ b/device/bluetooth/dbus/bluetooth_gatt_descriptor_client.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 "chromeos/dbus/bluetooth_gatt_descriptor_client.h" +#include "device/bluetooth/dbus/bluetooth_gatt_descriptor_client.h" #include "base/bind.h" #include "base/memory/weak_ptr.h" @@ -11,7 +11,7 @@ #include "dbus/object_manager.h" #include "third_party/cros_system_api/dbus/service_constants.h" -namespace chromeos { +namespace bluez { namespace { @@ -248,4 +248,4 @@ BluetoothGattDescriptorClient* BluetoothGattDescriptorClient::Create() { return new BluetoothGattDescriptorClientImpl(); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/bluetooth_gatt_descriptor_client.h b/device/bluetooth/dbus/bluetooth_gatt_descriptor_client.h index 15d3d9c..364331e 100644 --- a/chromeos/dbus/bluetooth_gatt_descriptor_client.h +++ b/device/bluetooth/dbus/bluetooth_gatt_descriptor_client.h @@ -2,24 +2,25 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_BLUETOOTH_GATT_DESCRIPTOR_CLIENT_H_ -#define CHROMEOS_DBUS_BLUETOOTH_GATT_DESCRIPTOR_CLIENT_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_DESCRIPTOR_CLIENT_H_ +#define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_DESCRIPTOR_CLIENT_H_ #include <string> #include <vector> #include "base/basictypes.h" #include "base/callback.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/dbus_client.h" #include "dbus/object_path.h" #include "dbus/property.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluez_dbus_client.h" -namespace chromeos { +namespace bluez { // BluetoothGattDescriptorClient is used to communicate with remote GATT // characteristic descriptor objects exposed by the Bluetooth daemon. -class CHROMEOS_EXPORT BluetoothGattDescriptorClient : public DBusClient { +class DEVICE_BLUETOOTH_EXPORT BluetoothGattDescriptorClient + : public BluezDBusClient { public: // Structure of properties associated with GATT descriptors. struct Properties : public dbus::PropertySet { @@ -110,6 +111,6 @@ class CHROMEOS_EXPORT BluetoothGattDescriptorClient : public DBusClient { DISALLOW_COPY_AND_ASSIGN(BluetoothGattDescriptorClient); }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_BLUETOOTH_GATT_DESCRIPTOR_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_DESCRIPTOR_CLIENT_H_ diff --git a/chromeos/dbus/bluetooth_gatt_descriptor_service_provider.cc b/device/bluetooth/dbus/bluetooth_gatt_descriptor_service_provider.cc index 1fe1657..e4aa245 100644 --- a/chromeos/dbus/bluetooth_gatt_descriptor_service_provider.cc +++ b/device/bluetooth/dbus/bluetooth_gatt_descriptor_service_provider.cc @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/dbus/bluetooth_gatt_descriptor_service_provider.h" +#include "device/bluetooth/dbus/bluetooth_gatt_descriptor_service_provider.h" #include "base/bind.h" #include "base/logging.h" #include "base/memory/weak_ptr.h" #include "base/strings/string_util.h" #include "base/threading/platform_thread.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_gatt_descriptor_service_provider.h" #include "dbus/exported_object.h" #include "dbus/message.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_service_provider.h" #include "third_party/cros_system_api/dbus/service_constants.h" -namespace chromeos { +namespace bluez { namespace { const char kErrorInvalidArgs[] = "org.freedesktop.DBus.Error.InvalidArgs"; const char kErrorPropertyReadOnly[] = @@ -446,7 +446,7 @@ BluetoothGattDescriptorServiceProvider::Create( const std::string& uuid, const std::vector<std::string>& permissions, const dbus::ObjectPath& characteristic_path) { - if (!DBusThreadManager::Get()->IsUsingStub(DBusClientBundle::BLUETOOTH)) { + if (!bluez::BluezDBusManager::Get()->IsUsingStub()) { return new BluetoothGattDescriptorServiceProviderImpl( bus, object_path, delegate, uuid, permissions, characteristic_path); } @@ -454,4 +454,4 @@ BluetoothGattDescriptorServiceProvider::Create( object_path, delegate, uuid, permissions, characteristic_path); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/bluetooth_gatt_descriptor_service_provider.h b/device/bluetooth/dbus/bluetooth_gatt_descriptor_service_provider.h index 4b5fef8..e4925ff 100644 --- a/chromeos/dbus/bluetooth_gatt_descriptor_service_provider.h +++ b/device/bluetooth/dbus/bluetooth_gatt_descriptor_service_provider.h @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_BLUETOOTH_GATT_DESCRIPTOR_SERVICE_PROVIDER_H_ -#define CHROMEOS_DBUS_BLUETOOTH_GATT_DESCRIPTOR_SERVICE_PROVIDER_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_DESCRIPTOR_SERVICE_PROVIDER_H_ +#define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_DESCRIPTOR_SERVICE_PROVIDER_H_ #include <string> #include <vector> #include "base/basictypes.h" #include "base/callback.h" -#include "chromeos/chromeos_export.h" #include "dbus/bus.h" #include "dbus/object_path.h" +#include "device/bluetooth/bluetooth_export.h" -namespace chromeos { +namespace bluez { // BluetoothGattDescriptorServiceProvider is used to provide a D-Bus object that // represents a local GATT characteristic descriptor that the Bluetooth daemon @@ -30,7 +30,7 @@ namespace chromeos { // mandatory during initialization. In addition, a "SendValueChanged" method is // provided, which emits a DBus.Properties.PropertyChanged signal for the // "Value" property. -class CHROMEOS_EXPORT BluetoothGattDescriptorServiceProvider { +class DEVICE_BLUETOOTH_EXPORT BluetoothGattDescriptorServiceProvider { public: // Interface for reacting to GATT characteristic descriptor value requests. class Delegate { @@ -104,6 +104,6 @@ class CHROMEOS_EXPORT BluetoothGattDescriptorServiceProvider { DISALLOW_COPY_AND_ASSIGN(BluetoothGattDescriptorServiceProvider); }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_BLUETOOTH_GATT_DESCRIPTOR_SERVICE_PROVIDER_H_ +#endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_DESCRIPTOR_SERVICE_PROVIDER_H_ diff --git a/chromeos/dbus/bluetooth_gatt_manager_client.cc b/device/bluetooth/dbus/bluetooth_gatt_manager_client.cc index b3e98c6..7e471a5 100644 --- a/chromeos/dbus/bluetooth_gatt_manager_client.cc +++ b/device/bluetooth/dbus/bluetooth_gatt_manager_client.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 "chromeos/dbus/bluetooth_gatt_manager_client.h" +#include "device/bluetooth/dbus/bluetooth_gatt_manager_client.h" #include "base/bind.h" #include "base/memory/weak_ptr.h" @@ -11,7 +11,7 @@ #include "dbus/object_proxy.h" #include "third_party/cros_system_api/dbus/service_constants.h" -namespace chromeos { +namespace bluez { const char BluetoothGattManagerClient::kNoResponseError[] = "org.chromium.Error.NoResponse"; @@ -126,4 +126,4 @@ BluetoothGattManagerClient* BluetoothGattManagerClient::Create() { return new BluetoothGattManagerClientImpl(); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/bluetooth_gatt_manager_client.h b/device/bluetooth/dbus/bluetooth_gatt_manager_client.h index 7a16a0b..b735f77 100644 --- a/chromeos/dbus/bluetooth_gatt_manager_client.h +++ b/device/bluetooth/dbus/bluetooth_gatt_manager_client.h @@ -2,24 +2,26 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_BLUETOOTH_GATT_MANAGER_CLIENT_H_ -#define CHROMEOS_DBUS_BLUETOOTH_GATT_MANAGER_CLIENT_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_MANAGER_CLIENT_H_ +#define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_MANAGER_CLIENT_H_ #include <string> #include "base/callback.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/dbus_client.h" +#include "base/macros.h" #include "dbus/object_path.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluez_dbus_client.h" -namespace chromeos { +namespace bluez { // BluetoothGattManagerClient is used to communicate with the GATT Service // manager object of the Bluetooth daemon. -class CHROMEOS_EXPORT BluetoothGattManagerClient : public DBusClient { +class DEVICE_BLUETOOTH_EXPORT BluetoothGattManagerClient + : public BluezDBusClient { public: // Options used to register a GATT service hierarchy. - struct CHROMEOS_EXPORT Options { + struct DEVICE_BLUETOOTH_EXPORT Options { // TODO(armansito): This parameter is not yet clearly defined. Add fields // later as we know more about how this will be used. }; @@ -67,6 +69,6 @@ class CHROMEOS_EXPORT BluetoothGattManagerClient : public DBusClient { DISALLOW_COPY_AND_ASSIGN(BluetoothGattManagerClient); }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_BLUETOOTH_GATT_MANAGER_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_MANAGER_CLIENT_H_ diff --git a/chromeos/dbus/bluetooth_gatt_service_client.cc b/device/bluetooth/dbus/bluetooth_gatt_service_client.cc index 53572f0..dc3ef5a 100644 --- a/chromeos/dbus/bluetooth_gatt_service_client.cc +++ b/device/bluetooth/dbus/bluetooth_gatt_service_client.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 "chromeos/dbus/bluetooth_gatt_service_client.h" +#include "device/bluetooth/dbus/bluetooth_gatt_service_client.h" #include "base/bind.h" #include "base/memory/weak_ptr.h" @@ -11,7 +11,7 @@ #include "dbus/object_manager.h" #include "third_party/cros_system_api/dbus/service_constants.h" -namespace chromeos { +namespace bluez { BluetoothGattServiceClient::Properties::Properties( dbus::ObjectProxy* object_proxy, @@ -140,4 +140,4 @@ BluetoothGattServiceClient* BluetoothGattServiceClient::Create() { return new BluetoothGattServiceClientImpl(); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/bluetooth_gatt_service_client.h b/device/bluetooth/dbus/bluetooth_gatt_service_client.h index 9c96bb8..641f505 100644 --- a/chromeos/dbus/bluetooth_gatt_service_client.h +++ b/device/bluetooth/dbus/bluetooth_gatt_service_client.h @@ -2,22 +2,24 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_BLUETOOTH_GATT_SERVICE_CLIENT_H_ -#define CHROMEOS_DBUS_BLUETOOTH_GATT_SERVICE_CLIENT_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_SERVICE_CLIENT_H_ +#define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_SERVICE_CLIENT_H_ #include <string> #include <vector> -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/dbus_client.h" +#include "base/macros.h" #include "dbus/object_path.h" #include "dbus/property.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluez_dbus_client.h" -namespace chromeos { +namespace bluez { // BluetoothGattServiceClient is used to communicate with remote GATT service // objects exposed by the Bluetooth daemon. -class CHROMEOS_EXPORT BluetoothGattServiceClient : public DBusClient { +class DEVICE_BLUETOOTH_EXPORT BluetoothGattServiceClient + : public BluezDBusClient { public: // Structure of properties associated with GATT services. struct Properties : public dbus::PropertySet { @@ -88,6 +90,6 @@ class CHROMEOS_EXPORT BluetoothGattServiceClient : public DBusClient { DISALLOW_COPY_AND_ASSIGN(BluetoothGattServiceClient); }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_BLUETOOTH_GATT_SERVICE_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_SERVICE_CLIENT_H_ diff --git a/chromeos/dbus/bluetooth_gatt_service_service_provider.cc b/device/bluetooth/dbus/bluetooth_gatt_service_service_provider.cc index 9de86d4..06b6827 100644 --- a/chromeos/dbus/bluetooth_gatt_service_service_provider.cc +++ b/device/bluetooth/dbus/bluetooth_gatt_service_service_provider.cc @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/dbus/bluetooth_gatt_service_service_provider.h" +#include "device/bluetooth/dbus/bluetooth_gatt_service_service_provider.h" #include "base/bind.h" #include "base/logging.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/threading/platform_thread.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_gatt_service_service_provider.h" #include "dbus/exported_object.h" #include "dbus/message.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_service_service_provider.h" #include "third_party/cros_system_api/dbus/service_constants.h" -namespace chromeos { +namespace bluez { namespace { const char kErrorInvalidArgs[] = "org.freedesktop.DBus.Error.InvalidArgs"; const char kErrorPropertyReadOnly[] = @@ -261,7 +261,7 @@ BluetoothGattServiceServiceProvider::Create( const dbus::ObjectPath& object_path, const std::string& uuid, const std::vector<dbus::ObjectPath>& includes) { - if (!DBusThreadManager::Get()->IsUsingStub(DBusClientBundle::BLUETOOTH)) { + if (!bluez::BluezDBusManager::Get()->IsUsingStub()) { return new BluetoothGattServiceServiceProviderImpl(bus, object_path, uuid, includes); } @@ -269,4 +269,4 @@ BluetoothGattServiceServiceProvider::Create( includes); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/bluetooth_gatt_service_service_provider.h b/device/bluetooth/dbus/bluetooth_gatt_service_service_provider.h index 258c4b4..cedec1e 100644 --- a/chromeos/dbus/bluetooth_gatt_service_service_provider.h +++ b/device/bluetooth/dbus/bluetooth_gatt_service_service_provider.h @@ -2,17 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_BLUETOOTH_GATT_SERVICE_SERVICE_PROVIDER_H_ -#define CHROMEOS_DBUS_BLUETOOTH_GATT_SERVICE_SERVICE_PROVIDER_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_SERVICE_SERVICE_PROVIDER_H_ +#define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_SERVICE_SERVICE_PROVIDER_H_ #include <string> #include <vector> -#include "chromeos/chromeos_export.h" +#include "base/macros.h" #include "dbus/bus.h" #include "dbus/object_path.h" +#include "device/bluetooth/bluetooth_export.h" -namespace chromeos { +namespace bluez { // BluetoothGattServiceServiceProvider is used to provide a D-Bus object that // the Bluetooth daemon can communicate with to register GATT service @@ -24,7 +25,7 @@ namespace chromeos { // chromeos::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 CHROMEOS_EXPORT BluetoothGattServiceServiceProvider { +class DEVICE_BLUETOOTH_EXPORT BluetoothGattServiceServiceProvider { public: virtual ~BluetoothGattServiceServiceProvider(); @@ -47,6 +48,6 @@ class CHROMEOS_EXPORT BluetoothGattServiceServiceProvider { DISALLOW_COPY_AND_ASSIGN(BluetoothGattServiceServiceProvider); }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_BLUETOOTH_GATT_SERVICE_SERVICE_PROVIDER_H_ +#endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_SERVICE_SERVICE_PROVIDER_H_ diff --git a/chromeos/dbus/bluetooth_input_client.cc b/device/bluetooth/dbus/bluetooth_input_client.cc index e8b1c8d..42542a8 100644 --- a/chromeos/dbus/bluetooth_input_client.cc +++ b/device/bluetooth/dbus/bluetooth_input_client.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 "chromeos/dbus/bluetooth_input_client.h" +#include "device/bluetooth/dbus/bluetooth_input_client.h" #include <map> @@ -14,7 +14,7 @@ #include "dbus/object_proxy.h" #include "third_party/cros_system_api/dbus/service_constants.h" -namespace chromeos { +namespace bluez { BluetoothInputClient::Properties::Properties( dbus::ObjectProxy* object_proxy, @@ -125,4 +125,4 @@ BluetoothInputClient* BluetoothInputClient::Create() { return new BluetoothInputClientImpl(); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/bluetooth_input_client.h b/device/bluetooth/dbus/bluetooth_input_client.h index 02abf99..829e94c 100644 --- a/chromeos/dbus/bluetooth_input_client.h +++ b/device/bluetooth/dbus/bluetooth_input_client.h @@ -2,24 +2,25 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_BLUETOOTH_INPUT_CLIENT_H_ -#define CHROMEOS_DBUS_BLUETOOTH_INPUT_CLIENT_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_INPUT_CLIENT_H_ +#define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_INPUT_CLIENT_H_ #include <string> #include <vector> #include "base/callback.h" +#include "base/macros.h" #include "base/observer_list.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/dbus_client.h" #include "dbus/object_path.h" #include "dbus/property.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluez_dbus_client.h" -namespace chromeos { +namespace bluez { // BluetoothInputClient is used to communicate with objects representing // Bluetooth Input (HID) devices. -class CHROMEOS_EXPORT BluetoothInputClient : public DBusClient { +class DEVICE_BLUETOOTH_EXPORT BluetoothInputClient : public BluezDBusClient { public: // Structure of properties associated with bluetooth input devices. struct Properties : public dbus::PropertySet { @@ -76,6 +77,6 @@ class CHROMEOS_EXPORT BluetoothInputClient : public DBusClient { DISALLOW_COPY_AND_ASSIGN(BluetoothInputClient); }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_BLUETOOTH_INPUT_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_INPUT_CLIENT_H_ diff --git a/chromeos/dbus/bluetooth_le_advertisement_service_provider.cc b/device/bluetooth/dbus/bluetooth_le_advertisement_service_provider.cc index dfaeb5e..e981124 100644 --- a/chromeos/dbus/bluetooth_le_advertisement_service_provider.cc +++ b/device/bluetooth/dbus/bluetooth_le_advertisement_service_provider.cc @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/dbus/bluetooth_le_advertisement_service_provider.h" +#include "device/bluetooth/dbus/bluetooth_le_advertisement_service_provider.h" #include "base/bind.h" #include "base/logging.h" #include "base/memory/ref_counted.h" #include "base/stl_util.h" #include "base/threading/platform_thread.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_le_advertisement_service_provider.h" #include "dbus/exported_object.h" #include "dbus/message.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" +#include "device/bluetooth/dbus/fake_bluetooth_le_advertisement_service_provider.h" #include "third_party/cros_system_api/dbus/service_constants.h" -namespace chromeos { +namespace bluez { namespace { const char kErrorInvalidArgs[] = "org.freedesktop.DBus.Error.InvalidArgs"; @@ -413,7 +413,7 @@ BluetoothLEAdvertisementServiceProvider::Create( scoped_ptr<ManufacturerData> manufacturer_data, scoped_ptr<UUIDList> solicit_uuids, scoped_ptr<ServiceData> service_data) { - if (!DBusThreadManager::Get()->IsUsingStub(DBusClientBundle::BLUETOOTH)) { + if (!bluez::BluezDBusManager::Get()->IsUsingStub()) { return make_scoped_ptr(new BluetoothAdvertisementServiceProviderImpl( bus, object_path, delegate, type, service_uuids.Pass(), manufacturer_data.Pass(), solicit_uuids.Pass(), service_data.Pass())); @@ -423,4 +423,4 @@ BluetoothLEAdvertisementServiceProvider::Create( } } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/bluetooth_le_advertisement_service_provider.h b/device/bluetooth/dbus/bluetooth_le_advertisement_service_provider.h index 98622a2..8f4692f 100644 --- a/chromeos/dbus/bluetooth_le_advertisement_service_provider.h +++ b/device/bluetooth/dbus/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_BLUETOOTH_LE_ADVERTISEMENT_SERVICE_PROVIDER_H_ -#define CHROMEOS_DBUS_BLUETOOTH_LE_ADVERTISEMENT_SERVICE_PROVIDER_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_LE_ADVERTISEMENT_SERVICE_PROVIDER_H_ +#define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_LE_ADVERTISEMENT_SERVICE_PROVIDER_H_ #include <stdint.h> @@ -14,16 +14,16 @@ #include "base/basictypes.h" #include "base/callback.h" #include "base/memory/scoped_ptr.h" -#include "chromeos/chromeos_export.h" #include "dbus/bus.h" #include "dbus/file_descriptor.h" #include "dbus/object_path.h" +#include "device/bluetooth/bluetooth_export.h" -namespace chromeos { +namespace bluez { // BluetoothAdvertisementServiceProvider is used to provide a D-Bus object that // the Bluetooth daemon can communicate with to advertise data. -class CHROMEOS_EXPORT BluetoothLEAdvertisementServiceProvider { +class DEVICE_BLUETOOTH_EXPORT BluetoothLEAdvertisementServiceProvider { public: using UUIDList = std::vector<std::string>; using ManufacturerData = std::map<uint16_t, std::vector<uint8_t>>; @@ -77,6 +77,6 @@ class CHROMEOS_EXPORT BluetoothLEAdvertisementServiceProvider { DISALLOW_COPY_AND_ASSIGN(BluetoothLEAdvertisementServiceProvider); }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_BLUETOOTH_LE_ADVERTISEMENT_SERVICE_PROVIDER_H_ +#endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_LE_ADVERTISEMENT_SERVICE_PROVIDER_H_ diff --git a/chromeos/dbus/bluetooth_le_advertising_manager_client.cc b/device/bluetooth/dbus/bluetooth_le_advertising_manager_client.cc index ca2c9e2..3c934e6 100644 --- a/chromeos/dbus/bluetooth_le_advertising_manager_client.cc +++ b/device/bluetooth/dbus/bluetooth_le_advertising_manager_client.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 "chromeos/dbus/bluetooth_le_advertising_manager_client.h" +#include "device/bluetooth/dbus/bluetooth_le_advertising_manager_client.h" #include "base/bind.h" #include "base/logging.h" @@ -13,7 +13,7 @@ #include "dbus/object_proxy.h" #include "third_party/cros_system_api/dbus/service_constants.h" -namespace chromeos { +namespace bluez { const char BluetoothLEAdvertisingManagerClient::kNoResponseError[] = "org.chromium.Error.NoResponse"; @@ -184,4 +184,4 @@ BluetoothLEAdvertisingManagerClient::Create() { return new BluetoothAdvertisementManagerClientImpl(); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/bluetooth_le_advertising_manager_client.h b/device/bluetooth/dbus/bluetooth_le_advertising_manager_client.h index 5160a9f..73aa9ed 100644 --- a/chromeos/dbus/bluetooth_le_advertising_manager_client.h +++ b/device/bluetooth/dbus/bluetooth_le_advertising_manager_client.h @@ -2,24 +2,26 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_BLUETOOTH_LE_ADVERTISING_MANAGER_CLIENT_H_ -#define CHROMEOS_DBUS_BLUETOOTH_LE_ADVERTISING_MANAGER_CLIENT_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_LE_ADVERTISING_MANAGER_CLIENT_H_ +#define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_LE_ADVERTISING_MANAGER_CLIENT_H_ #include <string> #include <vector> #include "base/callback.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/values.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/dbus_client.h" #include "dbus/object_path.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluez_dbus_client.h" -namespace chromeos { +namespace bluez { // BluetoothAdvertisingManagerClient is used to communicate with the advertising // manager object of the BlueZ daemon. -class CHROMEOS_EXPORT BluetoothLEAdvertisingManagerClient : public DBusClient { +class DEVICE_BLUETOOTH_EXPORT BluetoothLEAdvertisingManagerClient + : public BluezDBusClient { public: // Interface for observing changes to advertising managers. class Observer { @@ -78,6 +80,6 @@ class CHROMEOS_EXPORT BluetoothLEAdvertisingManagerClient : public DBusClient { DISALLOW_COPY_AND_ASSIGN(BluetoothLEAdvertisingManagerClient); }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_BLUETOOTH_LE_ADVERTISING_MANAGER_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_LE_ADVERTISING_MANAGER_CLIENT_H_ diff --git a/chromeos/dbus/bluetooth_media_client.cc b/device/bluetooth/dbus/bluetooth_media_client.cc index 301f765..0927d45 100644 --- a/chromeos/dbus/bluetooth_media_client.cc +++ b/device/bluetooth/dbus/bluetooth_media_client.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 "chromeos/dbus/bluetooth_media_client.h" +#include "device/bluetooth/dbus/bluetooth_media_client.h" #include "base/bind.h" #include "base/logging.h" @@ -35,7 +35,7 @@ const char kCapabilitiesEndpointProperty[] = "Capabilities"; } // namespace -namespace chromeos { +namespace bluez { // static const char BluetoothMediaClient::kNoResponseError[] = @@ -224,4 +224,4 @@ BluetoothMediaClient* BluetoothMediaClient::Create() { return new BluetoothMediaClientImpl(); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/bluetooth_media_client.h b/device/bluetooth/dbus/bluetooth_media_client.h index 1bb5547..88597c5 100644 --- a/chromeos/dbus/bluetooth_media_client.h +++ b/device/bluetooth/dbus/bluetooth_media_client.h @@ -2,28 +2,29 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_BLUETOOTH_MEDIA_CLIENT_H_ -#define CHROMEOS_DBUS_BLUETOOTH_MEDIA_CLIENT_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_MEDIA_CLIENT_H_ +#define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_MEDIA_CLIENT_H_ #include <memory> #include <string> #include <vector> #include "base/callback.h" +#include "base/macros.h" #include "base/values.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/dbus_client.h" #include "dbus/object_path.h" #include "dbus/property.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluez_dbus_client.h" -namespace chromeos { +namespace bluez { // BluetoothMediaClient is used to communicate with the Media interface of a // local Bluetooth adapter. -class CHROMEOS_EXPORT BluetoothMediaClient : public DBusClient { +class DEVICE_BLUETOOTH_EXPORT BluetoothMediaClient : public BluezDBusClient { public: // Properties used to register a Media Endpoint. - struct CHROMEOS_EXPORT EndpointProperties { + struct DEVICE_BLUETOOTH_EXPORT EndpointProperties { EndpointProperties(); ~EndpointProperties(); @@ -102,6 +103,6 @@ class CHROMEOS_EXPORT BluetoothMediaClient : public DBusClient { DISALLOW_COPY_AND_ASSIGN(BluetoothMediaClient); }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_BLUETOOTH_MEDIA_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_MEDIA_CLIENT_H_ diff --git a/chromeos/dbus/bluetooth_media_endpoint_service_provider.cc b/device/bluetooth/dbus/bluetooth_media_endpoint_service_provider.cc index 9dd7720..864a04d 100644 --- a/chromeos/dbus/bluetooth_media_endpoint_service_provider.cc +++ b/device/bluetooth/dbus/bluetooth_media_endpoint_service_provider.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 "chromeos/dbus/bluetooth_media_endpoint_service_provider.h" +#include "device/bluetooth/dbus/bluetooth_media_endpoint_service_provider.h" #include "base/bind.h" #include "base/logging.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/threading/platform_thread.h" -#include "chromeos/dbus/bluetooth_media_transport_client.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_media_endpoint_service_provider.h" #include "dbus/exported_object.h" +#include "device/bluetooth/dbus/bluetooth_media_transport_client.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" +#include "device/bluetooth/dbus/fake_bluetooth_media_endpoint_service_provider.h" namespace { @@ -31,10 +31,10 @@ const char kInvalidState[] = "unknown"; } // namespace -namespace chromeos { +namespace bluez { // The BluetoothMediaEndopintServiceProvider implementation used in production. -class CHROMEOS_EXPORT BluetoothMediaEndpointServiceProviderImpl +class DEVICE_BLUETOOTH_EXPORT BluetoothMediaEndpointServiceProviderImpl : public BluetoothMediaEndpointServiceProvider { public: BluetoothMediaEndpointServiceProviderImpl(dbus::Bus* bus, @@ -302,7 +302,7 @@ BluetoothMediaEndpointServiceProvider::Create( const dbus::ObjectPath& object_path, Delegate* delegate) { // Returns a real implementation. - if (!DBusThreadManager::Get()->IsUsingStub(DBusClientBundle::BLUETOOTH)) { + if (!bluez::BluezDBusManager::Get()->IsUsingStub()) { return new BluetoothMediaEndpointServiceProviderImpl(bus, object_path, delegate); } @@ -310,4 +310,4 @@ BluetoothMediaEndpointServiceProvider::Create( return new FakeBluetoothMediaEndpointServiceProvider(object_path, delegate); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/bluetooth_media_endpoint_service_provider.h b/device/bluetooth/dbus/bluetooth_media_endpoint_service_provider.h index fffaa53..d44c065 100644 --- a/chromeos/dbus/bluetooth_media_endpoint_service_provider.h +++ b/device/bluetooth/dbus/bluetooth_media_endpoint_service_provider.h @@ -2,19 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_BLUETOOTH_MEDIA_ENDPOINT_SERVICE_PROVIDER_H_ -#define CHROMEOS_DBUS_BLUETOOTH_MEDIA_ENDPOINT_SERVICE_PROVIDER_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_MEDIA_ENDPOINT_SERVICE_PROVIDER_H_ +#define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_MEDIA_ENDPOINT_SERVICE_PROVIDER_H_ #include <string> #include <vector> #include "base/callback.h" -#include "chromeos/chromeos_export.h" +#include "base/macros.h" #include "dbus/bus.h" #include "dbus/message.h" #include "dbus/object_path.h" +#include "device/bluetooth/bluetooth_export.h" -namespace chromeos { +namespace bluez { // BluetoothMediaEndpointServiceProvider is used to provide a D-Bus object that // the Bluetooth daemon can commuicate with to serve as a media source/sink. @@ -27,7 +28,7 @@ namespace chromeos { // Bluetooth daemon will make calls to this endpoint object and they will be // passed to user's Delegate object for handling. For SelectConfiguration method // the response is returned using the SelectConfiguration callback. -class CHROMEOS_EXPORT BluetoothMediaEndpointServiceProvider { +class DEVICE_BLUETOOTH_EXPORT BluetoothMediaEndpointServiceProvider { public: // Delegate is the interface for reacting to endpoint requests. User // applications will implement this interface to handle either A2DP Sink or @@ -35,7 +36,7 @@ class CHROMEOS_EXPORT BluetoothMediaEndpointServiceProvider { class Delegate { public: // Transport-specific properties. - struct CHROMEOS_EXPORT TransportProperties { + struct DEVICE_BLUETOOTH_EXPORT TransportProperties { TransportProperties(); ~TransportProperties(); @@ -128,6 +129,6 @@ class CHROMEOS_EXPORT BluetoothMediaEndpointServiceProvider { DISALLOW_COPY_AND_ASSIGN(BluetoothMediaEndpointServiceProvider); }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_BLUETOOTH_MEDIA_ENDPOINT_SERVICE_PROVIDER_H_ +#endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_MEDIA_ENDPOINT_SERVICE_PROVIDER_H_ diff --git a/chromeos/dbus/bluetooth_media_transport_client.cc b/device/bluetooth/dbus/bluetooth_media_transport_client.cc index 3117de2..7fc47d7 100644 --- a/chromeos/dbus/bluetooth_media_transport_client.cc +++ b/device/bluetooth/dbus/bluetooth_media_transport_client.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 "chromeos/dbus/bluetooth_media_transport_client.h" +#include "device/bluetooth/dbus/bluetooth_media_transport_client.h" #include "base/bind.h" #include "base/logging.h" @@ -31,7 +31,7 @@ const char kRelease[] = "Release"; } // namespace -namespace chromeos { +namespace bluez { // static const char BluetoothMediaTransportClient::kDeviceProperty[] = "Device"; @@ -283,4 +283,4 @@ BluetoothMediaTransportClient* BluetoothMediaTransportClient::Create() { return new BluetoothMediaTransportClientImpl(); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/bluetooth_media_transport_client.h b/device/bluetooth/dbus/bluetooth_media_transport_client.h index 4476ae7..09c6ea0 100644 --- a/chromeos/dbus/bluetooth_media_transport_client.h +++ b/device/bluetooth/dbus/bluetooth_media_transport_client.h @@ -2,22 +2,24 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ -#define CHROMEOS_DBUS_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ +#define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ #include <string> #include <vector> #include "base/callback.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/dbus_client.h" +#include "base/macros.h" #include "dbus/file_descriptor.h" #include "dbus/object_path.h" #include "dbus/property.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluez_dbus_client.h" -namespace chromeos { +namespace bluez { -class CHROMEOS_EXPORT BluetoothMediaTransportClient : public DBusClient { +class DEVICE_BLUETOOTH_EXPORT BluetoothMediaTransportClient + : public BluezDBusClient { public: struct Properties : public dbus::PropertySet { // The path to the device object which the transport is connected to. @@ -137,6 +139,6 @@ class CHROMEOS_EXPORT BluetoothMediaTransportClient : public DBusClient { DISALLOW_COPY_AND_ASSIGN(BluetoothMediaTransportClient); }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ diff --git a/chromeos/dbus/bluetooth_profile_manager_client.cc b/device/bluetooth/dbus/bluetooth_profile_manager_client.cc index 01301d4..742988a 100644 --- a/chromeos/dbus/bluetooth_profile_manager_client.cc +++ b/device/bluetooth/dbus/bluetooth_profile_manager_client.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 "chromeos/dbus/bluetooth_profile_manager_client.h" +#include "device/bluetooth/dbus/bluetooth_profile_manager_client.h" #include "base/bind.h" #include "base/logging.h" @@ -11,7 +11,7 @@ #include "dbus/object_proxy.h" #include "third_party/cros_system_api/dbus/service_constants.h" -namespace chromeos { +namespace bluez { const char BluetoothProfileManagerClient::kNoResponseError[] = "org.chromium.Error.NoResponse"; @@ -231,4 +231,4 @@ BluetoothProfileManagerClient* BluetoothProfileManagerClient::Create() { return new BluetoothProfileManagerClientImpl(); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/bluetooth_profile_manager_client.h b/device/bluetooth/dbus/bluetooth_profile_manager_client.h index 8f53412..4b6bd96 100644 --- a/chromeos/dbus/bluetooth_profile_manager_client.h +++ b/device/bluetooth/dbus/bluetooth_profile_manager_client.h @@ -2,24 +2,26 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_ -#define CHROMEOS_DBUS_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_ +#define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_ #include <string> #include <vector> #include "base/callback.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/values.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/dbus_client.h" #include "dbus/object_path.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluez_dbus_client.h" -namespace chromeos { +namespace bluez { // BluetoothProfileManagerClient is used to communicate with the profile // manager object of the Bluetooth daemon. -class CHROMEOS_EXPORT BluetoothProfileManagerClient : public DBusClient { +class DEVICE_BLUETOOTH_EXPORT BluetoothProfileManagerClient + : public BluezDBusClient { public: // Species the role of the object within the profile. SYMMETRIC should be // usually used unless the profile requires you specify as a CLIENT or as a @@ -27,7 +29,7 @@ class CHROMEOS_EXPORT BluetoothProfileManagerClient : public DBusClient { enum ProfileRole { SYMMETRIC, CLIENT, SERVER }; // Options used to register a Profile object. - struct CHROMEOS_EXPORT Options { + struct DEVICE_BLUETOOTH_EXPORT Options { Options(); ~Options(); @@ -102,6 +104,6 @@ class CHROMEOS_EXPORT BluetoothProfileManagerClient : public DBusClient { DISALLOW_COPY_AND_ASSIGN(BluetoothProfileManagerClient); }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_ diff --git a/chromeos/dbus/bluetooth_profile_service_provider.cc b/device/bluetooth/dbus/bluetooth_profile_service_provider.cc index f63f5ea..a2a23bb 100644 --- a/chromeos/dbus/bluetooth_profile_service_provider.cc +++ b/device/bluetooth/dbus/bluetooth_profile_service_provider.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 "chromeos/dbus/bluetooth_profile_service_provider.h" +#include "device/bluetooth/dbus/bluetooth_profile_service_provider.h" #include "base/bind.h" #include "base/logging.h" #include "base/memory/ref_counted.h" #include "base/threading/platform_thread.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_profile_service_provider.h" #include "dbus/exported_object.h" #include "dbus/message.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" +#include "device/bluetooth/dbus/fake_bluetooth_profile_service_provider.h" #include "third_party/cros_system_api/dbus/service_constants.h" -namespace chromeos { +namespace bluez { // The BluetoothProfileServiceProvider implementation used in production. class BluetoothProfileServiceProviderImpl @@ -238,11 +238,11 @@ BluetoothProfileServiceProvider* BluetoothProfileServiceProvider::Create( dbus::Bus* bus, const dbus::ObjectPath& object_path, Delegate* delegate) { - if (!DBusThreadManager::Get()->IsUsingStub(DBusClientBundle::BLUETOOTH)) { + if (!bluez::BluezDBusManager::Get()->IsUsingStub()) { return new BluetoothProfileServiceProviderImpl(bus, object_path, delegate); } else { return new FakeBluetoothProfileServiceProvider(object_path, delegate); } } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/bluetooth_profile_service_provider.h b/device/bluetooth/dbus/bluetooth_profile_service_provider.h index 366a354..f2db22c 100644 --- a/chromeos/dbus/bluetooth_profile_service_provider.h +++ b/device/bluetooth/dbus/bluetooth_profile_service_provider.h @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DBUS_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ -#define CHROMEOS_DBUS_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ +#define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ #include <string> #include "base/basictypes.h" #include "base/callback.h" #include "base/memory/scoped_ptr.h" -#include "chromeos/chromeos_export.h" #include "dbus/bus.h" #include "dbus/file_descriptor.h" #include "dbus/object_path.h" +#include "device/bluetooth/bluetooth_export.h" -namespace chromeos { +namespace bluez { // BluetoothProfileServiceProvider is used to provide a D-Bus object that the // Bluetooth daemon can communicate with to connect application profiles. @@ -29,7 +29,7 @@ namespace chromeos { // 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. -class CHROMEOS_EXPORT BluetoothProfileServiceProvider { +class DEVICE_BLUETOOTH_EXPORT BluetoothProfileServiceProvider { public: // Interface for reacting to profile requests. class Delegate { @@ -43,7 +43,7 @@ class CHROMEOS_EXPORT BluetoothProfileServiceProvider { enum Status { SUCCESS, REJECTED, CANCELLED }; // Connection-specific options. - struct CHROMEOS_EXPORT Options { + struct DEVICE_BLUETOOTH_EXPORT Options { Options() {} ~Options() {} @@ -115,6 +115,6 @@ class CHROMEOS_EXPORT BluetoothProfileServiceProvider { DISALLOW_COPY_AND_ASSIGN(BluetoothProfileServiceProvider); }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ +#endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ diff --git a/device/bluetooth/dbus/bluez_dbus_client.h b/device/bluetooth/dbus/bluez_dbus_client.h new file mode 100644 index 0000000..3dd0985 --- /dev/null +++ b/device/bluetooth/dbus/bluez_dbus_client.h @@ -0,0 +1,37 @@ +// Copyright 2013 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_BLUEZ_DBUS_CLIENT_H_ +#define DEVICE_BLUETOOTH_DBUS_BLUEZ_DBUS_CLIENT_H_ + +#include "base/basictypes.h" + +namespace dbus { +class Bus; +} // namespace dbus + +namespace bluez { + +// Interface for all Bluez DBus clients handled by BluezDBusManager. It +// restricts +// access to the Init function to BluezDBusManager only to prevent +// incorrect calls. Stub clients may lift that restriction however. +class BluezDBusClient { + protected: + virtual ~BluezDBusClient() {} + + // This function is called by DBusThreadManager. Only in unit tests, which + // don't use DBusThreadManager, this function can be called through Stub + // implementations (they change Init's member visibility to public). + virtual void Init(dbus::Bus* bus) = 0; + + private: + friend class BluezDBusManager; + + DISALLOW_ASSIGN(BluezDBusClient); +}; + +} // namespace bluez + +#endif // DEVICE_BLUETOOTH_DBUS_BLUEZ_DBUS_CLIENT_H_ diff --git a/device/bluetooth/dbus/bluez_dbus_manager.cc b/device/bluetooth/dbus/bluez_dbus_manager.cc new file mode 100644 index 0000000..376261d --- /dev/null +++ b/device/bluetooth/dbus/bluez_dbus_manager.cc @@ -0,0 +1,250 @@ +// 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/bluez_dbus_manager.h" + +#include "base/command_line.h" +#include "base/sys_info.h" +#include "base/threading/thread.h" +#include "dbus/bus.h" +#include "dbus/dbus_statistics.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" +#include "device/bluetooth/dbus/bluetooth_gatt_characteristic_client.h" +#include "device/bluetooth/dbus/bluetooth_gatt_descriptor_client.h" +#include "device/bluetooth/dbus/bluetooth_gatt_manager_client.h" +#include "device/bluetooth/dbus/bluetooth_gatt_service_client.h" +#include "device/bluetooth/dbus/bluetooth_input_client.h" +#include "device/bluetooth/dbus/bluetooth_le_advertising_manager_client.h" +#include "device/bluetooth/dbus/bluetooth_media_client.h" +#include "device/bluetooth/dbus/bluetooth_media_transport_client.h" +#include "device/bluetooth/dbus/bluetooth_profile_manager_client.h" + +namespace bluez { + +static BluezDBusManager* g_bluez_dbus_manager = nullptr; +static bool g_using_bluez_dbus_manager_for_testing = false; + +BluezDBusManager::BluezDBusManager( + dbus::Bus* bus, + scoped_ptr<BluetoothDBusClientBundle> client_bundle) + : bus_(bus), client_bundle_(client_bundle.Pass()) {} + +BluezDBusManager::~BluezDBusManager() { + // Delete all D-Bus clients before shutting down the system bus. + client_bundle_.reset(); +} + +dbus::Bus* bluez::BluezDBusManager::GetSystemBus() { + return bus_; +} + +BluetoothAdapterClient* bluez::BluezDBusManager::GetBluetoothAdapterClient() { + return client_bundle_->bluetooth_adapter_client(); +} + +BluetoothLEAdvertisingManagerClient* +bluez::BluezDBusManager::GetBluetoothLEAdvertisingManagerClient() { + return client_bundle_->bluetooth_le_advertising_manager_client(); +} + +BluetoothAgentManagerClient* +bluez::BluezDBusManager::GetBluetoothAgentManagerClient() { + return client_bundle_->bluetooth_agent_manager_client(); +} + +BluetoothDeviceClient* bluez::BluezDBusManager::GetBluetoothDeviceClient() { + return client_bundle_->bluetooth_device_client(); +} + +BluetoothGattCharacteristicClient* +bluez::BluezDBusManager::GetBluetoothGattCharacteristicClient() { + return client_bundle_->bluetooth_gatt_characteristic_client(); +} + +BluetoothGattDescriptorClient* +bluez::BluezDBusManager::GetBluetoothGattDescriptorClient() { + return client_bundle_->bluetooth_gatt_descriptor_client(); +} + +BluetoothGattManagerClient* +bluez::BluezDBusManager::GetBluetoothGattManagerClient() { + return client_bundle_->bluetooth_gatt_manager_client(); +} + +BluetoothGattServiceClient* +bluez::BluezDBusManager::GetBluetoothGattServiceClient() { + return client_bundle_->bluetooth_gatt_service_client(); +} + +BluetoothInputClient* bluez::BluezDBusManager::GetBluetoothInputClient() { + return client_bundle_->bluetooth_input_client(); +} + +BluetoothMediaClient* bluez::BluezDBusManager::GetBluetoothMediaClient() { + return client_bundle_->bluetooth_media_client(); +} + +BluetoothMediaTransportClient* +bluez::BluezDBusManager::GetBluetoothMediaTransportClient() { + return client_bundle_->bluetooth_media_transport_client(); +} + +BluetoothProfileManagerClient* +bluez::BluezDBusManager::GetBluetoothProfileManagerClient() { + return client_bundle_->bluetooth_profile_manager_client(); +} + +void BluezDBusManager::InitializeClients() { + GetBluetoothAdapterClient()->Init(GetSystemBus()); + GetBluetoothAgentManagerClient()->Init(GetSystemBus()); + GetBluetoothDeviceClient()->Init(GetSystemBus()); + GetBluetoothGattCharacteristicClient()->Init(GetSystemBus()); + GetBluetoothGattDescriptorClient()->Init(GetSystemBus()); + GetBluetoothGattManagerClient()->Init(GetSystemBus()); + GetBluetoothGattServiceClient()->Init(GetSystemBus()); + GetBluetoothInputClient()->Init(GetSystemBus()); + GetBluetoothLEAdvertisingManagerClient()->Init(GetSystemBus()); + GetBluetoothMediaClient()->Init(GetSystemBus()); + GetBluetoothMediaTransportClient()->Init(GetSystemBus()); + GetBluetoothProfileManagerClient()->Init(GetSystemBus()); + + // This must be called after the list of clients so they've each had a + // chance to register with their object g_dbus_thread_managers. + if (GetSystemBus()) + GetSystemBus()->GetManagedObjects(); +} + +// static +void BluezDBusManager::Initialize(dbus::Bus* bus, bool use_dbus_stub) { + // If we initialize BluezDBusManager twice we may also be shutting it down + // early; do not allow that. + if (g_using_bluez_dbus_manager_for_testing) + return; + + CHECK(!g_bluez_dbus_manager); + CreateGlobalInstance(bus, use_dbus_stub); +} + +// static +scoped_ptr<BluezDBusManagerSetter> +bluez::BluezDBusManager::GetSetterForTesting() { + if (!g_using_bluez_dbus_manager_for_testing) { + g_using_bluez_dbus_manager_for_testing = true; + CreateGlobalInstance(nullptr, true); + } + + return make_scoped_ptr(new BluezDBusManagerSetter()); +} + +// static +void BluezDBusManager::CreateGlobalInstance(dbus::Bus* bus, bool use_stubs) { + CHECK(!g_bluez_dbus_manager); + g_bluez_dbus_manager = new BluezDBusManager( + bus, make_scoped_ptr(new BluetoothDBusClientBundle(use_stubs))); + g_bluez_dbus_manager->InitializeClients(); +} + +// static +bool BluezDBusManager::IsInitialized() { + return g_bluez_dbus_manager != nullptr; +} + +// static +void BluezDBusManager::Shutdown() { + // Ensure that we only shutdown BluezDBusManager once. + CHECK(g_bluez_dbus_manager); + BluezDBusManager* dbus_manager = g_bluez_dbus_manager; + g_bluez_dbus_manager = nullptr; + g_using_bluez_dbus_manager_for_testing = false; + delete dbus_manager; + VLOG(1) << "BluezDBusManager Shutdown completed"; +} + +// static +BluezDBusManager* bluez::BluezDBusManager::Get() { + CHECK(g_bluez_dbus_manager) + << "bluez::BluezDBusManager::Get() called before Initialize()"; + return g_bluez_dbus_manager; +} + +BluezDBusManagerSetter::BluezDBusManagerSetter() {} + +BluezDBusManagerSetter::~BluezDBusManagerSetter() {} + +void BluezDBusManagerSetter::SetBluetoothAdapterClient( + scoped_ptr<BluetoothAdapterClient> client) { + bluez::BluezDBusManager::Get()->client_bundle_->bluetooth_adapter_client_ = + client.Pass(); +} + +void BluezDBusManagerSetter::SetBluetoothLEAdvertisingManagerClient( + scoped_ptr<BluetoothLEAdvertisingManagerClient> client) { + bluez::BluezDBusManager::Get() + ->client_bundle_->bluetooth_le_advertising_manager_client_ = + client.Pass(); +} + +void BluezDBusManagerSetter::SetBluetoothAgentManagerClient( + scoped_ptr<BluetoothAgentManagerClient> client) { + bluez::BluezDBusManager::Get() + ->client_bundle_->bluetooth_agent_manager_client_ = client.Pass(); +} + +void BluezDBusManagerSetter::SetBluetoothDeviceClient( + scoped_ptr<BluetoothDeviceClient> client) { + bluez::BluezDBusManager::Get()->client_bundle_->bluetooth_device_client_ = + client.Pass(); +} + +void BluezDBusManagerSetter::SetBluetoothGattCharacteristicClient( + scoped_ptr<BluetoothGattCharacteristicClient> client) { + bluez::BluezDBusManager::Get() + ->client_bundle_->bluetooth_gatt_characteristic_client_ = client.Pass(); +} + +void BluezDBusManagerSetter::SetBluetoothGattDescriptorClient( + scoped_ptr<BluetoothGattDescriptorClient> client) { + bluez::BluezDBusManager::Get() + ->client_bundle_->bluetooth_gatt_descriptor_client_ = client.Pass(); +} + +void BluezDBusManagerSetter::SetBluetoothGattManagerClient( + scoped_ptr<BluetoothGattManagerClient> client) { + bluez::BluezDBusManager::Get() + ->client_bundle_->bluetooth_gatt_manager_client_ = client.Pass(); +} + +void BluezDBusManagerSetter::SetBluetoothGattServiceClient( + scoped_ptr<BluetoothGattServiceClient> client) { + bluez::BluezDBusManager::Get() + ->client_bundle_->bluetooth_gatt_service_client_ = client.Pass(); +} + +void BluezDBusManagerSetter::SetBluetoothInputClient( + scoped_ptr<BluetoothInputClient> client) { + bluez::BluezDBusManager::Get()->client_bundle_->bluetooth_input_client_ = + client.Pass(); +} + +void BluezDBusManagerSetter::SetBluetoothMediaClient( + scoped_ptr<BluetoothMediaClient> client) { + bluez::BluezDBusManager::Get()->client_bundle_->bluetooth_media_client_ = + client.Pass(); +} + +void BluezDBusManagerSetter::SetBluetoothMediaTransportClient( + scoped_ptr<BluetoothMediaTransportClient> client) { + bluez::BluezDBusManager::Get() + ->client_bundle_->bluetooth_media_transport_client_ = client.Pass(); +} + +void BluezDBusManagerSetter::SetBluetoothProfileManagerClient( + scoped_ptr<BluetoothProfileManagerClient> client) { + bluez::BluezDBusManager::Get() + ->client_bundle_->bluetooth_profile_manager_client_ = client.Pass(); +} + +} // namespace bluez diff --git a/device/bluetooth/dbus/bluez_dbus_manager.h b/device/bluetooth/dbus/bluez_dbus_manager.h new file mode 100644 index 0000000..d87fadc --- /dev/null +++ b/device/bluetooth/dbus/bluez_dbus_manager.h @@ -0,0 +1,158 @@ +// 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_BLUEZ_DBUS_MANAGER_H_ +#define DEVICE_BLUETOOTH_DBUS_BLUEZ_DBUS_MANAGER_H_ + +#include <string> + +#include "base/callback.h" +#include "base/macros.h" +#include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluetooth_dbus_client_bundle.h" + +namespace dbus { +class Bus; +class ObjectPath; +} // namespace dbus + +namespace bluez { + +// Style Note: Clients are sorted by names. +class BluetoothAdapterClient; +class BluetoothAgentManagerClient; +class BluetoothDeviceClient; +class BluetoothGattCharacteristicClient; +class BluetoothGattDescriptorClient; +class BluetoothGattManagerClient; +class BluetoothGattServiceClient; +class BluetoothInputClient; +class BluetoothLEAdvertisingManagerClient; +class BluetoothMediaClient; +class BluetoothMediaTransportClient; +class BluetoothProfileManagerClient; +class BluezDBusManagerSetter; + +// BluezDBusManager manages manages D-Bus connections and D-Bus clients, which +// depend on the D-Bus thread to ensure the right order of shutdowns for +// the D-Bus thread, the D-Bus connections, and the D-Bus clients. +// +// CALLBACKS IN D-BUS CLIENTS: +// +// D-Bus clients managed by BluezDBusManagerSetter are guaranteed to be deleted +// after the D-Bus thread so the clients don't need to worry if new +// incoming messages arrive from the D-Bus thread during shutdown of the +// clients. The UI message loop is not running during the shutdown hence +// the UI message loop won't post tasks to D-BUS clients during the +// shutdown. However, to be extra cautious, clients should use +// WeakPtrFactory when creating callbacks that run on UI thread. See +// session_manager_client.cc for examples. +// +class DEVICE_BLUETOOTH_EXPORT BluezDBusManager { + 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. + // This will initialize real or stub DBusClients depending on command-line + // arguments and whether this process runs in a ChromeOS environment. + static void Initialize(dbus::Bus* bus, bool use_dbus_stub); + + // Returns a BluezDBusManagerSetter instance that allows tests to + // replace individual D-Bus clients with their own implementations. + // Also initializes the main BluezDBusManager for testing if necessary. + static scoped_ptr<BluezDBusManagerSetter> GetSetterForTesting(); + + // Returns true if BluezDBusManager has been initialized. Call this to + // avoid initializing + shutting down BluezDBusManager more than once. + static bool IsInitialized(); + + // Destroys the global instance. + static void Shutdown(); + + // Gets the global instance. Initialize() must be called first. + static BluezDBusManager* Get(); + + // Returns true if |client| is stubbed. + bool IsUsingStub() { return client_bundle_->IsUsingStub(); } + + // Returns various D-Bus bus instances, owned by BluezDBusManager. + dbus::Bus* GetSystemBus(); + + // All returned objects are owned by BluezDBusManager. Do not use these + // pointers after BluezDBusManager has been shut down. + BluetoothAdapterClient* GetBluetoothAdapterClient(); + BluetoothLEAdvertisingManagerClient* GetBluetoothLEAdvertisingManagerClient(); + BluetoothAgentManagerClient* GetBluetoothAgentManagerClient(); + BluetoothDeviceClient* GetBluetoothDeviceClient(); + BluetoothGattCharacteristicClient* GetBluetoothGattCharacteristicClient(); + BluetoothGattDescriptorClient* GetBluetoothGattDescriptorClient(); + BluetoothGattManagerClient* GetBluetoothGattManagerClient(); + BluetoothGattServiceClient* GetBluetoothGattServiceClient(); + BluetoothInputClient* GetBluetoothInputClient(); + BluetoothMediaClient* GetBluetoothMediaClient(); + BluetoothMediaTransportClient* GetBluetoothMediaTransportClient(); + BluetoothProfileManagerClient* GetBluetoothProfileManagerClient(); + + private: + friend class BluezDBusManagerSetter; + + // Creates a new BluezDBusManager using the DBusClients set in + // |client_bundle|. + explicit BluezDBusManager( + dbus::Bus* bus, + scoped_ptr<BluetoothDBusClientBundle> client_bundle); + ~BluezDBusManager(); + + // Creates a global instance of BluezDBusManager. Cannot be called more than + // once. + static void CreateGlobalInstance(dbus::Bus* bus, bool use_stubs); + + // Initializes all currently stored DBusClients with the system bus and + // performs additional setup. + void InitializeClients(); + + dbus::Bus* bus_; + scoped_ptr<BluetoothDBusClientBundle> client_bundle_; + + DISALLOW_COPY_AND_ASSIGN(BluezDBusManager); +}; + +class DEVICE_BLUETOOTH_EXPORT BluezDBusManagerSetter { + public: + ~BluezDBusManagerSetter(); + + void SetBluetoothAdapterClient(scoped_ptr<BluetoothAdapterClient> client); + void SetBluetoothLEAdvertisingManagerClient( + scoped_ptr<BluetoothLEAdvertisingManagerClient> client); + void SetBluetoothAgentManagerClient( + scoped_ptr<BluetoothAgentManagerClient> client); + void SetBluetoothDeviceClient(scoped_ptr<BluetoothDeviceClient> client); + void SetBluetoothGattCharacteristicClient( + scoped_ptr<BluetoothGattCharacteristicClient> client); + void SetBluetoothGattDescriptorClient( + scoped_ptr<BluetoothGattDescriptorClient> client); + void SetBluetoothGattManagerClient( + scoped_ptr<BluetoothGattManagerClient> client); + void SetBluetoothGattServiceClient( + scoped_ptr<BluetoothGattServiceClient> client); + void SetBluetoothInputClient(scoped_ptr<BluetoothInputClient> client); + void SetBluetoothMediaClient(scoped_ptr<BluetoothMediaClient> client); + void SetBluetoothMediaTransportClient( + scoped_ptr<BluetoothMediaTransportClient> client); + void SetBluetoothProfileManagerClient( + scoped_ptr<BluetoothProfileManagerClient> client); + + private: + friend class BluezDBusManager; + + BluezDBusManagerSetter(); + + DISALLOW_COPY_AND_ASSIGN(BluezDBusManagerSetter); +}; + +} // namespace bluez + +#endif // DEVICE_BLUETOOTH_DBUS_BLUEZ_DBUS_MANAGER_H_ diff --git a/chromeos/dbus/fake_bluetooth_adapter_client.cc b/device/bluetooth/dbus/fake_bluetooth_adapter_client.cc index 1ff4bcc..f928768 100644 --- a/chromeos/dbus/fake_bluetooth_adapter_client.cc +++ b/device/bluetooth/dbus/fake_bluetooth_adapter_client.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 "chromeos/dbus/fake_bluetooth_adapter_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h" #include "base/location.h" #include "base/logging.h" #include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" #include "base/time/time.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_device_client.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" +#include "device/bluetooth/dbus/fake_bluetooth_device_client.h" #include "third_party/cros_system_api/dbus/service_constants.h" -namespace chromeos { +namespace bluez { namespace { @@ -139,7 +139,7 @@ void FakeBluetoothAdapterClient::StartDiscovery( FakeBluetoothDeviceClient* device_client = static_cast<FakeBluetoothDeviceClient*>( - DBusThreadManager::Get()->GetBluetoothDeviceClient()); + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()); device_client->BeginDiscoverySimulation(dbus::ObjectPath(kAdapterPath)); } } @@ -167,7 +167,7 @@ void FakeBluetoothAdapterClient::StopDiscovery( if (discovering_count_ == 0) { FakeBluetoothDeviceClient* device_client = static_cast<FakeBluetoothDeviceClient*>( - DBusThreadManager::Get()->GetBluetoothDeviceClient()); + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()); device_client->EndDiscoverySimulation(dbus::ObjectPath(kAdapterPath)); if (simulation_interval_ms_ > 100) { @@ -196,7 +196,7 @@ void FakeBluetoothAdapterClient::RemoveDevice( FakeBluetoothDeviceClient* device_client = static_cast<FakeBluetoothDeviceClient*>( - DBusThreadManager::Get()->GetBluetoothDeviceClient()); + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()); device_client->RemoveDevice(dbus::ObjectPath(kAdapterPath), device_path); } @@ -293,4 +293,4 @@ void FakeBluetoothAdapterClient::PostDelayedTask( base::TimeDelta::FromMilliseconds(simulation_interval_ms_)); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/fake_bluetooth_adapter_client.h b/device/bluetooth/dbus/fake_bluetooth_adapter_client.h index 987fc6f..0dced89 100644 --- a/chromeos/dbus/fake_bluetooth_adapter_client.h +++ b/device/bluetooth/dbus/fake_bluetooth_adapter_client.h @@ -2,25 +2,25 @@ // 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> #include "base/bind.h" #include "base/callback.h" #include "base/observer_list.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/bluetooth_adapter_client.h" #include "dbus/object_path.h" #include "dbus/property.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluetooth_adapter_client.h" -namespace chromeos { +namespace bluez { // FakeBluetoothAdapterClient simulates the behavior of the Bluetooth Daemon // adapter objects and is used both in test cases in place of a mock and on // the Linux desktop. -class CHROMEOS_EXPORT FakeBluetoothAdapterClient +class DEVICE_BLUETOOTH_EXPORT FakeBluetoothAdapterClient : public BluetoothAdapterClient { public: struct Properties : public BluetoothAdapterClient::Properties { @@ -113,6 +113,6 @@ class CHROMEOS_EXPORT FakeBluetoothAdapterClient int simulation_interval_ms_; }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_ADAPTER_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_ADAPTER_CLIENT_H_ diff --git a/chromeos/dbus/fake_bluetooth_agent_manager_client.cc b/device/bluetooth/dbus/fake_bluetooth_agent_manager_client.cc index 4ced274..5904441 100644 --- a/chromeos/dbus/fake_bluetooth_agent_manager_client.cc +++ b/device/bluetooth/dbus/fake_bluetooth_agent_manager_client.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_agent_manager_client.h" #include "base/logging.h" -#include "chromeos/dbus/fake_bluetooth_agent_service_provider.h" +#include "device/bluetooth/dbus/fake_bluetooth_agent_service_provider.h" #include "third_party/cros_system_api/dbus/service_constants.h" -namespace chromeos { +namespace bluez { FakeBluetoothAgentManagerClient::FakeBluetoothAgentManagerClient() : service_provider_(NULL) {} @@ -75,4 +75,4 @@ FakeBluetoothAgentManagerClient::GetAgentServiceProvider() { return service_provider_; } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/fake_bluetooth_agent_manager_client.h b/device/bluetooth/dbus/fake_bluetooth_agent_manager_client.h index 68c91202c3..d5c83cf 100644 --- a/chromeos/dbus/fake_bluetooth_agent_manager_client.h +++ b/device/bluetooth/dbus/fake_bluetooth_agent_manager_client.h @@ -2,25 +2,25 @@ // 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" #include "base/observer_list.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/bluetooth_agent_manager_client.h" #include "dbus/object_path.h" #include "dbus/property.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluetooth_agent_manager_client.h" -namespace chromeos { +namespace bluez { class FakeBluetoothAgentServiceProvider; // FakeBluetoothAgentManagerClient simulates the behavior of the Bluetooth // Daemon's agent manager object and is used both in test cases in place of a // mock and on the Linux desktop. -class CHROMEOS_EXPORT FakeBluetoothAgentManagerClient +class DEVICE_BLUETOOTH_EXPORT FakeBluetoothAgentManagerClient : public BluetoothAgentManagerClient { public: FakeBluetoothAgentManagerClient(); @@ -52,6 +52,6 @@ class CHROMEOS_EXPORT FakeBluetoothAgentManagerClient FakeBluetoothAgentServiceProvider* service_provider_; }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_AGENT_MANAGER_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_AGENT_MANAGER_CLIENT_H_ diff --git a/chromeos/dbus/fake_bluetooth_agent_service_provider.cc b/device/bluetooth/dbus/fake_bluetooth_agent_service_provider.cc index de2dbd3..777deb0 100644 --- a/chromeos/dbus/fake_bluetooth_agent_service_provider.cc +++ b/device/bluetooth/dbus/fake_bluetooth_agent_service_provider.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 "chromeos/dbus/fake_bluetooth_agent_service_provider.h" +#include "device/bluetooth/dbus/fake_bluetooth_agent_service_provider.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" +#include "device/bluetooth/dbus/fake_bluetooth_agent_manager_client.h" -namespace chromeos { +namespace bluez { FakeBluetoothAgentServiceProvider::FakeBluetoothAgentServiceProvider( const dbus::ObjectPath& object_path, @@ -17,7 +17,7 @@ FakeBluetoothAgentServiceProvider::FakeBluetoothAgentServiceProvider( FakeBluetoothAgentManagerClient* fake_bluetooth_agent_manager_client = static_cast<FakeBluetoothAgentManagerClient*>( - DBusThreadManager::Get()->GetBluetoothAgentManagerClient()); + bluez::BluezDBusManager::Get()->GetBluetoothAgentManagerClient()); fake_bluetooth_agent_manager_client->RegisterAgentServiceProvider(this); } @@ -26,7 +26,7 @@ FakeBluetoothAgentServiceProvider::~FakeBluetoothAgentServiceProvider() { FakeBluetoothAgentManagerClient* fake_bluetooth_agent_manager_client = static_cast<FakeBluetoothAgentManagerClient*>( - DBusThreadManager::Get()->GetBluetoothAgentManagerClient()); + bluez::BluezDBusManager::Get()->GetBluetoothAgentManagerClient()); fake_bluetooth_agent_manager_client->UnregisterAgentServiceProvider(this); } @@ -99,4 +99,4 @@ void FakeBluetoothAgentServiceProvider::Cancel() { delegate_->Cancel(); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/fake_bluetooth_agent_service_provider.h b/device/bluetooth/dbus/fake_bluetooth_agent_service_provider.h index 6d17519..e3c8cd4 100644 --- a/chromeos/dbus/fake_bluetooth_agent_service_provider.h +++ b/device/bluetooth/dbus/fake_bluetooth_agent_service_provider.h @@ -2,25 +2,25 @@ // 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" #include "base/observer_list.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/bluetooth_agent_service_provider.h" #include "dbus/object_path.h" #include "dbus/property.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluetooth_agent_service_provider.h" -namespace chromeos { +namespace bluez { class FakeBluetoothAgentManagerClient; // FakeBluetoothAgentServiceProvider simulates the behavior of a local // Bluetooth agent object and is used both in test cases in place of a // mock and on the Linux desktop. -class CHROMEOS_EXPORT FakeBluetoothAgentServiceProvider +class DEVICE_BLUETOOTH_EXPORT FakeBluetoothAgentServiceProvider : public BluetoothAgentServiceProvider { public: FakeBluetoothAgentServiceProvider(const dbus::ObjectPath& object_path, @@ -63,6 +63,6 @@ class CHROMEOS_EXPORT FakeBluetoothAgentServiceProvider Delegate* delegate_; }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_ diff --git a/chromeos/dbus/fake_bluetooth_device_client.cc b/device/bluetooth/dbus/fake_bluetooth_device_client.cc index 1aa01a5..83d31dd4 100644 --- a/chromeos/dbus/fake_bluetooth_device_client.cc +++ b/device/bluetooth/dbus/fake_bluetooth_device_client.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 "chromeos/dbus/fake_bluetooth_device_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_device_client.h" #include <fcntl.h> #include <sys/socket.h> @@ -22,15 +22,15 @@ #include "base/thread_task_runner_handle.h" #include "base/threading/worker_pool.h" #include "base/time/time.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_adapter_client.h" -#include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" -#include "chromeos/dbus/fake_bluetooth_agent_service_provider.h" -#include "chromeos/dbus/fake_bluetooth_gatt_service_client.h" -#include "chromeos/dbus/fake_bluetooth_input_client.h" -#include "chromeos/dbus/fake_bluetooth_profile_manager_client.h" -#include "chromeos/dbus/fake_bluetooth_profile_service_provider.h" #include "dbus/file_descriptor.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" +#include "device/bluetooth/dbus/fake_bluetooth_agent_service_provider.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_service_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_input_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_profile_manager_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_profile_service_provider.h" #include "third_party/cros_system_api/dbus/service_constants.h" namespace { @@ -94,7 +94,7 @@ void SimpleErrorCallback(const std::string& error_name, } // namespace -namespace chromeos { +namespace bluez { const char FakeBluetoothDeviceClient::kTestPinCode[] = "123456"; const int FakeBluetoothDeviceClient::kTestPassKey = 123456; @@ -387,7 +387,7 @@ void FakeBluetoothDeviceClient::Connect(const dbus::ObjectPath& object_path, if (object_path == dbus::ObjectPath(kLowEnergyPath)) { FakeBluetoothGattServiceClient* gatt_service_client = static_cast<FakeBluetoothGattServiceClient*>( - DBusThreadManager::Get()->GetBluetoothGattServiceClient()); + bluez::BluezDBusManager::Get()->GetBluetoothGattServiceClient()); gatt_service_client->ExposeHeartRateService( dbus::ObjectPath(kLowEnergyPath)); properties->gatt_services.ReplaceValue(gatt_service_client->GetServices()); @@ -412,7 +412,7 @@ void FakeBluetoothDeviceClient::Disconnect( if (object_path == dbus::ObjectPath(kLowEnergyPath)) { FakeBluetoothGattServiceClient* gatt_service_client = static_cast<FakeBluetoothGattServiceClient*>( - DBusThreadManager::Get()->GetBluetoothGattServiceClient()); + bluez::BluezDBusManager::Get()->GetBluetoothGattServiceClient()); gatt_service_client->HideHeartRateService(); } @@ -429,7 +429,7 @@ void FakeBluetoothDeviceClient::ConnectProfile( FakeBluetoothProfileManagerClient* fake_bluetooth_profile_manager_client = static_cast<FakeBluetoothProfileManagerClient*>( - DBusThreadManager::Get()->GetBluetoothProfileManagerClient()); + bluez::BluezDBusManager::Get()->GetBluetoothProfileManagerClient()); FakeBluetoothProfileServiceProvider* profile_service_provider = fake_bluetooth_profile_manager_client->GetProfileServiceProvider(uuid); if (profile_service_provider == NULL) { @@ -492,7 +492,7 @@ void FakeBluetoothDeviceClient::DisconnectProfile( FakeBluetoothProfileManagerClient* fake_bluetooth_profile_manager_client = static_cast<FakeBluetoothProfileManagerClient*>( - DBusThreadManager::Get()->GetBluetoothProfileManagerClient()); + bluez::BluezDBusManager::Get()->GetBluetoothProfileManagerClient()); FakeBluetoothProfileServiceProvider* profile_service_provider = fake_bluetooth_profile_manager_client->GetProfileServiceProvider(uuid); if (profile_service_provider == NULL) { @@ -1003,13 +1003,13 @@ void FakeBluetoothDeviceClient::RemoveDevice( // BluetoothDeviceChromeOS object, including the device_path referenced here. FakeBluetoothInputClient* fake_bluetooth_input_client = static_cast<FakeBluetoothInputClient*>( - DBusThreadManager::Get()->GetBluetoothInputClient()); + bluez::BluezDBusManager::Get()->GetBluetoothInputClient()); fake_bluetooth_input_client->RemoveInputDevice(device_path); if (device_path == dbus::ObjectPath(kLowEnergyPath)) { FakeBluetoothGattServiceClient* gatt_service_client = static_cast<FakeBluetoothGattServiceClient*>( - DBusThreadManager::Get()->GetBluetoothGattServiceClient()); + bluez::BluezDBusManager::Get()->GetBluetoothGattServiceClient()); gatt_service_client->HideHeartRateService(); } @@ -1173,7 +1173,7 @@ void FakeBluetoothDeviceClient::SimulatePairing( FakeBluetoothAgentManagerClient* fake_bluetooth_agent_manager_client = static_cast<FakeBluetoothAgentManagerClient*>( - DBusThreadManager::Get()->GetBluetoothAgentManagerClient()); + bluez::BluezDBusManager::Get()->GetBluetoothAgentManagerClient()); FakeBluetoothAgentServiceProvider* agent_service_provider = fake_bluetooth_agent_manager_client->GetAgentServiceProvider(); CHECK(agent_service_provider != NULL); @@ -1426,7 +1426,7 @@ void FakeBluetoothDeviceClient::AddInputDeviceIfNeeded( // simulate the Input interface. FakeBluetoothInputClient* fake_bluetooth_input_client = static_cast<FakeBluetoothInputClient*>( - DBusThreadManager::Get()->GetBluetoothInputClient()); + bluez::BluezDBusManager::Get()->GetBluetoothInputClient()); if ((properties->bluetooth_class.value() & 0x001f03) == 0x000500) fake_bluetooth_input_client->AddInputDevice(object_path); @@ -1596,7 +1596,7 @@ void FakeBluetoothDeviceClient::SimulateKeypress( FakeBluetoothAgentManagerClient* fake_bluetooth_agent_manager_client = static_cast<FakeBluetoothAgentManagerClient*>( - DBusThreadManager::Get()->GetBluetoothAgentManagerClient()); + bluez::BluezDBusManager::Get()->GetBluetoothAgentManagerClient()); FakeBluetoothAgentServiceProvider* agent_service_provider = fake_bluetooth_agent_manager_client->GetAgentServiceProvider(); @@ -1659,4 +1659,4 @@ void FakeBluetoothDeviceClient::DisconnectionCallback( } } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/fake_bluetooth_device_client.h b/device/bluetooth/dbus/fake_bluetooth_device_client.h index 03a2cb1..f8051b4 100644 --- a/chromeos/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> @@ -12,19 +12,20 @@ #include "base/callback.h" #include "base/containers/scoped_ptr_map.h" #include "base/observer_list.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/bluetooth_agent_service_provider.h" -#include "chromeos/dbus/bluetooth_device_client.h" -#include "chromeos/dbus/bluetooth_profile_service_provider.h" #include "dbus/object_path.h" #include "dbus/property.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluetooth_agent_service_provider.h" +#include "device/bluetooth/dbus/bluetooth_device_client.h" +#include "device/bluetooth/dbus/bluetooth_profile_service_provider.h" -namespace chromeos { +namespace bluez { // FakeBluetoothDeviceClient simulates the behavior of the Bluetooth Daemon // device objects and is used both in test cases in place of a mock and on // the Linux desktop. -class CHROMEOS_EXPORT FakeBluetoothDeviceClient : public BluetoothDeviceClient { +class DEVICE_BLUETOOTH_EXPORT FakeBluetoothDeviceClient + : public BluetoothDeviceClient { public: struct Properties : public BluetoothDeviceClient::Properties { explicit Properties(const PropertyChangedCallback& callback); @@ -315,6 +316,6 @@ class CHROMEOS_EXPORT FakeBluetoothDeviceClient : public BluetoothDeviceClient { int16 max_transmit_power_; }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_DEVICE_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_DEVICE_CLIENT_H_ diff --git a/chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc b/device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_client.cc index 69779ec..10f073a 100644 --- a/chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc +++ b/device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_client.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 "chromeos/dbus/fake_bluetooth_gatt_characteristic_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_client.h" #include "base/bind.h" #include "base/location.h" @@ -10,11 +10,11 @@ #include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" #include "base/time/time.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_gatt_descriptor_client.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.h" #include "third_party/cros_system_api/dbus/service_constants.h" -namespace chromeos { +namespace bluez { namespace { @@ -377,7 +377,7 @@ void FakeBluetoothGattCharacteristicClient::ExposeHeartRateCharacteristics( // Expose CCC descriptor for Heart Rate Measurement characteristic. FakeBluetoothGattDescriptorClient* descriptor_client = static_cast<FakeBluetoothGattDescriptorClient*>( - DBusThreadManager::Get()->GetBluetoothGattDescriptorClient()); + bluez::BluezDBusManager::Get()->GetBluetoothGattDescriptorClient()); dbus::ObjectPath ccc_path(descriptor_client->ExposeDescriptor( dbus::ObjectPath(heart_rate_measurement_path_), FakeBluetoothGattDescriptorClient:: @@ -397,7 +397,7 @@ void FakeBluetoothGattCharacteristicClient::HideHeartRateCharacteristics() { // Hide the descriptors. FakeBluetoothGattDescriptorClient* descriptor_client = static_cast<FakeBluetoothGattDescriptorClient*>( - DBusThreadManager::Get()->GetBluetoothGattDescriptorClient()); + bluez::BluezDBusManager::Get()->GetBluetoothGattDescriptorClient()); descriptor_client->HideDescriptor( dbus::ObjectPath(heart_rate_measurement_ccc_desc_path_)); @@ -559,4 +559,4 @@ bool FakeBluetoothGattCharacteristicClient::IsHeartRateVisible() const { return heart_rate_visible_; } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/fake_bluetooth_gatt_characteristic_client.h b/device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_client.h index dc1eab3..89fefcc 100644 --- a/chromeos/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> @@ -12,17 +12,17 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/bluetooth_gatt_characteristic_client.h" #include "dbus/object_path.h" #include "dbus/property.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluetooth_gatt_characteristic_client.h" -namespace chromeos { +namespace bluez { // FakeBluetoothGattCharacteristicClient simulates the behavior of the // Bluetooth Daemon GATT characteristic objects and is used in test cases in // place of a mock and on the Linux desktop. -class CHROMEOS_EXPORT FakeBluetoothGattCharacteristicClient +class DEVICE_BLUETOOTH_EXPORT FakeBluetoothGattCharacteristicClient : public BluetoothGattCharacteristicClient { public: struct Properties : public BluetoothGattCharacteristicClient::Properties { @@ -189,6 +189,6 @@ class CHROMEOS_EXPORT FakeBluetoothGattCharacteristicClient DISALLOW_COPY_AND_ASSIGN(FakeBluetoothGattCharacteristicClient); }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ diff --git a/chromeos/dbus/fake_bluetooth_gatt_characteristic_service_provider.cc b/device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provider.cc index 39132d9..03f06d0 100644 --- a/chromeos/dbus/fake_bluetooth_gatt_characteristic_service_provider.cc +++ b/device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provider.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/dbus/fake_bluetooth_gatt_characteristic_service_provider.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provider.h" #include "base/logging.h" #include "base/strings/string_util.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_gatt_manager_client.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_manager_client.h" -namespace chromeos { +namespace bluez { FakeBluetoothGattCharacteristicServiceProvider:: FakeBluetoothGattCharacteristicServiceProvider( @@ -36,7 +36,7 @@ FakeBluetoothGattCharacteristicServiceProvider:: FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client = static_cast<FakeBluetoothGattManagerClient*>( - DBusThreadManager::Get()->GetBluetoothGattManagerClient()); + bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient()); fake_bluetooth_gatt_manager_client->RegisterCharacteristicServiceProvider( this); } @@ -48,7 +48,7 @@ FakeBluetoothGattCharacteristicServiceProvider:: FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client = static_cast<FakeBluetoothGattManagerClient*>( - DBusThreadManager::Get()->GetBluetoothGattManagerClient()); + bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient()); fake_bluetooth_gatt_manager_client->UnregisterCharacteristicServiceProvider( this); } @@ -68,7 +68,7 @@ void FakeBluetoothGattCharacteristicServiceProvider::GetValue( // Check if this characteristic is registered. FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client = static_cast<FakeBluetoothGattManagerClient*>( - DBusThreadManager::Get()->GetBluetoothGattManagerClient()); + bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient()); if (!fake_bluetooth_gatt_manager_client->IsServiceRegistered(service_path_)) { VLOG(1) << "GATT characteristic not registered."; error_callback.Run(); @@ -90,7 +90,7 @@ void FakeBluetoothGattCharacteristicServiceProvider::SetValue( // Check if this characteristic is registered. FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client = static_cast<FakeBluetoothGattManagerClient*>( - DBusThreadManager::Get()->GetBluetoothGattManagerClient()); + bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient()); if (!fake_bluetooth_gatt_manager_client->IsServiceRegistered(service_path_)) { VLOG(1) << "GATT characteristic not registered."; error_callback.Run(); @@ -102,4 +102,4 @@ void FakeBluetoothGattCharacteristicServiceProvider::SetValue( delegate_->SetCharacteristicValue(value, callback, error_callback); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/fake_bluetooth_gatt_characteristic_service_provider.h b/device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provider.h index 8a8440b..675eba9 100644 --- a/chromeos/dbus/fake_bluetooth_gatt_characteristic_service_provider.h +++ b/device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provider.h @@ -2,22 +2,23 @@ // 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> -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/bluetooth_gatt_characteristic_service_provider.h" +#include "base/macros.h" #include "dbus/object_path.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluetooth_gatt_characteristic_service_provider.h" -namespace chromeos { +namespace bluez { // FakeBluetoothGattCharacteristicServiceProvider simulates behavior of a local // GATT characteristic object and is used both in test cases in place of a mock // and on the Linux desktop. -class CHROMEOS_EXPORT FakeBluetoothGattCharacteristicServiceProvider +class DEVICE_BLUETOOTH_EXPORT FakeBluetoothGattCharacteristicServiceProvider : public BluetoothGattCharacteristicServiceProvider { public: FakeBluetoothGattCharacteristicServiceProvider( @@ -61,6 +62,6 @@ class CHROMEOS_EXPORT FakeBluetoothGattCharacteristicServiceProvider DISALLOW_COPY_AND_ASSIGN(FakeBluetoothGattCharacteristicServiceProvider); }; -} // namespace chromeos +} // 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/chromeos/dbus/fake_bluetooth_gatt_descriptor_client.cc b/device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.cc index 2e9cdf0..dcaf1ec 100644 --- a/chromeos/dbus/fake_bluetooth_gatt_descriptor_client.cc +++ b/device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/dbus/fake_bluetooth_gatt_descriptor_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.h" #include "base/bind.h" #include "base/logging.h" -#include "chromeos/dbus/bluetooth_gatt_characteristic_client.h" -#include "chromeos/dbus/dbus_thread_manager.h" +#include "device/bluetooth/dbus/bluetooth_gatt_characteristic_client.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" #include "third_party/cros_system_api/dbus/service_constants.h" -namespace chromeos { +namespace bluez { const char FakeBluetoothGattDescriptorClient:: kClientCharacteristicConfigurationPathComponent[] = "desc0000"; @@ -101,7 +101,7 @@ void FakeBluetoothGattDescriptorClient::ReadValue( Properties* properties = iter->second->properties.get(); if (properties->uuid.value() == kClientCharacteristicConfigurationUUID) { BluetoothGattCharacteristicClient::Properties* chrc_props = - DBusThreadManager::Get() + bluez::BluezDBusManager::Get() ->GetBluetoothGattCharacteristicClient() ->GetProperties(properties->characteristic.value()); DCHECK(chrc_props); @@ -206,4 +206,4 @@ void FakeBluetoothGattDescriptorClient::NotifyDescriptorRemoved( GattDescriptorRemoved(object_path)); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/fake_bluetooth_gatt_descriptor_client.h b/device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.h index e6106c1..0e8e856 100644 --- a/chromeos/dbus/fake_bluetooth_gatt_descriptor_client.h +++ b/device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.h @@ -2,24 +2,25 @@ // 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> +#include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/bluetooth_gatt_descriptor_client.h" #include "dbus/object_path.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluetooth_gatt_descriptor_client.h" -namespace chromeos { +namespace bluez { // FakeBluetoothGattDescriptorClient simulates the behavior of the Bluetooth // Daemon GATT characteristic descriptor objects and is used in test cases in // place of a mock and on the Linux desktop. -class CHROMEOS_EXPORT FakeBluetoothGattDescriptorClient +class DEVICE_BLUETOOTH_EXPORT FakeBluetoothGattDescriptorClient : public BluetoothGattDescriptorClient { public: struct Properties : public BluetoothGattDescriptorClient::Properties { @@ -98,6 +99,6 @@ class CHROMEOS_EXPORT FakeBluetoothGattDescriptorClient DISALLOW_COPY_AND_ASSIGN(FakeBluetoothGattDescriptorClient); }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_DESCRIPTOR_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_DESCRIPTOR_CLIENT_H_ diff --git a/chromeos/dbus/fake_bluetooth_gatt_descriptor_service_provider.cc b/device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_service_provider.cc index ad002ab..4376ce9 100644 --- a/chromeos/dbus/fake_bluetooth_gatt_descriptor_service_provider.cc +++ b/device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_service_provider.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/dbus/fake_bluetooth_gatt_descriptor_service_provider.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_service_provider.h" #include "base/logging.h" #include "base/strings/string_util.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_gatt_characteristic_service_provider.h" -#include "chromeos/dbus/fake_bluetooth_gatt_manager_client.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provider.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_manager_client.h" -namespace chromeos { +namespace bluez { FakeBluetoothGattDescriptorServiceProvider:: FakeBluetoothGattDescriptorServiceProvider( @@ -37,7 +37,7 @@ FakeBluetoothGattDescriptorServiceProvider:: FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client = static_cast<FakeBluetoothGattManagerClient*>( - DBusThreadManager::Get()->GetBluetoothGattManagerClient()); + bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient()); fake_bluetooth_gatt_manager_client->RegisterDescriptorServiceProvider(this); } @@ -47,7 +47,7 @@ FakeBluetoothGattDescriptorServiceProvider:: FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client = static_cast<FakeBluetoothGattManagerClient*>( - DBusThreadManager::Get()->GetBluetoothGattManagerClient()); + bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient()); fake_bluetooth_gatt_manager_client->UnregisterDescriptorServiceProvider(this); } @@ -66,7 +66,7 @@ void FakeBluetoothGattDescriptorServiceProvider::GetValue( // Check if this descriptor is registered. FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client = static_cast<FakeBluetoothGattManagerClient*>( - DBusThreadManager::Get()->GetBluetoothGattManagerClient()); + bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient()); FakeBluetoothGattCharacteristicServiceProvider* characteristic = fake_bluetooth_gatt_manager_client->GetCharacteristicServiceProvider( characteristic_path_); @@ -97,7 +97,7 @@ void FakeBluetoothGattDescriptorServiceProvider::SetValue( // Check if this descriptor is registered. FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client = static_cast<FakeBluetoothGattManagerClient*>( - DBusThreadManager::Get()->GetBluetoothGattManagerClient()); + bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient()); FakeBluetoothGattCharacteristicServiceProvider* characteristic = fake_bluetooth_gatt_manager_client->GetCharacteristicServiceProvider( characteristic_path_); @@ -118,4 +118,4 @@ void FakeBluetoothGattDescriptorServiceProvider::SetValue( delegate_->SetDescriptorValue(value, callback, error_callback); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/fake_bluetooth_gatt_descriptor_service_provider.h b/device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_service_provider.h index 054c21d..7640acc 100644 --- a/chromeos/dbus/fake_bluetooth_gatt_descriptor_service_provider.h +++ b/device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_service_provider.h @@ -2,22 +2,23 @@ // 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> -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/bluetooth_gatt_descriptor_service_provider.h" +#include "base/macros.h" #include "dbus/object_path.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluetooth_gatt_descriptor_service_provider.h" -namespace chromeos { +namespace bluez { // FakeBluetoothGattDescriptorServiceProvider simulates behavior of a local // GATT descriptor object and is used both in test cases in place of a mock // and on the Linux desktop. -class CHROMEOS_EXPORT FakeBluetoothGattDescriptorServiceProvider +class DEVICE_BLUETOOTH_EXPORT FakeBluetoothGattDescriptorServiceProvider : public BluetoothGattDescriptorServiceProvider { public: FakeBluetoothGattDescriptorServiceProvider( @@ -62,6 +63,6 @@ class CHROMEOS_EXPORT FakeBluetoothGattDescriptorServiceProvider DISALLOW_COPY_AND_ASSIGN(FakeBluetoothGattDescriptorServiceProvider); }; -} // namespace chromeos +} // 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/chromeos/dbus/fake_bluetooth_gatt_manager_client.cc b/device/bluetooth/dbus/fake_bluetooth_gatt_manager_client.cc index 1127eae..284a17c 100644 --- a/chromeos/dbus/fake_bluetooth_gatt_manager_client.cc +++ b/device/bluetooth/dbus/fake_bluetooth_gatt_manager_client.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/dbus/fake_bluetooth_gatt_manager_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_manager_client.h" #include "base/logging.h" -#include "chromeos/dbus/fake_bluetooth_gatt_characteristic_service_provider.h" -#include "chromeos/dbus/fake_bluetooth_gatt_descriptor_service_provider.h" -#include "chromeos/dbus/fake_bluetooth_gatt_service_service_provider.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provider.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_service_provider.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_service_service_provider.h" #include "third_party/cros_system_api/dbus/service_constants.h" -namespace chromeos { +namespace bluez { FakeBluetoothGattManagerClient::FakeBluetoothGattManagerClient() {} @@ -166,4 +166,4 @@ bool FakeBluetoothGattManagerClient::IsServiceRegistered( return iter->second.first; } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/fake_bluetooth_gatt_manager_client.h b/device/bluetooth/dbus/fake_bluetooth_gatt_manager_client.h index cd5d3b0..65082ae 100644 --- a/chromeos/dbus/fake_bluetooth_gatt_manager_client.h +++ b/device/bluetooth/dbus/fake_bluetooth_gatt_manager_client.h @@ -2,19 +2,20 @@ // 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> #include <utility> #include "base/callback.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/bluetooth_gatt_manager_client.h" +#include "base/macros.h" #include "dbus/object_path.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluetooth_gatt_manager_client.h" -namespace chromeos { +namespace bluez { class FakeBluetoothGattCharacteristicServiceProvider; class FakeBluetoothGattDescriptorServiceProvider; @@ -23,7 +24,7 @@ class FakeBluetoothGattServiceServiceProvider; // FakeBluetoothGattManagerClient simulates the behavior of the Bluetooth // daemon's GATT manager object and is used both in test cases in place of a // mock and on the Linux desktop. -class CHROMEOS_EXPORT FakeBluetoothGattManagerClient +class DEVICE_BLUETOOTH_EXPORT FakeBluetoothGattManagerClient : public BluetoothGattManagerClient { public: FakeBluetoothGattManagerClient(); @@ -95,6 +96,6 @@ class CHROMEOS_EXPORT FakeBluetoothGattManagerClient DISALLOW_COPY_AND_ASSIGN(FakeBluetoothGattManagerClient); }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_MANAGER_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_MANAGER_CLIENT_H_ diff --git a/chromeos/dbus/fake_bluetooth_gatt_service_client.cc b/device/bluetooth/dbus/fake_bluetooth_gatt_service_client.cc index 47b39b6..2e7aa0a 100644 --- a/chromeos/dbus/fake_bluetooth_gatt_service_client.cc +++ b/device/bluetooth/dbus/fake_bluetooth_gatt_service_client.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 "chromeos/dbus/fake_bluetooth_gatt_service_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_service_client.h" #include "base/bind.h" #include "base/location.h" #include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" #include "base/time/time.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_gatt_characteristic_client.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_client.h" #include "third_party/cros_system_api/dbus/service_constants.h" -namespace chromeos { +namespace bluez { namespace { @@ -122,7 +122,8 @@ void FakeBluetoothGattServiceClient::HideHeartRateService() { VLOG(2) << "Hiding fake Heart Rate Service."; FakeBluetoothGattCharacteristicClient* char_client = static_cast<FakeBluetoothGattCharacteristicClient*>( - DBusThreadManager::Get()->GetBluetoothGattCharacteristicClient()); + bluez::BluezDBusManager::Get() + ->GetBluetoothGattCharacteristicClient()); char_client->HideHeartRateCharacteristics(); // Notify observers before deleting the properties structure so that it @@ -172,7 +173,8 @@ void FakeBluetoothGattServiceClient::ExposeHeartRateCharacteristics() { } FakeBluetoothGattCharacteristicClient* char_client = static_cast<FakeBluetoothGattCharacteristicClient*>( - DBusThreadManager::Get()->GetBluetoothGattCharacteristicClient()); + bluez::BluezDBusManager::Get() + ->GetBluetoothGattCharacteristicClient()); char_client->ExposeHeartRateCharacteristics( dbus::ObjectPath(heart_rate_service_path_)); @@ -184,4 +186,4 @@ void FakeBluetoothGattServiceClient::ExposeHeartRateCharacteristics() { heart_rate_service_properties_->characteristics.ReplaceValue(char_paths); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/fake_bluetooth_gatt_service_client.h b/device/bluetooth/dbus/fake_bluetooth_gatt_service_client.h index f719727..faebb42 100644 --- a/chromeos/dbus/fake_bluetooth_gatt_service_client.h +++ b/device/bluetooth/dbus/fake_bluetooth_gatt_service_client.h @@ -2,26 +2,27 @@ // 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> +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/bluetooth_gatt_service_client.h" #include "dbus/object_path.h" #include "dbus/property.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluetooth_gatt_service_client.h" -namespace chromeos { +namespace bluez { // FakeBluetoothGattServiceClient simulates the behavior of the Bluetooth Daemon // GATT service objects and is used in test cases in place of a mock and on the // Linux desktop. -class CHROMEOS_EXPORT FakeBluetoothGattServiceClient +class DEVICE_BLUETOOTH_EXPORT FakeBluetoothGattServiceClient : public BluetoothGattServiceClient { public: struct Properties : public BluetoothGattServiceClient::Properties { @@ -101,6 +102,6 @@ class CHROMEOS_EXPORT FakeBluetoothGattServiceClient DISALLOW_COPY_AND_ASSIGN(FakeBluetoothGattServiceClient); }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_SERVICE_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_SERVICE_CLIENT_H_ diff --git a/chromeos/dbus/fake_bluetooth_gatt_service_service_provider.cc b/device/bluetooth/dbus/fake_bluetooth_gatt_service_service_provider.cc index f59cf98..8d724058 100644 --- a/chromeos/dbus/fake_bluetooth_gatt_service_service_provider.cc +++ b/device/bluetooth/dbus/fake_bluetooth_gatt_service_service_provider.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/dbus/fake_bluetooth_gatt_service_service_provider.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_service_service_provider.h" #include "base/logging.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_gatt_manager_client.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" +#include "device/bluetooth/dbus/fake_bluetooth_gatt_manager_client.h" -namespace chromeos { +namespace bluez { FakeBluetoothGattServiceServiceProvider:: FakeBluetoothGattServiceServiceProvider( @@ -20,7 +20,7 @@ FakeBluetoothGattServiceServiceProvider:: FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client = static_cast<FakeBluetoothGattManagerClient*>( - DBusThreadManager::Get()->GetBluetoothGattManagerClient()); + bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient()); fake_bluetooth_gatt_manager_client->RegisterServiceServiceProvider(this); } @@ -30,8 +30,8 @@ FakeBluetoothGattServiceServiceProvider:: FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client = static_cast<FakeBluetoothGattManagerClient*>( - DBusThreadManager::Get()->GetBluetoothGattManagerClient()); + bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient()); fake_bluetooth_gatt_manager_client->UnregisterServiceServiceProvider(this); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/fake_bluetooth_gatt_service_service_provider.h b/device/bluetooth/dbus/fake_bluetooth_gatt_service_service_provider.h index 6b49d78..ca8b52e 100644 --- a/chromeos/dbus/fake_bluetooth_gatt_service_service_provider.h +++ b/device/bluetooth/dbus/fake_bluetooth_gatt_service_service_provider.h @@ -2,22 +2,23 @@ // 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_SERVICE_PROVIDER_H_ -#define CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_SERVICE_SERVICE_PROVIDER_H_ +#ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_SERVICE_SERVICE_PROVIDER_H_ +#define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_SERVICE_SERVICE_PROVIDER_H_ #include <string> #include <vector> -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/bluetooth_gatt_service_service_provider.h" +#include "base/macros.h" #include "dbus/object_path.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluetooth_gatt_service_service_provider.h" -namespace chromeos { +namespace bluez { // FakeBluetoothGattServiceServiceProvider simulates behavior of a local GATT // service object and is used both in test cases in place of a mock and on the // Linux desktop. -class CHROMEOS_EXPORT FakeBluetoothGattServiceServiceProvider +class DEVICE_BLUETOOTH_EXPORT FakeBluetoothGattServiceServiceProvider : public BluetoothGattServiceServiceProvider { public: FakeBluetoothGattServiceServiceProvider( @@ -42,6 +43,6 @@ class CHROMEOS_EXPORT FakeBluetoothGattServiceServiceProvider DISALLOW_COPY_AND_ASSIGN(FakeBluetoothGattServiceServiceProvider); }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_SERVICE_SERVICE_PROVIDER_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_SERVICE_SERVICE_PROVIDER_H_ diff --git a/chromeos/dbus/fake_bluetooth_input_client.cc b/device/bluetooth/dbus/fake_bluetooth_input_client.cc index ab2c66b..849c3be 100644 --- a/chromeos/dbus/fake_bluetooth_input_client.cc +++ b/device/bluetooth/dbus/fake_bluetooth_input_client.cc @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/dbus/fake_bluetooth_input_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_input_client.h" #include <map> #include "base/logging.h" #include "base/stl_util.h" -#include "chromeos/dbus/fake_bluetooth_device_client.h" #include "dbus/bus.h" #include "dbus/message.h" #include "dbus/object_manager.h" #include "dbus/object_proxy.h" +#include "device/bluetooth/dbus/fake_bluetooth_device_client.h" #include "third_party/cros_system_api/dbus/service_constants.h" -namespace chromeos { +namespace bluez { FakeBluetoothInputClient::Properties::Properties( const PropertyChangedCallback& callback) @@ -120,4 +120,4 @@ void FakeBluetoothInputClient::OnPropertyChanged( InputPropertyChanged(object_path, property_name)); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/fake_bluetooth_input_client.h b/device/bluetooth/dbus/fake_bluetooth_input_client.h index 22369eb..81139db 100644 --- a/chromeos/dbus/fake_bluetooth_input_client.h +++ b/device/bluetooth/dbus/fake_bluetooth_input_client.h @@ -2,22 +2,24 @@ // 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/macros.h" #include "base/observer_list.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/bluetooth_input_client.h" #include "dbus/object_path.h" #include "dbus/property.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluetooth_input_client.h" -namespace chromeos { +namespace bluez { // FakeBluetoothInputClient simulates the behavior of the Bluetooth Daemon // input device objects and is used both in test cases in place of a mock and on // the Linux desktop. -class CHROMEOS_EXPORT FakeBluetoothInputClient : public BluetoothInputClient { +class DEVICE_BLUETOOTH_EXPORT FakeBluetoothInputClient + : public BluetoothInputClient { public: struct Properties : public BluetoothInputClient::Properties { explicit Properties(const PropertyChangedCallback& callback); @@ -59,6 +61,6 @@ class CHROMEOS_EXPORT FakeBluetoothInputClient : public BluetoothInputClient { DISALLOW_COPY_AND_ASSIGN(FakeBluetoothInputClient); }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_INPUT_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_INPUT_CLIENT_H_ diff --git a/chromeos/dbus/fake_bluetooth_le_advertisement_service_provider.cc b/device/bluetooth/dbus/fake_bluetooth_le_advertisement_service_provider.cc index ce46e3d..043df05 100644 --- a/chromeos/dbus/fake_bluetooth_le_advertisement_service_provider.cc +++ b/device/bluetooth/dbus/fake_bluetooth_le_advertisement_service_provider.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_le_advertisement_service_provider.h" -#include "chromeos/dbus/fake_bluetooth_le_advertising_manager_client.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" +#include "device/bluetooth/dbus/fake_bluetooth_le_advertisement_service_provider.h" +#include "device/bluetooth/dbus/fake_bluetooth_le_advertising_manager_client.h" -namespace chromeos { +namespace bluez { FakeBluetoothLEAdvertisementServiceProvider:: FakeBluetoothLEAdvertisementServiceProvider( @@ -19,7 +19,7 @@ FakeBluetoothLEAdvertisementServiceProvider:: FakeBluetoothLEAdvertisingManagerClient* fake_bluetooth_profile_manager_client = static_cast<FakeBluetoothLEAdvertisingManagerClient*>( - DBusThreadManager::Get() + bluez::BluezDBusManager::Get() ->GetBluetoothLEAdvertisingManagerClient()); fake_bluetooth_profile_manager_client->RegisterAdvertisementServiceProvider( this); @@ -32,7 +32,7 @@ FakeBluetoothLEAdvertisementServiceProvider:: FakeBluetoothLEAdvertisingManagerClient* fake_bluetooth_profile_manager_client = static_cast<FakeBluetoothLEAdvertisingManagerClient*>( - DBusThreadManager::Get() + bluez::BluezDBusManager::Get() ->GetBluetoothLEAdvertisingManagerClient()); fake_bluetooth_profile_manager_client->UnregisterAdvertisementServiceProvider( this); @@ -43,4 +43,4 @@ void FakeBluetoothLEAdvertisementServiceProvider::Release() { delegate_->Released(); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/fake_bluetooth_le_advertisement_service_provider.h b/device/bluetooth/dbus/fake_bluetooth_le_advertisement_service_provider.h index 5a19aee..29c8133 100644 --- a/chromeos/dbus/fake_bluetooth_le_advertisement_service_provider.h +++ b/device/bluetooth/dbus/fake_bluetooth_le_advertisement_service_provider.h @@ -2,23 +2,24 @@ // 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" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/bluetooth_le_advertisement_service_provider.h" #include "dbus/file_descriptor.h" #include "dbus/object_path.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluetooth_le_advertisement_service_provider.h" -namespace chromeos { +namespace bluez { // FakeBluetoothAdvertisementServiceProvider simulates the behavior of a local // Bluetooth agent object and is used both in test cases in place of a // mock and on the Linux desktop. -class CHROMEOS_EXPORT FakeBluetoothLEAdvertisementServiceProvider +class DEVICE_BLUETOOTH_EXPORT FakeBluetoothLEAdvertisementServiceProvider : public BluetoothLEAdvertisementServiceProvider { public: FakeBluetoothLEAdvertisementServiceProvider( @@ -44,6 +45,6 @@ class CHROMEOS_EXPORT FakeBluetoothLEAdvertisementServiceProvider DISALLOW_COPY_AND_ASSIGN(FakeBluetoothLEAdvertisementServiceProvider); }; -} // namespace chromeos +} // 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/chromeos/dbus/fake_bluetooth_le_advertising_manager_client.cc b/device/bluetooth/dbus/fake_bluetooth_le_advertising_manager_client.cc index 201fc42..2fcccd1 100644 --- a/chromeos/dbus/fake_bluetooth_le_advertising_manager_client.cc +++ b/device/bluetooth/dbus/fake_bluetooth_le_advertising_manager_client.cc @@ -9,11 +9,11 @@ #include "dbus/bus.h" #include "dbus/message.h" #include "dbus/object_proxy.h" -#include "fake_bluetooth_le_advertisement_service_provider.h" -#include "fake_bluetooth_le_advertising_manager_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_le_advertisement_service_provider.h" +#include "device/bluetooth/dbus/fake_bluetooth_le_advertising_manager_client.h" #include "third_party/cros_system_api/dbus/service_constants.h" -namespace chromeos { +namespace bluez { const char FakeBluetoothLEAdvertisingManagerClient::kAdvertisingManagerPath[] = "/fake/hci0"; @@ -98,4 +98,4 @@ void FakeBluetoothLEAdvertisingManagerClient:: service_provider_map_.erase(iter); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/fake_bluetooth_le_advertising_manager_client.h b/device/bluetooth/dbus/fake_bluetooth_le_advertising_manager_client.h index 5df129c..ae0d914 100644 --- a/chromeos/dbus/fake_bluetooth_le_advertising_manager_client.h +++ b/device/bluetooth/dbus/fake_bluetooth_le_advertising_manager_client.h @@ -2,21 +2,22 @@ // 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> #include "base/bind.h" #include "base/callback.h" +#include "base/macros.h" #include "base/observer_list.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/bluetooth_le_advertising_manager_client.h" #include "dbus/object_path.h" #include "dbus/property.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluetooth_le_advertising_manager_client.h" -namespace chromeos { +namespace bluez { class FakeBluetoothLEAdvertisementServiceProvider; @@ -24,7 +25,7 @@ class FakeBluetoothLEAdvertisementServiceProvider; // Bluetooth // Daemon's profile manager object and is used both in test cases in place of a // mock and on the Linux desktop. -class CHROMEOS_EXPORT FakeBluetoothLEAdvertisingManagerClient +class DEVICE_BLUETOOTH_EXPORT FakeBluetoothLEAdvertisingManagerClient : public BluetoothLEAdvertisingManagerClient { public: FakeBluetoothLEAdvertisingManagerClient(); @@ -74,6 +75,6 @@ class CHROMEOS_EXPORT FakeBluetoothLEAdvertisingManagerClient DISALLOW_COPY_AND_ASSIGN(FakeBluetoothLEAdvertisingManagerClient); }; -} // namespace chromeos +} // 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/chromeos/dbus/fake_bluetooth_media_client.cc b/device/bluetooth/dbus/fake_bluetooth_media_client.cc index f9cfb5a..246a140 100644 --- a/chromeos/dbus/fake_bluetooth_media_client.cc +++ b/device/bluetooth/dbus/fake_bluetooth_media_client.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/dbus/fake_bluetooth_media_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_media_client.h" #include <string> #include "base/stl_util.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_adapter_client.h" -#include "chromeos/dbus/fake_bluetooth_media_endpoint_service_provider.h" -#include "chromeos/dbus/fake_bluetooth_media_transport_client.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" +#include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_media_endpoint_service_provider.h" +#include "device/bluetooth/dbus/fake_bluetooth_media_transport_client.h" using dbus::ObjectPath; @@ -23,7 +23,7 @@ const char kInvalidArgumentsError[] = "org.chromium.Error.InvalidArguments"; } // namespace -namespace chromeos { +namespace bluez { // static const uint8_t FakeBluetoothMediaClient::kDefaultCodec = 0x00; @@ -119,7 +119,7 @@ void FakeBluetoothMediaClient::SetEndpointRegistered( // transport. FakeBluetoothMediaTransportClient* transport = static_cast<FakeBluetoothMediaTransportClient*>( - DBusThreadManager::Get()->GetBluetoothMediaTransportClient()); + bluez::BluezDBusManager::Get()->GetBluetoothMediaTransportClient()); transport->SetValid(endpoint, false); endpoints_.erase(endpoint->object_path()); @@ -131,4 +131,4 @@ bool FakeBluetoothMediaClient::IsRegistered( return ContainsKey(endpoints_, endpoint_path); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/fake_bluetooth_media_client.h b/device/bluetooth/dbus/fake_bluetooth_media_client.h index 3b4f4a7..2049f43 100644 --- a/chromeos/dbus/fake_bluetooth_media_client.h +++ b/device/bluetooth/dbus/fake_bluetooth_media_client.h @@ -2,22 +2,24 @@ // 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> #include "base/callback.h" +#include "base/macros.h" #include "base/observer_list.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/bluetooth_media_client.h" #include "dbus/object_path.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluetooth_media_client.h" -namespace chromeos { +namespace bluez { class FakeBluetoothMediaEndpointServiceProvider; -class CHROMEOS_EXPORT FakeBluetoothMediaClient : public BluetoothMediaClient { +class DEVICE_BLUETOOTH_EXPORT FakeBluetoothMediaClient + : public BluetoothMediaClient { public: // The default codec is SBC(0x00). static const uint8_t kDefaultCodec; @@ -71,6 +73,6 @@ class CHROMEOS_EXPORT FakeBluetoothMediaClient : public BluetoothMediaClient { DISALLOW_COPY_AND_ASSIGN(FakeBluetoothMediaClient); }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_MEDIA_CLIENT_H_ diff --git a/chromeos/dbus/fake_bluetooth_media_endpoint_service_provider.cc b/device/bluetooth/dbus/fake_bluetooth_media_endpoint_service_provider.cc index a275374..83a0822 100644 --- a/chromeos/dbus/fake_bluetooth_media_endpoint_service_provider.cc +++ b/device/bluetooth/dbus/fake_bluetooth_media_endpoint_service_provider.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/dbus/fake_bluetooth_media_endpoint_service_provider.h" +#include "device/bluetooth/dbus/fake_bluetooth_media_endpoint_service_provider.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_media_client.h" -#include "chromeos/dbus/fake_bluetooth_media_transport_client.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" +#include "device/bluetooth/dbus/fake_bluetooth_media_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_media_transport_client.h" using dbus::ObjectPath; -namespace chromeos { +namespace bluez { FakeBluetoothMediaEndpointServiceProvider:: FakeBluetoothMediaEndpointServiceProvider(const ObjectPath& object_path, @@ -43,7 +43,7 @@ void FakeBluetoothMediaEndpointServiceProvider::SelectConfiguration( // Makes the transport object valid for the given endpoint path. FakeBluetoothMediaTransportClient* transport = static_cast<FakeBluetoothMediaTransportClient*>( - DBusThreadManager::Get()->GetBluetoothMediaTransportClient()); + bluez::BluezDBusManager::Get()->GetBluetoothMediaTransportClient()); DCHECK(transport); transport->SetValid(this, true); } @@ -62,4 +62,4 @@ void FakeBluetoothMediaEndpointServiceProvider::Released() { delegate_->Released(); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/fake_bluetooth_media_endpoint_service_provider.h b/device/bluetooth/dbus/fake_bluetooth_media_endpoint_service_provider.h index 5efe14f..2e6b18a 100644 --- a/chromeos/dbus/fake_bluetooth_media_endpoint_service_provider.h +++ b/device/bluetooth/dbus/fake_bluetooth_media_endpoint_service_provider.h @@ -2,22 +2,23 @@ // 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> #include "base/logging.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/bluetooth_media_endpoint_service_provider.h" +#include "base/macros.h" #include "dbus/object_path.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluetooth_media_endpoint_service_provider.h" #include "testing/gtest/include/gtest/gtest_prod.h" -namespace chromeos { +namespace bluez { // FakeBluetoothMediaEndpointServiceProvider simulates the behavior of a local // Bluetooth Media Endpoint object. -class CHROMEOS_EXPORT FakeBluetoothMediaEndpointServiceProvider +class DEVICE_BLUETOOTH_EXPORT FakeBluetoothMediaEndpointServiceProvider : public BluetoothMediaEndpointServiceProvider { public: FakeBluetoothMediaEndpointServiceProvider(const dbus::ObjectPath& object_path, @@ -52,6 +53,6 @@ class CHROMEOS_EXPORT FakeBluetoothMediaEndpointServiceProvider DISALLOW_COPY_AND_ASSIGN(FakeBluetoothMediaEndpointServiceProvider); }; -} // namespace chromeos +} // 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/chromeos/dbus/fake_bluetooth_media_transport_client.cc b/device/bluetooth/dbus/fake_bluetooth_media_transport_client.cc index ae8f89b..1a0a106 100644 --- a/chromeos/dbus/fake_bluetooth_media_transport_client.cc +++ b/device/bluetooth/dbus/fake_bluetooth_media_transport_client.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 "chromeos/dbus/fake_bluetooth_media_transport_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_media_transport_client.h" #include <unistd.h> #include <sys/socket.h> @@ -11,12 +11,12 @@ #include "base/bind.h" #include "base/stl_util.h" -#include "chromeos/dbus/bluetooth_media_client.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_adapter_client.h" -#include "chromeos/dbus/fake_bluetooth_media_client.h" -#include "chromeos/dbus/fake_bluetooth_media_endpoint_service_provider.h" #include "dbus/file_descriptor.h" +#include "device/bluetooth/dbus/bluetooth_media_client.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" +#include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_media_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_media_endpoint_service_provider.h" using dbus::ObjectPath; @@ -35,8 +35,8 @@ ObjectPath GenerateTransportPath() { static unsigned int sequence_number = 0; ++sequence_number; std::stringstream path; - path << chromeos::FakeBluetoothAdapterClient::kAdapterPath - << chromeos::FakeBluetoothMediaTransportClient::kTransportDevicePath + path << bluez::FakeBluetoothAdapterClient::kAdapterPath + << bluez::FakeBluetoothMediaTransportClient::kTransportDevicePath << "/fd" << sequence_number; return ObjectPath(path.str()); } @@ -46,7 +46,7 @@ ObjectPath GenerateTransportPath() { } // namespace -namespace chromeos { +namespace bluez { // static const char FakeBluetoothMediaTransportClient::kTransportDevicePath[] = @@ -153,7 +153,7 @@ void FakeBluetoothMediaTransportClient::SetValid( FakeBluetoothMediaEndpointServiceProvider* endpoint, bool valid) { FakeBluetoothMediaClient* media = static_cast<FakeBluetoothMediaClient*>( - DBusThreadManager::Get()->GetBluetoothMediaClient()); + bluez::BluezDBusManager::Get()->GetBluetoothMediaClient()); DCHECK(media); ObjectPath endpoint_path(endpoint->object_path()); @@ -325,4 +325,4 @@ void FakeBluetoothMediaTransportClient::AcquireInternal( SetState(endpoint_path, "active"); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/fake_bluetooth_media_transport_client.h b/device/bluetooth/dbus/fake_bluetooth_media_transport_client.h index bbf30a5..8ad3bb9 100644 --- a/chromeos/dbus/fake_bluetooth_media_transport_client.h +++ b/device/bluetooth/dbus/fake_bluetooth_media_transport_client.h @@ -2,25 +2,26 @@ // 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> #include <vector> #include "base/files/file.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/observer_list.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/bluetooth_media_transport_client.h" #include "dbus/object_path.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluetooth_media_transport_client.h" -namespace chromeos { +namespace bluez { class FakeBluetoothMediaEndpointServiceProvider; -class CHROMEOS_EXPORT FakeBluetoothMediaTransportClient +class DEVICE_BLUETOOTH_EXPORT FakeBluetoothMediaTransportClient : public BluetoothMediaTransportClient { public: struct Properties : public BluetoothMediaTransportClient::Properties { @@ -143,6 +144,6 @@ class CHROMEOS_EXPORT FakeBluetoothMediaTransportClient DISALLOW_COPY_AND_ASSIGN(FakeBluetoothMediaTransportClient); }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ diff --git a/chromeos/dbus/fake_bluetooth_profile_manager_client.cc b/device/bluetooth/dbus/fake_bluetooth_profile_manager_client.cc index 1a06d41..96254a5 100644 --- a/chromeos/dbus/fake_bluetooth_profile_manager_client.cc +++ b/device/bluetooth/dbus/fake_bluetooth_profile_manager_client.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 "chromeos/dbus/fake_bluetooth_profile_manager_client.h" +#include "device/bluetooth/dbus/fake_bluetooth_profile_manager_client.h" #include "base/location.h" #include "base/logging.h" #include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" -#include "chromeos/dbus/fake_bluetooth_profile_service_provider.h" #include "dbus/bus.h" #include "dbus/message.h" #include "dbus/object_proxy.h" +#include "device/bluetooth/dbus/fake_bluetooth_profile_service_provider.h" #include "third_party/cros_system_api/dbus/service_constants.h" -namespace chromeos { +namespace bluez { const char FakeBluetoothProfileManagerClient::kL2capUuid[] = "4d995052-33cc-4fdf-b446-75f32942a076"; @@ -108,4 +108,4 @@ FakeBluetoothProfileManagerClient::GetProfileServiceProvider( return service_provider_map_[iter->second]; } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/fake_bluetooth_profile_manager_client.h b/device/bluetooth/dbus/fake_bluetooth_profile_manager_client.h index c142606..8ed7826 100644 --- a/chromeos/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> @@ -11,19 +11,19 @@ #include "base/bind.h" #include "base/callback.h" #include "base/observer_list.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/bluetooth_profile_manager_client.h" #include "dbus/object_path.h" #include "dbus/property.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluetooth_profile_manager_client.h" -namespace chromeos { +namespace bluez { class FakeBluetoothProfileServiceProvider; // FakeBluetoothProfileManagerClient simulates the behavior of the Bluetooth // Daemon's profile manager object and is used both in test cases in place of a // mock and on the Linux desktop. -class CHROMEOS_EXPORT FakeBluetoothProfileManagerClient +class DEVICE_BLUETOOTH_EXPORT FakeBluetoothProfileManagerClient : public BluetoothProfileManagerClient { public: FakeBluetoothProfileManagerClient(); @@ -69,6 +69,6 @@ class CHROMEOS_EXPORT FakeBluetoothProfileManagerClient ProfileMap profile_map_; }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_PROFILE_MANAGER_CLIENT_H_ diff --git a/chromeos/dbus/fake_bluetooth_profile_service_provider.cc b/device/bluetooth/dbus/fake_bluetooth_profile_service_provider.cc index 6f9c345..1089501 100644 --- a/chromeos/dbus/fake_bluetooth_profile_service_provider.cc +++ b/device/bluetooth/dbus/fake_bluetooth_profile_service_provider.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 "chromeos/dbus/fake_bluetooth_profile_service_provider.h" +#include "device/bluetooth/dbus/fake_bluetooth_profile_service_provider.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_profile_manager_client.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" +#include "device/bluetooth/dbus/fake_bluetooth_profile_manager_client.h" -namespace chromeos { +namespace bluez { FakeBluetoothProfileServiceProvider::FakeBluetoothProfileServiceProvider( const dbus::ObjectPath& object_path, @@ -17,7 +17,7 @@ FakeBluetoothProfileServiceProvider::FakeBluetoothProfileServiceProvider( FakeBluetoothProfileManagerClient* fake_bluetooth_profile_manager_client = static_cast<FakeBluetoothProfileManagerClient*>( - DBusThreadManager::Get()->GetBluetoothProfileManagerClient()); + bluez::BluezDBusManager::Get()->GetBluetoothProfileManagerClient()); fake_bluetooth_profile_manager_client->RegisterProfileServiceProvider(this); } @@ -26,7 +26,7 @@ FakeBluetoothProfileServiceProvider::~FakeBluetoothProfileServiceProvider() { FakeBluetoothProfileManagerClient* fake_bluetooth_profile_manager_client = static_cast<FakeBluetoothProfileManagerClient*>( - DBusThreadManager::Get()->GetBluetoothProfileManagerClient()); + bluez::BluezDBusManager::Get()->GetBluetoothProfileManagerClient()); fake_bluetooth_profile_manager_client->UnregisterProfileServiceProvider(this); } @@ -58,4 +58,4 @@ void FakeBluetoothProfileServiceProvider::Cancel() { delegate_->Cancel(); } -} // namespace chromeos +} // namespace bluez diff --git a/chromeos/dbus/fake_bluetooth_profile_service_provider.h b/device/bluetooth/dbus/fake_bluetooth_profile_service_provider.h index 2c98048..5d7af8d 100644 --- a/chromeos/dbus/fake_bluetooth_profile_service_provider.h +++ b/device/bluetooth/dbus/fake_bluetooth_profile_service_provider.h @@ -2,25 +2,26 @@ // 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" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/bluetooth_profile_service_provider.h" #include "dbus/file_descriptor.h" #include "dbus/object_path.h" +#include "device/bluetooth/bluetooth_export.h" +#include "device/bluetooth/dbus/bluetooth_profile_service_provider.h" -namespace chromeos { +namespace bluez { // FakeBluetoothProfileServiceProvider simulates the behavior of a local // Bluetooth agent object and is used both in test cases in place of a // mock and on the Linux desktop. // // This class is only called from the dbus origin thread and is not thread-safe. -class CHROMEOS_EXPORT FakeBluetoothProfileServiceProvider +class DEVICE_BLUETOOTH_EXPORT FakeBluetoothProfileServiceProvider : public BluetoothProfileServiceProvider { public: FakeBluetoothProfileServiceProvider(const dbus::ObjectPath& object_path, @@ -55,6 +56,6 @@ class CHROMEOS_EXPORT FakeBluetoothProfileServiceProvider DISALLOW_COPY_AND_ASSIGN(FakeBluetoothProfileServiceProvider); }; -} // namespace chromeos +} // namespace bluez -#endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ +#endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ |