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

Side by Side Diff: services/service_manager/public/cpp/lib/shared_file_util.cc

Issue 2684433003: Files required by a service now listed in manifest. (Closed)
Patch Set: Fix build. Created 3 years, 10 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 2017 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 "services/service_manager/public/cpp/shared_file_util.h"
6
7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/string_split.h"
9
10 namespace service_manager {
11
12 void SharedFileSwitchValueBuilder::AddEntry(const std::string& key_str,
13 int key_id) {
14 if (!switch_value_.empty()) {
15 switch_value_ += ",";
16 }
17 switch_value_ += key_str, switch_value_ += ":";
18 switch_value_ += base::IntToString(key_id);
19 }
20
21 base::Optional<std::map<int, std::string>> ParseSharedFileSwitchValue(
22 const std::string& value) {
23 std::map<int, std::string> values;
24 std::vector<std::string> string_pairs = base::SplitString(
25 value, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
26 for (const auto& pair : string_pairs) {
27 size_t colon_position = pair.find(":");
28 if (colon_position == std::string::npos || colon_position == 0 ||
29 colon_position == pair.size() - 1) {
30 DLOG(ERROR) << "Found invalid entry parsing shared file string value:"
31 << pair;
32 return base::nullopt;
33 }
34 std::string key = pair.substr(0, colon_position);
35 std::string number_string =
36 pair.substr(colon_position + 1, std::string::npos);
37 int key_int;
38 if (!base::StringToInt(number_string, &key_int)) {
39 DLOG(ERROR) << "Found invalid entry parsing shared file string value:"
40 << number_string << " (not an int).";
41 return base::nullopt;
42 }
43
44 values[key_int] = key;
45 }
46 return base::make_optional(std::move(values));
47 }
48
49 } // namespace service_manager
OLDNEW
« no previous file with comments | « services/service_manager/public/cpp/BUILD.gn ('k') | services/service_manager/public/cpp/shared_file_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698