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 <string> | 10 #include <string> |
(...skipping 28 matching lines...) Expand all Loading... |
39 class BASE_EXPORT TraceConfig { | 39 class BASE_EXPORT TraceConfig { |
40 public: | 40 public: |
41 typedef std::vector<std::string> StringList; | 41 typedef std::vector<std::string> StringList; |
42 | 42 |
43 // Specifies the memory dump config for tracing. Used only when | 43 // Specifies the memory dump config for tracing. Used only when |
44 // "memory-infra" category is enabled. | 44 // "memory-infra" category is enabled. |
45 struct MemoryDumpTriggerConfig { | 45 struct MemoryDumpTriggerConfig { |
46 uint32_t periodic_interval_ms; | 46 uint32_t periodic_interval_ms; |
47 MemoryDumpLevelOfDetail level_of_detail; | 47 MemoryDumpLevelOfDetail level_of_detail; |
48 }; | 48 }; |
| 49 typedef std::vector<MemoryDumpTriggerConfig> MemoryDumpConfig; |
49 | 50 |
50 typedef std::vector<MemoryDumpTriggerConfig> MemoryDumpConfig; | 51 class CategoryEventFilterConfig { |
| 52 public: |
| 53 CategoryEventFilterConfig(const std::string& predicate_name); |
| 54 ~CategoryEventFilterConfig(); |
| 55 |
| 56 CategoryEventFilterConfig(const CategoryEventFilterConfig& tc); |
| 57 CategoryEventFilterConfig& operator=(const CategoryEventFilterConfig& rhs); |
| 58 |
| 59 void AddIncludedCategory(const std::string& category); |
| 60 void AddExcludedCategory(const std::string& category); |
| 61 void SetArgs(std::unique_ptr<base::DictionaryValue> args); |
| 62 |
| 63 bool IsCategoryGroupEnabled(const char* category_group_name) const; |
| 64 |
| 65 const std::string& predicate_name() const { return predicate_name_; } |
| 66 base::DictionaryValue* args() const { return args_.get(); } |
| 67 const StringList& included_categories() const { |
| 68 return included_categories_; |
| 69 } |
| 70 const StringList& excluded_categories() const { |
| 71 return excluded_categories_; |
| 72 } |
| 73 |
| 74 private: |
| 75 std::string predicate_name_; |
| 76 StringList included_categories_; |
| 77 StringList excluded_categories_; |
| 78 std::unique_ptr<base::DictionaryValue> args_; |
| 79 }; |
| 80 typedef std::vector<CategoryEventFilterConfig> CategoryEventFilters; |
51 | 81 |
52 TraceConfig(); | 82 TraceConfig(); |
53 | 83 |
54 // Create TraceConfig object from category filter and trace options strings. | 84 // Create TraceConfig object from category filter and trace options strings. |
55 // | 85 // |
56 // |category_filter_string| is a comma-delimited list of category wildcards. | 86 // |category_filter_string| is a comma-delimited list of category wildcards. |
57 // A category can have an optional '-' prefix to make it an excluded category. | 87 // A category can have an optional '-' prefix to make it an excluded category. |
58 // All the same rules apply above, so for example, having both included and | 88 // All the same rules apply above, so for example, having both included and |
59 // excluded categories in the same list would not be supported. | 89 // excluded categories in the same list would not be supported. |
60 // | 90 // |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 std::string ToString() const; | 188 std::string ToString() const; |
159 | 189 |
160 // Returns a copy of the TraceConfig wrapped in a ConvertableToTraceFormat | 190 // Returns a copy of the TraceConfig wrapped in a ConvertableToTraceFormat |
161 std::unique_ptr<ConvertableToTraceFormat> AsConvertableToTraceFormat() const; | 191 std::unique_ptr<ConvertableToTraceFormat> AsConvertableToTraceFormat() const; |
162 | 192 |
163 // Write the string representation of the CategoryFilter part. | 193 // Write the string representation of the CategoryFilter part. |
164 std::string ToCategoryFilterString() const; | 194 std::string ToCategoryFilterString() const; |
165 | 195 |
166 // Returns true if at least one category in the list is enabled by this | 196 // Returns true if at least one category in the list is enabled by this |
167 // trace config. | 197 // trace config. |
168 bool IsCategoryGroupEnabled(const char* category_group) const; | 198 bool IsCategoryGroupEnabled(const char* category_group_name) const; |
169 | 199 |
170 // Merges config with the current TraceConfig | 200 // Merges config with the current TraceConfig |
171 void Merge(const TraceConfig& config); | 201 void Merge(const TraceConfig& config); |
172 | 202 |
173 void Clear(); | 203 void Clear(); |
174 | 204 |
175 const MemoryDumpConfig& memory_dump_config() const { | 205 const MemoryDumpConfig& memory_dump_config() const { |
176 return memory_dump_config_; | 206 return memory_dump_config_; |
177 } | 207 } |
178 | 208 |
| 209 const CategoryEventFilters& category_event_filters() const { |
| 210 return category_event_filters_; |
| 211 } |
| 212 |
179 private: | 213 private: |
180 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfigFromValidLegacyFormat); | 214 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfigFromValidLegacyFormat); |
181 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, | 215 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, |
182 TraceConfigFromInvalidLegacyStrings); | 216 TraceConfigFromInvalidLegacyStrings); |
183 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, ConstructDefaultTraceConfig); | 217 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, ConstructDefaultTraceConfig); |
184 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfigFromValidString); | 218 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfigFromValidString); |
185 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfigFromInvalidString); | 219 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfigFromInvalidString); |
186 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, | 220 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, |
187 IsEmptyOrContainsLeadingOrTrailingWhitespace); | 221 IsEmptyOrContainsLeadingOrTrailingWhitespace); |
188 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfigFromMemoryConfigString); | 222 FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfigFromMemoryConfigString); |
(...skipping 18 matching lines...) Expand all Loading... |
207 void SetCategoriesFromIncludedList(const base::ListValue& included_list); | 241 void SetCategoriesFromIncludedList(const base::ListValue& included_list); |
208 void SetCategoriesFromExcludedList(const base::ListValue& excluded_list); | 242 void SetCategoriesFromExcludedList(const base::ListValue& excluded_list); |
209 void SetSyntheticDelaysFromList(const base::ListValue& list); | 243 void SetSyntheticDelaysFromList(const base::ListValue& list); |
210 void AddCategoryToDict(base::DictionaryValue& dict, | 244 void AddCategoryToDict(base::DictionaryValue& dict, |
211 const char* param, | 245 const char* param, |
212 const StringList& categories) const; | 246 const StringList& categories) const; |
213 | 247 |
214 void SetMemoryDumpConfig(const base::DictionaryValue& memory_dump_config); | 248 void SetMemoryDumpConfig(const base::DictionaryValue& memory_dump_config); |
215 void SetDefaultMemoryDumpConfig(); | 249 void SetDefaultMemoryDumpConfig(); |
216 | 250 |
| 251 void SetCategoryEventFilters(const base::ListValue& category_event_filters); |
| 252 |
217 // Convert TraceConfig to the dict representation of the TraceConfig. | 253 // Convert TraceConfig to the dict representation of the TraceConfig. |
218 void ToDict(base::DictionaryValue& dict) const; | 254 void ToDict(base::DictionaryValue& dict) const; |
219 | 255 |
220 std::string ToTraceOptionsString() const; | 256 std::string ToTraceOptionsString() const; |
221 | 257 |
222 void WriteCategoryFilterString(const StringList& values, | 258 void WriteCategoryFilterString(const StringList& values, |
223 std::string* out, | 259 std::string* out, |
224 bool included) const; | 260 bool included) const; |
225 void WriteCategoryFilterString(const StringList& delays, | 261 void WriteCategoryFilterString(const StringList& delays, |
226 std::string* out) const; | 262 std::string* out) const; |
(...skipping 10 matching lines...) Expand all Loading... |
237 bool enable_sampling_ : 1; | 273 bool enable_sampling_ : 1; |
238 bool enable_systrace_ : 1; | 274 bool enable_systrace_ : 1; |
239 bool enable_argument_filter_ : 1; | 275 bool enable_argument_filter_ : 1; |
240 | 276 |
241 MemoryDumpConfig memory_dump_config_; | 277 MemoryDumpConfig memory_dump_config_; |
242 | 278 |
243 StringList included_categories_; | 279 StringList included_categories_; |
244 StringList disabled_categories_; | 280 StringList disabled_categories_; |
245 StringList excluded_categories_; | 281 StringList excluded_categories_; |
246 StringList synthetic_delays_; | 282 StringList synthetic_delays_; |
| 283 CategoryEventFilters category_event_filters_; |
247 }; | 284 }; |
248 | 285 |
249 } // namespace trace_event | 286 } // namespace trace_event |
250 } // namespace base | 287 } // namespace base |
251 | 288 |
252 #endif // BASE_TRACE_EVENT_TRACE_CONFIG_H_ | 289 #endif // BASE_TRACE_EVENT_TRACE_CONFIG_H_ |
OLD | NEW |