Chromium Code Reviews| Index: base/trace_event/trace_event.h |
| diff --git a/base/trace_event/trace_event.h b/base/trace_event/trace_event.h |
| index ed49fe4656f9326b232f973e69936ad3f31f4af9..a7bdeb917598145849d04f498922ad14e9082b9c 100644 |
| --- a/base/trace_event/trace_event.h |
| +++ b/base/trace_event/trace_event.h |
| @@ -7,7 +7,7 @@ |
| // This header file defines implementation details of how the trace macros in |
| // trace_event_common.h collect and store trace events. Anything not |
| -// implementation-specific should go in trace_macros_common.h instead of here. |
| +// implementation-specific should go in trace_event_common.h instead of here. |
| #include <stddef.h> |
| #include <stdint.h> |
| @@ -187,9 +187,14 @@ |
| // Adds a metadata event to the trace log. The |AppendValueAsTraceFormat| method |
| // on the convertable value will be called at flush time. |
|
fmeawad
2016/02/16 21:47:37
After a second thought I think it is better to eli
alph
2016/02/16 23:19:28
ok. done
|
| // TRACE_EVENT_API_ADD_METADATA_EVENT( |
| -// const char* event_name, |
| -// const char* arg_name, |
| -// scoped_refptr<ConvertableToTraceFormat> arg_value) |
| +// const char* event_name, |
| +// const char* arg_name, |
| +// scoped_refptr<ConvertableToTraceFormat> arg_value) |
| +// TRACE_EVENT_API_ADD_METADATA_EVENT( |
| +// const unsigned char* category_group_enabled, |
| +// const char* event_name, |
| +// const char* arg_name, |
| +// scoped_refptr<ConvertableToTraceFormat> arg_value) |
| #define TRACE_EVENT_API_ADD_METADATA_EVENT \ |
| trace_event_internal::AddMetadataEvent |
| @@ -347,8 +352,20 @@ TRACE_EVENT_API_CLASS_EXPORT extern \ |
| } \ |
| } while (0) |
| -// Implementation detail: internal macro to enter and leave a context based on |
| -// the current scope. |
| +// Implementation detail: internal macro to create static category and add |
| +// metadata event if the category is enabled. |
| +#define INTERNAL_TRACE_EVENT_METADATA_ADD(category_group, name, ...) \ |
| + do { \ |
| + INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
| + if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ |
| + TRACE_EVENT_API_ADD_METADATA_EVENT( \ |
| + INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ |
| + ##__VA_ARGS__); \ |
| + } \ |
| + } 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) \ |
| struct INTERNAL_TRACE_EVENT_UID(ScopedContext) { \ |
| public: \ |
| @@ -853,6 +870,39 @@ static inline void AddMetadataEvent( |
| convertable_values, TRACE_EVENT_FLAG_NONE); |
| } |
| +static inline void AddMetadataEvent( |
| + const unsigned char* category_group_enabled, |
| + const char* event_name, |
| + const char* arg_name, |
| + scoped_refptr<base::trace_event::ConvertableToTraceFormat> arg_value) { |
| + const char* arg_names[1] = {arg_name}; |
| + scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
| + convertable_values[1] = {arg_value}; |
| + unsigned char arg_types[1] = {TRACE_VALUE_TYPE_CONVERTABLE}; |
| + base::trace_event::TraceLog::GetInstance()->AddMetadataEvent( |
| + category_group_enabled, event_name, |
| + 1, // num_args |
| + arg_names, arg_types, |
| + nullptr, // arg_values |
| + convertable_values, TRACE_EVENT_FLAG_NONE); |
| +} |
| + |
| +template <class ARG1_TYPE> |
| +static void AddMetadataEvent(const unsigned char* category_group_enabled, |
| + const char* event_name, |
| + const char* arg_name, |
| + const ARG1_TYPE& arg_val) { |
| + const int num_args = 1; |
| + const char* arg_names[1] = {arg_name}; |
| + unsigned char arg_types[1]; |
| + unsigned long long arg_values[1]; |
| + SetTraceValue(arg_val, &arg_types[0], &arg_values[0]); |
| + |
| + base::trace_event::TraceLog::GetInstance()->AddMetadataEvent( |
| + category_group_enabled, event_name, num_args, arg_names, arg_types, |
| + arg_values, nullptr, TRACE_EVENT_FLAG_NONE); |
| +} |
| + |
| template <class ARG1_TYPE> |
| static void AddMetadataEvent(const char* event_name, |
| const char* arg_name, |