Index: device/bluetooth/bluetooth_adapter_chromeos.cc |
diff --git a/device/bluetooth/bluetooth_adapter_chromeos.cc b/device/bluetooth/bluetooth_adapter_chromeos.cc |
index 1ba14a58b09dad3b347db96c594847666b300c0d..15f30bf07982ffd9a473a350bba78bbb00e393bd 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,13 +200,13 @@ void BluetoothAdapterChromeOS::SetName(const std::string& name, |
return; |
} |
- DBusThreadManager::Get()->GetBluetoothAdapterClient()-> |
- GetProperties(object_path_)->alias.Set( |
+ bluez::BluezDBusManager::Get() |
+ ->GetBluetoothAdapterClient() |
+ ->GetProperties(object_path_) |
+ ->alias.Set( |
name, |
base::Bind(&BluetoothAdapterChromeOS::OnPropertyChangeCompleted, |
- weak_ptr_factory_.GetWeakPtr(), |
- callback, |
- error_callback)); |
+ weak_ptr_factory_.GetWeakPtr(), callback, error_callback)); |
} |
bool BluetoothAdapterChromeOS::IsInitialized() const { |
@@ -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,22 +238,23 @@ void BluetoothAdapterChromeOS::SetPowered( |
return; |
} |
- DBusThreadManager::Get()->GetBluetoothAdapterClient()-> |
- GetProperties(object_path_)->powered.Set( |
+ bluez::BluezDBusManager::Get() |
+ ->GetBluetoothAdapterClient() |
+ ->GetProperties(object_path_) |
+ ->powered.Set( |
powered, |
base::Bind(&BluetoothAdapterChromeOS::OnPropertyChangeCompleted, |
- weak_ptr_factory_.GetWeakPtr(), |
- callback, |
- error_callback)); |
+ weak_ptr_factory_.GetWeakPtr(), callback, error_callback)); |
} |
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,22 +268,23 @@ void BluetoothAdapterChromeOS::SetDiscoverable( |
return; |
} |
- DBusThreadManager::Get()->GetBluetoothAdapterClient()-> |
- GetProperties(object_path_)->discoverable.Set( |
+ bluez::BluezDBusManager::Get() |
+ ->GetBluetoothAdapterClient() |
+ ->GetProperties(object_path_) |
+ ->discoverable.Set( |
discoverable, |
base::Bind(&BluetoothAdapterChromeOS::OnSetDiscoverable, |
- weak_ptr_factory_.GetWeakPtr(), |
- callback, |
- error_callback)); |
+ weak_ptr_factory_.GetWeakPtr(), callback, error_callback)); |
} |
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,10 +405,10 @@ void BluetoothAdapterChromeOS::AdapterPropertyChanged( |
void BluetoothAdapterChromeOS::DeviceAdded( |
const dbus::ObjectPath& object_path) { |
- DCHECK(DBusThreadManager::Get()); |
- BluetoothDeviceClient::Properties* properties = |
- DBusThreadManager::Get()->GetBluetoothDeviceClient()-> |
- GetProperties(object_path); |
+ DCHECK(bluez::BluezDBusManager::Get()); |
+ bluez::BluetoothDeviceClient::Properties* properties = |
+ bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( |
+ object_path); |
if (!properties || properties->adapter.value() != object_path_) |
return; |
DCHECK(IsPresent()); |
@@ -437,9 +450,9 @@ void BluetoothAdapterChromeOS::DevicePropertyChanged( |
if (!device_chromeos) |
return; |
- BluetoothDeviceClient::Properties* properties = |
- DBusThreadManager::Get()->GetBluetoothDeviceClient()-> |
- GetProperties(object_path); |
+ bluez::BluetoothDeviceClient::Properties* properties = |
+ bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( |
+ object_path); |
if (property_name == properties->address.name()) { |
for (auto iter = devices_.begin(); iter != devices_.end(); ++iter) { |
@@ -504,9 +517,9 @@ void BluetoothAdapterChromeOS::InputPropertyChanged( |
if (!device_chromeos) |
return; |
- BluetoothInputClient::Properties* properties = |
- DBusThreadManager::Get()->GetBluetoothInputClient()-> |
- GetProperties(object_path); |
+ bluez::BluetoothInputClient::Properties* properties = |
+ bluez::BluezDBusManager::Get()->GetBluetoothInputClient()->GetProperties( |
+ object_path); |
// Properties structure can be removed, which triggers a change in the |
// BluetoothDevice::IsConnectable() property, as does a change in the |
@@ -663,8 +676,9 @@ void BluetoothAdapterChromeOS::Cancel() { |
void BluetoothAdapterChromeOS::OnRegisterAgent() { |
VLOG(1) << "Pairing agent registered, requesting to be made default"; |
- DBusThreadManager::Get()->GetBluetoothAgentManagerClient()-> |
- RequestDefaultAgent( |
+ bluez::BluezDBusManager::Get() |
+ ->GetBluetoothAgentManagerClient() |
+ ->RequestDefaultAgent( |
dbus::ObjectPath(kAgentPath), |
base::Bind(&BluetoothAdapterChromeOS::OnRequestDefaultAgent, |
weak_ptr_factory_.GetWeakPtr()), |
@@ -755,8 +769,9 @@ void BluetoothAdapterChromeOS::SetAdapter(const dbus::ObjectPath& object_path) { |
VLOG(1) << object_path_.value() << ": using adapter."; |
VLOG(1) << "Registering pairing agent"; |
- DBusThreadManager::Get()->GetBluetoothAgentManagerClient()-> |
- RegisterAgent( |
+ bluez::BluezDBusManager::Get() |
+ ->GetBluetoothAgentManagerClient() |
+ ->RegisterAgent( |
dbus::ObjectPath(kAgentPath), |
bluetooth_agent_manager::kKeyboardDisplayCapability, |
base::Bind(&BluetoothAdapterChromeOS::OnRegisterAgent, |
@@ -766,9 +781,10 @@ void BluetoothAdapterChromeOS::SetAdapter(const dbus::ObjectPath& object_path) { |
SetDefaultAdapterName(); |
- BluetoothAdapterClient::Properties* properties = |
- DBusThreadManager::Get()->GetBluetoothAdapterClient()-> |
- GetProperties(object_path_); |
+ bluez::BluetoothAdapterClient::Properties* properties = |
+ bluez::BluezDBusManager::Get() |
+ ->GetBluetoothAdapterClient() |
+ ->GetProperties(object_path_); |
PresentChanged(true); |
@@ -780,8 +796,9 @@ void BluetoothAdapterChromeOS::SetAdapter(const dbus::ObjectPath& object_path) { |
DiscoveringChanged(true); |
std::vector<dbus::ObjectPath> device_paths = |
- DBusThreadManager::Get()->GetBluetoothDeviceClient()-> |
- GetDevicesForAdapter(object_path_); |
+ bluez::BluezDBusManager::Get() |
+ ->GetBluetoothDeviceClient() |
+ ->GetDevicesForAdapter(object_path_); |
for (std::vector<dbus::ObjectPath>::iterator iter = device_paths.begin(); |
iter != device_paths.end(); ++iter) { |
@@ -818,9 +835,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(""); |
@@ -1008,8 +1026,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); |
@@ -1080,7 +1098,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()) { |
@@ -1123,13 +1141,13 @@ void BluetoothAdapterChromeOS::OnSetDiscoverable( |
// Set the discoverable_timeout property to zero so the adapter remains |
// discoverable forever. |
- DBusThreadManager::Get()->GetBluetoothAdapterClient()-> |
- GetProperties(object_path_)->discoverable_timeout.Set( |
+ bluez::BluezDBusManager::Get() |
+ ->GetBluetoothAdapterClient() |
+ ->GetProperties(object_path_) |
+ ->discoverable_timeout.Set( |
0, |
base::Bind(&BluetoothAdapterChromeOS::OnPropertyChangeCompleted, |
- weak_ptr_factory_.GetWeakPtr(), |
- callback, |
- error_callback)); |
+ weak_ptr_factory_.GetWeakPtr(), callback, error_callback)); |
} |
void BluetoothAdapterChromeOS::OnPropertyChangeCompleted( |
@@ -1197,7 +1215,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), |
@@ -1251,15 +1269,11 @@ void BluetoothAdapterChromeOS::RemoveDiscoverySession( |
// discovery. |
DCHECK_EQ(num_discovery_sessions_, 1); |
discovery_request_pending_ = true; |
- DBusThreadManager::Get()->GetBluetoothAdapterClient()-> |
- StopDiscovery( |
- object_path_, |
- base::Bind(&BluetoothAdapterChromeOS::OnStopDiscovery, |
- weak_ptr_factory_.GetWeakPtr(), |
- callback), |
- base::Bind(&BluetoothAdapterChromeOS::OnStopDiscoveryError, |
- weak_ptr_factory_.GetWeakPtr(), |
- error_callback)); |
+ bluez::BluezDBusManager::Get()->GetBluetoothAdapterClient()->StopDiscovery( |
+ object_path_, base::Bind(&BluetoothAdapterChromeOS::OnStopDiscovery, |
+ weak_ptr_factory_.GetWeakPtr(), callback), |
+ base::Bind(&BluetoothAdapterChromeOS::OnStopDiscoveryError, |
+ weak_ptr_factory_.GetWeakPtr(), error_callback)); |
} |
void BluetoothAdapterChromeOS::SetDiscoveryFilter( |
@@ -1288,7 +1302,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; |
@@ -1323,12 +1337,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( |
@@ -1418,7 +1434,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), |