OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 "components/task_scheduler_util/common/variations_util.h" | 5 #include "components/task_scheduler_util/common/variations_util.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_piece.h" | |
11 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
12 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
13 #include "base/task_scheduler/initialization_util.h" | 12 #include "base/task_scheduler/initialization_util.h" |
14 #include "base/time/time.h" | 13 #include "base/time/time.h" |
15 #include "components/variations/variations_associated_data.h" | 14 #include "components/variations/variations_associated_data.h" |
16 | 15 |
17 namespace task_scheduler_util { | 16 namespace task_scheduler_util { |
18 | 17 |
19 namespace { | 18 namespace { |
20 | 19 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 125 |
127 #if !defined(OS_IOS) | 126 #if !defined(OS_IOS) |
128 void AddVariationParamsToCommandLine(base::StringPiece key_prefix, | 127 void AddVariationParamsToCommandLine(base::StringPiece key_prefix, |
129 base::CommandLine* command_line) { | 128 base::CommandLine* command_line) { |
130 DCHECK(command_line); | 129 DCHECK(command_line); |
131 | 130 |
132 std::map<std::string, std::string> variation_params; | 131 std::map<std::string, std::string> variation_params; |
133 if (!variations::GetVariationParams("BrowserScheduler", &variation_params)) | 132 if (!variations::GetVariationParams("BrowserScheduler", &variation_params)) |
134 return; | 133 return; |
135 | 134 |
136 std::vector<std::string> parts; | 135 std::vector<base::StringPiece> parts; |
137 for (const auto& key_value : variation_params) { | 136 for (const auto& key_value : variation_params) { |
138 if (base::StartsWith(key_value.first, key_prefix, | 137 if (base::StartsWith(key_value.first, key_prefix, |
139 base::CompareCase::SENSITIVE)) { | 138 base::CompareCase::SENSITIVE)) { |
140 if (ContainsSeparator(key_value.first) || | 139 if (ContainsSeparator(key_value.first) || |
141 ContainsSeparator(key_value.second)) { | 140 ContainsSeparator(key_value.second)) { |
142 DLOG(ERROR) | 141 DLOG(ERROR) |
143 << "Unexpected Character in Task Scheduler Variation Params: " | 142 << "Unexpected Character in Task Scheduler Variation Params: " |
144 << key_value.first << " [" << key_value.second << "]"; | 143 << key_value.first << " [" << key_value.second << "]"; |
145 return; | 144 return; |
146 } | 145 } |
(...skipping 24 matching lines...) Expand all Loading... |
171 return std::map<std::string, std::string>(); | 170 return std::map<std::string, std::string>(); |
172 } | 171 } |
173 base::StringPiece value = *it; | 172 base::StringPiece value = *it; |
174 variation_params[key.as_string()] = value.as_string(); | 173 variation_params[key.as_string()] = value.as_string(); |
175 } | 174 } |
176 return variation_params; | 175 return variation_params; |
177 } | 176 } |
178 #endif // !defined(OS_IOS) | 177 #endif // !defined(OS_IOS) |
179 | 178 |
180 } // namespace task_scheduler_util | 179 } // namespace task_scheduler_util |
OLD | NEW |