diff options
Diffstat (limited to 'chromium/base/debug/trace_event_impl.h')
-rw-r--r-- | chromium/base/debug/trace_event_impl.h | 59 |
1 files changed, 41 insertions, 18 deletions
diff --git a/chromium/base/debug/trace_event_impl.h b/chromium/base/debug/trace_event_impl.h index 61794807a41..e5a6dbd71f9 100644 --- a/chromium/base/debug/trace_event_impl.h +++ b/chromium/base/debug/trace_event_impl.h @@ -125,10 +125,6 @@ class BASE_EXPORT TraceEvent { void UpdateDuration(const TimeTicks& now, const TimeTicks& thread_now); // Serialize event data to JSON - static void AppendEventsAsJSON(const std::vector<TraceEvent>& events, - size_t start, - size_t count, - std::string* out); void AppendAsJSON(std::string* out) const; void AppendPrettyPrinted(std::ostringstream* out) const; @@ -283,6 +279,8 @@ class BASE_EXPORT TraceResultBuffer { class BASE_EXPORT CategoryFilter { public: + typedef std::vector<std::string> StringList; + // The default category filter, used when none is provided. // Allows all categories through, except if they end in the suffix 'Debug' or // 'Test'. @@ -298,6 +296,17 @@ class BASE_EXPORT CategoryFilter { // Example: CategoryFilter("-excluded_category1,-excluded_category2"); // Example: CategoryFilter("-*,webkit"); would disable everything but webkit. // Example: CategoryFilter("-webkit"); would enable everything but webkit. + // + // Category filters can also be used to configure synthetic delays. + // + // Example: CategoryFilter("DELAY(gpu.PresentingFrame;16)"); would make swap + // buffers always take at least 16 ms. + // Example: CategoryFilter("DELAY(gpu.PresentingFrame;16;oneshot)"); would + // make swap buffers take at least 16 ms the first time it is + // called. + // Example: CategoryFilter("DELAY(gpu.PresentingFrame;16;alternating)"); + // would make swap buffers take at least 16 ms every other time it + // is called. explicit CategoryFilter(const std::string& filter_string); CategoryFilter(const CategoryFilter& cf); @@ -317,6 +326,9 @@ class BASE_EXPORT CategoryFilter { // disabled by this category filter. bool IsCategoryGroupEnabled(const char* category_group) const; + // Return a list of the synthetic delays specified in this category filter. + const StringList& GetSyntheticDelayValues() const; + // Merges nested_filter with the current CategoryFilter void Merge(const CategoryFilter& nested_filter); @@ -334,12 +346,11 @@ class BASE_EXPORT CategoryFilter { static bool IsEmptyOrContainsLeadingOrTrailingWhitespace( const std::string& str); - typedef std::vector<std::string> StringList; - void Initialize(const std::string& filter_string); void WriteString(const StringList& values, std::string* out, bool included) const; + void WriteString(const StringList& delays, std::string* out) const; bool HasIncludedPatterns() const; bool DoesCategoryGroupContainCategory(const char* category_group, @@ -348,12 +359,19 @@ class BASE_EXPORT CategoryFilter { StringList included_; StringList disabled_; StringList excluded_; + StringList delays_; }; class TraceSamplingThread; class BASE_EXPORT TraceLog { public: + enum Mode { + DISABLED = 0, + RECORDING_MODE, + MONITORING_MODE, + }; + // Options determines how the trace buffer stores data. enum Options { // Record until the trace buffer is full. @@ -366,21 +384,21 @@ class BASE_EXPORT TraceLog { // Enable the sampling profiler in the recording mode. ENABLE_SAMPLING = 1 << 2, - // Enable the sampling profiler in the monitoring mode. - MONITOR_SAMPLING = 1 << 3, - // Echo to console. Events are discarded. - ECHO_TO_CONSOLE = 1 << 4, + ECHO_TO_CONSOLE = 1 << 3, }; // The pointer returned from GetCategoryGroupEnabledInternal() points to a // value with zero or more of the following bits. Used in this class only. // The TRACE_EVENT macros should only use the value as a bool. + // These values must be in sync with macro values in TraceEvent.h in Blink. enum CategoryGroupEnabledFlags { - // Normal enabled flag for category groups enabled by SetEnabled(). + // Category group enabled for the recording mode. ENABLED_FOR_RECORDING = 1 << 0, + // Category group enabled for the monitoring mode. + ENABLED_FOR_MONITORING = 1 << 1, // Category group enabled by SetEventCallbackEnabled(). - ENABLED_FOR_EVENT_CALLBACK = 1 << 1, + ENABLED_FOR_EVENT_CALLBACK = 1 << 2, }; static TraceLog* GetInstance(); @@ -400,12 +418,13 @@ class BASE_EXPORT TraceLog { // See CategoryFilter comments for details on how to control what categories // will be traced. If tracing has already been enabled, |category_filter| will // be merged into the current category filter. - void SetEnabled(const CategoryFilter& category_filter, Options options); + void SetEnabled(const CategoryFilter& category_filter, + Mode mode, Options options); // Disables normal tracing for all categories. void SetDisabled(); - bool IsEnabled() { return enabled_; } + bool IsEnabled() { return mode_ != DISABLED; } // The number of times we have begun recording traces. If tracing is off, // returns -1. If tracing is on, then it returns the number of times we have @@ -426,7 +445,7 @@ class BASE_EXPORT TraceLog { class EnabledStateObserver { public: // Called just after the tracing system becomes enabled, outside of the - // |lock_|. TraceLog::IsEnabled() is true at this point. + // |lock_|. TraceLog::IsEnabled() is true at this point. virtual void OnTraceLogEnabled() = 0; // Called just after the tracing system disables, outside of the |lock_|. @@ -591,14 +610,18 @@ class BASE_EXPORT TraceLog { // by the Singleton class. friend struct DefaultSingletonTraits<TraceLog>; - // Enable/disable each category group based on the current enabled_, + // Enable/disable each category group based on the current mode_, // category_filter_, event_callback_ and event_callback_category_filter_. - // Enable the category group if enabled_ is true and category_filter_ matches + // Enable the category group in the enabled mode if category_filter_ matches // the category group, or event_callback_ is not null and // event_callback_category_filter_ matches the category group. void UpdateCategoryGroupEnabledFlags(); void UpdateCategoryGroupEnabledFlag(int category_index); + // Configure synthetic delays based on the values set in the current + // category filter. + void UpdateSyntheticDelaysFromCategoryFilter(); + class ThreadLocalEventBuffer; class OptionalAutoLock; @@ -652,7 +675,7 @@ class BASE_EXPORT TraceLog { // and thread_colors_. Lock thread_info_lock_; int locked_line_; - bool enabled_; + Mode mode_; int num_traces_recorded_; scoped_ptr<TraceBuffer> logged_events_; subtle::AtomicWord /* EventCallback */ event_callback_; |