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

Unified Diff: device/bluetooth/bluetooth_remote_gatt_descriptor.h

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/bluetooth_remote_gatt_descriptor.h
diff --git a/device/bluetooth/bluetooth_remote_gatt_descriptor.h b/device/bluetooth/bluetooth_remote_gatt_descriptor.h
new file mode 100644
index 0000000000000000000000000000000000000000..4f1dd26406bb309c98ce9a8325bd3fd192501916
--- /dev/null
+++ b/device/bluetooth/bluetooth_remote_gatt_descriptor.h
@@ -0,0 +1,78 @@
+// 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.
+
+#ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_H_
+#define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_H_
+
+#include <stdint.h>
+#include <vector>
+
+#include "base/callback.h"
+#include "base/callback_forward.h"
+#include "base/macros.h"
+#include "device/bluetooth/bluetooth_export.h"
+#include "device/bluetooth/bluetooth_gatt_characteristic.h"
+#include "device/bluetooth/bluetooth_gatt_descriptor.h"
+#include "device/bluetooth/bluetooth_uuid.h"
+
+namespace device {
+
+class BluetoothRemoteGattCharacteristic;
+
+// BluetoothRemoteGattDescriptor represents a remote GATT characteristic
+// descriptor.
+//
+// Note: We use virtual inheritance on the GATT descriptor since it will be
+// inherited by platform specific versions of the GATT descriptor classes also.
+// The platform specific remote GATT descriptor classes will inherit both this
+// class and their GATT descriptor class, hence causing an inheritance diamond.
+class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattDescriptor
+ : public virtual BluetoothGattDescriptor {
+ public:
+ // The ValueCallback is used to return the value of a remote characteristic
+ // descriptor upon a read request.
+ typedef base::Callback<void(const std::vector<uint8_t>&)> ValueCallback;
+
+ // The Bluetooth-specific UUID of the characteristic descriptor.
+ virtual BluetoothUUID GetUUID() const = 0;
+
+ // Returns the value of the descriptor. For remote descriptors, this is the
+ // most recently cached value of the remote descriptor. For local descriptors
+ // this is the most recently updated value or the value retrieved from the
+ // delegate.
+ virtual const std::vector<uint8_t>& GetValue() const = 0;
+
+ // Returns a pointer to the GATT characteristic that this characteristic
+ // descriptor belongs to.
+ virtual BluetoothRemoteGattCharacteristic* GetCharacteristic() const = 0;
+
+ // Returns the bitmask of characteristic descriptor attribute permissions.
+ virtual BluetoothGattCharacteristic::Permissions GetPermissions() const = 0;
+
+ // Sends a read request to a remote characteristic descriptor to read its
+ // value. |callback| is called to return the read value on success and
+ // |error_callback| is called for failures.
+ virtual void ReadRemoteDescriptor(const ValueCallback& callback,
+ const ErrorCallback& error_callback) = 0;
+
+ // Sends a write request to a remote characteristic descriptor, to modify the
+ // value of the descriptor with the new value |new_value|. |callback| is
+ // called to signal success and |error_callback| for failures. This method
+ // only applies to remote descriptors and will fail for those that are locally
+ // hosted.
+ virtual void WriteRemoteDescriptor(const std::vector<uint8_t>& new_value,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) = 0;
+
+ protected:
+ BluetoothRemoteGattDescriptor();
+ ~BluetoothRemoteGattDescriptor() override;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattDescriptor);
+};
+
+} // namespace device
+
+#endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_H_

Powered by Google App Engine
This is Rietveld 408576698