| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 5 |
| 6 #ifndef BASE_DEBUG_TRACE_EVENT_IMPL_H_ | 6 #ifndef BASE_DEBUG_TRACE_EVENT_IMPL_H_ |
| 7 #define BASE_DEBUG_TRACE_EVENT_IMPL_H_ | 7 #define BASE_DEBUG_TRACE_EVENT_IMPL_H_ |
| 8 | 8 |
| 9 #include <stack> | 9 #include <stack> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 // formatted output. | 276 // formatted output. |
| 277 void Finish(); | 277 void Finish(); |
| 278 | 278 |
| 279 private: | 279 private: |
| 280 OutputCallback output_callback_; | 280 OutputCallback output_callback_; |
| 281 bool append_comma_; | 281 bool append_comma_; |
| 282 }; | 282 }; |
| 283 | 283 |
| 284 class BASE_EXPORT CategoryFilter { | 284 class BASE_EXPORT CategoryFilter { |
| 285 public: | 285 public: |
| 286 typedef std::pair<std::string, std::string> DelayValue; |
| 287 typedef std::vector<DelayValue> DelayValueList; |
| 288 |
| 286 // The default category filter, used when none is provided. | 289 // The default category filter, used when none is provided. |
| 287 // Allows all categories through, except if they end in the suffix 'Debug' or | 290 // Allows all categories through, except if they end in the suffix 'Debug' or |
| 288 // 'Test'. | 291 // 'Test'. |
| 289 static const char* kDefaultCategoryFilterString; | 292 static const char* kDefaultCategoryFilterString; |
| 290 | 293 |
| 291 // |filter_string| is a comma-delimited list of category wildcards. | 294 // |filter_string| is a comma-delimited list of category wildcards. |
| 292 // A category can have an optional '-' prefix to make it an excluded category. | 295 // A category can have an optional '-' prefix to make it an excluded category. |
| 293 // All the same rules apply above, so for example, having both included and | 296 // All the same rules apply above, so for example, having both included and |
| 294 // excluded categories in the same list would not be supported. | 297 // excluded categories in the same list would not be supported. |
| 295 // | 298 // |
| 296 // Example: CategoryFilter"test_MyTest*"); | 299 // Example: CategoryFilter"test_MyTest*"); |
| 297 // Example: CategoryFilter("test_MyTest*,test_OtherStuff"); | 300 // Example: CategoryFilter("test_MyTest*,test_OtherStuff"); |
| 298 // Example: CategoryFilter("-excluded_category1,-excluded_category2"); | 301 // Example: CategoryFilter("-excluded_category1,-excluded_category2"); |
| 299 // Example: CategoryFilter("-*,webkit"); would disable everything but webkit. | 302 // Example: CategoryFilter("-*,webkit"); would disable everything but webkit. |
| 300 // Example: CategoryFilter("-webkit"); would enable everything but webkit. | 303 // Example: CategoryFilter("-webkit"); would enable everything but webkit. |
| 304 // |
| 305 // Category filters can also be used to configure synthetic delays. |
| 306 // |
| 307 // Example: CategoryFilter("DELAY(gpu.SwapBuffers;16)"); would make swap |
| 308 // buffers always take at least 16 ms. |
| 309 // Example: CategoryFilter("DELAY(gpu.SwapBuffers;16;oneshot)"); would |
| 310 // make swap buffers take at least 16 ms the first time it is called. |
| 311 // Example: CategoryFilter("DELAY(gpu.SwapBuffers;16;alternating)"); would |
| 312 // make swap buffers take at least 16 ms every other time it is |
| 313 // called. |
| 301 explicit CategoryFilter(const std::string& filter_string); | 314 explicit CategoryFilter(const std::string& filter_string); |
| 302 | 315 |
| 303 CategoryFilter(const CategoryFilter& cf); | 316 CategoryFilter(const CategoryFilter& cf); |
| 304 | 317 |
| 305 ~CategoryFilter(); | 318 ~CategoryFilter(); |
| 306 | 319 |
| 307 CategoryFilter& operator=(const CategoryFilter& rhs); | 320 CategoryFilter& operator=(const CategoryFilter& rhs); |
| 308 | 321 |
| 309 // Writes the string representation of the CategoryFilter. This is a comma | 322 // Writes the string representation of the CategoryFilter. This is a comma |
| 310 // separated string, similar in nature to the one used to determine | 323 // separated string, similar in nature to the one used to determine |
| 311 // enabled/disabled category patterns, except here there is an arbitrary | 324 // enabled/disabled category patterns, except here there is an arbitrary |
| 312 // order, included categories go first, then excluded categories. Excluded | 325 // order, included categories go first, then excluded categories. Excluded |
| 313 // categories are distinguished from included categories by the prefix '-'. | 326 // categories are distinguished from included categories by the prefix '-'. |
| 314 std::string ToString() const; | 327 std::string ToString() const; |
| 315 | 328 |
| 316 // Determines whether category group would be enabled or | 329 // Determines whether category group would be enabled or |
| 317 // disabled by this category filter. | 330 // disabled by this category filter. |
| 318 bool IsCategoryGroupEnabled(const char* category_group) const; | 331 bool IsCategoryGroupEnabled(const char* category_group) const; |
| 319 | 332 |
| 333 // Return a list of the synthetic delays specified in this category filter. |
| 334 const DelayValueList& GetSyntheticDelayValues() const; |
| 335 |
| 320 // Merges nested_filter with the current CategoryFilter | 336 // Merges nested_filter with the current CategoryFilter |
| 321 void Merge(const CategoryFilter& nested_filter); | 337 void Merge(const CategoryFilter& nested_filter); |
| 322 | 338 |
| 323 // Clears both included/excluded pattern lists. This would be equivalent to | 339 // Clears both included/excluded pattern lists. This would be equivalent to |
| 324 // creating a CategoryFilter with an empty string, through the constructor. | 340 // creating a CategoryFilter with an empty string, through the constructor. |
| 325 // i.e: CategoryFilter(""). | 341 // i.e: CategoryFilter(""). |
| 326 // | 342 // |
| 327 // When using an empty filter, all categories are considered included as we | 343 // When using an empty filter, all categories are considered included as we |
| 328 // are not excluding anything. | 344 // are not excluding anything. |
| 329 void Clear(); | 345 void Clear(); |
| 330 | 346 |
| 331 private: | 347 private: |
| 332 FRIEND_TEST_ALL_PREFIXES(TraceEventTestFixture, CategoryFilter); | 348 FRIEND_TEST_ALL_PREFIXES(TraceEventTestFixture, CategoryFilter); |
| 333 | 349 |
| 334 static bool IsEmptyOrContainsLeadingOrTrailingWhitespace( | 350 static bool IsEmptyOrContainsLeadingOrTrailingWhitespace( |
| 335 const std::string& str); | 351 const std::string& str); |
| 336 | 352 |
| 337 typedef std::vector<std::string> StringList; | 353 typedef std::vector<std::string> StringList; |
| 338 | 354 |
| 339 void Initialize(const std::string& filter_string); | 355 void Initialize(const std::string& filter_string); |
| 340 void WriteString(const StringList& values, | 356 void WriteString(const StringList& values, |
| 341 std::string* out, | 357 std::string* out, |
| 342 bool included) const; | 358 bool included) const; |
| 359 void WriteString(const DelayValueList& delays, std::string* out) const; |
| 343 bool HasIncludedPatterns() const; | 360 bool HasIncludedPatterns() const; |
| 344 | 361 |
| 345 bool DoesCategoryGroupContainCategory(const char* category_group, | 362 bool DoesCategoryGroupContainCategory(const char* category_group, |
| 346 const char* category) const; | 363 const char* category) const; |
| 347 | 364 |
| 348 StringList included_; | 365 StringList included_; |
| 349 StringList disabled_; | 366 StringList disabled_; |
| 350 StringList excluded_; | 367 StringList excluded_; |
| 368 DelayValueList delays_; |
| 351 }; | 369 }; |
| 352 | 370 |
| 353 class TraceSamplingThread; | 371 class TraceSamplingThread; |
| 354 | 372 |
| 355 class BASE_EXPORT TraceLog { | 373 class BASE_EXPORT TraceLog { |
| 356 public: | 374 public: |
| 357 enum Mode { | 375 enum Mode { |
| 358 DISABLED = 0, | 376 DISABLED = 0, |
| 359 RECORDING_MODE, | 377 RECORDING_MODE, |
| 360 MONITORING_MODE, | 378 MONITORING_MODE, |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 friend struct DefaultSingletonTraits<TraceLog>; | 617 friend struct DefaultSingletonTraits<TraceLog>; |
| 600 | 618 |
| 601 // Enable/disable each category group based on the current mode_, | 619 // Enable/disable each category group based on the current mode_, |
| 602 // category_filter_, event_callback_ and event_callback_category_filter_. | 620 // category_filter_, event_callback_ and event_callback_category_filter_. |
| 603 // Enable the category group in the enabled mode if category_filter_ matches | 621 // Enable the category group in the enabled mode if category_filter_ matches |
| 604 // the category group, or event_callback_ is not null and | 622 // the category group, or event_callback_ is not null and |
| 605 // event_callback_category_filter_ matches the category group. | 623 // event_callback_category_filter_ matches the category group. |
| 606 void UpdateCategoryGroupEnabledFlags(); | 624 void UpdateCategoryGroupEnabledFlags(); |
| 607 void UpdateCategoryGroupEnabledFlag(int category_index); | 625 void UpdateCategoryGroupEnabledFlag(int category_index); |
| 608 | 626 |
| 627 // Configure synthetic delays based on the values set in the current |
| 628 // category filter. |
| 629 void UpdateSyntheticDelaysFromCategoryFilter(); |
| 630 |
| 609 class ThreadLocalEventBuffer; | 631 class ThreadLocalEventBuffer; |
| 610 class OptionalAutoLock; | 632 class OptionalAutoLock; |
| 611 | 633 |
| 612 TraceLog(); | 634 TraceLog(); |
| 613 ~TraceLog(); | 635 ~TraceLog(); |
| 614 const unsigned char* GetCategoryGroupEnabledInternal(const char* name); | 636 const unsigned char* GetCategoryGroupEnabledInternal(const char* name); |
| 615 void AddMetadataEventsWhileLocked(); | 637 void AddMetadataEventsWhileLocked(); |
| 616 | 638 |
| 617 TraceBuffer* trace_buffer() const { return logged_events_.get(); } | 639 TraceBuffer* trace_buffer() const { return logged_events_.get(); } |
| 618 TraceBuffer* CreateTraceBuffer(); | 640 TraceBuffer* CreateTraceBuffer(); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 scoped_refptr<MessageLoopProxy> flush_message_loop_proxy_; | 738 scoped_refptr<MessageLoopProxy> flush_message_loop_proxy_; |
| 717 subtle::AtomicWord generation_; | 739 subtle::AtomicWord generation_; |
| 718 | 740 |
| 719 DISALLOW_COPY_AND_ASSIGN(TraceLog); | 741 DISALLOW_COPY_AND_ASSIGN(TraceLog); |
| 720 }; | 742 }; |
| 721 | 743 |
| 722 } // namespace debug | 744 } // namespace debug |
| 723 } // namespace base | 745 } // namespace base |
| 724 | 746 |
| 725 #endif // BASE_DEBUG_TRACE_EVENT_IMPL_H_ | 747 #endif // BASE_DEBUG_TRACE_EVENT_IMPL_H_ |
| OLD | NEW |