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

Side by Side Diff: dbus/string_util.cc

Issue 1172183002: Move StartsWith[ASCII] to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@string_util3
Patch Set: merger Created 5 years, 6 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 | « content/renderer/savable_resources.cc ('k') | extensions/browser/api/cast_channel/logger.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "dbus/string_util.h" 5 #include "dbus/string_util.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 8
9 namespace dbus { 9 namespace dbus {
10 10
11 bool IsValidObjectPath(const std::string& value) { 11 bool IsValidObjectPath(const std::string& value) {
12 // This implementation is based upon D-Bus Specification Version 0.19. 12 // This implementation is based upon D-Bus Specification Version 0.19.
13 13
14 const bool kCaseSensitive = true; 14 const bool kCaseSensitive = true;
15 15
16 // A valid object path begins with '/'. 16 // A valid object path begins with '/'.
17 if (!StartsWithASCII(value, "/", kCaseSensitive)) 17 if (!base::StartsWithASCII(value, "/", kCaseSensitive))
18 return false; 18 return false;
19 19
20 // Elements are pieces delimited by '/'. For instance, "org", "chromium", 20 // Elements are pieces delimited by '/'. For instance, "org", "chromium",
21 // "Foo" are elements of "/org/chromium/Foo". 21 // "Foo" are elements of "/org/chromium/Foo".
22 int element_length = 0; 22 int element_length = 0;
23 for (size_t i = 1; i < value.size(); ++i) { 23 for (size_t i = 1; i < value.size(); ++i) {
24 const char c = value[i]; 24 const char c = value[i];
25 if (c == '/') { 25 if (c == '/') {
26 // No element may be the empty string. 26 // No element may be the empty string.
27 if (element_length == 0) 27 if (element_length == 0)
(...skipping 11 matching lines...) Expand all
39 } 39 }
40 40
41 // A trailing '/' character is not allowed unless the path is the root path. 41 // A trailing '/' character is not allowed unless the path is the root path.
42 if (value.size() > 1 && EndsWith(value, "/", kCaseSensitive)) 42 if (value.size() > 1 && EndsWith(value, "/", kCaseSensitive))
43 return false; 43 return false;
44 44
45 return true; 45 return true;
46 } 46 }
47 47
48 } // namespace dbus 48 } // namespace dbus
OLDNEW
« no previous file with comments | « content/renderer/savable_resources.cc ('k') | extensions/browser/api/cast_channel/logger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698