| Index: device/bluetooth/bluetooth_device_bluez.cc
|
| diff --git a/device/bluetooth/bluetooth_device_chromeos.cc b/device/bluetooth/bluetooth_device_bluez.cc
|
| similarity index 72%
|
| rename from device/bluetooth/bluetooth_device_chromeos.cc
|
| rename to device/bluetooth/bluetooth_device_bluez.cc
|
| index ea4a168cf0cb39e8a29bbb0ca554394220878901..a2b056b4f88b58d06516a8f0034f480027dacd18 100644
|
| --- a/device/bluetooth/bluetooth_device_chromeos.cc
|
| +++ b/device/bluetooth/bluetooth_device_bluez.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "device/bluetooth/bluetooth_device_chromeos.h"
|
| +#include "device/bluetooth/bluetooth_device_bluez.h"
|
|
|
| #include <stdio.h>
|
|
|
| @@ -12,12 +12,12 @@
|
| #include "base/strings/string_number_conversions.h"
|
| #include "base/strings/string_util.h"
|
| #include "dbus/bus.h"
|
| -#include "device/bluetooth/bluetooth_adapter_chromeos.h"
|
| -#include "device/bluetooth/bluetooth_gatt_connection_chromeos.h"
|
| -#include "device/bluetooth/bluetooth_pairing_chromeos.h"
|
| -#include "device/bluetooth/bluetooth_remote_gatt_service_chromeos.h"
|
| +#include "device/bluetooth/bluetooth_adapter_bluez.h"
|
| +#include "device/bluetooth/bluetooth_gatt_connection_bluez.h"
|
| +#include "device/bluetooth/bluetooth_pairing_bluez.h"
|
| +#include "device/bluetooth/bluetooth_remote_gatt_service_bluez.h"
|
| #include "device/bluetooth/bluetooth_socket.h"
|
| -#include "device/bluetooth/bluetooth_socket_chromeos.h"
|
| +#include "device/bluetooth/bluetooth_socket_bluez.h"
|
| #include "device/bluetooth/bluetooth_socket_thread.h"
|
| #include "device/bluetooth/bluetooth_uuid.h"
|
| #include "device/bluetooth/dbus/bluetooth_adapter_client.h"
|
| @@ -64,11 +64,11 @@ void ParseModalias(const dbus::ObjectPath& object_path,
|
| BluetoothDevice::VendorIDSource source_value;
|
| int vendor_value, product_value, device_value;
|
|
|
| - if (sscanf(modalias.c_str(), "bluetooth:v%04xp%04xd%04x",
|
| - &vendor_value, &product_value, &device_value) == 3) {
|
| + if (sscanf(modalias.c_str(), "bluetooth:v%04xp%04xd%04x", &vendor_value,
|
| + &product_value, &device_value) == 3) {
|
| source_value = BluetoothDevice::VENDOR_ID_BLUETOOTH;
|
| - } else if (sscanf(modalias.c_str(), "usb:v%04xp%04xd%04x",
|
| - &vendor_value, &product_value, &device_value) == 3) {
|
| + } else if (sscanf(modalias.c_str(), "usb:v%04xp%04xd%04x", &vendor_value,
|
| + &product_value, &device_value) == 3) {
|
| source_value = BluetoothDevice::VENDOR_ID_USB;
|
| } else {
|
| return;
|
| @@ -112,8 +112,7 @@ void RecordPairingResult(BluetoothDevice::ConnectErrorCode error_code) {
|
| pairing_result = UMA_PAIRING_RESULT_UNKNOWN_ERROR;
|
| }
|
|
|
| - UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingResult",
|
| - pairing_result,
|
| + UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingResult", pairing_result,
|
| UMA_PAIRING_RESULT_COUNT);
|
| }
|
|
|
| @@ -138,10 +137,10 @@ BluetoothDevice::ConnectErrorCode DBusErrorToConnectError(
|
|
|
| } // namespace
|
|
|
| -namespace chromeos {
|
| +namespace bluez {
|
|
|
| -BluetoothDeviceChromeOS::BluetoothDeviceChromeOS(
|
| - BluetoothAdapterChromeOS* adapter,
|
| +BluetoothDeviceBlueZ::BluetoothDeviceBlueZ(
|
| + BluetoothAdapterBlueZ* adapter,
|
| const dbus::ObjectPath& object_path,
|
| scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
|
| scoped_refptr<device::BluetoothSocketThread> socket_thread)
|
| @@ -166,7 +165,7 @@ BluetoothDeviceChromeOS::BluetoothDeviceChromeOS(
|
| }
|
| }
|
|
|
| -BluetoothDeviceChromeOS::~BluetoothDeviceChromeOS() {
|
| +BluetoothDeviceBlueZ::~BluetoothDeviceBlueZ() {
|
| bluez::BluezDBusManager::Get()
|
| ->GetBluetoothGattServiceClient()
|
| ->RemoveObserver(this);
|
| @@ -178,11 +177,11 @@ BluetoothDeviceChromeOS::~BluetoothDeviceChromeOS() {
|
| for (const auto& iter : gatt_services_swapped) {
|
| DCHECK(adapter_);
|
| adapter()->NotifyGattServiceRemoved(
|
| - static_cast<BluetoothRemoteGattServiceChromeOS*>(iter.second));
|
| + static_cast<BluetoothRemoteGattServiceBlueZ*>(iter.second));
|
| }
|
| }
|
|
|
| -uint32 BluetoothDeviceChromeOS::GetBluetoothClass() const {
|
| +uint32 BluetoothDeviceBlueZ::GetBluetoothClass() const {
|
| bluez::BluetoothDeviceClient::Properties* properties =
|
| bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties(
|
| object_path_);
|
| @@ -191,7 +190,7 @@ uint32 BluetoothDeviceChromeOS::GetBluetoothClass() const {
|
| return properties->bluetooth_class.value();
|
| }
|
|
|
| -std::string BluetoothDeviceChromeOS::GetDeviceName() const {
|
| +std::string BluetoothDeviceBlueZ::GetDeviceName() const {
|
| bluez::BluetoothDeviceClient::Properties* properties =
|
| bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties(
|
| object_path_);
|
| @@ -200,19 +199,19 @@ std::string BluetoothDeviceChromeOS::GetDeviceName() const {
|
| return properties->alias.value();
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::CreateGattConnectionImpl() {
|
| - // ChromeOS implementation does not use the default CreateGattConnection
|
| +void BluetoothDeviceBlueZ::CreateGattConnectionImpl() {
|
| + // BlueZ implementation does not use the default CreateGattConnection
|
| // implementation.
|
| NOTIMPLEMENTED();
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::DisconnectGatt() {
|
| - // ChromeOS implementation does not use the default CreateGattConnection
|
| +void BluetoothDeviceBlueZ::DisconnectGatt() {
|
| + // BlueZ implementation does not use the default CreateGattConnection
|
| // implementation.
|
| NOTIMPLEMENTED();
|
| }
|
|
|
| -std::string BluetoothDeviceChromeOS::GetAddress() const {
|
| +std::string BluetoothDeviceBlueZ::GetAddress() const {
|
| bluez::BluetoothDeviceClient::Properties* properties =
|
| bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties(
|
| object_path_);
|
| @@ -221,32 +220,32 @@ std::string BluetoothDeviceChromeOS::GetAddress() const {
|
| return CanonicalizeAddress(properties->address.value());
|
| }
|
|
|
| -BluetoothDevice::VendorIDSource
|
| -BluetoothDeviceChromeOS::GetVendorIDSource() const {
|
| +BluetoothDevice::VendorIDSource BluetoothDeviceBlueZ::GetVendorIDSource()
|
| + const {
|
| VendorIDSource vendor_id_source = VENDOR_ID_UNKNOWN;
|
| ParseModalias(object_path_, &vendor_id_source, NULL, NULL, NULL);
|
| return vendor_id_source;
|
| }
|
|
|
| -uint16 BluetoothDeviceChromeOS::GetVendorID() const {
|
| - uint16 vendor_id = 0;
|
| +uint16 BluetoothDeviceBlueZ::GetVendorID() const {
|
| + uint16 vendor_id = 0;
|
| ParseModalias(object_path_, NULL, &vendor_id, NULL, NULL);
|
| return vendor_id;
|
| }
|
|
|
| -uint16 BluetoothDeviceChromeOS::GetProductID() const {
|
| - uint16 product_id = 0;
|
| +uint16 BluetoothDeviceBlueZ::GetProductID() const {
|
| + uint16 product_id = 0;
|
| ParseModalias(object_path_, NULL, NULL, &product_id, NULL);
|
| return product_id;
|
| }
|
|
|
| -uint16 BluetoothDeviceChromeOS::GetDeviceID() const {
|
| - uint16 device_id = 0;
|
| +uint16 BluetoothDeviceBlueZ::GetDeviceID() const {
|
| + uint16 device_id = 0;
|
| ParseModalias(object_path_, NULL, NULL, NULL, &device_id);
|
| return device_id;
|
| }
|
|
|
| -bool BluetoothDeviceChromeOS::IsPaired() const {
|
| +bool BluetoothDeviceBlueZ::IsPaired() const {
|
| bluez::BluetoothDeviceClient::Properties* properties =
|
| bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties(
|
| object_path_);
|
| @@ -258,7 +257,7 @@ bool BluetoothDeviceChromeOS::IsPaired() const {
|
| return properties->paired.value() || properties->trusted.value();
|
| }
|
|
|
| -bool BluetoothDeviceChromeOS::IsConnected() const {
|
| +bool BluetoothDeviceBlueZ::IsConnected() const {
|
| bluez::BluetoothDeviceClient::Properties* properties =
|
| bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties(
|
| object_path_);
|
| @@ -267,12 +266,12 @@ bool BluetoothDeviceChromeOS::IsConnected() const {
|
| return properties->connected.value();
|
| }
|
|
|
| -bool BluetoothDeviceChromeOS::IsGattConnected() const {
|
| +bool BluetoothDeviceBlueZ::IsGattConnected() const {
|
| NOTIMPLEMENTED();
|
| return false;
|
| }
|
|
|
| -bool BluetoothDeviceChromeOS::IsConnectable() const {
|
| +bool BluetoothDeviceBlueZ::IsConnectable() const {
|
| bluez::BluetoothInputClient::Properties* input_properties =
|
| bluez::BluezDBusManager::Get()->GetBluetoothInputClient()->GetProperties(
|
| object_path_);
|
| @@ -284,18 +283,18 @@ bool BluetoothDeviceChromeOS::IsConnectable() const {
|
| return input_properties->reconnect_mode.value() != "device";
|
| }
|
|
|
| -bool BluetoothDeviceChromeOS::IsConnecting() const {
|
| +bool BluetoothDeviceBlueZ::IsConnecting() const {
|
| return num_connecting_calls_ > 0;
|
| }
|
|
|
| -BluetoothDeviceChromeOS::UUIDList BluetoothDeviceChromeOS::GetUUIDs() const {
|
| +BluetoothDeviceBlueZ::UUIDList BluetoothDeviceBlueZ::GetUUIDs() const {
|
| bluez::BluetoothDeviceClient::Properties* properties =
|
| bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties(
|
| object_path_);
|
| DCHECK(properties);
|
|
|
| std::vector<device::BluetoothUUID> uuids;
|
| - const std::vector<std::string> &dbus_uuids = properties->uuids.value();
|
| + const std::vector<std::string>& dbus_uuids = properties->uuids.value();
|
| for (std::vector<std::string>::const_iterator iter = dbus_uuids.begin();
|
| iter != dbus_uuids.end(); ++iter) {
|
| device::BluetoothUUID uuid(*iter);
|
| @@ -305,7 +304,7 @@ BluetoothDeviceChromeOS::UUIDList BluetoothDeviceChromeOS::GetUUIDs() const {
|
| return uuids;
|
| }
|
|
|
| -int16 BluetoothDeviceChromeOS::GetInquiryRSSI() const {
|
| +int16 BluetoothDeviceBlueZ::GetInquiryRSSI() const {
|
| bluez::BluetoothDeviceClient::Properties* properties =
|
| bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties(
|
| object_path_);
|
| @@ -317,7 +316,7 @@ int16 BluetoothDeviceChromeOS::GetInquiryRSSI() const {
|
| return properties->rssi.value();
|
| }
|
|
|
| -int16 BluetoothDeviceChromeOS::GetInquiryTxPower() const {
|
| +int16 BluetoothDeviceBlueZ::GetInquiryTxPower() const {
|
| bluez::BluetoothDeviceClient::Properties* properties =
|
| bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties(
|
| object_path_);
|
| @@ -329,30 +328,30 @@ int16 BluetoothDeviceChromeOS::GetInquiryTxPower() const {
|
| return properties->tx_power.value();
|
| }
|
|
|
| -bool BluetoothDeviceChromeOS::ExpectingPinCode() const {
|
| +bool BluetoothDeviceBlueZ::ExpectingPinCode() const {
|
| return pairing_.get() && pairing_->ExpectingPinCode();
|
| }
|
|
|
| -bool BluetoothDeviceChromeOS::ExpectingPasskey() const {
|
| +bool BluetoothDeviceBlueZ::ExpectingPasskey() const {
|
| return pairing_.get() && pairing_->ExpectingPasskey();
|
| }
|
|
|
| -bool BluetoothDeviceChromeOS::ExpectingConfirmation() const {
|
| +bool BluetoothDeviceBlueZ::ExpectingConfirmation() const {
|
| return pairing_.get() && pairing_->ExpectingConfirmation();
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::GetConnectionInfo(
|
| +void BluetoothDeviceBlueZ::GetConnectionInfo(
|
| const ConnectionInfoCallback& callback) {
|
| // DBus method call should gracefully return an error if the device is not
|
| // currently connected.
|
| bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetConnInfo(
|
| - object_path_, base::Bind(&BluetoothDeviceChromeOS::OnGetConnInfo,
|
| + object_path_, base::Bind(&BluetoothDeviceBlueZ::OnGetConnInfo,
|
| weak_ptr_factory_.GetWeakPtr(), callback),
|
| - base::Bind(&BluetoothDeviceChromeOS::OnGetConnInfoError,
|
| + base::Bind(&BluetoothDeviceBlueZ::OnGetConnInfoError,
|
| weak_ptr_factory_.GetWeakPtr(), callback));
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::Connect(
|
| +void BluetoothDeviceBlueZ::Connect(
|
| BluetoothDevice::PairingDelegate* pairing_delegate,
|
| const base::Closure& callback,
|
| const ConnectErrorCallback& error_callback) {
|
| @@ -371,14 +370,14 @@ void BluetoothDeviceChromeOS::Connect(
|
|
|
| bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->Pair(
|
| object_path_,
|
| - base::Bind(&BluetoothDeviceChromeOS::OnPairDuringConnect,
|
| + base::Bind(&BluetoothDeviceBlueZ::OnPairDuringConnect,
|
| weak_ptr_factory_.GetWeakPtr(), callback, error_callback),
|
| - base::Bind(&BluetoothDeviceChromeOS::OnPairDuringConnectError,
|
| + base::Bind(&BluetoothDeviceBlueZ::OnPairDuringConnectError,
|
| weak_ptr_factory_.GetWeakPtr(), error_callback));
|
| }
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::Pair(
|
| +void BluetoothDeviceBlueZ::Pair(
|
| BluetoothDevice::PairingDelegate* pairing_delegate,
|
| const base::Closure& callback,
|
| const ConnectErrorCallback& error_callback) {
|
| @@ -386,41 +385,41 @@ void BluetoothDeviceChromeOS::Pair(
|
| BeginPairing(pairing_delegate);
|
|
|
| bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->Pair(
|
| - object_path_, base::Bind(&BluetoothDeviceChromeOS::OnPair,
|
| + object_path_, base::Bind(&BluetoothDeviceBlueZ::OnPair,
|
| weak_ptr_factory_.GetWeakPtr(), callback),
|
| - base::Bind(&BluetoothDeviceChromeOS::OnPairError,
|
| + base::Bind(&BluetoothDeviceBlueZ::OnPairError,
|
| weak_ptr_factory_.GetWeakPtr(), error_callback));
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::SetPinCode(const std::string& pincode) {
|
| +void BluetoothDeviceBlueZ::SetPinCode(const std::string& pincode) {
|
| if (!pairing_.get())
|
| return;
|
|
|
| pairing_->SetPinCode(pincode);
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::SetPasskey(uint32 passkey) {
|
| +void BluetoothDeviceBlueZ::SetPasskey(uint32 passkey) {
|
| if (!pairing_.get())
|
| return;
|
|
|
| pairing_->SetPasskey(passkey);
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::ConfirmPairing() {
|
| +void BluetoothDeviceBlueZ::ConfirmPairing() {
|
| if (!pairing_.get())
|
| return;
|
|
|
| pairing_->ConfirmPairing();
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::RejectPairing() {
|
| +void BluetoothDeviceBlueZ::RejectPairing() {
|
| if (!pairing_.get())
|
| return;
|
|
|
| pairing_->RejectPairing();
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::CancelPairing() {
|
| +void BluetoothDeviceBlueZ::CancelPairing() {
|
| bool canceled = false;
|
|
|
| // If there is a callback in progress that we can reply to then use that
|
| @@ -434,7 +433,7 @@ void BluetoothDeviceChromeOS::CancelPairing() {
|
| << "Sending explicit cancel";
|
| bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->CancelPairing(
|
| object_path_, base::Bind(&base::DoNothing),
|
| - base::Bind(&BluetoothDeviceChromeOS::OnCancelPairingError,
|
| + base::Bind(&BluetoothDeviceBlueZ::OnCancelPairingError,
|
| weak_ptr_factory_.GetWeakPtr()));
|
| }
|
|
|
| @@ -445,53 +444,53 @@ void BluetoothDeviceChromeOS::CancelPairing() {
|
| EndPairing();
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::Disconnect(const base::Closure& callback,
|
| - const ErrorCallback& error_callback) {
|
| +void BluetoothDeviceBlueZ::Disconnect(const base::Closure& callback,
|
| + const ErrorCallback& error_callback) {
|
| VLOG(1) << object_path_.value() << ": Disconnecting";
|
| bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->Disconnect(
|
| - object_path_, base::Bind(&BluetoothDeviceChromeOS::OnDisconnect,
|
| + object_path_, base::Bind(&BluetoothDeviceBlueZ::OnDisconnect,
|
| weak_ptr_factory_.GetWeakPtr(), callback),
|
| - base::Bind(&BluetoothDeviceChromeOS::OnDisconnectError,
|
| + base::Bind(&BluetoothDeviceBlueZ::OnDisconnectError,
|
| weak_ptr_factory_.GetWeakPtr(), error_callback));
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::Forget(const ErrorCallback& error_callback) {
|
| +void BluetoothDeviceBlueZ::Forget(const ErrorCallback& error_callback) {
|
| VLOG(1) << object_path_.value() << ": Removing device";
|
| bluez::BluezDBusManager::Get()->GetBluetoothAdapterClient()->RemoveDevice(
|
| adapter()->object_path(), object_path_, base::Bind(&base::DoNothing),
|
| - base::Bind(&BluetoothDeviceChromeOS::OnForgetError,
|
| + base::Bind(&BluetoothDeviceBlueZ::OnForgetError,
|
| weak_ptr_factory_.GetWeakPtr(), error_callback));
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::ConnectToService(
|
| +void BluetoothDeviceBlueZ::ConnectToService(
|
| const BluetoothUUID& uuid,
|
| const ConnectToServiceCallback& callback,
|
| const ConnectToServiceErrorCallback& error_callback) {
|
| - VLOG(1) << object_path_.value() << ": Connecting to service: "
|
| - << uuid.canonical_value();
|
| - scoped_refptr<BluetoothSocketChromeOS> socket =
|
| - BluetoothSocketChromeOS::CreateBluetoothSocket(
|
| - ui_task_runner_, socket_thread_);
|
| - socket->Connect(this, uuid, BluetoothSocketChromeOS::SECURITY_LEVEL_MEDIUM,
|
| + VLOG(1) << object_path_.value()
|
| + << ": Connecting to service: " << uuid.canonical_value();
|
| + scoped_refptr<BluetoothSocketBlueZ> socket =
|
| + BluetoothSocketBlueZ::CreateBluetoothSocket(ui_task_runner_,
|
| + socket_thread_);
|
| + socket->Connect(this, uuid, BluetoothSocketBlueZ::SECURITY_LEVEL_MEDIUM,
|
| base::Bind(callback, socket), error_callback);
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::ConnectToServiceInsecurely(
|
| +void BluetoothDeviceBlueZ::ConnectToServiceInsecurely(
|
| const BluetoothUUID& uuid,
|
| const ConnectToServiceCallback& callback,
|
| const ConnectToServiceErrorCallback& error_callback) {
|
| - VLOG(1) << object_path_.value() << ": Connecting insecurely to service: "
|
| - << uuid.canonical_value();
|
| - scoped_refptr<BluetoothSocketChromeOS> socket =
|
| - BluetoothSocketChromeOS::CreateBluetoothSocket(
|
| - ui_task_runner_, socket_thread_);
|
| - socket->Connect(this, uuid, BluetoothSocketChromeOS::SECURITY_LEVEL_LOW,
|
| + VLOG(1) << object_path_.value()
|
| + << ": Connecting insecurely to service: " << uuid.canonical_value();
|
| + scoped_refptr<BluetoothSocketBlueZ> socket =
|
| + BluetoothSocketBlueZ::CreateBluetoothSocket(ui_task_runner_,
|
| + socket_thread_);
|
| + socket->Connect(this, uuid, BluetoothSocketBlueZ::SECURITY_LEVEL_LOW,
|
| base::Bind(callback, socket), error_callback);
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::CreateGattConnection(
|
| - const GattConnectionCallback& callback,
|
| - const ConnectErrorCallback& error_callback) {
|
| +void BluetoothDeviceBlueZ::CreateGattConnection(
|
| + const GattConnectionCallback& callback,
|
| + const ConnectErrorCallback& error_callback) {
|
| // TODO(sacomoto): Workaround to retrieve the connection for already connected
|
| // devices. Currently, BluetoothGattConnection::Disconnect doesn't do
|
| // anything, the unique underlying physical GATT connection is kept. This
|
| @@ -504,32 +503,30 @@ void BluetoothDeviceChromeOS::CreateGattConnection(
|
|
|
| // TODO(armansito): Until there is a way to create a reference counted GATT
|
| // connection in bluetoothd, simply do a regular connect.
|
| - Connect(NULL,
|
| - base::Bind(&BluetoothDeviceChromeOS::OnCreateGattConnection,
|
| - weak_ptr_factory_.GetWeakPtr(),
|
| - callback),
|
| + Connect(NULL, base::Bind(&BluetoothDeviceBlueZ::OnCreateGattConnection,
|
| + weak_ptr_factory_.GetWeakPtr(), callback),
|
| error_callback);
|
| }
|
|
|
| -BluetoothPairingChromeOS* BluetoothDeviceChromeOS::BeginPairing(
|
| +BluetoothPairingBlueZ* BluetoothDeviceBlueZ::BeginPairing(
|
| BluetoothDevice::PairingDelegate* pairing_delegate) {
|
| - pairing_.reset(new BluetoothPairingChromeOS(this, pairing_delegate));
|
| + pairing_.reset(new BluetoothPairingBlueZ(this, pairing_delegate));
|
| return pairing_.get();
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::EndPairing() {
|
| +void BluetoothDeviceBlueZ::EndPairing() {
|
| pairing_.reset();
|
| }
|
|
|
| -BluetoothPairingChromeOS* BluetoothDeviceChromeOS::GetPairing() const {
|
| +BluetoothPairingBlueZ* BluetoothDeviceBlueZ::GetPairing() const {
|
| return pairing_.get();
|
| }
|
|
|
| -BluetoothAdapterChromeOS* BluetoothDeviceChromeOS::adapter() const {
|
| - return static_cast<BluetoothAdapterChromeOS*>(adapter_);
|
| +BluetoothAdapterBlueZ* BluetoothDeviceBlueZ::adapter() const {
|
| + return static_cast<BluetoothAdapterBlueZ*>(adapter_);
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::GattServiceAdded(
|
| +void BluetoothDeviceBlueZ::GattServiceAdded(
|
| const dbus::ObjectPath& object_path) {
|
| if (GetGattService(object_path.value())) {
|
| VLOG(1) << "Remote GATT service already exists: " << object_path.value();
|
| @@ -548,8 +545,8 @@ void BluetoothDeviceChromeOS::GattServiceAdded(
|
|
|
| VLOG(1) << "Adding new remote GATT service for device: " << GetAddress();
|
|
|
| - BluetoothRemoteGattServiceChromeOS* service =
|
| - new BluetoothRemoteGattServiceChromeOS(adapter(), this, object_path);
|
| + BluetoothRemoteGattServiceBlueZ* service =
|
| + new BluetoothRemoteGattServiceBlueZ(adapter(), this, object_path);
|
|
|
| gatt_services_.set(service->GetIdentifier(),
|
| scoped_ptr<BluetoothGattService>(service));
|
| @@ -560,7 +557,7 @@ void BluetoothDeviceChromeOS::GattServiceAdded(
|
| adapter()->NotifyGattServiceAdded(service);
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::GattServiceRemoved(
|
| +void BluetoothDeviceBlueZ::GattServiceRemoved(
|
| const dbus::ObjectPath& object_path) {
|
| GattServiceMap::const_iterator iter =
|
| gatt_services_.find(object_path.value());
|
| @@ -569,8 +566,8 @@ void BluetoothDeviceChromeOS::GattServiceRemoved(
|
| return;
|
| }
|
|
|
| - BluetoothRemoteGattServiceChromeOS* service =
|
| - static_cast<BluetoothRemoteGattServiceChromeOS*>(iter->second);
|
| + BluetoothRemoteGattServiceBlueZ* service =
|
| + static_cast<BluetoothRemoteGattServiceBlueZ*>(iter->second);
|
|
|
| VLOG(1) << "Removing remote GATT service with UUID: '"
|
| << service->GetUUID().canonical_value()
|
| @@ -584,15 +581,14 @@ void BluetoothDeviceChromeOS::GattServiceRemoved(
|
| adapter()->NotifyGattServiceRemoved(service);
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::OnGetConnInfo(
|
| - const ConnectionInfoCallback& callback,
|
| - int16 rssi,
|
| - int16 transmit_power,
|
| - int16 max_transmit_power) {
|
| +void BluetoothDeviceBlueZ::OnGetConnInfo(const ConnectionInfoCallback& callback,
|
| + int16 rssi,
|
| + int16 transmit_power,
|
| + int16 max_transmit_power) {
|
| callback.Run(ConnectionInfo(rssi, transmit_power, max_transmit_power));
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::OnGetConnInfoError(
|
| +void BluetoothDeviceBlueZ::OnGetConnInfoError(
|
| const ConnectionInfoCallback& callback,
|
| const std::string& error_name,
|
| const std::string& error_message) {
|
| @@ -602,28 +598,28 @@ void BluetoothDeviceChromeOS::OnGetConnInfoError(
|
| callback.Run(ConnectionInfo());
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::ConnectInternal(
|
| +void BluetoothDeviceBlueZ::ConnectInternal(
|
| bool after_pairing,
|
| const base::Closure& callback,
|
| const ConnectErrorCallback& error_callback) {
|
| VLOG(1) << object_path_.value() << ": Connecting";
|
| bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->Connect(
|
| object_path_,
|
| - base::Bind(&BluetoothDeviceChromeOS::OnConnect,
|
| + base::Bind(&BluetoothDeviceBlueZ::OnConnect,
|
| weak_ptr_factory_.GetWeakPtr(), after_pairing, callback),
|
| - base::Bind(&BluetoothDeviceChromeOS::OnConnectError,
|
| + base::Bind(&BluetoothDeviceBlueZ::OnConnectError,
|
| weak_ptr_factory_.GetWeakPtr(), after_pairing,
|
| error_callback));
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::OnConnect(bool after_pairing,
|
| - const base::Closure& callback) {
|
| +void BluetoothDeviceBlueZ::OnConnect(bool after_pairing,
|
| + const base::Closure& callback) {
|
| if (--num_connecting_calls_ == 0)
|
| adapter()->NotifyDeviceChanged(this);
|
|
|
| DCHECK(num_connecting_calls_ >= 0);
|
| VLOG(1) << object_path_.value() << ": Connected, " << num_connecting_calls_
|
| - << " still in progress";
|
| + << " still in progress";
|
|
|
| SetTrusted();
|
|
|
| @@ -635,15 +631,14 @@ void BluetoothDeviceChromeOS::OnConnect(bool after_pairing,
|
| callback.Run();
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::OnCreateGattConnection(
|
| +void BluetoothDeviceBlueZ::OnCreateGattConnection(
|
| const GattConnectionCallback& callback) {
|
| scoped_ptr<device::BluetoothGattConnection> conn(
|
| - new BluetoothGattConnectionChromeOS(
|
| - adapter_, GetAddress(), object_path_));
|
| + new BluetoothGattConnectionBlueZ(adapter_, GetAddress(), object_path_));
|
| callback.Run(conn.Pass());
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::OnConnectError(
|
| +void BluetoothDeviceBlueZ::OnConnectError(
|
| bool after_pairing,
|
| const ConnectErrorCallback& error_callback,
|
| const std::string& error_name,
|
| @@ -652,8 +647,9 @@ void BluetoothDeviceChromeOS::OnConnectError(
|
| adapter()->NotifyDeviceChanged(this);
|
|
|
| DCHECK(num_connecting_calls_ >= 0);
|
| - LOG(WARNING) << object_path_.value() << ": Failed to connect device: "
|
| - << error_name << ": " << error_message;
|
| + LOG(WARNING) << object_path_.value()
|
| + << ": Failed to connect device: " << error_name << ": "
|
| + << error_message;
|
| VLOG(1) << object_path_.value() << ": " << num_connecting_calls_
|
| << " still in progress";
|
|
|
| @@ -672,7 +668,7 @@ void BluetoothDeviceChromeOS::OnConnectError(
|
| error_callback.Run(error_code);
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::OnPairDuringConnect(
|
| +void BluetoothDeviceBlueZ::OnPairDuringConnect(
|
| const base::Closure& callback,
|
| const ConnectErrorCallback& error_callback) {
|
| VLOG(1) << object_path_.value() << ": Paired";
|
| @@ -682,7 +678,7 @@ void BluetoothDeviceChromeOS::OnPairDuringConnect(
|
| ConnectInternal(true, callback, error_callback);
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::OnPairDuringConnectError(
|
| +void BluetoothDeviceBlueZ::OnPairDuringConnectError(
|
| const ConnectErrorCallback& error_callback,
|
| const std::string& error_name,
|
| const std::string& error_message) {
|
| @@ -690,8 +686,9 @@ void BluetoothDeviceChromeOS::OnPairDuringConnectError(
|
| adapter()->NotifyDeviceChanged(this);
|
|
|
| DCHECK(num_connecting_calls_ >= 0);
|
| - LOG(WARNING) << object_path_.value() << ": Failed to pair device: "
|
| - << error_name << ": " << error_message;
|
| + LOG(WARNING) << object_path_.value()
|
| + << ": Failed to pair device: " << error_name << ": "
|
| + << error_message;
|
| VLOG(1) << object_path_.value() << ": " << num_connecting_calls_
|
| << " still in progress";
|
|
|
| @@ -704,13 +701,13 @@ void BluetoothDeviceChromeOS::OnPairDuringConnectError(
|
| error_callback.Run(error_code);
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::OnPair(const base::Closure& callback) {
|
| +void BluetoothDeviceBlueZ::OnPair(const base::Closure& callback) {
|
| VLOG(1) << object_path_.value() << ": Paired";
|
| EndPairing();
|
| callback.Run();
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::OnPairError(
|
| +void BluetoothDeviceBlueZ::OnPairError(
|
| const ConnectErrorCallback& error_callback,
|
| const std::string& error_name,
|
| const std::string& error_message) {
|
| @@ -723,14 +720,15 @@ void BluetoothDeviceChromeOS::OnPairError(
|
| error_callback.Run(error_code);
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::OnCancelPairingError(
|
| +void BluetoothDeviceBlueZ::OnCancelPairingError(
|
| const std::string& error_name,
|
| const std::string& error_message) {
|
| - LOG(WARNING) << object_path_.value() << ": Failed to cancel pairing: "
|
| - << error_name << ": " << error_message;
|
| + LOG(WARNING) << object_path_.value()
|
| + << ": Failed to cancel pairing: " << error_name << ": "
|
| + << error_message;
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::SetTrusted() {
|
| +void BluetoothDeviceBlueZ::SetTrusted() {
|
| // Unconditionally send the property change, rather than checking the value
|
| // first; there's no harm in doing this and it solves any race conditions
|
| // with the property becoming true or false and this call happening before
|
| @@ -738,36 +736,37 @@ void BluetoothDeviceChromeOS::SetTrusted() {
|
| bluez::BluezDBusManager::Get()
|
| ->GetBluetoothDeviceClient()
|
| ->GetProperties(object_path_)
|
| - ->trusted.Set(true, base::Bind(&BluetoothDeviceChromeOS::OnSetTrusted,
|
| + ->trusted.Set(true, base::Bind(&BluetoothDeviceBlueZ::OnSetTrusted,
|
| weak_ptr_factory_.GetWeakPtr()));
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::OnSetTrusted(bool success) {
|
| +void BluetoothDeviceBlueZ::OnSetTrusted(bool success) {
|
| LOG_IF(WARNING, !success) << object_path_.value()
|
| << ": Failed to set device as trusted";
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::OnDisconnect(const base::Closure& callback) {
|
| +void BluetoothDeviceBlueZ::OnDisconnect(const base::Closure& callback) {
|
| VLOG(1) << object_path_.value() << ": Disconnected";
|
| callback.Run();
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::OnDisconnectError(
|
| +void BluetoothDeviceBlueZ::OnDisconnectError(
|
| const ErrorCallback& error_callback,
|
| const std::string& error_name,
|
| const std::string& error_message) {
|
| - LOG(WARNING) << object_path_.value() << ": Failed to disconnect device: "
|
| - << error_name << ": " << error_message;
|
| + LOG(WARNING) << object_path_.value()
|
| + << ": Failed to disconnect device: " << error_name << ": "
|
| + << error_message;
|
| error_callback.Run();
|
| }
|
|
|
| -void BluetoothDeviceChromeOS::OnForgetError(
|
| - const ErrorCallback& error_callback,
|
| - const std::string& error_name,
|
| - const std::string& error_message) {
|
| - LOG(WARNING) << object_path_.value() << ": Failed to remove device: "
|
| - << error_name << ": " << error_message;
|
| +void BluetoothDeviceBlueZ::OnForgetError(const ErrorCallback& error_callback,
|
| + const std::string& error_name,
|
| + const std::string& error_message) {
|
| + LOG(WARNING) << object_path_.value()
|
| + << ": Failed to remove device: " << error_name << ": "
|
| + << error_message;
|
| error_callback.Run();
|
| }
|
|
|
| -} // namespace chromeos
|
| +} // namespace bluez
|
|
|