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

Side by Side Diff: mojo/shell/public/cpp/lib/names.cc

Issue 1743473002: Change Mojo URLs to structured names (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@18collapse
Patch Set: . Created 4 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
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 "mojo/shell/public/cpp/names.h"
6
7 #include "base/strings/string_split.h"
8
9 namespace mojo {
10
11 bool IsValidName(const std::string& name) {
12 std::vector<std::string> parts =
13 base::SplitString(name, ":", base::KEEP_WHITESPACE,
14 base::SPLIT_WANT_ALL);
15 return parts.size() == 2 && !parts.front().empty() && !parts.back().empty();
sky 2016/02/26 18:37:27 Is it worth making sure parts.back() doesn't start
16 }
17
18 std::string GetNameType(const std::string& name) {
19 std::vector<std::string> parts =
20 base::SplitString(name, ":", base::KEEP_WHITESPACE,
21 base::SPLIT_WANT_ALL);
22 DCHECK_EQ(2, parts.size());
23 return parts.front();
24 }
25
26 std::string GetNamePath(const std::string& name) {
27 std::vector<std::string> parts =
28 base::SplitString(name, ":", base::KEEP_WHITESPACE,
29 base::SPLIT_WANT_ALL);
30 DCHECK_EQ(2, parts.size());
31 return parts.back();
32 }
33
34 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698