Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1841)

Unified Diff: device/bluetooth/dbus/bluetooth_gatt_characteristic_service_provider.cc

Issue 1347193004: Refactor DBusThreadManager to split away BT clients. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/dbus/bluetooth_gatt_characteristic_service_provider.cc
diff --git a/chromeos/dbus/bluetooth_gatt_characteristic_service_provider.cc b/device/bluetooth/dbus/bluetooth_gatt_characteristic_service_provider.cc
similarity index 85%
rename from chromeos/dbus/bluetooth_gatt_characteristic_service_provider.cc
rename to device/bluetooth/dbus/bluetooth_gatt_characteristic_service_provider.cc
index 545880ac522d00db8180a47d25e4ad3782cd9272..4decdf0171607437ab8438021b196c3337b011cf 100644
--- a/chromeos/dbus/bluetooth_gatt_characteristic_service_provider.cc
+++ b/device/bluetooth/dbus/bluetooth_gatt_characteristic_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_characteristic_service_provider.h"
+#include "device/bluetooth/dbus/bluetooth_gatt_characteristic_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_characteristic_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_characteristic_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 BluetoothGattCharacteristicServiceProvider implementation used in
@@ -52,31 +50,27 @@ class BluetoothGattCharacteristicServiceProviderImpl
DCHECK(!uuid_.empty());
DCHECK(object_path_.IsValid());
DCHECK(service_path_.IsValid());
- DCHECK(base::StartsWith(object_path_.value(),
- service_path_.value() + "/",
+ DCHECK(base::StartsWith(object_path_.value(), service_path_.value() + "/",
base::CompareCase::SENSITIVE));
exported_object_ = bus_->GetExportedObject(object_path_);
exported_object_->ExportMethod(
- dbus::kDBusPropertiesInterface,
- dbus::kDBusPropertiesGet,
+ dbus::kDBusPropertiesInterface, dbus::kDBusPropertiesGet,
base::Bind(&BluetoothGattCharacteristicServiceProviderImpl::Get,
weak_ptr_factory_.GetWeakPtr()),
base::Bind(&BluetoothGattCharacteristicServiceProviderImpl::OnExported,
weak_ptr_factory_.GetWeakPtr()));
exported_object_->ExportMethod(
- dbus::kDBusPropertiesInterface,
- dbus::kDBusPropertiesSet,
+ dbus::kDBusPropertiesInterface, dbus::kDBusPropertiesSet,
base::Bind(&BluetoothGattCharacteristicServiceProviderImpl::Set,
weak_ptr_factory_.GetWeakPtr()),
base::Bind(&BluetoothGattCharacteristicServiceProviderImpl::OnExported,
weak_ptr_factory_.GetWeakPtr()));
exported_object_->ExportMethod(
- dbus::kDBusPropertiesInterface,
- dbus::kDBusPropertiesGetAll,
+ dbus::kDBusPropertiesInterface, dbus::kDBusPropertiesGetAll,
base::Bind(&BluetoothGattCharacteristicServiceProviderImpl::GetAll,
weak_ptr_factory_.GetWeakPtr()),
base::Bind(&BluetoothGattCharacteristicServiceProviderImpl::OnExported,
@@ -92,9 +86,8 @@ class BluetoothGattCharacteristicServiceProviderImpl
// BluetoothGattCharacteristicServiceProvider override.
void SendValueChanged(const std::vector<uint8>& value) override {
VLOG(2) << "Emitting a PropertiesChanged signal for characteristic 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);
@@ -141,11 +134,10 @@ class BluetoothGattCharacteristicServiceProviderImpl
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;
}
@@ -166,11 +158,11 @@ class BluetoothGattCharacteristicServiceProviderImpl
DCHECK(delegate_);
delegate_->GetCharacteristicValue(
base::Bind(&BluetoothGattCharacteristicServiceProviderImpl::OnGet,
- weak_ptr_factory_.GetWeakPtr(),
- method_call, response_sender),
+ weak_ptr_factory_.GetWeakPtr(), method_call,
+ response_sender),
base::Bind(&BluetoothGattCharacteristicServiceProviderImpl::OnFailure,
- weak_ptr_factory_.GetWeakPtr(),
- method_call, response_sender));
+ weak_ptr_factory_.GetWeakPtr(), method_call,
+ response_sender));
return;
}
@@ -191,8 +183,7 @@ class BluetoothGattCharacteristicServiceProviderImpl
writer.CloseContainer(&variant_writer);
} else {
response = dbus::ErrorResponse::FromMethodCall(
- method_call,
- kErrorInvalidArgs,
+ method_call, kErrorInvalidArgs,
"No such property: '" + property_name + "'.");
}
@@ -214,11 +205,10 @@ class BluetoothGattCharacteristicServiceProviderImpl
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;
}
@@ -247,8 +237,8 @@ class BluetoothGattCharacteristicServiceProviderImpl
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;
}
@@ -271,11 +261,11 @@ class BluetoothGattCharacteristicServiceProviderImpl
delegate_->SetCharacteristicValue(
value,
base::Bind(&BluetoothGattCharacteristicServiceProviderImpl::OnSet,
- weak_ptr_factory_.GetWeakPtr(),
- method_call, response_sender),
+ weak_ptr_factory_.GetWeakPtr(), method_call,
+ response_sender),
base::Bind(&BluetoothGattCharacteristicServiceProviderImpl::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
@@ -291,8 +281,8 @@ class BluetoothGattCharacteristicServiceProviderImpl
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;
}
@@ -313,19 +303,19 @@ class BluetoothGattCharacteristicServiceProviderImpl
DCHECK(delegate_);
delegate_->GetCharacteristicValue(
base::Bind(&BluetoothGattCharacteristicServiceProviderImpl::OnGetAll,
- weak_ptr_factory_.GetWeakPtr(),
- method_call, response_sender),
+ weak_ptr_factory_.GetWeakPtr(), method_call,
+ response_sender),
base::Bind(&BluetoothGattCharacteristicServiceProviderImpl::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
@@ -448,24 +438,22 @@ class BluetoothGattCharacteristicServiceProviderImpl
};
BluetoothGattCharacteristicServiceProvider::
- BluetoothGattCharacteristicServiceProvider() {
-}
+ BluetoothGattCharacteristicServiceProvider() {}
BluetoothGattCharacteristicServiceProvider::
- ~BluetoothGattCharacteristicServiceProvider() {
-}
+ ~BluetoothGattCharacteristicServiceProvider() {}
// static
BluetoothGattCharacteristicServiceProvider*
BluetoothGattCharacteristicServiceProvider::Create(
- dbus::Bus* bus,
- const dbus::ObjectPath& object_path,
- Delegate* delegate,
- const std::string& uuid,
- const std::vector<std::string>& flags,
- const std::vector<std::string>& permissions,
- const dbus::ObjectPath& service_path) {
- if (!DBusThreadManager::Get()->IsUsingStub(DBusClientBundle::BLUETOOTH)) {
+ dbus::Bus* bus,
+ const dbus::ObjectPath& object_path,
+ Delegate* delegate,
+ const std::string& uuid,
+ const std::vector<std::string>& flags,
+ const std::vector<std::string>& permissions,
+ const dbus::ObjectPath& service_path) {
+ if (!bluez::BluezDBusManager::Get()->IsUsingStub()) {
return new BluetoothGattCharacteristicServiceProviderImpl(
bus, object_path, delegate, uuid, flags, permissions, service_path);
}
@@ -473,4 +461,4 @@ BluetoothGattCharacteristicServiceProvider::Create(
object_path, delegate, uuid, flags, permissions, service_path);
}
-} // namespace chromeos
+} // namespace bluez

Powered by Google App Engine
This is Rietveld 408576698