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

Unified Diff: device/bluetooth/dbus/fake_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/fake_bluetooth_gatt_characteristic_client.cc
diff --git a/chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc b/device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_client.cc
similarity index 90%
rename from chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc
rename to device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_client.cc
index 61bbb8dd92042fa88f0776c960b69cc999cc28ec..10f073a1833f122ecbf807a439d754d122a54205 100644
--- a/chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc
+++ b/device/bluetooth/dbus/fake_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/fake_bluetooth_gatt_characteristic_client.h"
+#include "device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_client.h"
#include "base/bind.h"
#include "base/location.h"
@@ -10,11 +10,11 @@
#include "base/single_thread_task_runner.h"
#include "base/thread_task_runner_handle.h"
#include "base/time/time.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
-#include "chromeos/dbus/fake_bluetooth_gatt_descriptor_client.h"
+#include "device/bluetooth/dbus/bluez_dbus_manager.h"
+#include "device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
-namespace chromeos {
+namespace bluez {
namespace {
@@ -26,17 +26,16 @@ const int kHeartRateMeasurementNotificationIntervalMs = 2000;
FakeBluetoothGattCharacteristicClient::DelayedCallback::DelayedCallback(
base::Closure callback,
size_t delay)
- : callback_(callback), delay_(delay) {
-}
+ : callback_(callback), delay_(delay) {}
-FakeBluetoothGattCharacteristicClient::DelayedCallback::~DelayedCallback() {
-}
+FakeBluetoothGattCharacteristicClient::DelayedCallback::~DelayedCallback() {}
// static
const char FakeBluetoothGattCharacteristicClient::
kHeartRateMeasurementPathComponent[] = "char0000";
-const char FakeBluetoothGattCharacteristicClient::
- kBodySensorLocationPathComponent[] = "char0001";
+const char
+ FakeBluetoothGattCharacteristicClient::kBodySensorLocationPathComponent[] =
+ "char0001";
const char FakeBluetoothGattCharacteristicClient::
kHeartRateControlPointPathComponent[] = "char0002";
@@ -53,11 +52,9 @@ FakeBluetoothGattCharacteristicClient::Properties::Properties(
: BluetoothGattCharacteristicClient::Properties(
NULL,
bluetooth_gatt_characteristic::kBluetoothGattCharacteristicInterface,
- callback) {
-}
+ callback) {}
-FakeBluetoothGattCharacteristicClient::Properties::~Properties() {
-}
+FakeBluetoothGattCharacteristicClient::Properties::~Properties() {}
void FakeBluetoothGattCharacteristicClient::Properties::Get(
dbus::PropertyBase* property,
@@ -83,8 +80,7 @@ FakeBluetoothGattCharacteristicClient::FakeBluetoothGattCharacteristicClient()
authenticated_(true),
calories_burned_(0),
extra_requests_(0),
- weak_ptr_factory_(this) {
-}
+ weak_ptr_factory_(this) {}
FakeBluetoothGattCharacteristicClient::
~FakeBluetoothGattCharacteristicClient() {
@@ -94,8 +90,7 @@ FakeBluetoothGattCharacteristicClient::
action_extra_requests_.clear();
}
-void FakeBluetoothGattCharacteristicClient::Init(dbus::Bus* bus) {
-}
+void FakeBluetoothGattCharacteristicClient::Init(dbus::Bus* bus) {}
void FakeBluetoothGattCharacteristicClient::AddObserver(Observer* observer) {
observers_.AddObserver(observer);
@@ -247,12 +242,11 @@ void FakeBluetoothGattCharacteristicClient::WriteValue(
}
base::Closure completed_callback;
if (value.size() != 1) {
- completed_callback = base::Bind(error_callback,
- "org.bluez.Error.InvalidValueLength",
- "Invalid length for write");
+ completed_callback =
+ base::Bind(error_callback, "org.bluez.Error.InvalidValueLength",
+ "Invalid length for write");
} else if (value[0] > 1) {
- completed_callback = base::Bind(error_callback,
- "org.bluez.Error.Failed",
+ completed_callback = base::Bind(error_callback, "org.bluez.Error.Failed",
"Invalid value given for write");
} else if (value[0] == 1) {
// TODO(jamuraa): make this happen when the callback happens
@@ -337,10 +331,10 @@ void FakeBluetoothGattCharacteristicClient::ExposeHeartRateCharacteristics(
// ==== Heart Rate Measurement Characteristic ====
heart_rate_measurement_path_ =
service_path.value() + "/" + kHeartRateMeasurementPathComponent;
- heart_rate_measurement_properties_.reset(new Properties(base::Bind(
- &FakeBluetoothGattCharacteristicClient::OnPropertyChanged,
- weak_ptr_factory_.GetWeakPtr(),
- dbus::ObjectPath(heart_rate_measurement_path_))));
+ heart_rate_measurement_properties_.reset(new Properties(
+ base::Bind(&FakeBluetoothGattCharacteristicClient::OnPropertyChanged,
+ weak_ptr_factory_.GetWeakPtr(),
+ dbus::ObjectPath(heart_rate_measurement_path_))));
heart_rate_measurement_properties_->uuid.ReplaceValue(
kHeartRateMeasurementUUID);
heart_rate_measurement_properties_->service.ReplaceValue(service_path);
@@ -350,10 +344,10 @@ void FakeBluetoothGattCharacteristicClient::ExposeHeartRateCharacteristics(
// ==== Body Sensor Location Characteristic ====
body_sensor_location_path_ =
service_path.value() + "/" + kBodySensorLocationPathComponent;
- body_sensor_location_properties_.reset(new Properties(base::Bind(
- &FakeBluetoothGattCharacteristicClient::OnPropertyChanged,
- weak_ptr_factory_.GetWeakPtr(),
- dbus::ObjectPath(body_sensor_location_path_))));
+ body_sensor_location_properties_.reset(new Properties(
+ base::Bind(&FakeBluetoothGattCharacteristicClient::OnPropertyChanged,
+ weak_ptr_factory_.GetWeakPtr(),
+ dbus::ObjectPath(body_sensor_location_path_))));
body_sensor_location_properties_->uuid.ReplaceValue(kBodySensorLocationUUID);
body_sensor_location_properties_->service.ReplaceValue(service_path);
flags.clear();
@@ -363,10 +357,10 @@ void FakeBluetoothGattCharacteristicClient::ExposeHeartRateCharacteristics(
// ==== Heart Rate Control Point Characteristic ====
heart_rate_control_point_path_ =
service_path.value() + "/" + kHeartRateControlPointPathComponent;
- heart_rate_control_point_properties_.reset(new Properties(base::Bind(
- &FakeBluetoothGattCharacteristicClient::OnPropertyChanged,
- weak_ptr_factory_.GetWeakPtr(),
- dbus::ObjectPath(heart_rate_control_point_path_))));
+ heart_rate_control_point_properties_.reset(new Properties(
+ base::Bind(&FakeBluetoothGattCharacteristicClient::OnPropertyChanged,
+ weak_ptr_factory_.GetWeakPtr(),
+ dbus::ObjectPath(heart_rate_control_point_path_))));
heart_rate_control_point_properties_->uuid.ReplaceValue(
kHeartRateControlPointUUID);
heart_rate_control_point_properties_->service.ReplaceValue(service_path);
@@ -383,7 +377,7 @@ void FakeBluetoothGattCharacteristicClient::ExposeHeartRateCharacteristics(
// Expose CCC descriptor for Heart Rate Measurement characteristic.
FakeBluetoothGattDescriptorClient* descriptor_client =
static_cast<FakeBluetoothGattDescriptorClient*>(
- DBusThreadManager::Get()->GetBluetoothGattDescriptorClient());
+ bluez::BluezDBusManager::Get()->GetBluetoothGattDescriptorClient());
dbus::ObjectPath ccc_path(descriptor_client->ExposeDescriptor(
dbus::ObjectPath(heart_rate_measurement_path_),
FakeBluetoothGattDescriptorClient::
@@ -403,7 +397,7 @@ void FakeBluetoothGattCharacteristicClient::HideHeartRateCharacteristics() {
// Hide the descriptors.
FakeBluetoothGattDescriptorClient* descriptor_client =
static_cast<FakeBluetoothGattDescriptorClient*>(
- DBusThreadManager::Get()->GetBluetoothGattDescriptorClient());
+ bluez::BluezDBusManager::Get()->GetBluetoothGattDescriptorClient());
descriptor_client->HideDescriptor(
dbus::ObjectPath(heart_rate_measurement_ccc_desc_path_));
@@ -459,12 +453,12 @@ FakeBluetoothGattCharacteristicClient::GetHeartRateControlPointPath() const {
void FakeBluetoothGattCharacteristicClient::OnPropertyChanged(
const dbus::ObjectPath& object_path,
const std::string& property_name) {
- VLOG(2) << "Characteristic property changed: " << object_path.value()
- << ": " << property_name;
+ VLOG(2) << "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));
}
void FakeBluetoothGattCharacteristicClient::NotifyCharacteristicAdded(
@@ -546,7 +540,7 @@ FakeBluetoothGattCharacteristicClient::GetHeartRateMeasurementValue() {
value.energy_expanded = calories_burned_++;
// Include one RR-Interval value, in seconds.
- value.rr_interval = 60/value.bpm;
+ value.rr_interval = 60 / value.bpm;
// Return the bytes in an array.
uint8* bytes = reinterpret_cast<uint8*>(&value);
@@ -565,4 +559,4 @@ bool FakeBluetoothGattCharacteristicClient::IsHeartRateVisible() const {
return heart_rate_visible_;
}
-} // namespace chromeos
+} // namespace bluez

Powered by Google App Engine
This is Rietveld 408576698