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

Unified Diff: device/bluetooth/bluez/bluetooth_remote_gatt_descriptor_bluez.cc

Issue 1898643002: Refactor device::BluetoothGattXXX classes to split into remote/local. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/bluez/bluetooth_remote_gatt_descriptor_bluez.cc
diff --git a/device/bluetooth/bluetooth_gatt_descriptor_bluez.cc b/device/bluetooth/bluez/bluetooth_remote_gatt_descriptor_bluez.cc
similarity index 59%
rename from device/bluetooth/bluetooth_gatt_descriptor_bluez.cc
rename to device/bluetooth/bluez/bluetooth_remote_gatt_descriptor_bluez.cc
index 1284e84ade3c7bf6acfdf78a6c255eee4d85f6a1..a1acc46f4bf6ac70361e50ba659f4fe92b0613e8 100644
--- a/device/bluetooth/bluetooth_gatt_descriptor_bluez.cc
+++ b/device/bluetooth/bluez/bluetooth_remote_gatt_descriptor_bluez.cc
@@ -1,7 +1,9 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
+// Copyright 2016 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/bluez/bluetooth_remote_gatt_descriptor_bluez.h"
+
#include <iterator>
#include <ostream>
@@ -11,10 +13,10 @@
#include "base/logging.h"
#include "base/strings/stringprintf.h"
#include "dbus/property.h"
-#include "device/bluetooth/bluetooth_gatt_characteristic.h"
-#include "device/bluetooth/bluetooth_gatt_characteristic_bluez.h"
-#include "device/bluetooth/bluetooth_gatt_descriptor_bluez.h"
-#include "device/bluetooth/bluetooth_gatt_service_bluez.h"
+#include "device/bluetooth/bluetooth_remote_gatt_characteristic.h"
+#include "device/bluetooth/bluez/bluetooth_gatt_characteristic_bluez.h"
+#include "device/bluetooth/bluez/bluetooth_gatt_descriptor_bluez.h"
+#include "device/bluetooth/bluez/bluetooth_gatt_service_bluez.h"
#include "device/bluetooth/dbus/bluetooth_gatt_descriptor_client.h"
#include "device/bluetooth/dbus/bluez_dbus_manager.h"
@@ -34,61 +36,52 @@ std::ostream& operator<<(std::ostream& out, const std::vector<uint8_t> bytes) {
} // namespace
-BluetoothGattDescriptorBlueZ::BluetoothGattDescriptorBlueZ(
- BluetoothGattCharacteristicBlueZ* characteristic,
- const dbus::ObjectPath& object_path,
- bool is_local)
- : object_path_(object_path),
+BluetoothRemoteGattDescriptorBlueZ::BluetoothRemoteGattDescriptorBlueZ(
+ BluetoothRemoteGattCharacteristicBlueZ* characteristic,
+ const dbus::ObjectPath& object_path)
+ : BluetoothGattDescriptorBlueZ(object_path),
characteristic_(characteristic),
- is_local_(is_local),
weak_ptr_factory_(this) {
VLOG(1) << "Creating remote GATT descriptor with identifier: "
<< GetIdentifier() << ", UUID: " << GetUUID().canonical_value();
}
-BluetoothGattDescriptorBlueZ::~BluetoothGattDescriptorBlueZ() {}
-
-std::string BluetoothGattDescriptorBlueZ::GetIdentifier() const {
- return object_path_.value();
-}
+BluetoothRemoteGattDescriptorBlueZ::~BluetoothRemoteGattDescriptorBlueZ() {}
-device::BluetoothUUID BluetoothGattDescriptorBlueZ::GetUUID() const {
+device::BluetoothUUID BluetoothRemoteGattDescriptorBlueZ::GetUUID() const {
bluez::BluetoothGattDescriptorClient::Properties* properties =
bluez::BluezDBusManager::Get()
->GetBluetoothGattDescriptorClient()
- ->GetProperties(object_path_);
+ ->GetProperties(object_path());
DCHECK(properties);
return device::BluetoothUUID(properties->uuid.value());
}
-bool BluetoothGattDescriptorBlueZ::IsLocal() const {
- return is_local_;
-}
-
-const std::vector<uint8_t>& BluetoothGattDescriptorBlueZ::GetValue() const {
+const std::vector<uint8_t>& BluetoothRemoteGattDescriptorBlueZ::GetValue()
+ const {
bluez::BluetoothGattDescriptorClient::Properties* properties =
bluez::BluezDBusManager::Get()
->GetBluetoothGattDescriptorClient()
- ->GetProperties(object_path_);
+ ->GetProperties(object_path());
DCHECK(properties);
return properties->value.value();
}
-device::BluetoothGattCharacteristic*
-BluetoothGattDescriptorBlueZ::GetCharacteristic() const {
+device::BluetoothRemoteGattCharacteristic*
+BluetoothRemoteGattDescriptorBlueZ::GetCharacteristic() const {
return characteristic_;
}
-device::BluetoothGattCharacteristic::Permissions
-BluetoothGattDescriptorBlueZ::GetPermissions() const {
+device::BluetoothRemoteGattCharacteristic::Permissions
+BluetoothRemoteGattDescriptorBlueZ::GetPermissions() const {
// TODO(armansito): Once BlueZ defines the permissions, return the correct
// values here.
- return device::BluetoothGattCharacteristic::PERMISSION_NONE;
+ return device::BluetoothRemoteGattCharacteristic::PERMISSION_NONE;
}
-void BluetoothGattDescriptorBlueZ::ReadRemoteDescriptor(
+void BluetoothRemoteGattDescriptorBlueZ::ReadRemoteDescriptor(
const ValueCallback& callback,
const ErrorCallback& error_callback) {
VLOG(1) << "Sending GATT characteristic descriptor read request to "
@@ -96,12 +89,12 @@ void BluetoothGattDescriptorBlueZ::ReadRemoteDescriptor(
<< ", UUID: " << GetUUID().canonical_value();
bluez::BluezDBusManager::Get()->GetBluetoothGattDescriptorClient()->ReadValue(
- object_path_, callback,
- base::Bind(&BluetoothGattDescriptorBlueZ::OnError,
+ object_path(), callback,
+ base::Bind(&BluetoothRemoteGattDescriptorBlueZ::OnError,
weak_ptr_factory_.GetWeakPtr(), error_callback));
}
-void BluetoothGattDescriptorBlueZ::WriteRemoteDescriptor(
+void BluetoothRemoteGattDescriptorBlueZ::WriteRemoteDescriptor(
const std::vector<uint8_t>& new_value,
const base::Closure& callback,
const ErrorCallback& error_callback) {
@@ -112,14 +105,15 @@ void BluetoothGattDescriptorBlueZ::WriteRemoteDescriptor(
bluez::BluezDBusManager::Get()
->GetBluetoothGattDescriptorClient()
- ->WriteValue(object_path_, new_value, callback,
- base::Bind(&BluetoothGattDescriptorBlueZ::OnError,
+ ->WriteValue(object_path(), new_value, callback,
+ base::Bind(&BluetoothRemoteGattDescriptorBlueZ::OnError,
weak_ptr_factory_.GetWeakPtr(), error_callback));
}
-void BluetoothGattDescriptorBlueZ::OnError(const ErrorCallback& error_callback,
- const std::string& error_name,
- const std::string& error_message) {
+void BluetoothRemoteGattDescriptorBlueZ::OnError(
+ const ErrorCallback& error_callback,
+ const std::string& error_name,
+ const std::string& error_message) {
VLOG(1) << "Operation failed: " << error_name
<< ", message: " << error_message;

Powered by Google App Engine
This is Rietveld 408576698