| Index: device/bluetooth/dbus/bluetooth_gatt_descriptor_service_provider.cc
|
| diff --git a/chromeos/dbus/bluetooth_gatt_descriptor_service_provider.cc b/device/bluetooth/dbus/bluetooth_gatt_descriptor_service_provider.cc
|
| similarity index 85%
|
| rename from chromeos/dbus/bluetooth_gatt_descriptor_service_provider.cc
|
| rename to device/bluetooth/dbus/bluetooth_gatt_descriptor_service_provider.cc
|
| index 3ed39b9315d06b7727ddbc52a40c8256f18309a1..e4aa24545539135a4369e606a73e97e4f67a87f7 100644
|
| --- a/chromeos/dbus/bluetooth_gatt_descriptor_service_provider.cc
|
| +++ b/device/bluetooth/dbus/bluetooth_gatt_descriptor_service_provider.cc
|
| @@ -2,27 +2,25 @@
|
| // 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 kErrorInvalidArgs[] = "org.freedesktop.DBus.Error.InvalidArgs";
|
| const char kErrorPropertyReadOnly[] =
|
| "org.freedesktop.DBus.Error.PropertyReadOnly";
|
| -const char kErrorFailed[] =
|
| - "org.freedesktop.DBus.Error.Failed";
|
| +const char kErrorFailed[] = "org.freedesktop.DBus.Error.Failed";
|
| } // namespace
|
|
|
| // The BluetoothGattDescriptorServiceProvider implementation used in production.
|
| @@ -57,24 +55,21 @@ class BluetoothGattDescriptorServiceProviderImpl
|
| exported_object_ = bus_->GetExportedObject(object_path_);
|
|
|
| exported_object_->ExportMethod(
|
| - dbus::kDBusPropertiesInterface,
|
| - dbus::kDBusPropertiesGet,
|
| + dbus::kDBusPropertiesInterface, dbus::kDBusPropertiesGet,
|
| base::Bind(&BluetoothGattDescriptorServiceProviderImpl::Get,
|
| weak_ptr_factory_.GetWeakPtr()),
|
| base::Bind(&BluetoothGattDescriptorServiceProviderImpl::OnExported,
|
| weak_ptr_factory_.GetWeakPtr()));
|
|
|
| exported_object_->ExportMethod(
|
| - dbus::kDBusPropertiesInterface,
|
| - dbus::kDBusPropertiesSet,
|
| + dbus::kDBusPropertiesInterface, dbus::kDBusPropertiesSet,
|
| base::Bind(&BluetoothGattDescriptorServiceProviderImpl::Set,
|
| weak_ptr_factory_.GetWeakPtr()),
|
| base::Bind(&BluetoothGattDescriptorServiceProviderImpl::OnExported,
|
| weak_ptr_factory_.GetWeakPtr()));
|
|
|
| exported_object_->ExportMethod(
|
| - dbus::kDBusPropertiesInterface,
|
| - dbus::kDBusPropertiesGetAll,
|
| + dbus::kDBusPropertiesInterface, dbus::kDBusPropertiesGetAll,
|
| base::Bind(&BluetoothGattDescriptorServiceProviderImpl::GetAll,
|
| weak_ptr_factory_.GetWeakPtr()),
|
| base::Bind(&BluetoothGattDescriptorServiceProviderImpl::OnExported,
|
| @@ -90,9 +85,8 @@ class BluetoothGattDescriptorServiceProviderImpl
|
| // BluetoothGattDescriptorServiceProvider override.
|
| void SendValueChanged(const std::vector<uint8>& value) override {
|
| VLOG(2) << "Emitting a PropertiesChanged signal for descriptor value.";
|
| - dbus::Signal signal(
|
| - dbus::kDBusPropertiesInterface,
|
| - dbus::kDBusPropertiesChangedSignal);
|
| + dbus::Signal signal(dbus::kDBusPropertiesInterface,
|
| + dbus::kDBusPropertiesChangedSignal);
|
| dbus::MessageWriter writer(&signal);
|
| dbus::MessageWriter array_writer(NULL);
|
| dbus::MessageWriter dict_entry_writer(NULL);
|
| @@ -138,11 +132,10 @@ class BluetoothGattDescriptorServiceProviderImpl
|
| std::string interface_name;
|
| std::string property_name;
|
| if (!reader.PopString(&interface_name) ||
|
| - !reader.PopString(&property_name) ||
|
| - reader.HasMoreData()) {
|
| + !reader.PopString(&property_name) || reader.HasMoreData()) {
|
| scoped_ptr<dbus::ErrorResponse> error_response =
|
| - dbus::ErrorResponse::FromMethodCall(
|
| - method_call, kErrorInvalidArgs, "Expected 'ss'.");
|
| + dbus::ErrorResponse::FromMethodCall(method_call, kErrorInvalidArgs,
|
| + "Expected 'ss'.");
|
| response_sender.Run(error_response.Pass());
|
| return;
|
| }
|
| @@ -163,11 +156,11 @@ class BluetoothGattDescriptorServiceProviderImpl
|
| DCHECK(delegate_);
|
| delegate_->GetDescriptorValue(
|
| base::Bind(&BluetoothGattDescriptorServiceProviderImpl::OnGet,
|
| - weak_ptr_factory_.GetWeakPtr(),
|
| - method_call, response_sender),
|
| + weak_ptr_factory_.GetWeakPtr(), method_call,
|
| + response_sender),
|
| base::Bind(&BluetoothGattDescriptorServiceProviderImpl::OnFailure,
|
| - weak_ptr_factory_.GetWeakPtr(),
|
| - method_call, response_sender));
|
| + weak_ptr_factory_.GetWeakPtr(), method_call,
|
| + response_sender));
|
| return;
|
| }
|
|
|
| @@ -188,8 +181,7 @@ class BluetoothGattDescriptorServiceProviderImpl
|
| writer.CloseContainer(&variant_writer);
|
| } else {
|
| response = dbus::ErrorResponse::FromMethodCall(
|
| - method_call,
|
| - kErrorInvalidArgs,
|
| + method_call, kErrorInvalidArgs,
|
| "No such property: '" + property_name + "'.");
|
| }
|
|
|
| @@ -211,11 +203,10 @@ class BluetoothGattDescriptorServiceProviderImpl
|
| dbus::MessageReader variant_reader(NULL);
|
| if (!reader.PopString(&interface_name) ||
|
| !reader.PopString(&property_name) ||
|
| - !reader.PopVariant(&variant_reader) ||
|
| - reader.HasMoreData()) {
|
| + !reader.PopVariant(&variant_reader) || reader.HasMoreData()) {
|
| scoped_ptr<dbus::ErrorResponse> error_response =
|
| - dbus::ErrorResponse::FromMethodCall(
|
| - method_call, kErrorInvalidArgs, "Expected 'ssv'.");
|
| + dbus::ErrorResponse::FromMethodCall(method_call, kErrorInvalidArgs,
|
| + "Expected 'ssv'.");
|
| response_sender.Run(error_response.Pass());
|
| return;
|
| }
|
| @@ -244,8 +235,8 @@ class BluetoothGattDescriptorServiceProviderImpl
|
| error_message = "No such property: '" + property_name + "'.";
|
| }
|
| scoped_ptr<dbus::ErrorResponse> error_response =
|
| - dbus::ErrorResponse::FromMethodCall(
|
| - method_call, error_name, error_message);
|
| + dbus::ErrorResponse::FromMethodCall(method_call, error_name,
|
| + error_message);
|
| response_sender.Run(error_response.Pass());
|
| return;
|
| }
|
| @@ -266,13 +257,12 @@ class BluetoothGattDescriptorServiceProviderImpl
|
| std::vector<uint8> value(bytes, bytes + length);
|
| DCHECK(delegate_);
|
| delegate_->SetDescriptorValue(
|
| - value,
|
| - base::Bind(&BluetoothGattDescriptorServiceProviderImpl::OnSet,
|
| - weak_ptr_factory_.GetWeakPtr(),
|
| - method_call, response_sender),
|
| + value, base::Bind(&BluetoothGattDescriptorServiceProviderImpl::OnSet,
|
| + weak_ptr_factory_.GetWeakPtr(), method_call,
|
| + response_sender),
|
| base::Bind(&BluetoothGattDescriptorServiceProviderImpl::OnFailure,
|
| - weak_ptr_factory_.GetWeakPtr(),
|
| - method_call, response_sender));
|
| + weak_ptr_factory_.GetWeakPtr(), method_call,
|
| + response_sender));
|
| }
|
|
|
| // Called by dbus:: when the Bluetooth daemon fetches all properties of the
|
| @@ -288,8 +278,8 @@ class BluetoothGattDescriptorServiceProviderImpl
|
| std::string interface_name;
|
| if (!reader.PopString(&interface_name) || reader.HasMoreData()) {
|
| scoped_ptr<dbus::ErrorResponse> error_response =
|
| - dbus::ErrorResponse::FromMethodCall(
|
| - method_call, kErrorInvalidArgs, "Expected 's'.");
|
| + dbus::ErrorResponse::FromMethodCall(method_call, kErrorInvalidArgs,
|
| + "Expected 's'.");
|
| response_sender.Run(error_response.Pass());
|
| return;
|
| }
|
| @@ -310,19 +300,19 @@ class BluetoothGattDescriptorServiceProviderImpl
|
| DCHECK(delegate_);
|
| delegate_->GetDescriptorValue(
|
| base::Bind(&BluetoothGattDescriptorServiceProviderImpl::OnGetAll,
|
| - weak_ptr_factory_.GetWeakPtr(),
|
| - method_call, response_sender),
|
| + weak_ptr_factory_.GetWeakPtr(), method_call,
|
| + response_sender),
|
| base::Bind(&BluetoothGattDescriptorServiceProviderImpl::OnFailure,
|
| - weak_ptr_factory_.GetWeakPtr(),
|
| - method_call, response_sender));
|
| + weak_ptr_factory_.GetWeakPtr(), method_call,
|
| + response_sender));
|
| }
|
|
|
| // Called by dbus:: when a method is exported.
|
| void OnExported(const std::string& interface_name,
|
| const std::string& method_name,
|
| bool success) {
|
| - LOG_IF(WARNING, !success) << "Failed to export "
|
| - << interface_name << "." << method_name;
|
| + LOG_IF(WARNING, !success) << "Failed to export " << interface_name << "."
|
| + << method_name;
|
| }
|
|
|
| // Called by the Delegate in response to a method to call to get all
|
| @@ -344,8 +334,7 @@ class BluetoothGattDescriptorServiceProviderImpl
|
| writer.OpenArray("{sv}", &array_writer);
|
|
|
| array_writer.OpenDictEntry(&dict_entry_writer);
|
| - dict_entry_writer.AppendString(
|
| - bluetooth_gatt_descriptor::kUUIDProperty);
|
| + dict_entry_writer.AppendString(bluetooth_gatt_descriptor::kUUIDProperty);
|
| dict_entry_writer.AppendVariantOfString(uuid_);
|
| array_writer.CloseContainer(&dict_entry_writer);
|
|
|
| @@ -356,8 +345,7 @@ class BluetoothGattDescriptorServiceProviderImpl
|
| array_writer.CloseContainer(&dict_entry_writer);
|
|
|
| array_writer.OpenDictEntry(&dict_entry_writer);
|
| - dict_entry_writer.AppendString(
|
| - bluetooth_gatt_descriptor::kValueProperty);
|
| + dict_entry_writer.AppendString(bluetooth_gatt_descriptor::kValueProperty);
|
| dict_entry_writer.OpenVariant("ay", &variant_writer);
|
| variant_writer.AppendArrayOfBytes(value.data(), value.size());
|
| dict_entry_writer.CloseContainer(&variant_writer);
|
| @@ -403,8 +391,7 @@ class BluetoothGattDescriptorServiceProviderImpl
|
| VLOG(2) << "Failed to get/set descriptor value. Report error.";
|
| scoped_ptr<dbus::ErrorResponse> error_response =
|
| dbus::ErrorResponse::FromMethodCall(
|
| - method_call, kErrorFailed,
|
| - "Failed to get/set descriptor value.");
|
| + method_call, kErrorFailed, "Failed to get/set descriptor value.");
|
| response_sender.Run(error_response.Pass());
|
| }
|
|
|
| @@ -445,12 +432,10 @@ class BluetoothGattDescriptorServiceProviderImpl
|
| };
|
|
|
| BluetoothGattDescriptorServiceProvider::
|
| - BluetoothGattDescriptorServiceProvider() {
|
| -}
|
| + BluetoothGattDescriptorServiceProvider() {}
|
|
|
| BluetoothGattDescriptorServiceProvider::
|
| - ~BluetoothGattDescriptorServiceProvider() {
|
| -}
|
| + ~BluetoothGattDescriptorServiceProvider() {}
|
|
|
| // static
|
| BluetoothGattDescriptorServiceProvider*
|
| @@ -461,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);
|
| }
|
| @@ -469,4 +454,4 @@ BluetoothGattDescriptorServiceProvider::Create(
|
| object_path, delegate, uuid, permissions, characteristic_path);
|
| }
|
|
|
| -} // namespace chromeos
|
| +} // namespace bluez
|
|
|