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 c7eda727580cb5d26954f95ce0d12cb2a9f95b91..e82a0d9dedd1fb61409ce101f999536dcd0d77a6 100644 |
--- a/third_party/WebKit/Source/platform/TraceEvent.h |
+++ b/third_party/WebKit/Source/platform/TraceEvent.h |
@@ -234,6 +234,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) |
@@ -613,6 +617,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 |