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