| 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 #ifndef BASE_TRACE_EVENT_TRACE_CONFIG_H_ | 5 #ifndef BASE_TRACE_EVENT_TRACE_CONFIG_H_ |
| 6 #define BASE_TRACE_EVENT_TRACE_CONFIG_H_ | 6 #define BASE_TRACE_EVENT_TRACE_CONFIG_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 73 |
| 74 // Set of memory dump modes allowed for the tracing session. The explicitly | 74 // Set of memory dump modes allowed for the tracing session. The explicitly |
| 75 // triggered dumps will be successful only if the dump mode is allowed in | 75 // triggered dumps will be successful only if the dump mode is allowed in |
| 76 // the config. | 76 // the config. |
| 77 std::set<MemoryDumpLevelOfDetail> allowed_dump_modes; | 77 std::set<MemoryDumpLevelOfDetail> allowed_dump_modes; |
| 78 | 78 |
| 79 std::vector<Trigger> triggers; | 79 std::vector<Trigger> triggers; |
| 80 HeapProfiler heap_profiler_options; | 80 HeapProfiler heap_profiler_options; |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 class EventFilterConfig { |
| 84 public: |
| 85 EventFilterConfig(const std::string& predicate_name); |
| 86 EventFilterConfig(const EventFilterConfig& tc); |
| 87 |
| 88 ~EventFilterConfig(); |
| 89 |
| 90 EventFilterConfig& operator=(const EventFilterConfig& rhs); |
| 91 |
| 92 void AddIncludedCategory(const std::string& category); |
| 93 void AddExcludedCategory(const std::string& category); |
| 94 void SetArgs(std::unique_ptr<base::DictionaryValue> args); |
| 95 |
| 96 bool IsCategoryGroupEnabled(const char* category_group_name) const; |
| 97 |
| 98 const std::string& predicate_name() const { return predicate_name_; } |
| 99 base::DictionaryValue* filter_args() const { return args_.get(); } |
| 100 const StringList& included_categories() const { |
| 101 return included_categories_; |
| 102 } |
| 103 const StringList& excluded_categories() const { |
| 104 return excluded_categories_; |
| 105 } |
| 106 |
| 107 private: |
| 108 std::string predicate_name_; |
| 109 StringList included_categories_; |
| 110 StringList excluded_categories_; |
| 111 std::unique_ptr<base::DictionaryValue> args_; |
| 112 }; |
| 113 typedef std::vector<EventFilterConfig> EventFilters; |
| 114 |
| 83 TraceConfig(); | 115 TraceConfig(); |
| 84 | 116 |
| 85 // Create TraceConfig object from category filter and trace options strings. | 117 // Create TraceConfig object from category filter and trace options strings. |
| 86 // | 118 // |
| 87 // |category_filter_string| is a comma-delimited list of category wildcards. | 119 // |category_filter_string| is a comma-delimited list of category wildcards. |
| 88 // A category can have an optional '-' prefix to make it an excluded category. | 120 // A category can have an optional '-' prefix to make it an excluded category. |
| 89 // All the same rules apply above, so for example, having both included and | 121 // All the same rules apply above, so for example, having both included and |
| 90 // excluded categories in the same list would not be supported. | 122 // excluded categories in the same list would not be supported. |
| 91 // | 123 // |
| 92 // Category filters can also be used to configure synthetic delays. | 124 // Category filters can also be used to configure synthetic delays. |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 | 221 |
| 190 // Returns a copy of the TraceConfig wrapped in a ConvertableToTraceFormat | 222 // Returns a copy of the TraceConfig wrapped in a ConvertableToTraceFormat |
| 191 std::unique_ptr<ConvertableToTraceFormat> AsConvertableToTraceFormat() const; | 223 std::unique_ptr<ConvertableToTraceFormat> AsConvertableToTraceFormat() const; |
| 192 | 224 |
| 193 // Write the string representation of the CategoryFilter part. | 225 // Write the string representation of the CategoryFilter part. |
| 194 std::string ToCategoryFilterString() const; | 226 std::string ToCategoryFilterString() const; |
| 195 | 227 |
| 196 // Returns true if at least one category in the list is enabled by this | 228 // Returns true if at least one category in the list is enabled by this |
| 197 // trace config. This is used to determine if the category filters are | 229 // trace config. This is used to determine if the category filters are |
| 198 // enabled in the TRACE_* macros. | 230 // enabled in the TRACE_* macros. |
| 199 bool IsCategoryGroupEnabled(const char* category_group) const; | 231 bool IsCategoryGroupEnabled(const char* category_group_name) const; |
| 200 | 232 |
| 201 // Merges config with the current TraceConfig | 233 // Merges config with the current TraceConfig |
| 202 void Merge(const TraceConfig& config); | 234 void Merge(const TraceConfig& config); |
| 203 | 235 |
| 204 void Clear(); | 236 void Clear(); |
| 205 | 237 |
| 206 // Clears and resets the memory dump config. | 238 // Clears and resets the memory dump config. |
| 207 void ResetMemoryDumpConfig(const MemoryDumpConfig& memory_dump_config); | 239 void ResetMemoryDumpConfig(const MemoryDumpConfig& memory_dump_config); |
| 208 | 240 |
| 209 const MemoryDumpConfig& memory_dump_config() const { | 241 const MemoryDumpConfig& memory_dump_config() const { |
| 210 return memory_dump_config_; | 242 return memory_dump_config_; |
| 211 } | 243 } |
| 212 | 244 |
| 245 const EventFilters& event_filters() const { return event_filters_; } |
| 246 |
| 213 private: | 247 private: |
| 214 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfigFromValidLegacyFormat); | 248 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfigFromValidLegacyFormat); |
| 215 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, | 249 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, |
| 216 TraceConfigFromInvalidLegacyStrings); | 250 TraceConfigFromInvalidLegacyStrings); |
| 217 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfigFromValidString); | 251 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfigFromValidString); |
| 218 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfigFromInvalidString); | 252 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfigFromInvalidString); |
| 219 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, | 253 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, |
| 220 IsEmptyOrContainsLeadingOrTrailingWhitespace); | 254 IsEmptyOrContainsLeadingOrTrailingWhitespace); |
| 221 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfigFromMemoryConfigString); | 255 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfigFromMemoryConfigString); |
| 222 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, LegacyStringToMemoryDumpConfig); | 256 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, LegacyStringToMemoryDumpConfig); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 243 void SetCategoriesFromExcludedList(const ListValue& excluded_list); | 277 void SetCategoriesFromExcludedList(const ListValue& excluded_list); |
| 244 void SetSyntheticDelaysFromList(const ListValue& list); | 278 void SetSyntheticDelaysFromList(const ListValue& list); |
| 245 void AddCategoryToDict(DictionaryValue* dict, | 279 void AddCategoryToDict(DictionaryValue* dict, |
| 246 const char* param, | 280 const char* param, |
| 247 const StringList& categories) const; | 281 const StringList& categories) const; |
| 248 | 282 |
| 249 void SetMemoryDumpConfigFromConfigDict( | 283 void SetMemoryDumpConfigFromConfigDict( |
| 250 const DictionaryValue& memory_dump_config); | 284 const DictionaryValue& memory_dump_config); |
| 251 void SetDefaultMemoryDumpConfig(); | 285 void SetDefaultMemoryDumpConfig(); |
| 252 | 286 |
| 287 void SetEventFilters(const base::ListValue& event_filters); |
| 253 std::unique_ptr<DictionaryValue> ToDict() const; | 288 std::unique_ptr<DictionaryValue> ToDict() const; |
| 254 | 289 |
| 255 std::string ToTraceOptionsString() const; | 290 std::string ToTraceOptionsString() const; |
| 256 | 291 |
| 257 void WriteCategoryFilterString(const StringList& values, | 292 void WriteCategoryFilterString(const StringList& values, |
| 258 std::string* out, | 293 std::string* out, |
| 259 bool included) const; | 294 bool included) const; |
| 260 void WriteCategoryFilterString(const StringList& delays, | 295 void WriteCategoryFilterString(const StringList& delays, |
| 261 std::string* out) const; | 296 std::string* out) const; |
| 262 | 297 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 274 bool enable_sampling_ : 1; | 309 bool enable_sampling_ : 1; |
| 275 bool enable_systrace_ : 1; | 310 bool enable_systrace_ : 1; |
| 276 bool enable_argument_filter_ : 1; | 311 bool enable_argument_filter_ : 1; |
| 277 | 312 |
| 278 MemoryDumpConfig memory_dump_config_; | 313 MemoryDumpConfig memory_dump_config_; |
| 279 | 314 |
| 280 StringList included_categories_; | 315 StringList included_categories_; |
| 281 StringList disabled_categories_; | 316 StringList disabled_categories_; |
| 282 StringList excluded_categories_; | 317 StringList excluded_categories_; |
| 283 StringList synthetic_delays_; | 318 StringList synthetic_delays_; |
| 319 EventFilters event_filters_; |
| 284 }; | 320 }; |
| 285 | 321 |
| 286 } // namespace trace_event | 322 } // namespace trace_event |
| 287 } // namespace base | 323 } // namespace base |
| 288 | 324 |
| 289 #endif // BASE_TRACE_EVENT_TRACE_CONFIG_H_ | 325 #endif // BASE_TRACE_EVENT_TRACE_CONFIG_H_ |
| OLD | NEW |