Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 | |
| OLD | NEW |