| 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 "base/macros.h" | 5 #include "base/macros.h" | 
| 6 #include "base/values.h" | 6 #include "base/values.h" | 
| 7 #include "content/browser/tracing/background_tracing_config_impl.h" | 7 #include "content/browser/tracing/background_tracing_config_impl.h" | 
| 8 #include "content/browser/tracing/background_tracing_rule.h" | 8 #include "content/browser/tracing/background_tracing_rule.h" | 
| 9 | 9 | 
| 10 namespace content { | 10 namespace content { | 
| 11 | 11 | 
| 12 namespace { | 12 namespace { | 
| 13 | 13 | 
| 14 const char kConfigsKey[] = "configs"; | 14 const char kConfigsKey[] = "configs"; | 
| 15 | 15 | 
| 16 const char kConfigModeKey[] = "mode"; | 16 const char kConfigModeKey[] = "mode"; | 
| 17 const char kConfigModePreemptive[] = "PREEMPTIVE_TRACING_MODE"; | 17 const char kConfigModePreemptive[] = "PREEMPTIVE_TRACING_MODE"; | 
| 18 const char kConfigModeReactive[] = "REACTIVE_TRACING_MODE"; | 18 const char kConfigModeReactive[] = "REACTIVE_TRACING_MODE"; | 
| 19 | 19 | 
| 20 const char kConfigScenarioName[] = "scenario_name"; |  | 
| 21 const char kConfigEnableBlinkFeatures[] = "enable_blink_features"; |  | 
| 22 const char kConfigDisableBlinkFeatures[] = "disable_blink_features"; |  | 
| 23 |  | 
| 24 const char kConfigCategoryKey[] = "category"; | 20 const char kConfigCategoryKey[] = "category"; | 
| 25 const char kConfigCategoryBenchmark[] = "BENCHMARK"; | 21 const char kConfigCategoryBenchmark[] = "BENCHMARK"; | 
| 26 const char kConfigCategoryBenchmarkDeep[] = "BENCHMARK_DEEP"; | 22 const char kConfigCategoryBenchmarkDeep[] = "BENCHMARK_DEEP"; | 
| 27 const char kConfigCategoryBenchmarkGPU[] = "BENCHMARK_GPU"; | 23 const char kConfigCategoryBenchmarkGPU[] = "BENCHMARK_GPU"; | 
| 28 const char kConfigCategoryBenchmarkIPC[] = "BENCHMARK_IPC"; | 24 const char kConfigCategoryBenchmarkIPC[] = "BENCHMARK_IPC"; | 
| 29 const char kConfigCategoryBenchmarkStartup[] = "BENCHMARK_STARTUP"; | 25 const char kConfigCategoryBenchmarkStartup[] = "BENCHMARK_STARTUP"; | 
| 30 | 26 | 
| 31 }  // namespace | 27 }  // namespace | 
| 32 | 28 | 
| 33 BackgroundTracingConfigImpl::BackgroundTracingConfigImpl( | 29 BackgroundTracingConfigImpl::BackgroundTracingConfigImpl( | 
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 100 | 96 | 
| 101   scoped_ptr<base::ListValue> configs_list(new base::ListValue()); | 97   scoped_ptr<base::ListValue> configs_list(new base::ListValue()); | 
| 102   for (const auto& it : rules_) { | 98   for (const auto& it : rules_) { | 
| 103     scoped_ptr<base::DictionaryValue> config_dict(new base::DictionaryValue()); | 99     scoped_ptr<base::DictionaryValue> config_dict(new base::DictionaryValue()); | 
| 104     DCHECK(it); | 100     DCHECK(it); | 
| 105     it->IntoDict(config_dict.get()); | 101     it->IntoDict(config_dict.get()); | 
| 106     configs_list->Append(config_dict.Pass()); | 102     configs_list->Append(config_dict.Pass()); | 
| 107   } | 103   } | 
| 108 | 104 | 
| 109   dict->Set(kConfigsKey, configs_list.Pass()); | 105   dict->Set(kConfigsKey, configs_list.Pass()); | 
| 110 |  | 
| 111   if (!scenario_name_.empty()) |  | 
| 112     dict->SetString(kConfigScenarioName, scenario_name_); |  | 
| 113   if (!enable_blink_features_.empty()) |  | 
| 114     dict->SetString(kConfigEnableBlinkFeatures, enable_blink_features_); |  | 
| 115   if (!disable_blink_features_.empty()) |  | 
| 116     dict->SetString(kConfigDisableBlinkFeatures, disable_blink_features_); |  | 
| 117 } | 106 } | 
| 118 | 107 | 
| 119 void BackgroundTracingConfigImpl::AddPreemptiveRule( | 108 void BackgroundTracingConfigImpl::AddPreemptiveRule( | 
| 120     const base::DictionaryValue* dict) { | 109     const base::DictionaryValue* dict) { | 
| 121   scoped_ptr<BackgroundTracingRule> rule = | 110   scoped_ptr<BackgroundTracingRule> rule = | 
| 122       BackgroundTracingRule::PreemptiveRuleFromDict(dict); | 111       BackgroundTracingRule::PreemptiveRuleFromDict(dict); | 
| 123   if (rule) | 112   if (rule) | 
| 124     rules_.push_back(rule.Pass()); | 113     rules_.push_back(rule.Pass()); | 
| 125 } | 114 } | 
| 126 | 115 | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 144   scoped_ptr<BackgroundTracingConfigImpl> config; | 133   scoped_ptr<BackgroundTracingConfigImpl> config; | 
| 145 | 134 | 
| 146   if (mode == kConfigModePreemptive) { | 135   if (mode == kConfigModePreemptive) { | 
| 147     config = PreemptiveFromDict(dict); | 136     config = PreemptiveFromDict(dict); | 
| 148   } else if (mode == kConfigModeReactive) { | 137   } else if (mode == kConfigModeReactive) { | 
| 149     config = ReactiveFromDict(dict); | 138     config = ReactiveFromDict(dict); | 
| 150   } else { | 139   } else { | 
| 151     return nullptr; | 140     return nullptr; | 
| 152   } | 141   } | 
| 153 | 142 | 
| 154   dict->GetString(kConfigScenarioName, &config->scenario_name_); |  | 
| 155   dict->GetString(kConfigEnableBlinkFeatures, &config->enable_blink_features_); |  | 
| 156   dict->GetString(kConfigDisableBlinkFeatures, |  | 
| 157                   &config->disable_blink_features_); |  | 
| 158 |  | 
| 159   return config.Pass(); | 143   return config.Pass(); | 
| 160 } | 144 } | 
| 161 | 145 | 
| 162 scoped_ptr<BackgroundTracingConfigImpl> | 146 scoped_ptr<BackgroundTracingConfigImpl> | 
| 163 BackgroundTracingConfigImpl::PreemptiveFromDict( | 147 BackgroundTracingConfigImpl::PreemptiveFromDict( | 
| 164     const base::DictionaryValue* dict) { | 148     const base::DictionaryValue* dict) { | 
| 165   DCHECK(dict); | 149   DCHECK(dict); | 
| 166 | 150 | 
| 167   scoped_ptr<BackgroundTracingConfigImpl> config( | 151   scoped_ptr<BackgroundTracingConfigImpl> config( | 
| 168       new BackgroundTracingConfigImpl(BackgroundTracingConfigImpl::PREEMPTIVE)); | 152       new BackgroundTracingConfigImpl(BackgroundTracingConfigImpl::PREEMPTIVE)); | 
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 221     config->AddReactiveRule(config_dict, new_category_preset); | 205     config->AddReactiveRule(config_dict, new_category_preset); | 
| 222   } | 206   } | 
| 223 | 207 | 
| 224   if (config->rules().empty()) | 208   if (config->rules().empty()) | 
| 225     return nullptr; | 209     return nullptr; | 
| 226 | 210 | 
| 227   return config.Pass(); | 211   return config.Pass(); | 
| 228 } | 212 } | 
| 229 | 213 | 
| 230 }  // namspace content | 214 }  // namspace content | 
| OLD | NEW | 
|---|