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

Side by Side Diff: device/udev_linux/udev.cc

Issue 989913002: Move UdevDecodeString from media/midi to device/udev_linux (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@seq3
Patch Set: Fix unit tests Created 5 years, 9 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
« no previous file with comments | « device/udev_linux/udev.h ('k') | device/udev_linux/udev_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « device/udev_linux/udev.h ('k') | device/udev_linux/udev_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698