OLD | NEW |
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 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 category_group, name, id, TRACE_EVENT_FLAG_NONE) | 724 category_group, name, id, TRACE_EVENT_FLAG_NONE) |
725 #define TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(category_group, name, id, arg1_name, \ | 725 #define TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(category_group, name, id, arg1_name, \ |
726 arg1_val) \ | 726 arg1_val) \ |
727 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, \ | 727 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, \ |
728 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) | 728 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) |
729 #define TRACE_EVENT_NESTABLE_ASYNC_BEGIN2(category_group, name, id, arg1_name, \ | 729 #define TRACE_EVENT_NESTABLE_ASYNC_BEGIN2(category_group, name, id, arg1_name, \ |
730 arg1_val, arg2_name, arg2_val) \ | 730 arg1_val, arg2_name, arg2_val) \ |
731 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, \ | 731 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, \ |
732 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ | 732 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ |
733 arg2_name, arg2_val) | 733 arg2_name, arg2_val) |
734 // Records a single NESTABLE_ASYNC_END event called "name" immediately, with 0, | 734 // Records a single NESTABLE_ASYNC_END event called "name" immediately, with 0 |
735 // 1, or 2 associated arguments. If the category is not enabled, then this does | 735 // or 2 associated arguments. If the category is not enabled, then this does |
736 // nothing. | 736 // nothing. |
737 #define TRACE_EVENT_NESTABLE_ASYNC_END0(category_group, name, id) \ | 737 #define TRACE_EVENT_NESTABLE_ASYNC_END0(category_group, name, id) \ |
738 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, \ | 738 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, \ |
739 category_group, name, id, TRACE_EVENT_FLAG_NONE) | 739 category_group, name, id, TRACE_EVENT_FLAG_NONE) |
740 #define TRACE_EVENT_NESTABLE_ASYNC_END1(category_group, name, id, arg1_name, \ | |
741 arg1_val) \ | |
742 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, \ | |
743 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) | |
744 #define TRACE_EVENT_NESTABLE_ASYNC_END2(category_group, name, id, arg1_name, \ | 740 #define TRACE_EVENT_NESTABLE_ASYNC_END2(category_group, name, id, arg1_name, \ |
745 arg1_val, arg2_name, arg2_val) \ | 741 arg1_val, arg2_name, arg2_val) \ |
746 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, \ | 742 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, \ |
747 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ | 743 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ |
748 arg2_name, arg2_val) | 744 arg2_name, arg2_val) |
749 | 745 |
750 #define TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TTS2(category_group, name, \ | 746 #define TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TTS2(category_group, name, \ |
751 id, arg1_name, arg1_val, arg2_name, arg2_val) \ | 747 id, arg1_name, arg1_val, arg2_name, arg2_val) \ |
752 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, \ | 748 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, \ |
753 category_group, name, id, \ | 749 category_group, name, id, \ |
754 TRACE_EVENT_FLAG_ASYNC_TTS | TRACE_EVENT_FLAG_COPY, \ | 750 TRACE_EVENT_FLAG_ASYNC_TTS | TRACE_EVENT_FLAG_COPY, \ |
755 arg1_name, arg1_val, arg2_name, arg2_val) | 751 arg1_name, arg1_val, arg2_name, arg2_val) |
756 #define TRACE_EVENT_COPY_NESTABLE_ASYNC_END_WITH_TTS2(category_group, name, \ | 752 #define TRACE_EVENT_COPY_NESTABLE_ASYNC_END_WITH_TTS2(category_group, name, \ |
757 id, arg1_name, arg1_val, arg2_name, arg2_val) \ | 753 id, arg1_name, arg1_val, arg2_name, arg2_val) \ |
758 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, \ | 754 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, \ |
759 category_group, name, id, \ | 755 category_group, name, id, \ |
760 TRACE_EVENT_FLAG_ASYNC_TTS | TRACE_EVENT_FLAG_COPY, \ | 756 TRACE_EVENT_FLAG_ASYNC_TTS | TRACE_EVENT_FLAG_COPY, \ |
761 arg1_name, arg1_val, arg2_name, arg2_val) | 757 arg1_name, arg1_val, arg2_name, arg2_val) |
762 | 758 |
| 759 // Similar to TRACE_EVENT_NESTABLE_ASYNC_{BEGIN,END}x but with a custom |
| 760 // |timestamp| provided. |
| 761 #define TRACE_EVENT_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP0(category_group, name, \ |
| 762 id, timestamp) \ |
| 763 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ |
| 764 TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, category_group, name, id, \ |
| 765 static_cast<int>(base::PlatformThread::CurrentId()), timestamp, \ |
| 766 TRACE_EVENT_FLAG_NONE) |
| 767 |
| 768 #define TRACE_EVENT_NESTABLE_ASYNC_END_WITH_TIMESTAMP0(category_group, name, \ |
| 769 id, timestamp) \ |
| 770 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ |
| 771 TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, category_group, name, id, \ |
| 772 static_cast<int>(base::PlatformThread::CurrentId()), timestamp, \ |
| 773 TRACE_EVENT_FLAG_NONE) |
| 774 |
763 // Records a single NESTABLE_ASYNC_INSTANT event called "name" immediately, | 775 // Records a single NESTABLE_ASYNC_INSTANT event called "name" immediately, |
764 // with 2 associated arguments. If the category is not enabled, then this | 776 // with 2 associated arguments. If the category is not enabled, then this |
765 // does nothing. | 777 // does nothing. |
766 #define TRACE_EVENT_NESTABLE_ASYNC_INSTANT2(category_group, name, id, \ | 778 #define TRACE_EVENT_NESTABLE_ASYNC_INSTANT2(category_group, name, id, \ |
767 arg1_name, arg1_val, arg2_name, arg2_val) \ | 779 arg1_name, arg1_val, arg2_name, arg2_val) \ |
768 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_INSTANT, \ | 780 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_INSTANT, \ |
769 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ | 781 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ |
770 arg2_name, arg2_val) | 782 arg2_name, arg2_val) |
771 | 783 |
772 // Records a single FLOW_BEGIN event called "name" immediately, with 0, 1 or 2 | 784 // Records a single FLOW_BEGIN event called "name" immediately, with 0, 1 or 2 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 base::trace_event::TraceLog::GetInstance()->AddTraceEvent | 959 base::trace_event::TraceLog::GetInstance()->AddTraceEvent |
948 | 960 |
949 // Add a trace event to the platform tracing system. | 961 // Add a trace event to the platform tracing system. |
950 // base::trace_event::TraceEventHandle | 962 // base::trace_event::TraceEventHandle |
951 // TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_TIMESTAMP( | 963 // TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_TIMESTAMP( |
952 // char phase, | 964 // char phase, |
953 // const unsigned char* category_group_enabled, | 965 // const unsigned char* category_group_enabled, |
954 // const char* name, | 966 // const char* name, |
955 // unsigned long long id, | 967 // unsigned long long id, |
956 // int thread_id, | 968 // int thread_id, |
957 // const TimeTicks& timestamp, | 969 // const TraceTicks& timestamp, |
958 // int num_args, | 970 // int num_args, |
959 // const char** arg_names, | 971 // const char** arg_names, |
960 // const unsigned char* arg_types, | 972 // const unsigned char* arg_types, |
961 // const unsigned long long* arg_values, | 973 // const unsigned long long* arg_values, |
962 // unsigned char flags) | 974 // unsigned char flags) |
963 #define TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP \ | 975 #define TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP \ |
964 base::trace_event::TraceLog::GetInstance() \ | 976 base::trace_event::TraceLog::GetInstance() \ |
965 ->AddTraceEventWithThreadIdAndTimestamp | 977 ->AddTraceEventWithThreadIdAndTimestamp |
966 | 978 |
967 // Set the duration field of a COMPLETE trace event. | 979 // Set the duration field of a COMPLETE trace event. |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 category_group, name, id, thread_id, timestamp, flags, ...) \ | 1088 category_group, name, id, thread_id, timestamp, flags, ...) \ |
1077 do { \ | 1089 do { \ |
1078 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ | 1090 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
1079 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ | 1091 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ |
1080 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ | 1092 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ |
1081 trace_event_internal::TraceID trace_event_trace_id( \ | 1093 trace_event_internal::TraceID trace_event_trace_id( \ |
1082 id, &trace_event_flags); \ | 1094 id, &trace_event_flags); \ |
1083 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ | 1095 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ |
1084 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ | 1096 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ |
1085 name, trace_event_trace_id.data(), \ | 1097 name, trace_event_trace_id.data(), \ |
1086 thread_id, base::TimeTicks::FromInternalValue(timestamp), \ | 1098 thread_id, base::TraceTicks::FromInternalValue(timestamp), \ |
1087 trace_event_flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \ | 1099 trace_event_flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \ |
1088 ##__VA_ARGS__); \ | 1100 ##__VA_ARGS__); \ |
1089 } \ | 1101 } \ |
1090 } while (0) | 1102 } while (0) |
1091 | 1103 |
1092 // Notes regarding the following definitions: | 1104 // Notes regarding the following definitions: |
1093 // New values can be added and propagated to third party libraries, but existing | 1105 // New values can be added and propagated to third party libraries, but existing |
1094 // definitions must never be changed, because third party libraries may use old | 1106 // definitions must never be changed, because third party libraries may use old |
1095 // definitions. | 1107 // definitions. |
1096 | 1108 |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1317 // std::string version of SetTraceValue so that trace arguments can be strings. | 1329 // std::string version of SetTraceValue so that trace arguments can be strings. |
1318 static inline void SetTraceValue(const std::string& arg, | 1330 static inline void SetTraceValue(const std::string& arg, |
1319 unsigned char* type, | 1331 unsigned char* type, |
1320 unsigned long long* value) { | 1332 unsigned long long* value) { |
1321 TraceValueUnion type_value; | 1333 TraceValueUnion type_value; |
1322 type_value.as_string = arg.c_str(); | 1334 type_value.as_string = arg.c_str(); |
1323 *type = TRACE_VALUE_TYPE_COPY_STRING; | 1335 *type = TRACE_VALUE_TYPE_COPY_STRING; |
1324 *value = type_value.as_uint; | 1336 *value = type_value.as_uint; |
1325 } | 1337 } |
1326 | 1338 |
1327 // base::Time and base::TimeTicks version of SetTraceValue to make it easier to | 1339 // base::Time, base::TimeTicks, etc. versions of SetTraceValue to make it easier |
1328 // trace these types. | 1340 // to trace these types. |
1329 static inline void SetTraceValue(const base::Time arg, | 1341 static inline void SetTraceValue(const base::Time arg, |
1330 unsigned char* type, | 1342 unsigned char* type, |
1331 unsigned long long* value) { | 1343 unsigned long long* value) { |
1332 *type = TRACE_VALUE_TYPE_INT; | 1344 *type = TRACE_VALUE_TYPE_INT; |
1333 *value = arg.ToInternalValue(); | 1345 *value = arg.ToInternalValue(); |
1334 } | 1346 } |
1335 | 1347 |
1336 static inline void SetTraceValue(const base::TimeTicks arg, | 1348 static inline void SetTraceValue(const base::TimeTicks arg, |
1337 unsigned char* type, | 1349 unsigned char* type, |
1338 unsigned long long* value) { | 1350 unsigned long long* value) { |
1339 *type = TRACE_VALUE_TYPE_INT; | 1351 *type = TRACE_VALUE_TYPE_INT; |
1340 *value = arg.ToInternalValue(); | 1352 *value = arg.ToInternalValue(); |
1341 } | 1353 } |
1342 | 1354 |
| 1355 static inline void SetTraceValue(const base::ThreadTicks arg, |
| 1356 unsigned char* type, |
| 1357 unsigned long long* value) { |
| 1358 *type = TRACE_VALUE_TYPE_INT; |
| 1359 *value = arg.ToInternalValue(); |
| 1360 } |
| 1361 |
| 1362 static inline void SetTraceValue(const base::TraceTicks arg, |
| 1363 unsigned char* type, |
| 1364 unsigned long long* value) { |
| 1365 *type = TRACE_VALUE_TYPE_INT; |
| 1366 *value = arg.ToInternalValue(); |
| 1367 } |
| 1368 |
1343 // These AddTraceEvent and AddTraceEventWithThreadIdAndTimestamp template | 1369 // These AddTraceEvent and AddTraceEventWithThreadIdAndTimestamp template |
1344 // functions are defined here instead of in the macro, because the arg_values | 1370 // functions are defined here instead of in the macro, because the arg_values |
1345 // could be temporary objects, such as std::string. In order to store | 1371 // could be temporary objects, such as std::string. In order to store |
1346 // pointers to the internal c_str and pass through to the tracing API, | 1372 // pointers to the internal c_str and pass through to the tracing API, |
1347 // the arg_values must live throughout these procedures. | 1373 // the arg_values must live throughout these procedures. |
1348 | 1374 |
1349 static inline base::trace_event::TraceEventHandle | 1375 static inline base::trace_event::TraceEventHandle |
1350 AddTraceEventWithThreadIdAndTimestamp( | 1376 AddTraceEventWithThreadIdAndTimestamp( |
1351 char phase, | 1377 char phase, |
1352 const unsigned char* category_group_enabled, | 1378 const unsigned char* category_group_enabled, |
1353 const char* name, | 1379 const char* name, |
1354 unsigned long long id, | 1380 unsigned long long id, |
1355 int thread_id, | 1381 int thread_id, |
1356 const base::TimeTicks& timestamp, | 1382 const base::TraceTicks& timestamp, |
1357 unsigned char flags, | 1383 unsigned char flags, |
1358 const char* arg1_name, | 1384 const char* arg1_name, |
1359 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& | 1385 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& |
1360 arg1_val) { | 1386 arg1_val) { |
1361 const int num_args = 1; | 1387 const int num_args = 1; |
1362 unsigned char arg_types[1] = { TRACE_VALUE_TYPE_CONVERTABLE }; | 1388 unsigned char arg_types[1] = { TRACE_VALUE_TYPE_CONVERTABLE }; |
1363 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 1389 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
1364 phase, category_group_enabled, name, id, thread_id, timestamp, | 1390 phase, category_group_enabled, name, id, thread_id, timestamp, |
1365 num_args, &arg1_name, arg_types, NULL, &arg1_val, flags); | 1391 num_args, &arg1_name, arg_types, NULL, &arg1_val, flags); |
1366 } | 1392 } |
1367 | 1393 |
1368 template<class ARG1_TYPE> | 1394 template<class ARG1_TYPE> |
1369 static inline base::trace_event::TraceEventHandle | 1395 static inline base::trace_event::TraceEventHandle |
1370 AddTraceEventWithThreadIdAndTimestamp( | 1396 AddTraceEventWithThreadIdAndTimestamp( |
1371 char phase, | 1397 char phase, |
1372 const unsigned char* category_group_enabled, | 1398 const unsigned char* category_group_enabled, |
1373 const char* name, | 1399 const char* name, |
1374 unsigned long long id, | 1400 unsigned long long id, |
1375 int thread_id, | 1401 int thread_id, |
1376 const base::TimeTicks& timestamp, | 1402 const base::TraceTicks& timestamp, |
1377 unsigned char flags, | 1403 unsigned char flags, |
1378 const char* arg1_name, | 1404 const char* arg1_name, |
1379 const ARG1_TYPE& arg1_val, | 1405 const ARG1_TYPE& arg1_val, |
1380 const char* arg2_name, | 1406 const char* arg2_name, |
1381 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& | 1407 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& |
1382 arg2_val) { | 1408 arg2_val) { |
1383 const int num_args = 2; | 1409 const int num_args = 2; |
1384 const char* arg_names[2] = { arg1_name, arg2_name }; | 1410 const char* arg_names[2] = { arg1_name, arg2_name }; |
1385 | 1411 |
1386 unsigned char arg_types[2]; | 1412 unsigned char arg_types[2]; |
(...skipping 11 matching lines...) Expand all Loading... |
1398 } | 1424 } |
1399 | 1425 |
1400 template<class ARG2_TYPE> | 1426 template<class ARG2_TYPE> |
1401 static inline base::trace_event::TraceEventHandle | 1427 static inline base::trace_event::TraceEventHandle |
1402 AddTraceEventWithThreadIdAndTimestamp( | 1428 AddTraceEventWithThreadIdAndTimestamp( |
1403 char phase, | 1429 char phase, |
1404 const unsigned char* category_group_enabled, | 1430 const unsigned char* category_group_enabled, |
1405 const char* name, | 1431 const char* name, |
1406 unsigned long long id, | 1432 unsigned long long id, |
1407 int thread_id, | 1433 int thread_id, |
1408 const base::TimeTicks& timestamp, | 1434 const base::TraceTicks& timestamp, |
1409 unsigned char flags, | 1435 unsigned char flags, |
1410 const char* arg1_name, | 1436 const char* arg1_name, |
1411 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& arg1_val, | 1437 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& arg1_val, |
1412 const char* arg2_name, | 1438 const char* arg2_name, |
1413 const ARG2_TYPE& arg2_val) { | 1439 const ARG2_TYPE& arg2_val) { |
1414 const int num_args = 2; | 1440 const int num_args = 2; |
1415 const char* arg_names[2] = { arg1_name, arg2_name }; | 1441 const char* arg_names[2] = { arg1_name, arg2_name }; |
1416 | 1442 |
1417 unsigned char arg_types[2]; | 1443 unsigned char arg_types[2]; |
1418 unsigned long long arg_values[2]; | 1444 unsigned long long arg_values[2]; |
(...skipping 10 matching lines...) Expand all Loading... |
1429 num_args, arg_names, arg_types, arg_values, convertable_values, flags); | 1455 num_args, arg_names, arg_types, arg_values, convertable_values, flags); |
1430 } | 1456 } |
1431 | 1457 |
1432 static inline base::trace_event::TraceEventHandle | 1458 static inline base::trace_event::TraceEventHandle |
1433 AddTraceEventWithThreadIdAndTimestamp( | 1459 AddTraceEventWithThreadIdAndTimestamp( |
1434 char phase, | 1460 char phase, |
1435 const unsigned char* category_group_enabled, | 1461 const unsigned char* category_group_enabled, |
1436 const char* name, | 1462 const char* name, |
1437 unsigned long long id, | 1463 unsigned long long id, |
1438 int thread_id, | 1464 int thread_id, |
1439 const base::TimeTicks& timestamp, | 1465 const base::TraceTicks& timestamp, |
1440 unsigned char flags, | 1466 unsigned char flags, |
1441 const char* arg1_name, | 1467 const char* arg1_name, |
1442 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& arg1_val, | 1468 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& arg1_val, |
1443 const char* arg2_name, | 1469 const char* arg2_name, |
1444 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& | 1470 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& |
1445 arg2_val) { | 1471 arg2_val) { |
1446 const int num_args = 2; | 1472 const int num_args = 2; |
1447 const char* arg_names[2] = { arg1_name, arg2_name }; | 1473 const char* arg_names[2] = { arg1_name, arg2_name }; |
1448 unsigned char arg_types[2] = | 1474 unsigned char arg_types[2] = |
1449 { TRACE_VALUE_TYPE_CONVERTABLE, TRACE_VALUE_TYPE_CONVERTABLE }; | 1475 { TRACE_VALUE_TYPE_CONVERTABLE, TRACE_VALUE_TYPE_CONVERTABLE }; |
1450 scoped_refptr<base::trace_event::ConvertableToTraceFormat> | 1476 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
1451 convertable_values[2] = {arg1_val, arg2_val}; | 1477 convertable_values[2] = {arg1_val, arg2_val}; |
1452 | 1478 |
1453 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 1479 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
1454 phase, category_group_enabled, name, id, thread_id, timestamp, | 1480 phase, category_group_enabled, name, id, thread_id, timestamp, |
1455 num_args, arg_names, arg_types, NULL, convertable_values, flags); | 1481 num_args, arg_names, arg_types, NULL, convertable_values, flags); |
1456 } | 1482 } |
1457 | 1483 |
1458 static inline base::trace_event::TraceEventHandle | 1484 static inline base::trace_event::TraceEventHandle |
1459 AddTraceEventWithThreadIdAndTimestamp( | 1485 AddTraceEventWithThreadIdAndTimestamp( |
1460 char phase, | 1486 char phase, |
1461 const unsigned char* category_group_enabled, | 1487 const unsigned char* category_group_enabled, |
1462 const char* name, | 1488 const char* name, |
1463 unsigned long long id, | 1489 unsigned long long id, |
1464 int thread_id, | 1490 int thread_id, |
1465 const base::TimeTicks& timestamp, | 1491 const base::TraceTicks& timestamp, |
1466 unsigned char flags) { | 1492 unsigned char flags) { |
1467 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 1493 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
1468 phase, category_group_enabled, name, id, thread_id, timestamp, | 1494 phase, category_group_enabled, name, id, thread_id, timestamp, |
1469 kZeroNumArgs, NULL, NULL, NULL, NULL, flags); | 1495 kZeroNumArgs, NULL, NULL, NULL, NULL, flags); |
1470 } | 1496 } |
1471 | 1497 |
1472 static inline base::trace_event::TraceEventHandle AddTraceEvent( | 1498 static inline base::trace_event::TraceEventHandle AddTraceEvent( |
1473 char phase, | 1499 char phase, |
1474 const unsigned char* category_group_enabled, | 1500 const unsigned char* category_group_enabled, |
1475 const char* name, | 1501 const char* name, |
1476 unsigned long long id, | 1502 unsigned long long id, |
1477 unsigned char flags) { | 1503 unsigned char flags) { |
1478 const int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); | 1504 const int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); |
1479 const base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime(); | 1505 const base::TraceTicks now = base::TraceTicks::Now(); |
1480 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, | 1506 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, |
1481 name, id, thread_id, now, flags); | 1507 name, id, thread_id, now, flags); |
1482 } | 1508 } |
1483 | 1509 |
1484 template<class ARG1_TYPE> | 1510 template<class ARG1_TYPE> |
1485 static inline base::trace_event::TraceEventHandle | 1511 static inline base::trace_event::TraceEventHandle |
1486 AddTraceEventWithThreadIdAndTimestamp( | 1512 AddTraceEventWithThreadIdAndTimestamp( |
1487 char phase, | 1513 char phase, |
1488 const unsigned char* category_group_enabled, | 1514 const unsigned char* category_group_enabled, |
1489 const char* name, | 1515 const char* name, |
1490 unsigned long long id, | 1516 unsigned long long id, |
1491 int thread_id, | 1517 int thread_id, |
1492 const base::TimeTicks& timestamp, | 1518 const base::TraceTicks& timestamp, |
1493 unsigned char flags, | 1519 unsigned char flags, |
1494 const char* arg1_name, | 1520 const char* arg1_name, |
1495 const ARG1_TYPE& arg1_val) { | 1521 const ARG1_TYPE& arg1_val) { |
1496 const int num_args = 1; | 1522 const int num_args = 1; |
1497 unsigned char arg_types[1]; | 1523 unsigned char arg_types[1]; |
1498 unsigned long long arg_values[1]; | 1524 unsigned long long arg_values[1]; |
1499 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); | 1525 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); |
1500 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 1526 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
1501 phase, category_group_enabled, name, id, thread_id, timestamp, | 1527 phase, category_group_enabled, name, id, thread_id, timestamp, |
1502 num_args, &arg1_name, arg_types, arg_values, NULL, flags); | 1528 num_args, &arg1_name, arg_types, arg_values, NULL, flags); |
1503 } | 1529 } |
1504 | 1530 |
1505 template<class ARG1_TYPE> | 1531 template<class ARG1_TYPE> |
1506 static inline base::trace_event::TraceEventHandle AddTraceEvent( | 1532 static inline base::trace_event::TraceEventHandle AddTraceEvent( |
1507 char phase, | 1533 char phase, |
1508 const unsigned char* category_group_enabled, | 1534 const unsigned char* category_group_enabled, |
1509 const char* name, | 1535 const char* name, |
1510 unsigned long long id, | 1536 unsigned long long id, |
1511 unsigned char flags, | 1537 unsigned char flags, |
1512 const char* arg1_name, | 1538 const char* arg1_name, |
1513 const ARG1_TYPE& arg1_val) { | 1539 const ARG1_TYPE& arg1_val) { |
1514 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); | 1540 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); |
1515 base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime(); | 1541 base::TraceTicks now = base::TraceTicks::Now(); |
1516 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, | 1542 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, |
1517 name, id, thread_id, now, flags, | 1543 name, id, thread_id, now, flags, |
1518 arg1_name, arg1_val); | 1544 arg1_name, arg1_val); |
1519 } | 1545 } |
1520 | 1546 |
1521 template<class ARG1_TYPE, class ARG2_TYPE> | 1547 template<class ARG1_TYPE, class ARG2_TYPE> |
1522 static inline base::trace_event::TraceEventHandle | 1548 static inline base::trace_event::TraceEventHandle |
1523 AddTraceEventWithThreadIdAndTimestamp( | 1549 AddTraceEventWithThreadIdAndTimestamp( |
1524 char phase, | 1550 char phase, |
1525 const unsigned char* category_group_enabled, | 1551 const unsigned char* category_group_enabled, |
1526 const char* name, | 1552 const char* name, |
1527 unsigned long long id, | 1553 unsigned long long id, |
1528 int thread_id, | 1554 int thread_id, |
1529 const base::TimeTicks& timestamp, | 1555 const base::TraceTicks& timestamp, |
1530 unsigned char flags, | 1556 unsigned char flags, |
1531 const char* arg1_name, | 1557 const char* arg1_name, |
1532 const ARG1_TYPE& arg1_val, | 1558 const ARG1_TYPE& arg1_val, |
1533 const char* arg2_name, | 1559 const char* arg2_name, |
1534 const ARG2_TYPE& arg2_val) { | 1560 const ARG2_TYPE& arg2_val) { |
1535 const int num_args = 2; | 1561 const int num_args = 2; |
1536 const char* arg_names[2] = { arg1_name, arg2_name }; | 1562 const char* arg_names[2] = { arg1_name, arg2_name }; |
1537 unsigned char arg_types[2]; | 1563 unsigned char arg_types[2]; |
1538 unsigned long long arg_values[2]; | 1564 unsigned long long arg_values[2]; |
1539 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); | 1565 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); |
1540 SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]); | 1566 SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]); |
1541 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 1567 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
1542 phase, category_group_enabled, name, id, thread_id, timestamp, | 1568 phase, category_group_enabled, name, id, thread_id, timestamp, |
1543 num_args, arg_names, arg_types, arg_values, NULL, flags); | 1569 num_args, arg_names, arg_types, arg_values, NULL, flags); |
1544 } | 1570 } |
1545 | 1571 |
1546 template<class ARG1_TYPE, class ARG2_TYPE> | 1572 template<class ARG1_TYPE, class ARG2_TYPE> |
1547 static inline base::trace_event::TraceEventHandle AddTraceEvent( | 1573 static inline base::trace_event::TraceEventHandle AddTraceEvent( |
1548 char phase, | 1574 char phase, |
1549 const unsigned char* category_group_enabled, | 1575 const unsigned char* category_group_enabled, |
1550 const char* name, | 1576 const char* name, |
1551 unsigned long long id, | 1577 unsigned long long id, |
1552 unsigned char flags, | 1578 unsigned char flags, |
1553 const char* arg1_name, | 1579 const char* arg1_name, |
1554 const ARG1_TYPE& arg1_val, | 1580 const ARG1_TYPE& arg1_val, |
1555 const char* arg2_name, | 1581 const char* arg2_name, |
1556 const ARG2_TYPE& arg2_val) { | 1582 const ARG2_TYPE& arg2_val) { |
1557 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); | 1583 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); |
1558 base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime(); | 1584 base::TraceTicks now = base::TraceTicks::Now(); |
1559 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, | 1585 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, |
1560 name, id, thread_id, now, flags, | 1586 name, id, thread_id, now, flags, |
1561 arg1_name, arg1_val, | 1587 arg1_name, arg1_val, |
1562 arg2_name, arg2_val); | 1588 arg2_name, arg2_val); |
1563 } | 1589 } |
1564 | 1590 |
1565 // Used by TRACE_EVENTx macros. Do not use directly. | 1591 // Used by TRACE_EVENTx macros. Do not use directly. |
1566 class TRACE_EVENT_API_CLASS_EXPORT ScopedTracer { | 1592 class TRACE_EVENT_API_CLASS_EXPORT ScopedTracer { |
1567 public: | 1593 public: |
1568 // Note: members of data_ intentionally left uninitialized. See Initialize. | 1594 // Note: members of data_ intentionally left uninitialized. See Initialize. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1678 const char* name_; | 1704 const char* name_; |
1679 IDType id_; | 1705 IDType id_; |
1680 | 1706 |
1681 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); | 1707 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); |
1682 }; | 1708 }; |
1683 | 1709 |
1684 } // namespace trace_event | 1710 } // namespace trace_event |
1685 } // namespace base | 1711 } // namespace base |
1686 | 1712 |
1687 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ | 1713 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ |
OLD | NEW |