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

Unified Diff: base/debug/trace_event_internal.h

Issue 13590005: Add a ConvertableToTraceFormat type to the trace framework. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 8 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
Index: base/debug/trace_event_internal.h
diff --git a/base/debug/trace_event_internal.h b/base/debug/trace_event_internal.h
index 46495f4460c4d60e04d0345359a2dd441f332eb7..afafbe13ce24990f8679a4b0731c5d1171a1b433 100644
--- a/base/debug/trace_event_internal.h
+++ b/base/debug/trace_event_internal.h
@@ -731,6 +731,7 @@
#define TRACE_VALUE_TYPE_POINTER (static_cast<unsigned char>(5))
#define TRACE_VALUE_TYPE_STRING (static_cast<unsigned char>(6))
#define TRACE_VALUE_TYPE_COPY_STRING (static_cast<unsigned char>(7))
+#define TRACE_VALUE_TYPE_CONVERTABLE (static_cast<unsigned char>(8))
// Enum reflecting the scope of an INSTANT event. Must fit within
// TRACE_EVENT_FLAG_SCOPE_MASK.
@@ -838,9 +839,11 @@ class TraceStringWithCopy {
#define INTERNAL_DECLARE_SET_TRACE_VALUE(actual_type, \
union_member, \
value_type_id) \
- static inline void SetTraceValue(actual_type arg, \
- unsigned char* type, \
- unsigned long long* value) { \
+ static inline void SetTraceValue( \
+ actual_type arg, \
+ unsigned char* type, \
+ unsigned long long* value, \
+ scoped_ptr<base::debug::ConvertableToJSON>* convertable_value) { \
TraceValueUnion type_value; \
type_value.union_member = arg; \
*type = value_type_id; \
@@ -849,9 +852,11 @@ class TraceStringWithCopy {
// Simpler form for int types that can be safely casted.
#define INTERNAL_DECLARE_SET_TRACE_VALUE_INT(actual_type, \
value_type_id) \
- static inline void SetTraceValue(actual_type arg, \
- unsigned char* type, \
- unsigned long long* value) { \
+ static inline void SetTraceValue( \
+ actual_type arg, \
+ unsigned char* type, \
+ unsigned long long* value, \
+ scoped_ptr<base::debug::ConvertableToJSON>* convertable_value) { \
*type = value_type_id; \
*value = static_cast<unsigned long long>(arg); \
}
@@ -879,15 +884,26 @@ INTERNAL_DECLARE_SET_TRACE_VALUE(const TraceStringWithCopy&, as_string,
#undef INTERNAL_DECLARE_SET_TRACE_VALUE_INT
// std::string version of SetTraceValue so that trace arguments can be strings.
-static inline void SetTraceValue(const std::string& arg,
- unsigned char* type,
- unsigned long long* value) {
+static inline void SetTraceValue(
+ const std::string& arg,
+ unsigned char* type,
+ unsigned long long* value,
+ scoped_ptr<base::debug::ConvertableToJSON>* convertable_value) {
TraceValueUnion type_value;
type_value.as_string = arg.c_str();
*type = TRACE_VALUE_TYPE_COPY_STRING;
*value = type_value.as_uint;
}
+static inline void SetTraceValue(
+ base::debug::ConvertableToJSON* arg,
dsinclair 2013/04/09 22:37:45 This has to be scoped_ptr<base::debug::Convertable
dsinclair 2013/04/10 01:09:31 Done.
+ unsigned char* type,
+ unsigned long long* value,
+ scoped_ptr<base::debug::ConvertableToJSON>* convertable_value) {
+ *type = TRACE_VALUE_TYPE_CONVERTABLE;
+ convertable_value->reset(arg);
+}
+
// These AddTraceEvent and AddTraceEventWithThreadIdAndTimestamp template
// functions are defined here instead of in the macro, because the arg_values
// could be temporary objects, such as std::string. In order to store
@@ -903,7 +919,7 @@ static inline void AddTraceEventWithThreadIdAndTimestamp(char phase,
unsigned char flags) {
TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(
phase, category_enabled, name, id, thread_id, timestamp,
- kZeroNumArgs, NULL, NULL, NULL, flags);
+ kZeroNumArgs, NULL, NULL, NULL, NULL, flags);
}
static inline void AddTraceEvent(char phase,
@@ -930,10 +946,12 @@ static inline void AddTraceEventWithThreadIdAndTimestamp(char phase,
const int num_args = 1;
unsigned char arg_types[1];
unsigned long long arg_values[1];
- SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]);
+ scoped_ptr<base::debug::ConvertableToJSON> convertable_values[1];
+ SetTraceValue(arg1_val, &arg_types[0], &arg_values[0],
+ &convertable_values[0]);
TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(
phase, category_enabled, name, id, thread_id, timestamp,
- num_args, &arg1_name, arg_types, arg_values, flags);
+ num_args, &arg1_name, arg_types, arg_values, convertable_values, flags);
}
template<class ARG1_TYPE>
@@ -967,11 +985,14 @@ static inline void AddTraceEventWithThreadIdAndTimestamp(char phase,
const char* arg_names[2] = { arg1_name, arg2_name };
unsigned char arg_types[2];
unsigned long long arg_values[2];
- SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]);
- SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]);
+ scoped_ptr<base::debug::ConvertableToJSON> convertable_values[2];
+ SetTraceValue(arg1_val, &arg_types[0], &arg_values[0],
+ &convertable_values[0]);
+ SetTraceValue(arg2_val, &arg_types[1], &arg_values[1],
+ &convertable_values[1]);
TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(
phase, category_enabled, name, id, thread_id, timestamp,
- num_args, arg_names, arg_types, arg_values, flags);
+ num_args, arg_names, arg_types, arg_values, convertable_values, flags);
}
template<class ARG1_TYPE, class ARG2_TYPE>
@@ -1017,7 +1038,7 @@ class TRACE_EVENT_API_CLASS_EXPORT TraceEndOnScopeClose {
TRACE_EVENT_PHASE_END,
p_data_->category_enabled,
p_data_->name, kNoEventId,
- kZeroNumArgs, NULL, NULL, NULL,
+ kZeroNumArgs, NULL, NULL, NULL, NULL,
TRACE_EVENT_FLAG_NONE);
}
}

Powered by Google App Engine
This is Rietveld 408576698