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

Side by Side Diff: device/bluetooth/dbus/bluetooth_gatt_attribute_helpers.cc

Issue 1984723006: Add implementation for parsing device info in read/write attribute calls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@devices_dbus_readwrite
Patch Set: gyp fix Created 4 years, 7 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 #include "device/bluetooth/dbus/bluetooth_gatt_attribute_helpers.h"
6
7 #include <string>
8
9 #include "base/logging.h"
10 #include "dbus/message.h"
11 #include "dbus/object_path.h"
12
13 namespace bluez {
14
15 namespace {
16
17 const char kDeviceField[] = "device";
xiyuan 2016/05/17 18:06:29 nit: const -> constexpr learned from my other rev
rkc 2016/05/17 18:42:59 Makes sense, since constexpr is compile-time. Done
18
19 } // namespace
20
21 dbus::ObjectPath ReadDevicePath(dbus::MessageReader* reader) {
22 dbus::MessageReader array_reader(nullptr);
23 if (!reader->PopArray(&array_reader))
24 return dbus::ObjectPath();
25
26 // Go through all the keys in the dictionary to find the device key.
27 while (array_reader.HasMoreData()) {
28 dbus::MessageReader dict_entry_reader(nullptr);
29 std::string key;
30 if (!array_reader.PopDictEntry(&dict_entry_reader) ||
31 !dict_entry_reader.PopString(&key)) {
32 return dbus::ObjectPath();
33 } else if (key == kDeviceField) {
34 dbus::ObjectPath device_path;
35 dict_entry_reader.PopVariantOfObjectPath(&device_path);
36 return device_path;
37 }
38 }
39
40 return dbus::ObjectPath();
41 }
42
43 } // namespace bluez
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698