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

Side by Side 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, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_SERVICE_ATTRIBUTE_VALUE_BLUEZ_H_
6 #define DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_SERVICE_ATTRIBUTE_VALUE_BLUEZ_H_
7
8 #include <cstddef>
9 #include <utility>
10 #include <vector>
11
12 #include "device/bluetooth/bluetooth_export.h"
13
14 namespace base {
15 class Value;
16 }
17
18 namespace bluez {
19
20 // This class contains a Bluetooth service attribute. A service attribute is
21 // defined by the following fields,
22 // type: This is the type of the attribute. Along with being any of the
23 // fixed types, an attribute can also be of type sequence, which means
24 // that it contains an array of other attributes.
25 // size: This is the size of the attribute. This can be variable for each type.
26 // For example, a UUID can have the sizes, 2, 4 or 16 bytes.
27 // value: This is the raw value of the attribute. For example, for a UUID, it
28 // will be the string representation of the UUID. For a sequence, it
29 // will be an array of other attributes.
30 class DEVICE_BLUETOOTH_EXPORT BluetoothServiceAttributeValueBlueZ {
31 public:
32 using Sequence = std::vector<BluetoothServiceAttributeValueBlueZ>;
33
34 enum Type { NULLTYPE, UINT, INT, UUID, STRING, BOOL, SEQUENCE, URL };
35 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
36 base::Value* value;
37 Sequence* sequence;
38 };
39
40 using AttributeValue = std::pair<Type, ValueType>;
xiyuan 2016/06/22 15:53:05 not used?
rkc 2016/06/22 21:06:37 Done.
41
42 // We take ownership of the Value/Sequence pointers.
43 BluetoothServiceAttributeValueBlueZ(Type type,
44 size_t size,
45 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.
46 BluetoothServiceAttributeValueBlueZ(Type type,
47 size_t size,
48 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.
49 BluetoothServiceAttributeValueBlueZ(
50 const BluetoothServiceAttributeValueBlueZ& attribute);
51 ~BluetoothServiceAttributeValueBlueZ();
52
53 Type get_type() const { return type_; }
54 size_t get_size() const { return size_; }
55 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.
56
57 private:
58 Type type_;
59 size_t size_;
60 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
61 };
62
63 } // namespace bluez
64
65 #endif // DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_SERVICE_ATTRIBUTE_VALUE_BLUEZ_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698