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

Side by Side Diff: base/trace_event/trace_event.h

Issue 1239593002: Implement a new flow event API that allows binding flow events and regular events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unnecessary comments. Created 5 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This header file defines the set of trace_event macros without specifying 5 // This header file defines the set of trace_event macros without specifying
6 // how the events actually get collected and stored. If you need to expose trace 6 // how the events actually get collected and stored. If you need to expose trace
7 // events to some other universe, you can copy-and-paste this file as well as 7 // events to some other universe, you can copy-and-paste this file as well as
8 // trace_event.h, modifying the macros contained there as necessary for the 8 // trace_event.h, modifying the macros contained there as necessary for the
9 // target platform. The end result is that multiple libraries can funnel events 9 // target platform. The end result is that multiple libraries can funnel events
10 // through to a shared trace event collector. 10 // through to a shared trace event collector.
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 trace_event_internal::TraceID::DontMangle(id) 218 trace_event_internal::TraceID::DontMangle(id)
219 219
220 // Records a pair of begin and end events called "name" for the current 220 // Records a pair of begin and end events called "name" for the current
221 // scope, with 0, 1 or 2 associated arguments. If the category is not 221 // scope, with 0, 1 or 2 associated arguments. If the category is not
222 // enabled, then this does nothing. 222 // enabled, then this does nothing.
223 // - category and name strings must have application lifetime (statics or 223 // - category and name strings must have application lifetime (statics or
224 // literals). They may not include " chars. 224 // literals). They may not include " chars.
225 #define TRACE_EVENT0(category_group, name) \ 225 #define TRACE_EVENT0(category_group, name) \
226 INTERNAL_TRACE_MEMORY(category_group, name) \ 226 INTERNAL_TRACE_MEMORY(category_group, name) \
227 INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name) 227 INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name)
228 #define TRACE_EVENT_WITH_FLOW0(category_group, name, bind_id, flow_direction) \
vmpstr 2015/07/16 21:30:11 nit: I think bind_id should be named flow_id here
229 INTERNAL_TRACE_MEMORY(category_group, name) \
230 INTERNAL_TRACE_EVENT_ADD_SCOPED_WITH_FLOW(category_group, name, bind_id, flo w_direction)
vmpstr 2015/07/16 21:30:11 nit: run this through clang-format please (git cl
228 #define TRACE_EVENT1(category_group, name, arg1_name, arg1_val) \ 231 #define TRACE_EVENT1(category_group, name, arg1_name, arg1_val) \
229 INTERNAL_TRACE_MEMORY(category_group, name) \ 232 INTERNAL_TRACE_MEMORY(category_group, name) \
230 INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, arg1_name, arg1_val) 233 INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, arg1_name, arg1_val)
234 #define TRACE_EVENT_WITH_FLOW1(category_group, name, bind_id, flow_direction, ar g1_name, arg1_val) \
235 INTERNAL_TRACE_MEMORY(category_group, name) \
236 INTERNAL_TRACE_EVENT_ADD_SCOPED_WITH_FLOW(category_group, name, bind_id, flo w_direction, arg1_name, arg1_val)
231 #define TRACE_EVENT2( \ 237 #define TRACE_EVENT2( \
232 category_group, name, arg1_name, arg1_val, arg2_name, arg2_val) \ 238 category_group, name, arg1_name, arg1_val, arg2_name, arg2_val) \
233 INTERNAL_TRACE_MEMORY(category_group, name) \ 239 INTERNAL_TRACE_MEMORY(category_group, name) \
234 INTERNAL_TRACE_EVENT_ADD_SCOPED( \ 240 INTERNAL_TRACE_EVENT_ADD_SCOPED( \
235 category_group, name, arg1_name, arg1_val, arg2_name, arg2_val) 241 category_group, name, arg1_name, arg1_val, arg2_name, arg2_val)
242 #define TRACE_EVENT_WITH_FLOW2( \
243 category_group, name, bind_id, flow_direction, arg1_name, arg1_val, arg2_nam e, arg2_val) \
244 INTERNAL_TRACE_MEMORY(category_group, name) \
245 INTERNAL_TRACE_EVENT_ADD_SCOPED_WITH_FLOW( \
246 category_group, name, bind_id, flow_direction, arg1_name, arg1_val, arg2_n ame, arg2_val)
236 247
237 // Records events like TRACE_EVENT2 but uses |memory_tag| for memory tracing. 248 // Records events like TRACE_EVENT2 but uses |memory_tag| for memory tracing.
238 // Use this where |name| is too generic to accurately aggregate allocations. 249 // Use this where |name| is too generic to accurately aggregate allocations.
239 #define TRACE_EVENT_WITH_MEMORY_TAG2( \ 250 #define TRACE_EVENT_WITH_MEMORY_TAG2( \
240 category, name, memory_tag, arg1_name, arg1_val, arg2_name, arg2_val) \ 251 category, name, memory_tag, arg1_name, arg1_val, arg2_name, arg2_val) \
241 INTERNAL_TRACE_MEMORY(category, memory_tag) \ 252 INTERNAL_TRACE_MEMORY(category, memory_tag) \
242 INTERNAL_TRACE_EVENT_ADD_SCOPED( \ 253 INTERNAL_TRACE_EVENT_ADD_SCOPED( \
243 category, name, arg1_name, arg1_val, arg2_name, arg2_val) 254 category, name, arg1_name, arg1_val, arg2_name, arg2_val)
244 255
245 // UNSHIPPED_TRACE_EVENT* are like TRACE_EVENT* except that they are not 256 // UNSHIPPED_TRACE_EVENT* are like TRACE_EVENT* except that they are not
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 INTERNAL_TRACE_EVENT_UID(category_group_enabled)); 1059 INTERNAL_TRACE_EVENT_UID(category_group_enabled));
1049 1060
1050 // Implementation detail: internal macro to create static category and add 1061 // Implementation detail: internal macro to create static category and add
1051 // event if the category is enabled. 1062 // event if the category is enabled.
1052 #define INTERNAL_TRACE_EVENT_ADD(phase, category_group, name, flags, ...) \ 1063 #define INTERNAL_TRACE_EVENT_ADD(phase, category_group, name, flags, ...) \
1053 do { \ 1064 do { \
1054 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ 1065 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \
1055 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ 1066 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \
1056 trace_event_internal::AddTraceEvent( \ 1067 trace_event_internal::AddTraceEvent( \
1057 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ 1068 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \
1058 trace_event_internal::kNoEventId, flags, ##__VA_ARGS__); \ 1069 trace_event_internal::kNoEventId, flags, \
1070 trace_event_internal::kNoBindId, ##__VA_ARGS__); \
1059 } \ 1071 } \
1060 } while (0) 1072 } while (0)
1061 1073
1062 // Implementation detail: internal macro to create static category and add begin 1074 // Implementation detail: internal macro to create static category and add begin
1063 // event if the category is enabled. Also adds the end event when the scope 1075 // event if the category is enabled. Also adds the end event when the scope
1064 // ends. 1076 // ends.
1065 #define INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, ...) \ 1077 #define INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, ...) \
1066 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ 1078 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \
1067 trace_event_internal::ScopedTracer INTERNAL_TRACE_EVENT_UID(tracer); \ 1079 trace_event_internal::ScopedTracer INTERNAL_TRACE_EVENT_UID(tracer); \
1068 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ 1080 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \
1069 base::trace_event::TraceEventHandle h = \ 1081 base::trace_event::TraceEventHandle h = \
1070 trace_event_internal::AddTraceEvent( \ 1082 trace_event_internal::AddTraceEvent( \
1071 TRACE_EVENT_PHASE_COMPLETE, \ 1083 TRACE_EVENT_PHASE_COMPLETE, \
1072 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ 1084 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \
1073 trace_event_internal::kNoEventId, TRACE_EVENT_FLAG_NONE, \ 1085 trace_event_internal::kNoEventId, TRACE_EVENT_FLAG_NONE, \
1074 ##__VA_ARGS__); \ 1086 trace_event_internal::kNoBindId, ##__VA_ARGS__); \
1075 INTERNAL_TRACE_EVENT_UID(tracer).Initialize( \ 1087 INTERNAL_TRACE_EVENT_UID(tracer).Initialize( \
1076 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, h); \ 1088 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, h); \
1077 } 1089 }
1090
1091 #define INTERNAL_TRACE_EVENT_ADD_SCOPED_WITH_FLOW(category_group, name, bind_id, flow_direction, ...) \
1092 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \
1093 trace_event_internal::ScopedTracer INTERNAL_TRACE_EVENT_UID(tracer); \
1094 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \
1095 base::trace_event::TraceEventHandle h = \
1096 trace_event_internal::AddTraceEvent( \
1097 TRACE_EVENT_PHASE_COMPLETE, \
1098 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \
1099 trace_event_internal::kNoEventId, flow_direction, \
1100 bind_id, ##__VA_ARGS__); \
1101 INTERNAL_TRACE_EVENT_UID(tracer).Initialize( \
1102 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, h); \
1103 }
1078 1104
1079 // Implementation detail: internal macro to create static category and add 1105 // Implementation detail: internal macro to create static category and add
1080 // event if the category is enabled. 1106 // event if the category is enabled.
1081 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category_group, name, id, \ 1107 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category_group, name, id, \
1082 flags, ...) \ 1108 flags, ...) \
1083 do { \ 1109 do { \
1084 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ 1110 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \
1085 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ 1111 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \
1086 unsigned int trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ 1112 unsigned int trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \
1087 trace_event_internal::TraceID trace_event_trace_id( \ 1113 trace_event_internal::TraceID trace_event_trace_id( \
1088 id, &trace_event_flags); \ 1114 id, &trace_event_flags); \
1089 trace_event_internal::AddTraceEvent( \ 1115 trace_event_internal::AddTraceEvent( \
1090 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ 1116 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \
1091 name, trace_event_trace_id.data(), trace_event_flags, \ 1117 name, trace_event_trace_id.data(), trace_event_flags, \
1092 ##__VA_ARGS__); \ 1118 trace_event_internal::kNoBindId, ##__VA_ARGS__); \
1093 } \ 1119 } \
1094 } while (0) 1120 } while (0)
1095 1121
1096 // Implementation detail: internal macro to create static category and add 1122 // Implementation detail: internal macro to create static category and add
1097 // event if the category is enabled. 1123 // event if the category is enabled.
1098 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP(phase, \ 1124 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP(phase, \
1099 category_group, name, id, thread_id, timestamp, flags, ...) \ 1125 category_group, name, id, thread_id, timestamp, flags, ...) \
1100 do { \ 1126 do { \
1101 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ 1127 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \
1102 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ 1128 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \
1103 unsigned int trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ 1129 unsigned int trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \
1104 trace_event_internal::TraceID trace_event_trace_id( \ 1130 trace_event_internal::TraceID trace_event_trace_id( \
1105 id, &trace_event_flags); \ 1131 id, &trace_event_flags); \
1106 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ 1132 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \
1107 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ 1133 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \
1108 name, trace_event_trace_id.data(), \ 1134 name, trace_event_trace_id.data(), \
1109 thread_id, base::TraceTicks::FromInternalValue(timestamp), \ 1135 thread_id, base::TraceTicks::FromInternalValue(timestamp), \
1110 trace_event_flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \ 1136 trace_event_flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \
1111 ##__VA_ARGS__); \ 1137 trace_event_internal::kNoBindId, ##__VA_ARGS__); \
1112 } \ 1138 } \
1113 } while (0) 1139 } while (0)
1114 1140
1115 // Notes regarding the following definitions: 1141 // Notes regarding the following definitions:
1116 // New values can be added and propagated to third party libraries, but existing 1142 // New values can be added and propagated to third party libraries, but existing
1117 // definitions must never be changed, because third party libraries may use old 1143 // definitions must never be changed, because third party libraries may use old
1118 // definitions. 1144 // definitions.
1119 1145
1120 // Phase indicates the nature of an event entry. E.g. part of a begin/end pair. 1146 // Phase indicates the nature of an event entry. E.g. part of a begin/end pair.
1121 #define TRACE_EVENT_PHASE_BEGIN ('B') 1147 #define TRACE_EVENT_PHASE_BEGIN ('B')
(...skipping 21 matching lines...) Expand all
1143 // Flags for changing the behavior of TRACE_EVENT_API_ADD_TRACE_EVENT. 1169 // Flags for changing the behavior of TRACE_EVENT_API_ADD_TRACE_EVENT.
1144 #define TRACE_EVENT_FLAG_NONE (static_cast<unsigned int>(0)) 1170 #define TRACE_EVENT_FLAG_NONE (static_cast<unsigned int>(0))
1145 #define TRACE_EVENT_FLAG_COPY (static_cast<unsigned int>(1 << 0)) 1171 #define TRACE_EVENT_FLAG_COPY (static_cast<unsigned int>(1 << 0))
1146 #define TRACE_EVENT_FLAG_HAS_ID (static_cast<unsigned int>(1 << 1)) 1172 #define TRACE_EVENT_FLAG_HAS_ID (static_cast<unsigned int>(1 << 1))
1147 #define TRACE_EVENT_FLAG_MANGLE_ID (static_cast<unsigned int>(1 << 2)) 1173 #define TRACE_EVENT_FLAG_MANGLE_ID (static_cast<unsigned int>(1 << 2))
1148 #define TRACE_EVENT_FLAG_SCOPE_OFFSET (static_cast<unsigned int>(1 << 3)) 1174 #define TRACE_EVENT_FLAG_SCOPE_OFFSET (static_cast<unsigned int>(1 << 3))
1149 #define TRACE_EVENT_FLAG_SCOPE_EXTRA (static_cast<unsigned int>(1 << 4)) 1175 #define TRACE_EVENT_FLAG_SCOPE_EXTRA (static_cast<unsigned int>(1 << 4))
1150 #define TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP (static_cast<unsigned int>(1 << 5)) 1176 #define TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP (static_cast<unsigned int>(1 << 5))
1151 #define TRACE_EVENT_FLAG_ASYNC_TTS (static_cast<unsigned int>(1 << 6)) 1177 #define TRACE_EVENT_FLAG_ASYNC_TTS (static_cast<unsigned int>(1 << 6))
1152 #define TRACE_EVENT_FLAG_BIND_TO_ENCLOSING (static_cast<unsigned int>(1 << 7)) 1178 #define TRACE_EVENT_FLAG_BIND_TO_ENCLOSING (static_cast<unsigned int>(1 << 7))
1179 #define TRACE_EVENT_FLAG_FLOW_IN (static_cast<unsigned int>(1 << 8))
1180 #define TRACE_EVENT_FLAG_FLOW_OUT (static_cast<unsigned int>(1 << 9))
1153 1181
1154 #define TRACE_EVENT_FLAG_SCOPE_MASK (static_cast<unsigned int>( \ 1182 #define TRACE_EVENT_FLAG_SCOPE_MASK (static_cast<unsigned int>( \
1155 TRACE_EVENT_FLAG_SCOPE_OFFSET | TRACE_EVENT_FLAG_SCOPE_EXTRA)) 1183 TRACE_EVENT_FLAG_SCOPE_OFFSET | TRACE_EVENT_FLAG_SCOPE_EXTRA))
1156 1184
1157 // Type values for identifying types in the TraceValue union. 1185 // Type values for identifying types in the TraceValue union.
1158 #define TRACE_VALUE_TYPE_BOOL (static_cast<unsigned char>(1)) 1186 #define TRACE_VALUE_TYPE_BOOL (static_cast<unsigned char>(1))
1159 #define TRACE_VALUE_TYPE_UINT (static_cast<unsigned char>(2)) 1187 #define TRACE_VALUE_TYPE_UINT (static_cast<unsigned char>(2))
1160 #define TRACE_VALUE_TYPE_INT (static_cast<unsigned char>(3)) 1188 #define TRACE_VALUE_TYPE_INT (static_cast<unsigned char>(3))
1161 #define TRACE_VALUE_TYPE_DOUBLE (static_cast<unsigned char>(4)) 1189 #define TRACE_VALUE_TYPE_DOUBLE (static_cast<unsigned char>(4))
1162 #define TRACE_VALUE_TYPE_POINTER (static_cast<unsigned char>(5)) 1190 #define TRACE_VALUE_TYPE_POINTER (static_cast<unsigned char>(5))
(...skipping 10 matching lines...) Expand all
1173 #define TRACE_EVENT_SCOPE_NAME_GLOBAL ('g') 1201 #define TRACE_EVENT_SCOPE_NAME_GLOBAL ('g')
1174 #define TRACE_EVENT_SCOPE_NAME_PROCESS ('p') 1202 #define TRACE_EVENT_SCOPE_NAME_PROCESS ('p')
1175 #define TRACE_EVENT_SCOPE_NAME_THREAD ('t') 1203 #define TRACE_EVENT_SCOPE_NAME_THREAD ('t')
1176 1204
1177 namespace trace_event_internal { 1205 namespace trace_event_internal {
1178 1206
1179 // Specify these values when the corresponding argument of AddTraceEvent is not 1207 // Specify these values when the corresponding argument of AddTraceEvent is not
1180 // used. 1208 // used.
1181 const int kZeroNumArgs = 0; 1209 const int kZeroNumArgs = 0;
1182 const unsigned long long kNoEventId = 0; 1210 const unsigned long long kNoEventId = 0;
1211 const unsigned long long kNoBindId = 0;
1183 1212
1184 // TraceID encapsulates an ID that can either be an integer or pointer. Pointers 1213 // TraceID encapsulates an ID that can either be an integer or pointer. Pointers
1185 // are by default mangled with the Process ID so that they are unlikely to 1214 // are by default mangled with the Process ID so that they are unlikely to
1186 // collide when the same pointer is used on different processes. 1215 // collide when the same pointer is used on different processes.
1187 class TraceID { 1216 class TraceID {
1188 public: 1217 public:
1189 class DontMangle { 1218 class DontMangle {
1190 public: 1219 public:
1191 explicit DontMangle(const void* id) 1220 explicit DontMangle(const void* id)
1192 : data_(static_cast<unsigned long long>( 1221 : data_(static_cast<unsigned long long>(
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 1415
1387 static inline base::trace_event::TraceEventHandle 1416 static inline base::trace_event::TraceEventHandle
1388 AddTraceEventWithThreadIdAndTimestamp( 1417 AddTraceEventWithThreadIdAndTimestamp(
1389 char phase, 1418 char phase,
1390 const unsigned char* category_group_enabled, 1419 const unsigned char* category_group_enabled,
1391 const char* name, 1420 const char* name,
1392 unsigned long long id, 1421 unsigned long long id,
1393 int thread_id, 1422 int thread_id,
1394 const base::TraceTicks& timestamp, 1423 const base::TraceTicks& timestamp,
1395 unsigned int flags, 1424 unsigned int flags,
1425 unsigned long long bind_id,
1396 const char* arg1_name, 1426 const char* arg1_name,
1397 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& 1427 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>&
1398 arg1_val) { 1428 arg1_val) {
1399 const int num_args = 1; 1429 const int num_args = 1;
1400 unsigned char arg_types[1] = { TRACE_VALUE_TYPE_CONVERTABLE }; 1430 unsigned char arg_types[1] = { TRACE_VALUE_TYPE_CONVERTABLE };
1401 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( 1431 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(
1402 phase, category_group_enabled, name, id, thread_id, timestamp, 1432 phase, category_group_enabled, name, id, thread_id, timestamp,
1403 num_args, &arg1_name, arg_types, NULL, &arg1_val, flags); 1433 num_args, &arg1_name, arg_types, NULL, &arg1_val, flags, bind_id);
1404 } 1434 }
1405 1435
1406 template<class ARG1_TYPE> 1436 template<class ARG1_TYPE>
1407 static inline base::trace_event::TraceEventHandle 1437 static inline base::trace_event::TraceEventHandle
1408 AddTraceEventWithThreadIdAndTimestamp( 1438 AddTraceEventWithThreadIdAndTimestamp(
1409 char phase, 1439 char phase,
1410 const unsigned char* category_group_enabled, 1440 const unsigned char* category_group_enabled,
1411 const char* name, 1441 const char* name,
1412 unsigned long long id, 1442 unsigned long long id,
1413 int thread_id, 1443 int thread_id,
1414 const base::TraceTicks& timestamp, 1444 const base::TraceTicks& timestamp,
1415 unsigned int flags, 1445 unsigned int flags,
1446 unsigned long long bind_id,
1416 const char* arg1_name, 1447 const char* arg1_name,
1417 const ARG1_TYPE& arg1_val, 1448 const ARG1_TYPE& arg1_val,
1418 const char* arg2_name, 1449 const char* arg2_name,
1419 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& 1450 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>&
1420 arg2_val) { 1451 arg2_val) {
1421 const int num_args = 2; 1452 const int num_args = 2;
1422 const char* arg_names[2] = { arg1_name, arg2_name }; 1453 const char* arg_names[2] = { arg1_name, arg2_name };
1423 1454
1424 unsigned char arg_types[2]; 1455 unsigned char arg_types[2];
1425 unsigned long long arg_values[2]; 1456 unsigned long long arg_values[2];
1426 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); 1457 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]);
1427 arg_types[1] = TRACE_VALUE_TYPE_CONVERTABLE; 1458 arg_types[1] = TRACE_VALUE_TYPE_CONVERTABLE;
1428 1459
1429 scoped_refptr<base::trace_event::ConvertableToTraceFormat> 1460 scoped_refptr<base::trace_event::ConvertableToTraceFormat>
1430 convertable_values[2]; 1461 convertable_values[2];
1431 convertable_values[1] = arg2_val; 1462 convertable_values[1] = arg2_val;
1432 1463
1433 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( 1464 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(
1434 phase, category_group_enabled, name, id, thread_id, timestamp, 1465 phase, category_group_enabled, name, id, thread_id, timestamp,
1435 num_args, arg_names, arg_types, arg_values, convertable_values, flags); 1466 num_args, arg_names, arg_types, arg_values, convertable_values, flags, bin d_id);
1436 } 1467 }
1437 1468
1438 template<class ARG2_TYPE> 1469 template<class ARG2_TYPE>
1439 static inline base::trace_event::TraceEventHandle 1470 static inline base::trace_event::TraceEventHandle
1440 AddTraceEventWithThreadIdAndTimestamp( 1471 AddTraceEventWithThreadIdAndTimestamp(
1441 char phase, 1472 char phase,
1442 const unsigned char* category_group_enabled, 1473 const unsigned char* category_group_enabled,
1443 const char* name, 1474 const char* name,
1444 unsigned long long id, 1475 unsigned long long id,
1445 int thread_id, 1476 int thread_id,
1446 const base::TraceTicks& timestamp, 1477 const base::TraceTicks& timestamp,
1447 unsigned int flags, 1478 unsigned int flags,
1479 unsigned long long bind_id,
1448 const char* arg1_name, 1480 const char* arg1_name,
1449 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& arg1_val, 1481 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& arg1_val,
1450 const char* arg2_name, 1482 const char* arg2_name,
1451 const ARG2_TYPE& arg2_val) { 1483 const ARG2_TYPE& arg2_val) {
1452 const int num_args = 2; 1484 const int num_args = 2;
1453 const char* arg_names[2] = { arg1_name, arg2_name }; 1485 const char* arg_names[2] = { arg1_name, arg2_name };
1454 1486
1455 unsigned char arg_types[2]; 1487 unsigned char arg_types[2];
1456 unsigned long long arg_values[2]; 1488 unsigned long long arg_values[2];
1457 arg_types[0] = TRACE_VALUE_TYPE_CONVERTABLE; 1489 arg_types[0] = TRACE_VALUE_TYPE_CONVERTABLE;
1458 arg_values[0] = 0; 1490 arg_values[0] = 0;
1459 SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]); 1491 SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]);
1460 1492
1461 scoped_refptr<base::trace_event::ConvertableToTraceFormat> 1493 scoped_refptr<base::trace_event::ConvertableToTraceFormat>
1462 convertable_values[2]; 1494 convertable_values[2];
1463 convertable_values[0] = arg1_val; 1495 convertable_values[0] = arg1_val;
1464 1496
1465 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( 1497 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(
1466 phase, category_group_enabled, name, id, thread_id, timestamp, 1498 phase, category_group_enabled, name, id, thread_id, timestamp,
1467 num_args, arg_names, arg_types, arg_values, convertable_values, flags); 1499 num_args, arg_names, arg_types, arg_values, convertable_values, flags, bin d_id);
1468 } 1500 }
1469 1501
1470 static inline base::trace_event::TraceEventHandle 1502 static inline base::trace_event::TraceEventHandle
1471 AddTraceEventWithThreadIdAndTimestamp( 1503 AddTraceEventWithThreadIdAndTimestamp(
1472 char phase, 1504 char phase,
1473 const unsigned char* category_group_enabled, 1505 const unsigned char* category_group_enabled,
1474 const char* name, 1506 const char* name,
1475 unsigned long long id, 1507 unsigned long long id,
1476 int thread_id, 1508 int thread_id,
1477 const base::TraceTicks& timestamp, 1509 const base::TraceTicks& timestamp,
1478 unsigned int flags, 1510 unsigned int flags,
1511 unsigned long long bind_id,
1479 const char* arg1_name, 1512 const char* arg1_name,
1480 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& arg1_val, 1513 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& arg1_val,
1481 const char* arg2_name, 1514 const char* arg2_name,
1482 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& 1515 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>&
1483 arg2_val) { 1516 arg2_val) {
1484 const int num_args = 2; 1517 const int num_args = 2;
1485 const char* arg_names[2] = { arg1_name, arg2_name }; 1518 const char* arg_names[2] = { arg1_name, arg2_name };
1486 unsigned char arg_types[2] = 1519 unsigned char arg_types[2] =
1487 { TRACE_VALUE_TYPE_CONVERTABLE, TRACE_VALUE_TYPE_CONVERTABLE }; 1520 { TRACE_VALUE_TYPE_CONVERTABLE, TRACE_VALUE_TYPE_CONVERTABLE };
1488 scoped_refptr<base::trace_event::ConvertableToTraceFormat> 1521 scoped_refptr<base::trace_event::ConvertableToTraceFormat>
1489 convertable_values[2] = {arg1_val, arg2_val}; 1522 convertable_values[2] = {arg1_val, arg2_val};
1490 1523
1491 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( 1524 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(
1492 phase, category_group_enabled, name, id, thread_id, timestamp, 1525 phase, category_group_enabled, name, id, thread_id, timestamp,
1493 num_args, arg_names, arg_types, NULL, convertable_values, flags); 1526 num_args, arg_names, arg_types, NULL, convertable_values, flags, bind_id);
1494 } 1527 }
1495 1528
1496 static inline base::trace_event::TraceEventHandle 1529 static inline base::trace_event::TraceEventHandle
1497 AddTraceEventWithThreadIdAndTimestamp( 1530 AddTraceEventWithThreadIdAndTimestamp(
1498 char phase, 1531 char phase,
1499 const unsigned char* category_group_enabled, 1532 const unsigned char* category_group_enabled,
1500 const char* name, 1533 const char* name,
1501 unsigned long long id, 1534 unsigned long long id,
1502 int thread_id, 1535 int thread_id,
1503 const base::TraceTicks& timestamp, 1536 const base::TraceTicks& timestamp,
1504 unsigned int flags) { 1537 unsigned int flags,
1538 unsigned long long bind_id) {
1505 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( 1539 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(
1506 phase, category_group_enabled, name, id, thread_id, timestamp, 1540 phase, category_group_enabled, name, id, thread_id, timestamp,
1507 kZeroNumArgs, NULL, NULL, NULL, NULL, flags); 1541 kZeroNumArgs, NULL, NULL, NULL, NULL, flags, bind_id);
1508 } 1542 }
1509 1543
1510 static inline base::trace_event::TraceEventHandle AddTraceEvent( 1544 static inline base::trace_event::TraceEventHandle AddTraceEvent(
1511 char phase, 1545 char phase,
1512 const unsigned char* category_group_enabled, 1546 const unsigned char* category_group_enabled,
1513 const char* name, 1547 const char* name,
1514 unsigned long long id, 1548 unsigned long long id,
1515 unsigned int flags) { 1549 unsigned int flags,
1550 unsigned long long bind_id) {
1516 const int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); 1551 const int thread_id = static_cast<int>(base::PlatformThread::CurrentId());
1517 const base::TraceTicks now = base::TraceTicks::Now(); 1552 const base::TraceTicks now = base::TraceTicks::Now();
1518 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, 1553 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled,
1519 name, id, thread_id, now, flags); 1554 name, id, thread_id, now, flags,
1555 bind_id);
1520 } 1556 }
1521 1557
1522 template<class ARG1_TYPE> 1558 template<class ARG1_TYPE>
1523 static inline base::trace_event::TraceEventHandle 1559 static inline base::trace_event::TraceEventHandle
1524 AddTraceEventWithThreadIdAndTimestamp( 1560 AddTraceEventWithThreadIdAndTimestamp(
1525 char phase, 1561 char phase,
1526 const unsigned char* category_group_enabled, 1562 const unsigned char* category_group_enabled,
1527 const char* name, 1563 const char* name,
1528 unsigned long long id, 1564 unsigned long long id,
1529 int thread_id, 1565 int thread_id,
1530 const base::TraceTicks& timestamp, 1566 const base::TraceTicks& timestamp,
1531 unsigned int flags, 1567 unsigned int flags,
1568 unsigned long long bind_id,
1532 const char* arg1_name, 1569 const char* arg1_name,
1533 const ARG1_TYPE& arg1_val) { 1570 const ARG1_TYPE& arg1_val) {
1534 const int num_args = 1; 1571 const int num_args = 1;
1535 unsigned char arg_types[1]; 1572 unsigned char arg_types[1];
1536 unsigned long long arg_values[1]; 1573 unsigned long long arg_values[1];
1537 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); 1574 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]);
1538 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( 1575 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(
1539 phase, category_group_enabled, name, id, thread_id, timestamp, 1576 phase, category_group_enabled, name, id, thread_id, timestamp,
1540 num_args, &arg1_name, arg_types, arg_values, NULL, flags); 1577 num_args, &arg1_name, arg_types, arg_values, NULL, flags, bind_id);
1541 } 1578 }
1542 1579
1543 template<class ARG1_TYPE> 1580 template<class ARG1_TYPE>
1544 static inline base::trace_event::TraceEventHandle AddTraceEvent( 1581 static inline base::trace_event::TraceEventHandle AddTraceEvent(
1545 char phase, 1582 char phase,
1546 const unsigned char* category_group_enabled, 1583 const unsigned char* category_group_enabled,
1547 const char* name, 1584 const char* name,
1548 unsigned long long id, 1585 unsigned long long id,
1549 unsigned int flags, 1586 unsigned int flags,
1587 unsigned long long bind_id,
1550 const char* arg1_name, 1588 const char* arg1_name,
1551 const ARG1_TYPE& arg1_val) { 1589 const ARG1_TYPE& arg1_val) {
1552 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); 1590 int thread_id = static_cast<int>(base::PlatformThread::CurrentId());
1553 base::TraceTicks now = base::TraceTicks::Now(); 1591 base::TraceTicks now = base::TraceTicks::Now();
1554 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, 1592 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled,
1555 name, id, thread_id, now, flags, 1593 name, id, thread_id, now, flags,
1594 bind_id,
1556 arg1_name, arg1_val); 1595 arg1_name, arg1_val);
1557 } 1596 }
1558 1597
1559 template<class ARG1_TYPE, class ARG2_TYPE> 1598 template<class ARG1_TYPE, class ARG2_TYPE>
1560 static inline base::trace_event::TraceEventHandle 1599 static inline base::trace_event::TraceEventHandle
1561 AddTraceEventWithThreadIdAndTimestamp( 1600 AddTraceEventWithThreadIdAndTimestamp(
1562 char phase, 1601 char phase,
1563 const unsigned char* category_group_enabled, 1602 const unsigned char* category_group_enabled,
1564 const char* name, 1603 const char* name,
1565 unsigned long long id, 1604 unsigned long long id,
1566 int thread_id, 1605 int thread_id,
1567 const base::TraceTicks& timestamp, 1606 const base::TraceTicks& timestamp,
1568 unsigned int flags, 1607 unsigned int flags,
1608 unsigned long long bind_id,
1569 const char* arg1_name, 1609 const char* arg1_name,
1570 const ARG1_TYPE& arg1_val, 1610 const ARG1_TYPE& arg1_val,
1571 const char* arg2_name, 1611 const char* arg2_name,
1572 const ARG2_TYPE& arg2_val) { 1612 const ARG2_TYPE& arg2_val) {
1573 const int num_args = 2; 1613 const int num_args = 2;
1574 const char* arg_names[2] = { arg1_name, arg2_name }; 1614 const char* arg_names[2] = { arg1_name, arg2_name };
1575 unsigned char arg_types[2]; 1615 unsigned char arg_types[2];
1576 unsigned long long arg_values[2]; 1616 unsigned long long arg_values[2];
1577 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); 1617 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]);
1578 SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]); 1618 SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]);
1579 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( 1619 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(
1580 phase, category_group_enabled, name, id, thread_id, timestamp, 1620 phase, category_group_enabled, name, id, thread_id, timestamp,
1581 num_args, arg_names, arg_types, arg_values, NULL, flags); 1621 num_args, arg_names, arg_types, arg_values, NULL, flags, bind_id);
1582 } 1622 }
1583 1623
1584 template<class ARG1_TYPE, class ARG2_TYPE> 1624 template<class ARG1_TYPE, class ARG2_TYPE>
1585 static inline base::trace_event::TraceEventHandle AddTraceEvent( 1625 static inline base::trace_event::TraceEventHandle AddTraceEvent(
1586 char phase, 1626 char phase,
1587 const unsigned char* category_group_enabled, 1627 const unsigned char* category_group_enabled,
1588 const char* name, 1628 const char* name,
1589 unsigned long long id, 1629 unsigned long long id,
1590 unsigned int flags, 1630 unsigned int flags,
1631 unsigned long long bind_id,
1591 const char* arg1_name, 1632 const char* arg1_name,
1592 const ARG1_TYPE& arg1_val, 1633 const ARG1_TYPE& arg1_val,
1593 const char* arg2_name, 1634 const char* arg2_name,
1594 const ARG2_TYPE& arg2_val) { 1635 const ARG2_TYPE& arg2_val) {
1595 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); 1636 int thread_id = static_cast<int>(base::PlatformThread::CurrentId());
1596 base::TraceTicks now = base::TraceTicks::Now(); 1637 base::TraceTicks now = base::TraceTicks::Now();
1597 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, 1638 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled,
1598 name, id, thread_id, now, flags, 1639 name, id, thread_id, now, flags,
1640 bind_id,
1599 arg1_name, arg1_val, 1641 arg1_name, arg1_val,
1600 arg2_name, arg2_val); 1642 arg2_name, arg2_val);
1601 } 1643 }
1602 1644
1603 // Used by TRACE_EVENTx macros. Do not use directly. 1645 // Used by TRACE_EVENTx macros. Do not use directly.
1604 class TRACE_EVENT_API_CLASS_EXPORT ScopedTracer { 1646 class TRACE_EVENT_API_CLASS_EXPORT ScopedTracer {
1605 public: 1647 public:
1606 // Note: members of data_ intentionally left uninitialized. See Initialize. 1648 // Note: members of data_ intentionally left uninitialized. See Initialize.
1607 ScopedTracer() : p_data_(NULL) {} 1649 ScopedTracer() : p_data_(NULL) {}
1608 1650
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1716 const char* name_; 1758 const char* name_;
1717 IDType id_; 1759 IDType id_;
1718 1760
1719 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); 1761 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject);
1720 }; 1762 };
1721 1763
1722 } // namespace trace_event 1764 } // namespace trace_event
1723 } // namespace base 1765 } // namespace base
1724 1766
1725 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ 1767 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_
OLDNEW
« no previous file with comments | « no previous file | base/trace_event/trace_event_impl.h » ('j') | base/trace_event/trace_event_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698