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

Unified Diff: device/bluetooth/dbus/bluetooth_gatt_characteristic_client.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_client.cc
diff --git a/chromeos/dbus/bluetooth_gatt_characteristic_client.cc b/device/bluetooth/dbus/bluetooth_gatt_characteristic_client.cc
similarity index 84%
rename from chromeos/dbus/bluetooth_gatt_characteristic_client.cc
rename to device/bluetooth/dbus/bluetooth_gatt_characteristic_client.cc
index 5e486010bb40be2603ac181a8d674ea0b293e159..6000a525208c720763a5a7bc52bbae9a22d2613f 100644
--- a/chromeos/dbus/bluetooth_gatt_characteristic_client.cc
+++ b/device/bluetooth/dbus/bluetooth_gatt_characteristic_client.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 "chromeos/dbus/bluetooth_gatt_characteristic_client.h"
+#include "device/bluetooth/dbus/bluetooth_gatt_characteristic_client.h"
#include "base/bind.h"
#include "base/memory/weak_ptr.h"
@@ -11,7 +11,7 @@
#include "dbus/object_manager.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
-namespace chromeos {
+namespace bluez {
namespace {
@@ -42,8 +42,7 @@ BluetoothGattCharacteristicClient::Properties::Properties(
&descriptors);
}
-BluetoothGattCharacteristicClient::Properties::~Properties() {
-}
+BluetoothGattCharacteristicClient::Properties::~Properties() {}
// The BluetoothGattCharacteristicClient implementation used in production.
class BluetoothGattCharacteristicClientImpl
@@ -51,9 +50,7 @@ class BluetoothGattCharacteristicClientImpl
public dbus::ObjectManager::Interface {
public:
BluetoothGattCharacteristicClientImpl()
- : object_manager_(NULL),
- weak_ptr_factory_(this) {
- }
+ : object_manager_(NULL), weak_ptr_factory_(this) {}
~BluetoothGattCharacteristicClientImpl() override {
object_manager_->UnregisterInterface(
@@ -84,11 +81,9 @@ class BluetoothGattCharacteristicClientImpl
// BluetoothGattCharacteristicClient override.
Properties* GetProperties(const dbus::ObjectPath& object_path) override {
DCHECK(object_manager_);
- return static_cast<Properties*>(
- object_manager_->GetProperties(
- object_path,
- bluetooth_gatt_characteristic::
- kBluetoothGattCharacteristicInterface));
+ return static_cast<Properties*>(object_manager_->GetProperties(
+ object_path,
+ bluetooth_gatt_characteristic::kBluetoothGattCharacteristicInterface));
}
// BluetoothGattCharacteristicClient override.
@@ -107,14 +102,11 @@ class BluetoothGattCharacteristicClientImpl
bluetooth_gatt_characteristic::kReadValue);
object_proxy->CallMethodWithErrorCallback(
- &method_call,
- dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
+ &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::Bind(&BluetoothGattCharacteristicClientImpl::OnValueSuccess,
- weak_ptr_factory_.GetWeakPtr(),
- callback),
+ weak_ptr_factory_.GetWeakPtr(), callback),
base::Bind(&BluetoothGattCharacteristicClientImpl::OnError,
- weak_ptr_factory_.GetWeakPtr(),
- error_callback));
+ weak_ptr_factory_.GetWeakPtr(), error_callback));
}
// BluetoothGattCharacteristicClient override.
@@ -136,14 +128,11 @@ class BluetoothGattCharacteristicClientImpl
writer.AppendArrayOfBytes(value.data(), value.size());
object_proxy->CallMethodWithErrorCallback(
- &method_call,
- dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
+ &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::Bind(&BluetoothGattCharacteristicClientImpl::OnSuccess,
- weak_ptr_factory_.GetWeakPtr(),
- callback),
+ weak_ptr_factory_.GetWeakPtr(), callback),
base::Bind(&BluetoothGattCharacteristicClientImpl::OnError,
- weak_ptr_factory_.GetWeakPtr(),
- error_callback));
+ weak_ptr_factory_.GetWeakPtr(), error_callback));
}
// BluetoothGattCharacteristicClient override.
@@ -162,14 +151,11 @@ class BluetoothGattCharacteristicClientImpl
bluetooth_gatt_characteristic::kStartNotify);
object_proxy->CallMethodWithErrorCallback(
- &method_call,
- dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
+ &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::Bind(&BluetoothGattCharacteristicClientImpl::OnSuccess,
- weak_ptr_factory_.GetWeakPtr(),
- callback),
+ weak_ptr_factory_.GetWeakPtr(), callback),
base::Bind(&BluetoothGattCharacteristicClientImpl::OnError,
- weak_ptr_factory_.GetWeakPtr(),
- error_callback));
+ weak_ptr_factory_.GetWeakPtr(), error_callback));
}
// BluetoothGattCharacteristicClient override.
@@ -188,14 +174,11 @@ class BluetoothGattCharacteristicClientImpl
bluetooth_gatt_characteristic::kStopNotify);
object_proxy->CallMethodWithErrorCallback(
- &method_call,
- dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
+ &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::Bind(&BluetoothGattCharacteristicClientImpl::OnSuccess,
- weak_ptr_factory_.GetWeakPtr(),
- callback),
+ weak_ptr_factory_.GetWeakPtr(), callback),
base::Bind(&BluetoothGattCharacteristicClientImpl::OnError,
- weak_ptr_factory_.GetWeakPtr(),
- error_callback));
+ weak_ptr_factory_.GetWeakPtr(), error_callback));
}
// dbus::ObjectManager::Interface override.
@@ -204,11 +187,9 @@ class BluetoothGattCharacteristicClientImpl
const dbus::ObjectPath& object_path,
const std::string& interface_name) override {
Properties* properties = new Properties(
- object_proxy,
- interface_name,
+ object_proxy, interface_name,
base::Bind(&BluetoothGattCharacteristicClientImpl::OnPropertyChanged,
- weak_ptr_factory_.GetWeakPtr(),
- object_path));
+ weak_ptr_factory_.GetWeakPtr(), object_path));
return static_cast<dbus::PropertySet*>(properties);
}
@@ -248,9 +229,9 @@ class BluetoothGattCharacteristicClientImpl
const std::string& property_name) {
VLOG(2) << "Remote GATT characteristic property changed: "
<< object_path.value() << ": " << property_name;
- FOR_EACH_OBSERVER(BluetoothGattCharacteristicClient::Observer, observers_,
- GattCharacteristicPropertyChanged(object_path,
- property_name));
+ FOR_EACH_OBSERVER(
+ BluetoothGattCharacteristicClient::Observer, observers_,
+ GattCharacteristicPropertyChanged(object_path, property_name));
}
// Called when a response for successful method call is received.
@@ -305,21 +286,18 @@ class BluetoothGattCharacteristicClientImpl
// than we do.
// Note: This should remain the last member so it'll be destroyed and
// invalidate its weak pointers before any other members are destroyed.
- base::WeakPtrFactory<BluetoothGattCharacteristicClientImpl>
- weak_ptr_factory_;
+ base::WeakPtrFactory<BluetoothGattCharacteristicClientImpl> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(BluetoothGattCharacteristicClientImpl);
};
-BluetoothGattCharacteristicClient::BluetoothGattCharacteristicClient() {
-}
+BluetoothGattCharacteristicClient::BluetoothGattCharacteristicClient() {}
-BluetoothGattCharacteristicClient::~BluetoothGattCharacteristicClient() {
-}
+BluetoothGattCharacteristicClient::~BluetoothGattCharacteristicClient() {}
// static
BluetoothGattCharacteristicClient* BluetoothGattCharacteristicClient::Create() {
return new BluetoothGattCharacteristicClientImpl();
}
-} // namespace chromeos
+} // namespace bluez

Powered by Google App Engine
This is Rietveld 408576698