| 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/public/browser/background_tracing_preemptive_config.h" | 7 #include "content/public/browser/background_tracing_preemptive_config.h" |
| 8 #include "content/public/browser/background_tracing_reactive_config.h" | 8 #include "content/public/browser/background_tracing_reactive_config.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 kConfigCategoryKey[] = "category"; | 20 const char kConfigCategoryKey[] = "category"; |
| 21 const char kConfigCategoryBenchmark[] = "BENCHMARK"; | 21 const char kConfigCategoryBenchmark[] = "BENCHMARK"; |
| 22 const char kConfigCategoryBenchmarkDeep[] = "BENCHMARK_DEEP"; | 22 const char kConfigCategoryBenchmarkDeep[] = "BENCHMARK_DEEP"; |
| 23 | 23 |
| 24 const char kConfigRuleKey[] = "rule"; | 24 const char kConfigRuleKey[] = "rule"; |
| 25 const char kConfigRuleTriggerNameKey[] = "trigger_name"; | 25 const char kConfigRuleTriggerNameKey[] = "trigger_name"; |
| 26 | 26 |
| 27 const char kPreemptiveConfigRuleMonitorNamed[] = | 27 const char kPreemptiveConfigRuleMonitorNamed[] = |
| 28 "MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED"; | 28 "MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED"; |
| 29 | 29 |
| 30 const char kReactiveConfigRuleTraceOnTriggerOr10sOrTriggerOrFull[] = | 30 const char kReactiveConfigRuleTraceFor10sOrTriggerOrFull[] = |
| 31 "TRACE_ON_MANUAL_TRIGGER_UNTIL_10S_OR_NEXT_TRIGGER_OR_FULL"; | 31 "TRACE_FOR_10S_OR_TRIGGER_OR_FULL"; |
| 32 | 32 |
| 33 std::string CategoryPresetToString( | 33 std::string CategoryPresetToString( |
| 34 BackgroundTracingConfig::CategoryPreset category_preset) { | 34 BackgroundTracingConfig::CategoryPreset category_preset) { |
| 35 switch (category_preset) { | 35 switch (category_preset) { |
| 36 case BackgroundTracingConfig::BENCHMARK: | 36 case BackgroundTracingConfig::BENCHMARK: |
| 37 return kConfigCategoryBenchmark; | 37 return kConfigCategoryBenchmark; |
| 38 case BackgroundTracingConfig::BENCHMARK_DEEP: | 38 case BackgroundTracingConfig::BENCHMARK_DEEP: |
| 39 return kConfigCategoryBenchmarkDeep; | 39 return kConfigCategoryBenchmarkDeep; |
| 40 break; | 40 break; |
| 41 } | 41 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 if (!config_dict->GetString(kConfigCategoryKey, &category_preset_string)) | 126 if (!config_dict->GetString(kConfigCategoryKey, &category_preset_string)) |
| 127 return nullptr; | 127 return nullptr; |
| 128 | 128 |
| 129 if (!StringToCategoryPreset(category_preset_string, &rule.category_preset)) | 129 if (!StringToCategoryPreset(category_preset_string, &rule.category_preset)) |
| 130 return nullptr; | 130 return nullptr; |
| 131 | 131 |
| 132 std::string type; | 132 std::string type; |
| 133 if (!config_dict->GetString(kConfigRuleKey, &type)) | 133 if (!config_dict->GetString(kConfigRuleKey, &type)) |
| 134 return nullptr; | 134 return nullptr; |
| 135 | 135 |
| 136 if (type != kReactiveConfigRuleTraceOnTriggerOr10sOrTriggerOrFull) | 136 if (type != kReactiveConfigRuleTraceFor10sOrTriggerOrFull) |
| 137 return nullptr; | 137 return nullptr; |
| 138 | 138 |
| 139 rule.type = BackgroundTracingReactiveConfig:: | 139 rule.type = BackgroundTracingReactiveConfig:: |
| 140 TRACE_ON_MANUAL_TRIGGER_UNTIL_10S_OR_NEXT_TRIGGER_OR_FULL; | 140 TRACE_FOR_10S_OR_TRIGGER_OR_FULL; |
| 141 | 141 |
| 142 std::string trigger_name; | 142 std::string trigger_name; |
| 143 if (!config_dict->GetString(kConfigRuleTriggerNameKey, &trigger_name)) | 143 if (!config_dict->GetString(kConfigRuleTriggerNameKey, &trigger_name)) |
| 144 return nullptr; | 144 return nullptr; |
| 145 | 145 |
| 146 rule.trigger_name = trigger_name; | 146 rule.trigger_name = trigger_name; |
| 147 | 147 |
| 148 config->configs.push_back(rule); | 148 config->configs.push_back(rule); |
| 149 } | 149 } |
| 150 | 150 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 scoped_ptr<base::ListValue> configs_list(new base::ListValue()); | 187 scoped_ptr<base::ListValue> configs_list(new base::ListValue()); |
| 188 | 188 |
| 189 for (size_t i = 0; i < config->configs.size(); ++i) { | 189 for (size_t i = 0; i < config->configs.size(); ++i) { |
| 190 scoped_ptr<base::DictionaryValue> config_dict(new base::DictionaryValue()); | 190 scoped_ptr<base::DictionaryValue> config_dict(new base::DictionaryValue()); |
| 191 | 191 |
| 192 config_dict->SetString( | 192 config_dict->SetString( |
| 193 kConfigCategoryKey, | 193 kConfigCategoryKey, |
| 194 CategoryPresetToString(config->configs[i].category_preset)); | 194 CategoryPresetToString(config->configs[i].category_preset)); |
| 195 | 195 |
| 196 switch (config->configs[i].type) { | 196 switch (config->configs[i].type) { |
| 197 case BackgroundTracingReactiveConfig:: | 197 case BackgroundTracingReactiveConfig::TRACE_FOR_10S_OR_TRIGGER_OR_FULL: |
| 198 TRACE_ON_MANUAL_TRIGGER_UNTIL_10S_OR_NEXT_TRIGGER_OR_FULL: | |
| 199 config_dict->SetString( | 198 config_dict->SetString( |
| 200 kConfigRuleKey, | 199 kConfigRuleKey, |
| 201 kReactiveConfigRuleTraceOnTriggerOr10sOrTriggerOrFull); | 200 kReactiveConfigRuleTraceFor10sOrTriggerOrFull); |
| 202 break; | 201 break; |
| 203 default: | 202 default: |
| 204 NOTREACHED(); | 203 NOTREACHED(); |
| 205 continue; | 204 continue; |
| 206 } | 205 } |
| 207 | 206 |
| 208 config_dict->SetString(kConfigRuleTriggerNameKey, | 207 config_dict->SetString(kConfigRuleTriggerNameKey, |
| 209 config->configs[i].trigger_name.c_str()); | 208 config->configs[i].trigger_name.c_str()); |
| 210 | 209 |
| 211 configs_list->Append(config_dict.Pass()); | 210 configs_list->Append(config_dict.Pass()); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 dict->SetString(kConfigModeKey, kConfigModeReactive); | 252 dict->SetString(kConfigModeKey, kConfigModeReactive); |
| 254 if (!BackgroundTracingReactiveConfig_IntoDict( | 253 if (!BackgroundTracingReactiveConfig_IntoDict( |
| 255 static_cast<const BackgroundTracingReactiveConfig*>(config), | 254 static_cast<const BackgroundTracingReactiveConfig*>(config), |
| 256 dict)) | 255 dict)) |
| 257 dict->Clear(); | 256 dict->Clear(); |
| 258 break; | 257 break; |
| 259 } | 258 } |
| 260 } | 259 } |
| 261 | 260 |
| 262 } // namspace content | 261 } // namspace content |
| OLD | NEW |