| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "device/udev_linux/udev.h" | 5 #include "device/udev_linux/udev.h" |
| 6 | 6 |
| 7 #include "base/strings/string_util.h" |
| 7 #include "device/udev_linux/udev_loader.h" | 8 #include "device/udev_linux/udev_loader.h" |
| 8 | 9 |
| 9 namespace device { | 10 namespace device { |
| 10 | 11 |
| 11 const char* udev_device_get_action(udev_device* udev_device) { | 12 const char* udev_device_get_action(udev_device* udev_device) { |
| 12 return UdevLoader::Get()->udev_device_get_action(udev_device); | 13 return UdevLoader::Get()->udev_device_get_action(udev_device); |
| 13 } | 14 } |
| 14 | 15 |
| 15 const char* udev_device_get_devnode(udev_device* udev_device) { | 16 const char* udev_device_get_devnode(udev_device* udev_device) { |
| 16 return UdevLoader::Get()->udev_device_get_devnode(udev_device); | 17 return UdevLoader::Get()->udev_device_get_devnode(udev_device); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 void udev_unref(udev* udev) { | 146 void udev_unref(udev* udev) { |
| 146 UdevLoader::Get()->udev_unref(udev); | 147 UdevLoader::Get()->udev_unref(udev); |
| 147 } | 148 } |
| 148 | 149 |
| 149 std::string UdevDeviceGetPropertyValue(udev_device* udev_device, | 150 std::string UdevDeviceGetPropertyValue(udev_device* udev_device, |
| 150 const char* key) { | 151 const char* key) { |
| 151 const char* value = device::udev_device_get_property_value(udev_device, key); | 152 const char* value = device::udev_device_get_property_value(udev_device, key); |
| 152 return value ? value : std::string(); | 153 return value ? value : std::string(); |
| 153 } | 154 } |
| 154 | 155 |
| 156 std::string UdevDecodeString(const std::string& encoded) { |
| 157 std::string decoded; |
| 158 const size_t size = encoded.size(); |
| 159 for (size_t i = 0; i < size; ++i) { |
| 160 char c = encoded[i]; |
| 161 if ((i + 3 < size) && c == '\\' && encoded[i + 1] == 'x') { |
| 162 c = (HexDigitToInt(encoded[i + 2]) << 4) + |
| 163 HexDigitToInt(encoded[i + 3]); |
| 164 i += 3; |
| 165 } |
| 166 decoded.push_back(c); |
| 167 } |
| 168 return decoded; |
| 169 } |
| 170 |
| 155 } // namespace device | 171 } // namespace device |
| OLD | NEW |