OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/browser/tracing/background_tracing_config_impl.h" | 5 #include "content/browser/tracing/background_tracing_config_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 if (!StringToCategoryPreset(category_preset_string, | 226 if (!StringToCategoryPreset(category_preset_string, |
227 &config->category_preset_)) | 227 &config->category_preset_)) |
228 return nullptr; | 228 return nullptr; |
229 | 229 |
230 const base::ListValue* configs_list = nullptr; | 230 const base::ListValue* configs_list = nullptr; |
231 if (!dict->GetList(kConfigsKey, &configs_list)) | 231 if (!dict->GetList(kConfigsKey, &configs_list)) |
232 return nullptr; | 232 return nullptr; |
233 | 233 |
234 for (const auto& it : *configs_list) { | 234 for (const auto& it : *configs_list) { |
235 const base::DictionaryValue* config_dict = nullptr; | 235 const base::DictionaryValue* config_dict = nullptr; |
236 if (!it->GetAsDictionary(&config_dict)) | 236 if (!it.GetAsDictionary(&config_dict)) |
237 return nullptr; | 237 return nullptr; |
238 | 238 |
239 config->AddPreemptiveRule(config_dict); | 239 config->AddPreemptiveRule(config_dict); |
240 } | 240 } |
241 | 241 |
242 if (config->rules().empty()) | 242 if (config->rules().empty()) |
243 return nullptr; | 243 return nullptr; |
244 | 244 |
245 return config; | 245 return config; |
246 } | 246 } |
247 | 247 |
248 std::unique_ptr<BackgroundTracingConfigImpl> | 248 std::unique_ptr<BackgroundTracingConfigImpl> |
249 BackgroundTracingConfigImpl::ReactiveFromDict( | 249 BackgroundTracingConfigImpl::ReactiveFromDict( |
250 const base::DictionaryValue* dict) { | 250 const base::DictionaryValue* dict) { |
251 DCHECK(dict); | 251 DCHECK(dict); |
252 | 252 |
253 std::unique_ptr<BackgroundTracingConfigImpl> config( | 253 std::unique_ptr<BackgroundTracingConfigImpl> config( |
254 new BackgroundTracingConfigImpl(BackgroundTracingConfigImpl::REACTIVE)); | 254 new BackgroundTracingConfigImpl(BackgroundTracingConfigImpl::REACTIVE)); |
255 | 255 |
256 const base::ListValue* configs_list = nullptr; | 256 const base::ListValue* configs_list = nullptr; |
257 if (!dict->GetList(kConfigsKey, &configs_list)) | 257 if (!dict->GetList(kConfigsKey, &configs_list)) |
258 return nullptr; | 258 return nullptr; |
259 | 259 |
260 for (const auto& it : *configs_list) { | 260 for (const auto& it : *configs_list) { |
261 const base::DictionaryValue* config_dict = nullptr; | 261 const base::DictionaryValue* config_dict = nullptr; |
262 if (!it->GetAsDictionary(&config_dict)) | 262 if (!it.GetAsDictionary(&config_dict)) |
263 return nullptr; | 263 return nullptr; |
264 | 264 |
265 std::string category_preset_string; | 265 std::string category_preset_string; |
266 if (!config_dict->GetString(kConfigCategoryKey, &category_preset_string)) | 266 if (!config_dict->GetString(kConfigCategoryKey, &category_preset_string)) |
267 return nullptr; | 267 return nullptr; |
268 | 268 |
269 BackgroundTracingConfigImpl::CategoryPreset new_category_preset; | 269 BackgroundTracingConfigImpl::CategoryPreset new_category_preset; |
270 if (!StringToCategoryPreset(category_preset_string, &new_category_preset)) | 270 if (!StringToCategoryPreset(category_preset_string, &new_category_preset)) |
271 return nullptr; | 271 return nullptr; |
272 | 272 |
273 config->AddReactiveRule(config_dict, new_category_preset); | 273 config->AddReactiveRule(config_dict, new_category_preset); |
274 } | 274 } |
275 | 275 |
276 if (config->rules().empty()) | 276 if (config->rules().empty()) |
277 return nullptr; | 277 return nullptr; |
278 | 278 |
279 return config; | 279 return config; |
280 } | 280 } |
281 | 281 |
282 } // namspace content | 282 } // namspace content |
OLD | NEW |