Index: device/bluetooth/bluetooth_device_chromeos.cc |
diff --git a/device/bluetooth/bluetooth_device_chromeos.cc b/device/bluetooth/bluetooth_device_chromeos.cc |
index 9acaec0be862622afaa6d9c32ce660a91d5d7661..89c5572d0a0c0b9f409e4c58d7b7e18ff07cdd59 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; |
@@ -54,9 +54,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(); |
@@ -132,11 +132,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); |
@@ -144,8 +147,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. |
@@ -161,18 +165,18 @@ BluetoothDeviceChromeOS::~BluetoothDeviceChromeOS() { |
} |
uint32 BluetoothDeviceChromeOS::GetBluetoothClass() const { |
- BluetoothDeviceClient::Properties* properties = |
- DBusThreadManager::Get()->GetBluetoothDeviceClient()-> |
- GetProperties(object_path_); |
+ bluez::BluetoothDeviceClient::Properties* properties = |
+ bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( |
+ object_path_); |
DCHECK(properties); |
return properties->bluetooth_class.value(); |
} |
std::string BluetoothDeviceChromeOS::GetDeviceName() const { |
- BluetoothDeviceClient::Properties* properties = |
- DBusThreadManager::Get()->GetBluetoothDeviceClient()-> |
- GetProperties(object_path_); |
+ bluez::BluetoothDeviceClient::Properties* properties = |
+ bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( |
+ object_path_); |
DCHECK(properties); |
return properties->alias.value(); |
@@ -191,9 +195,9 @@ void BluetoothDeviceChromeOS::DisconnectGatt() { |
} |
std::string BluetoothDeviceChromeOS::GetAddress() const { |
- BluetoothDeviceClient::Properties* properties = |
- DBusThreadManager::Get()->GetBluetoothDeviceClient()-> |
- GetProperties(object_path_); |
+ bluez::BluetoothDeviceClient::Properties* properties = |
+ bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( |
+ object_path_); |
DCHECK(properties); |
return CanonicalizeAddress(properties->address.value()); |
@@ -225,9 +229,9 @@ uint16 BluetoothDeviceChromeOS::GetDeviceID() const { |
} |
bool BluetoothDeviceChromeOS::IsPaired() const { |
- BluetoothDeviceClient::Properties* properties = |
- DBusThreadManager::Get()->GetBluetoothDeviceClient()-> |
- GetProperties(object_path_); |
+ bluez::BluetoothDeviceClient::Properties* properties = |
+ bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( |
+ object_path_); |
DCHECK(properties); |
// Trusted devices are devices that don't support pairing but that the |
@@ -237,9 +241,9 @@ bool BluetoothDeviceChromeOS::IsPaired() const { |
} |
bool BluetoothDeviceChromeOS::IsConnected() const { |
- BluetoothDeviceClient::Properties* properties = |
- DBusThreadManager::Get()->GetBluetoothDeviceClient()-> |
- GetProperties(object_path_); |
+ bluez::BluetoothDeviceClient::Properties* properties = |
+ bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( |
+ object_path_); |
DCHECK(properties); |
return properties->connected.value(); |
@@ -251,9 +255,9 @@ bool BluetoothDeviceChromeOS::IsGattConnected() const { |
} |
bool BluetoothDeviceChromeOS::IsConnectable() const { |
- BluetoothInputClient::Properties* input_properties = |
- DBusThreadManager::Get()->GetBluetoothInputClient()-> |
- GetProperties(object_path_); |
+ 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. |
if (!input_properties) |
@@ -267,9 +271,9 @@ bool BluetoothDeviceChromeOS::IsConnecting() const { |
} |
BluetoothDeviceChromeOS::UUIDList BluetoothDeviceChromeOS::GetUUIDs() const { |
- BluetoothDeviceClient::Properties* properties = |
- DBusThreadManager::Get()->GetBluetoothDeviceClient()-> |
- GetProperties(object_path_); |
+ bluez::BluetoothDeviceClient::Properties* properties = |
+ bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( |
+ object_path_); |
DCHECK(properties); |
std::vector<device::BluetoothUUID> uuids; |
@@ -284,9 +288,9 @@ BluetoothDeviceChromeOS::UUIDList BluetoothDeviceChromeOS::GetUUIDs() const { |
} |
int16 BluetoothDeviceChromeOS::GetInquiryRSSI() const { |
- BluetoothDeviceClient::Properties* properties = |
- DBusThreadManager::Get()->GetBluetoothDeviceClient()-> |
- GetProperties(object_path_); |
+ bluez::BluetoothDeviceClient::Properties* properties = |
+ bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( |
+ object_path_); |
DCHECK(properties); |
if (!properties->rssi.is_valid()) |
@@ -296,9 +300,9 @@ int16 BluetoothDeviceChromeOS::GetInquiryRSSI() const { |
} |
int16 BluetoothDeviceChromeOS::GetInquiryTxPower() const { |
- BluetoothDeviceClient::Properties* properties = |
- DBusThreadManager::Get()->GetBluetoothDeviceClient()-> |
- GetProperties(object_path_); |
+ bluez::BluetoothDeviceClient::Properties* properties = |
+ bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( |
+ object_path_); |
DCHECK(properties); |
if (!properties->tx_power.is_valid()) |
@@ -323,7 +327,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, |
@@ -347,14 +351,12 @@ void BluetoothDeviceChromeOS::Connect( |
// Initiate high-security connection with pairing. |
BeginPairing(pairing_delegate); |
- DBusThreadManager::Get()->GetBluetoothDeviceClient()-> |
- Pair(object_path_, |
- base::Bind(&BluetoothDeviceChromeOS::OnPair, |
- weak_ptr_factory_.GetWeakPtr(), |
- callback, error_callback), |
- base::Bind(&BluetoothDeviceChromeOS::OnPairError, |
- weak_ptr_factory_.GetWeakPtr(), |
- error_callback)); |
+ bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->Pair( |
+ object_path_, |
+ base::Bind(&BluetoothDeviceChromeOS::OnPair, |
+ weak_ptr_factory_.GetWeakPtr(), callback, error_callback), |
+ base::Bind(&BluetoothDeviceChromeOS::OnPairError, |
+ weak_ptr_factory_.GetWeakPtr(), error_callback)); |
} |
} |
@@ -398,12 +400,10 @@ void BluetoothDeviceChromeOS::CancelPairing() { |
if (!canceled) { |
VLOG(1) << object_path_.value() << ": No pairing context or callback. " |
<< "Sending explicit cancel"; |
- DBusThreadManager::Get()->GetBluetoothDeviceClient()-> |
- CancelPairing( |
- object_path_, |
- base::Bind(&base::DoNothing), |
- base::Bind(&BluetoothDeviceChromeOS::OnCancelPairingError, |
- weak_ptr_factory_.GetWeakPtr())); |
+ bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->CancelPairing( |
+ object_path_, base::Bind(&base::DoNothing), |
+ base::Bind(&BluetoothDeviceChromeOS::OnCancelPairingError, |
+ weak_ptr_factory_.GetWeakPtr())); |
} |
// Since there is no callback to this method it's possible that the pairing |
@@ -416,20 +416,16 @@ void BluetoothDeviceChromeOS::CancelPairing() { |
void BluetoothDeviceChromeOS::Disconnect(const base::Closure& callback, |
const ErrorCallback& error_callback) { |
VLOG(1) << object_path_.value() << ": Disconnecting"; |
- DBusThreadManager::Get()->GetBluetoothDeviceClient()-> |
- Disconnect( |
- object_path_, |
- base::Bind(&BluetoothDeviceChromeOS::OnDisconnect, |
- weak_ptr_factory_.GetWeakPtr(), |
- callback), |
- base::Bind(&BluetoothDeviceChromeOS::OnDisconnectError, |
- weak_ptr_factory_.GetWeakPtr(), |
- error_callback)); |
+ bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->Disconnect( |
+ object_path_, base::Bind(&BluetoothDeviceChromeOS::OnDisconnect, |
+ weak_ptr_factory_.GetWeakPtr(), callback), |
+ base::Bind(&BluetoothDeviceChromeOS::OnDisconnectError, |
+ weak_ptr_factory_.GetWeakPtr(), error_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)); |
@@ -508,9 +504,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."; |
@@ -577,17 +574,13 @@ void BluetoothDeviceChromeOS::ConnectInternal( |
const base::Closure& callback, |
const ConnectErrorCallback& error_callback) { |
VLOG(1) << object_path_.value() << ": Connecting"; |
- DBusThreadManager::Get()->GetBluetoothDeviceClient()-> |
- Connect( |
- object_path_, |
- base::Bind(&BluetoothDeviceChromeOS::OnConnect, |
- weak_ptr_factory_.GetWeakPtr(), |
- after_pairing, |
- callback), |
- base::Bind(&BluetoothDeviceChromeOS::OnConnectError, |
- weak_ptr_factory_.GetWeakPtr(), |
- after_pairing, |
- error_callback)); |
+ bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->Connect( |
+ object_path_, |
+ base::Bind(&BluetoothDeviceChromeOS::OnConnect, |
+ weak_ptr_factory_.GetWeakPtr(), after_pairing, callback), |
+ base::Bind(&BluetoothDeviceChromeOS::OnConnectError, |
+ weak_ptr_factory_.GetWeakPtr(), after_pairing, |
+ error_callback)); |
} |
void BluetoothDeviceChromeOS::OnConnect(bool after_pairing, |
@@ -703,11 +696,11 @@ 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()->GetBluetoothDeviceClient()-> |
- GetProperties(object_path_)->trusted.Set( |
- true, |
- base::Bind(&BluetoothDeviceChromeOS::OnSetTrusted, |
- weak_ptr_factory_.GetWeakPtr())); |
+ bluez::BluezDBusManager::Get() |
+ ->GetBluetoothDeviceClient() |
+ ->GetProperties(object_path_) |
+ ->trusted.Set(true, base::Bind(&BluetoothDeviceChromeOS::OnSetTrusted, |
+ weak_ptr_factory_.GetWeakPtr())); |
} |
void BluetoothDeviceChromeOS::OnSetTrusted(bool success) { |