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 "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 | |
| OLD | NEW |