Index: base/trace_event/trace_event.h |
diff --git a/base/trace_event/trace_event.h b/base/trace_event/trace_event.h |
index e0249f5539a181175127ba4df1cc7fc489328f44..c82522ce8c1e3c930651821f3ca479e006b54885 100644 |
--- a/base/trace_event/trace_event.h |
+++ b/base/trace_event/trace_event.h |
@@ -542,7 +542,7 @@ |
TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, arg2_name, arg2_val) |
// ASYNC_STEP_* APIs should be only used by legacy code. New code should |
-// consider using NESTABLE_ASYNC_* APIs to describe substeps within an async |
+// consider using NESTABLE_ASYNC* APIs to describe substeps within an async |
// event. |
// Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2 |
// associated arguments. If the category is not enabled, then this |
@@ -682,7 +682,7 @@ |
static_cast<int>(base::PlatformThread::CurrentId()), \ |
timestamp, TRACE_EVENT_FLAG_NONE) |
-// NESTABLE_ASYNC_* APIs are used to describe an async operation, which can |
+// NESTABLE_ASYNC* APIs are used to describe an async operation, which can |
// be nested within a NESTABLE_ASYNC event and/or have inner NESTABLE_ASYNC |
// events. |
// - category and name strings must have application lifetime (statics or |
@@ -702,8 +702,12 @@ |
// NESTABLE_ASYNC event of that id. Corresponding warning messages for |
// unmatched events will be shown in the analysis view. |
-// Records a single NESTABLE_ASYNC_BEGIN event called "name" immediately, with 2 |
-// associated arguments. If the category is not enabled, then this does nothing. |
+// Records a single NESTABLE_ASYNC_BEGIN event called "name" immediately, with 0 |
+// or 2 associated arguments. If the category is not enabled, then this does |
+// nothing. |
+#define TRACE_EVENT_NESTABLE_ASYNC_BEGIN0(category_group, name, id) \ |
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, \ |
+ category_group, name, id, TRACE_EVENT_FLAG_NONE) |
#define TRACE_EVENT_NESTABLE_ASYNC_BEGIN2(category_group, name, id, arg1_name, \ |
arg1_val, arg2_name, arg2_val) \ |
INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, \ |
@@ -711,6 +715,13 @@ |
arg2_name, arg2_val) |
// Records a single NESTABLE_ASYNC_END event called "name" immediately, with 2 |
// associated arguments. If the category is not enabled, then this does nothing. |
+#define TRACE_EVENT_NESTABLE_ASYNC_END0(category_group, name, id) \ |
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, \ |
+ category_group, name, id, TRACE_EVENT_FLAG_NONE) |
+#define TRACE_EVENT_NESTABLE_ASYNC_END1(category_group, name, id, arg1_name, \ |
+ arg1_val) \ |
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, \ |
+ category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) |
#define TRACE_EVENT_NESTABLE_ASYNC_END2(category_group, name, id, arg1_name, \ |
arg1_val, arg2_name, arg2_val) \ |
INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, \ |
@@ -725,6 +736,28 @@ |
category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ |
arg2_name, arg2_val) |
+// Call TRACE_EVENT_NESTABLE_ASYNC_BEGIN* to set up a nestable id before calling |
+// TRACE_EVENT_NESTABLE_ASYNC*. Records a nested pair of begin and end events |
+// called "name" for the current scope and assocated with the id passed to |
+// _BEGIN. Handles 0, 1 or 2 associated arguments. If the category is |
+// not enabled, then this does nothing. |
+// - category and name strings must have application lifetime (statics or |
+// literals). They may not include " chars. |
+#define TRACE_EVENT_NESTABLE_ASYNC0(category_group, name, id) \ |
+ INTERNAL_TRACE_EVENT_ADD_SCOPED_WITH_ID( \ |
+ TRACE_EVENT_PHASE_NESTABLE_ASYNC_COMPLETE, category_group, name, id, \ |
+ TRACE_EVENT_FLAG_NONE) |
+#define TRACE_EVENT_NESTABLE_ASYNC1( \ |
+ category_group, name, id, arg1_name, arg1_val) \ |
+ INTERNAL_TRACE_EVENT_ADD_SCOPED_WITH_ID( \ |
+ TRACE_EVENT_PHASE_NESTABLE_ASYNC_COMPLETE, category_group, name, id, \ |
+ TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) |
+#define TRACE_EVENT_NESTABLE_ASYNC2( \ |
+ category_group, name, id, arg1_name, arg1_val, arg2_name, arg2_val) \ |
+ INTERNAL_TRACE_EVENT_ADD_SCOPED_WITH_ID( \ |
+ TRACE_EVENT_PHASE_NESTABLE_ASYNC_COMPLETE, category_group, name, id, \ |
+ TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, arg2_name, arg2_val) |
+ |
// Records a single FLOW_BEGIN event called "name" immediately, with 0, 1 or 2 |
// associated arguments. If the category is not enabled, then this |
// does nothing. |
@@ -1027,6 +1060,26 @@ TRACE_EVENT_API_CLASS_EXPORT extern \ |
} while (0) |
// Implementation detail: internal macro to create static category and add |
+// event if the category is enabled. Also adds the end event when the scope |
+// ends. |
+#define INTERNAL_TRACE_EVENT_ADD_SCOPED_WITH_ID( \ |
+ phase, category_group, name, id, flags, ...) \ |
+ INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
+ trace_event_internal::ScopedTracer INTERNAL_TRACE_EVENT_UID(tracer); \ |
+ if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ |
+ unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ |
+ trace_event_internal::TraceID trace_event_trace_id( \ |
+ id, &trace_event_flags); \ |
+ base::trace_event::TraceEventHandle h = \ |
+ trace_event_internal::AddTraceEvent( \ |
+ phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ |
+ name, trace_event_trace_id.data(), trace_event_flags, \ |
+ ##__VA_ARGS__); \ |
+ INTERNAL_TRACE_EVENT_UID(tracer).Initialize( \ |
+ INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, h); \ |
+ } |
+ |
+// Implementation detail: internal macro to create static category and add |
// event if the category is enabled. |
#define INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP(phase, \ |
category_group, name, id, thread_id, timestamp, flags, ...) \ |
@@ -1061,6 +1114,7 @@ TRACE_EVENT_API_CLASS_EXPORT extern \ |
#define TRACE_EVENT_PHASE_ASYNC_END ('F') |
#define TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN ('b') |
#define TRACE_EVENT_PHASE_NESTABLE_ASYNC_END ('e') |
+#define TRACE_EVENT_PHASE_NESTABLE_ASYNC_COMPLETE ('x') |
#define TRACE_EVENT_PHASE_NESTABLE_ASYNC_INSTANT ('n') |
#define TRACE_EVENT_PHASE_FLOW_BEGIN ('s') |
#define TRACE_EVENT_PHASE_FLOW_STEP ('t') |
@@ -1521,10 +1575,10 @@ static inline base::trace_event::TraceEventHandle AddTraceEvent( |
class TRACE_EVENT_API_CLASS_EXPORT ScopedTracer { |
public: |
// Note: members of data_ intentionally left uninitialized. See Initialize. |
- ScopedTracer() : p_data_(NULL) {} |
+ ScopedTracer() : initialized_(false) {} |
Dan Beam
2015/04/30 04:40:13
forgot i did this. can revert if you want...
|
~ScopedTracer() { |
- if (p_data_ && *data_.category_group_enabled) |
+ if (initialized_ && *data_.category_group_enabled) |
TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( |
data_.category_group_enabled, data_.name, data_.event_handle); |
} |
@@ -1535,7 +1589,7 @@ class TRACE_EVENT_API_CLASS_EXPORT ScopedTracer { |
data_.category_group_enabled = category_group_enabled; |
data_.name = name; |
data_.event_handle = event_handle; |
- p_data_ = &data_; |
+ initialized_ = true; |
} |
private: |
@@ -1549,7 +1603,7 @@ class TRACE_EVENT_API_CLASS_EXPORT ScopedTracer { |
const char* name; |
base::trace_event::TraceEventHandle event_handle; |
}; |
- Data* p_data_; |
+ bool initialized_; |
Data data_; |
}; |