Index: base/trace_event/trace_event.h |
diff --git a/base/trace_event/trace_event.h b/base/trace_event/trace_event.h |
index 7a2a65653d22c88bd9cc70f5f8998d760a60c462..f804e163e2f0f8f555e49ddd5947e6a951a1ee63 100644 |
--- a/base/trace_event/trace_event.h |
+++ b/base/trace_event/trace_event.h |
@@ -12,6 +12,7 @@ |
#include <string> |
#include "base/atomicops.h" |
+#include "base/macros.h" |
#include "base/time/time.h" |
#include "base/trace_event/common/trace_event_common.h" |
#include "base/trace_event/trace_event_system_stats_monitor.h" |
@@ -335,6 +336,11 @@ TRACE_EVENT_API_CLASS_EXPORT extern \ |
} \ |
} while (0) |
+// Implementation detail: internal macro to enter and leave a context based on |
+// the current scope. |
+#define INTERNAL_TRACE_EVENT_SCOPED_CONTEXT(category_group, name, context) \ |
+ trace_event_internal::TraceScopedContext INTERNAL_TRACE_EVENT_UID( \ |
+ scoped_trace)(category_group, name, context) |
fmeawad
2016/01/19 18:38:10
Can you move this to common as well, I do not see
Sami
2016/01/20 10:34:08
Yeah, I wasn't sure where we draw the line. I didn
|
namespace trace_event_internal { |
@@ -897,11 +903,35 @@ class TraceEventSamplingStateScope { |
const char* previous_state_; |
}; |
+using TraceContext = const void*; |
+ |
+class TraceScopedContext { |
+ public: |
+ TraceScopedContext(const char* category_group, |
+ const char* name, |
+ TraceContext context) |
+ : category_group_(category_group), name_(name), context_(context) { |
+ TRACE_EVENT_ENTER_CONTEXT(category_group_, name_, context_); |
+ } |
+ |
+ ~TraceScopedContext() { |
+ TRACE_EVENT_LEAVE_CONTEXT(category_group_, name_, context_); |
+ } |
+ |
+ private: |
+ const char* category_group_; |
+ const char* name_; |
+ TraceContext context_; |
+ DISALLOW_COPY_AND_ASSIGN(TraceScopedContext); |
+}; |
+ |
} // namespace trace_event_internal |
namespace base { |
namespace trace_event { |
+using trace_event_internal::TraceContext; |
+ |
template<typename IDType> class TraceScopedTrackableObject { |
public: |
TraceScopedTrackableObject(const char* category_group, const char* name, |