Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1068)

Unified Diff: third_party/WebKit/Source/platform/TraceEvent.h

Issue 1499683002: tracing: Add macros for generating context trace events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/trace_event/trace_event_unittest.cc ('k') | third_party/WebKit/Source/platform/TraceEventCommon.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/TraceEvent.h
diff --git a/third_party/WebKit/Source/platform/TraceEvent.h b/third_party/WebKit/Source/platform/TraceEvent.h
index 01e4edec905443a96d6e8b1fb8a00d14e232de0e..fe656337b7594000f2d31e0b2b7abc0112a0ce6a 100644
--- a/third_party/WebKit/Source/platform/TraceEvent.h
+++ b/third_party/WebKit/Source/platform/TraceEvent.h
@@ -235,6 +235,10 @@
} \
} while (0)
+// Implementation detail: internal macro to enter and leave a context based on
+// the current scope.
+#define INTERNAL_TRACE_EVENT_SCOPED_CONTEXT(categoryGroup, name, context) \
+ blink::TraceEvent::TraceScopedContext INTERNAL_TRACE_EVENT_UID(scopedTracer)(categoryGroup, name, context)
// These values must be in sync with base::debug::TraceLog::CategoryGroupEnabledFlags.
#define ENABLED_FOR_RECORDING (1 << 0)
@@ -623,6 +627,31 @@ private:
IDType m_id;
};
+using TraceContext = const void*;
+
+class TraceScopedContext {
+ WTF_MAKE_NONCOPYABLE(TraceScopedContext);
+
+public:
+ TraceScopedContext(const char* categoryGroup, const char* name, TraceContext context)
+ : m_categoryGroup(categoryGroup)
+ , m_name(name)
+ , m_context(context)
+ {
+ TRACE_EVENT_ENTER_CONTEXT(m_categoryGroup, m_name, m_context);
+ }
+
+ ~TraceScopedContext()
+ {
+ TRACE_EVENT_LEAVE_CONTEXT(m_categoryGroup, m_name, m_context);
+ }
+
+private:
+ const char* m_categoryGroup;
+ const char* m_name;
+ TraceContext m_context;
+};
+
} // namespace TraceEvent
} // namespace blink
« no previous file with comments | « base/trace_event/trace_event_unittest.cc ('k') | third_party/WebKit/Source/platform/TraceEventCommon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698