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

Unified Diff: device/bluetooth/bluez/bluetooth_service_attribute_value_bluez.h

Issue 2084463002: BlueZ + DBus implementations of create/remove service record functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes + moar tests Created 4 years, 6 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_service_attribute_value_bluez.h
diff --git a/device/bluetooth/bluez/bluetooth_service_attribute_value_bluez.h b/device/bluetooth/bluez/bluetooth_service_attribute_value_bluez.h
new file mode 100644
index 0000000000000000000000000000000000000000..66a0025479072f5b2014d59f2416ac211c99b9ff
--- /dev/null
+++ b/device/bluetooth/bluez/bluetooth_service_attribute_value_bluez.h
@@ -0,0 +1,65 @@
+// 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_BLUEZ_BLUETOOTH_SERVICE_ATTRIBUTE_VALUE_BLUEZ_H_
+#define DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_SERVICE_ATTRIBUTE_VALUE_BLUEZ_H_
+
+#include <cstddef>
+#include <utility>
+#include <vector>
+
+#include "device/bluetooth/bluetooth_export.h"
+
+namespace base {
+class Value;
+}
+
+namespace bluez {
+
+// This class contains a Bluetooth service attribute. A service attribute is
+// defined by the following fields,
+// type: This is the type of the attribute. Along with being any of the
+// fixed types, an attribute can also be of type sequence, which means
+// that it contains an array of other attributes.
+// size: This is the size of the attribute. This can be variable for each type.
+// For example, a UUID can have the sizes, 2, 4 or 16 bytes.
+// value: This is the raw value of the attribute. For example, for a UUID, it
+// will be the string representation of the UUID. For a sequence, it
+// will be an array of other attributes.
+class DEVICE_BLUETOOTH_EXPORT BluetoothServiceAttributeValueBlueZ {
+ public:
+ using Sequence = std::vector<BluetoothServiceAttributeValueBlueZ>;
+
+ enum Type { NULLTYPE, UINT, INT, UUID, STRING, BOOL, SEQUENCE, URL };
+ union ValueType {
xiyuan 2016/06/22 15:53:05 Can we avoid using union and use two value accesso
rkc 2016/06/22 21:06:36 That does allow us to use unique_ptrs, which I rea
+ base::Value* value;
+ Sequence* sequence;
+ };
+
+ using AttributeValue = std::pair<Type, ValueType>;
xiyuan 2016/06/22 15:53:05 not used?
rkc 2016/06/22 21:06:37 Done.
+
+ // We take ownership of the Value/Sequence pointers.
+ BluetoothServiceAttributeValueBlueZ(Type type,
+ size_t size,
+ base::Value* value);
xiyuan 2016/06/22 15:53:05 Make ownership transfer explicit by passing std::u
rkc 2016/06/22 21:06:36 Done.
+ BluetoothServiceAttributeValueBlueZ(Type type,
+ size_t size,
+ Sequence* sequence);
xiyuan 2016/06/22 15:53:05 Same here, pass in std::unique_ptr<Sequence>
rkc 2016/06/22 21:06:36 Done.
+ BluetoothServiceAttributeValueBlueZ(
+ const BluetoothServiceAttributeValueBlueZ& attribute);
+ ~BluetoothServiceAttributeValueBlueZ();
+
+ Type get_type() const { return type_; }
+ size_t get_size() const { return size_; }
+ ValueType get_value() const { return value_; }
xiyuan 2016/06/22 15:53:05 nit: return a const ValueType?
rkc 2016/06/22 21:06:36 Done.
+
+ private:
+ Type type_;
+ size_t size_;
+ ValueType value_;
xiyuan 2016/06/22 15:53:05 We only store a pointer in |value_|. Who is going
rkc 2016/06/22 21:06:37 We were storing a pointer both in |value_| and |se
+};
+
+} // namespace bluez
+
+#endif // DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_SERVICE_ATTRIBUTE_VALUE_BLUEZ_H_

Powered by Google App Engine
This is Rietveld 408576698