diff options
author | yoichio <yoichio@chromium.org> | 2015-09-29 00:39:22 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-09-29 07:39:59 +0000 |
commit | 500c6dbb7438f38c5bb28c529d4bd43e6d1b1f9e (patch) | |
tree | 43fd774d2c09ad46db949e824bce328e158ba57d /device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.cc | |
parent | a543d12194462ac37a25d150dcbb0077ccd72b73 (diff) | |
download | chromium_src-500c6dbb7438f38c5bb28c529d4bd43e6d1b1f9e.zip chromium_src-500c6dbb7438f38c5bb28c529d4bd43e6d1b1f9e.tar.gz chromium_src-500c6dbb7438f38c5bb28c529d4bd43e6d1b1f9e.tar.bz2 |
Revert of Add Linux support for the Bluetooth API. (patchset #10 id:90001 of
https://codereview.chromium.org/1367663002/ )
Reason for revert:
perf regression.
http://build.chromium.org/p/chromium/builders/Linux%20x64/builds/10130
Original issue's description:
> Add Linux support for the Bluetooth API.
>
> This refactors all the code in //device/bluetooth to be non-ChromeOS specific
> and adds code to enable all of it to run on Linux through the linux specific
> DBusThreadManager that is added.
>
> This CL depends on https://codereview.chromium.org/1347193004/
>
> Owners reviews requested,
> //device - armansito@
> //extensions - rockot@
> //chrome/browser/chrome_browser_main_linux.* - jhawkins@
>
> R=armansito@chromium.org, jhawkins@chromium.org, rockot@chromium.org
> BUG=522633
>
> Committed: https://crrev.com/17fcdab015a073437404f35e7e63c1464280d36b
> Cr-Commit-Position: refs/heads/master@{#351237}
TBR=armansito@chromium.org,jhawkins@chromium.org,rockot@chromium.org,jdeokule@chromi
um.org,scheib@chromium.org,rkc@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=522633
Review URL: https://codereview.chromium.org/1380463003
Cr-Commit-Position: refs/heads/master@{#351266}
Diffstat (limited to 'device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.cc')
-rw-r--r-- | device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.cc | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.cc b/device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.cc new file mode 100644 index 0000000..f864c3b --- /dev/null +++ b/device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.cc @@ -0,0 +1,126 @@ +// 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/bluetooth_remote_gatt_descriptor_chromeos.h" + +#include "base/bind.h" +#include "base/logging.h" +#include "base/strings/stringprintf.h" +#include "device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h" +#include "device/bluetooth/bluetooth_remote_gatt_service_chromeos.h" +#include "device/bluetooth/dbus/bluetooth_gatt_descriptor_client.h" +#include "device/bluetooth/dbus/bluez_dbus_manager.h" + +namespace chromeos { + +namespace { + +// Stream operator for logging vector<uint8>. +std::ostream& operator<<(std::ostream& out, const std::vector<uint8> bytes) { + out << "["; + for (std::vector<uint8>::const_iterator iter = bytes.begin(); + iter != bytes.end(); ++iter) { + out << base::StringPrintf("%02X", *iter); + } + return out << "]"; +} + +} // namespace + +BluetoothRemoteGattDescriptorChromeOS::BluetoothRemoteGattDescriptorChromeOS( + BluetoothRemoteGattCharacteristicChromeOS* characteristic, + const dbus::ObjectPath& object_path) + : object_path_(object_path), + characteristic_(characteristic), + weak_ptr_factory_(this) { + VLOG(1) << "Creating remote GATT descriptor with identifier: " + << GetIdentifier() << ", UUID: " << GetUUID().canonical_value(); +} + +BluetoothRemoteGattDescriptorChromeOS:: + ~BluetoothRemoteGattDescriptorChromeOS() { +} + +std::string BluetoothRemoteGattDescriptorChromeOS::GetIdentifier() const { + return object_path_.value(); +} + +device::BluetoothUUID BluetoothRemoteGattDescriptorChromeOS::GetUUID() const { + bluez::BluetoothGattDescriptorClient::Properties* properties = + bluez::BluezDBusManager::Get() + ->GetBluetoothGattDescriptorClient() + ->GetProperties(object_path_); + DCHECK(properties); + return device::BluetoothUUID(properties->uuid.value()); +} + +bool BluetoothRemoteGattDescriptorChromeOS::IsLocal() const { + return false; +} + +const std::vector<uint8>& +BluetoothRemoteGattDescriptorChromeOS::GetValue() const { + bluez::BluetoothGattDescriptorClient::Properties* properties = + bluez::BluezDBusManager::Get() + ->GetBluetoothGattDescriptorClient() + ->GetProperties(object_path_); + + DCHECK(properties); + + return properties->value.value(); +} + +device::BluetoothGattCharacteristic* +BluetoothRemoteGattDescriptorChromeOS::GetCharacteristic() const { + return characteristic_; +} + +device::BluetoothGattCharacteristic::Permissions +BluetoothRemoteGattDescriptorChromeOS::GetPermissions() const { + // TODO(armansito): Once BlueZ defines the permissions, return the correct + // values here. + return device::BluetoothGattCharacteristic::PERMISSION_NONE; +} + +void BluetoothRemoteGattDescriptorChromeOS::ReadRemoteDescriptor( + const ValueCallback& callback, + const ErrorCallback& error_callback) { + VLOG(1) << "Sending GATT characteristic descriptor read request to " + << "descriptor: " << GetIdentifier() << ", UUID: " + << GetUUID().canonical_value(); + + bluez::BluezDBusManager::Get()->GetBluetoothGattDescriptorClient()->ReadValue( + object_path_, callback, + base::Bind(&BluetoothRemoteGattDescriptorChromeOS::OnError, + weak_ptr_factory_.GetWeakPtr(), error_callback)); +} + +void BluetoothRemoteGattDescriptorChromeOS::WriteRemoteDescriptor( + const std::vector<uint8>& new_value, + const base::Closure& callback, + const ErrorCallback& error_callback) { + VLOG(1) << "Sending GATT characteristic descriptor write request to " + << "characteristic: " << GetIdentifier() << ", UUID: " + << GetUUID().canonical_value() << ", with value: " + << new_value << "."; + + bluez::BluezDBusManager::Get() + ->GetBluetoothGattDescriptorClient() + ->WriteValue(object_path_, new_value, callback, + base::Bind(&BluetoothRemoteGattDescriptorChromeOS::OnError, + weak_ptr_factory_.GetWeakPtr(), error_callback)); +} + +void BluetoothRemoteGattDescriptorChromeOS::OnError( + const ErrorCallback& error_callback, + const std::string& error_name, + const std::string& error_message) { + VLOG(1) << "Operation failed: " << error_name + << ", message: " << error_message; + + error_callback.Run( + BluetoothRemoteGattServiceChromeOS::DBusErrorToServiceError(error_name)); +} + +} // namespace chromeos |