| 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 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 base::trace_event::TraceLog::GetInstance()->AddTraceEvent | 947 base::trace_event::TraceLog::GetInstance()->AddTraceEvent |
| 948 | 948 |
| 949 // Add a trace event to the platform tracing system. | 949 // Add a trace event to the platform tracing system. |
| 950 // base::trace_event::TraceEventHandle | 950 // base::trace_event::TraceEventHandle |
| 951 // TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_TIMESTAMP( | 951 // TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_TIMESTAMP( |
| 952 // char phase, | 952 // char phase, |
| 953 // const unsigned char* category_group_enabled, | 953 // const unsigned char* category_group_enabled, |
| 954 // const char* name, | 954 // const char* name, |
| 955 // unsigned long long id, | 955 // unsigned long long id, |
| 956 // int thread_id, | 956 // int thread_id, |
| 957 // const TimeTicks& timestamp, | 957 // const TraceTicks& timestamp, |
| 958 // int num_args, | 958 // int num_args, |
| 959 // const char** arg_names, | 959 // const char** arg_names, |
| 960 // const unsigned char* arg_types, | 960 // const unsigned char* arg_types, |
| 961 // const unsigned long long* arg_values, | 961 // const unsigned long long* arg_values, |
| 962 // unsigned char flags) | 962 // unsigned char flags) |
| 963 #define TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP \ | 963 #define TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP \ |
| 964 base::trace_event::TraceLog::GetInstance() \ | 964 base::trace_event::TraceLog::GetInstance() \ |
| 965 ->AddTraceEventWithThreadIdAndTimestamp | 965 ->AddTraceEventWithThreadIdAndTimestamp |
| 966 | 966 |
| 967 // Set the duration field of a COMPLETE trace event. | 967 // 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, ...) \ | 1076 category_group, name, id, thread_id, timestamp, flags, ...) \ |
| 1077 do { \ | 1077 do { \ |
| 1078 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ | 1078 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
| 1079 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ | 1079 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ |
| 1080 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ | 1080 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ |
| 1081 trace_event_internal::TraceID trace_event_trace_id( \ | 1081 trace_event_internal::TraceID trace_event_trace_id( \ |
| 1082 id, &trace_event_flags); \ | 1082 id, &trace_event_flags); \ |
| 1083 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ | 1083 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ |
| 1084 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ | 1084 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ |
| 1085 name, trace_event_trace_id.data(), \ | 1085 name, trace_event_trace_id.data(), \ |
| 1086 thread_id, base::TimeTicks::FromInternalValue(timestamp), \ | 1086 thread_id, base::TraceTicks::FromInternalValue(timestamp), \ |
| 1087 trace_event_flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \ | 1087 trace_event_flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \ |
| 1088 ##__VA_ARGS__); \ | 1088 ##__VA_ARGS__); \ |
| 1089 } \ | 1089 } \ |
| 1090 } while (0) | 1090 } while (0) |
| 1091 | 1091 |
| 1092 // Notes regarding the following definitions: | 1092 // Notes regarding the following definitions: |
| 1093 // New values can be added and propagated to third party libraries, but existing | 1093 // 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 | 1094 // definitions must never be changed, because third party libraries may use old |
| 1095 // definitions. | 1095 // definitions. |
| 1096 | 1096 |
| (...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. | 1317 // std::string version of SetTraceValue so that trace arguments can be strings. |
| 1318 static inline void SetTraceValue(const std::string& arg, | 1318 static inline void SetTraceValue(const std::string& arg, |
| 1319 unsigned char* type, | 1319 unsigned char* type, |
| 1320 unsigned long long* value) { | 1320 unsigned long long* value) { |
| 1321 TraceValueUnion type_value; | 1321 TraceValueUnion type_value; |
| 1322 type_value.as_string = arg.c_str(); | 1322 type_value.as_string = arg.c_str(); |
| 1323 *type = TRACE_VALUE_TYPE_COPY_STRING; | 1323 *type = TRACE_VALUE_TYPE_COPY_STRING; |
| 1324 *value = type_value.as_uint; | 1324 *value = type_value.as_uint; |
| 1325 } | 1325 } |
| 1326 | 1326 |
| 1327 // base::Time and base::TimeTicks version of SetTraceValue to make it easier to | 1327 // base::Time, base::TimeTicks, etc. versions of SetTraceValue to make it easier |
| 1328 // trace these types. | 1328 // to trace these types. |
| 1329 static inline void SetTraceValue(const base::Time arg, | 1329 static inline void SetTraceValue(const base::Time arg, |
| 1330 unsigned char* type, | 1330 unsigned char* type, |
| 1331 unsigned long long* value) { | 1331 unsigned long long* value) { |
| 1332 *type = TRACE_VALUE_TYPE_INT; | 1332 *type = TRACE_VALUE_TYPE_INT; |
| 1333 *value = arg.ToInternalValue(); | 1333 *value = arg.ToInternalValue(); |
| 1334 } | 1334 } |
| 1335 | 1335 |
| 1336 static inline void SetTraceValue(const base::TimeTicks arg, | 1336 static inline void SetTraceValue(const base::TimeTicks arg, |
| 1337 unsigned char* type, | 1337 unsigned char* type, |
| 1338 unsigned long long* value) { | 1338 unsigned long long* value) { |
| 1339 *type = TRACE_VALUE_TYPE_INT; | 1339 *type = TRACE_VALUE_TYPE_INT; |
| 1340 *value = arg.ToInternalValue(); | 1340 *value = arg.ToInternalValue(); |
| 1341 } | 1341 } |
| 1342 | 1342 |
| 1343 static inline void SetTraceValue(const base::ThreadTicks arg, |
| 1344 unsigned char* type, |
| 1345 unsigned long long* value) { |
| 1346 *type = TRACE_VALUE_TYPE_INT; |
| 1347 *value = arg.ToInternalValue(); |
| 1348 } |
| 1349 |
| 1350 static inline void SetTraceValue(const base::TraceTicks arg, |
| 1351 unsigned char* type, |
| 1352 unsigned long long* value) { |
| 1353 *type = TRACE_VALUE_TYPE_INT; |
| 1354 *value = arg.ToInternalValue(); |
| 1355 } |
| 1356 |
| 1343 // These AddTraceEvent and AddTraceEventWithThreadIdAndTimestamp template | 1357 // These AddTraceEvent and AddTraceEventWithThreadIdAndTimestamp template |
| 1344 // functions are defined here instead of in the macro, because the arg_values | 1358 // 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 | 1359 // 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, | 1360 // pointers to the internal c_str and pass through to the tracing API, |
| 1347 // the arg_values must live throughout these procedures. | 1361 // the arg_values must live throughout these procedures. |
| 1348 | 1362 |
| 1349 static inline base::trace_event::TraceEventHandle | 1363 static inline base::trace_event::TraceEventHandle |
| 1350 AddTraceEventWithThreadIdAndTimestamp( | 1364 AddTraceEventWithThreadIdAndTimestamp( |
| 1351 char phase, | 1365 char phase, |
| 1352 const unsigned char* category_group_enabled, | 1366 const unsigned char* category_group_enabled, |
| 1353 const char* name, | 1367 const char* name, |
| 1354 unsigned long long id, | 1368 unsigned long long id, |
| 1355 int thread_id, | 1369 int thread_id, |
| 1356 const base::TimeTicks& timestamp, | 1370 const base::TraceTicks& timestamp, |
| 1357 unsigned char flags, | 1371 unsigned char flags, |
| 1358 const char* arg1_name, | 1372 const char* arg1_name, |
| 1359 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& | 1373 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& |
| 1360 arg1_val) { | 1374 arg1_val) { |
| 1361 const int num_args = 1; | 1375 const int num_args = 1; |
| 1362 unsigned char arg_types[1] = { TRACE_VALUE_TYPE_CONVERTABLE }; | 1376 unsigned char arg_types[1] = { TRACE_VALUE_TYPE_CONVERTABLE }; |
| 1363 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 1377 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
| 1364 phase, category_group_enabled, name, id, thread_id, timestamp, | 1378 phase, category_group_enabled, name, id, thread_id, timestamp, |
| 1365 num_args, &arg1_name, arg_types, NULL, &arg1_val, flags); | 1379 num_args, &arg1_name, arg_types, NULL, &arg1_val, flags); |
| 1366 } | 1380 } |
| 1367 | 1381 |
| 1368 template<class ARG1_TYPE> | 1382 template<class ARG1_TYPE> |
| 1369 static inline base::trace_event::TraceEventHandle | 1383 static inline base::trace_event::TraceEventHandle |
| 1370 AddTraceEventWithThreadIdAndTimestamp( | 1384 AddTraceEventWithThreadIdAndTimestamp( |
| 1371 char phase, | 1385 char phase, |
| 1372 const unsigned char* category_group_enabled, | 1386 const unsigned char* category_group_enabled, |
| 1373 const char* name, | 1387 const char* name, |
| 1374 unsigned long long id, | 1388 unsigned long long id, |
| 1375 int thread_id, | 1389 int thread_id, |
| 1376 const base::TimeTicks& timestamp, | 1390 const base::TraceTicks& timestamp, |
| 1377 unsigned char flags, | 1391 unsigned char flags, |
| 1378 const char* arg1_name, | 1392 const char* arg1_name, |
| 1379 const ARG1_TYPE& arg1_val, | 1393 const ARG1_TYPE& arg1_val, |
| 1380 const char* arg2_name, | 1394 const char* arg2_name, |
| 1381 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& | 1395 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& |
| 1382 arg2_val) { | 1396 arg2_val) { |
| 1383 const int num_args = 2; | 1397 const int num_args = 2; |
| 1384 const char* arg_names[2] = { arg1_name, arg2_name }; | 1398 const char* arg_names[2] = { arg1_name, arg2_name }; |
| 1385 | 1399 |
| 1386 unsigned char arg_types[2]; | 1400 unsigned char arg_types[2]; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1398 } | 1412 } |
| 1399 | 1413 |
| 1400 template<class ARG2_TYPE> | 1414 template<class ARG2_TYPE> |
| 1401 static inline base::trace_event::TraceEventHandle | 1415 static inline base::trace_event::TraceEventHandle |
| 1402 AddTraceEventWithThreadIdAndTimestamp( | 1416 AddTraceEventWithThreadIdAndTimestamp( |
| 1403 char phase, | 1417 char phase, |
| 1404 const unsigned char* category_group_enabled, | 1418 const unsigned char* category_group_enabled, |
| 1405 const char* name, | 1419 const char* name, |
| 1406 unsigned long long id, | 1420 unsigned long long id, |
| 1407 int thread_id, | 1421 int thread_id, |
| 1408 const base::TimeTicks& timestamp, | 1422 const base::TraceTicks& timestamp, |
| 1409 unsigned char flags, | 1423 unsigned char flags, |
| 1410 const char* arg1_name, | 1424 const char* arg1_name, |
| 1411 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& arg1_val, | 1425 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& arg1_val, |
| 1412 const char* arg2_name, | 1426 const char* arg2_name, |
| 1413 const ARG2_TYPE& arg2_val) { | 1427 const ARG2_TYPE& arg2_val) { |
| 1414 const int num_args = 2; | 1428 const int num_args = 2; |
| 1415 const char* arg_names[2] = { arg1_name, arg2_name }; | 1429 const char* arg_names[2] = { arg1_name, arg2_name }; |
| 1416 | 1430 |
| 1417 unsigned char arg_types[2]; | 1431 unsigned char arg_types[2]; |
| 1418 unsigned long long arg_values[2]; | 1432 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); | 1443 num_args, arg_names, arg_types, arg_values, convertable_values, flags); |
| 1430 } | 1444 } |
| 1431 | 1445 |
| 1432 static inline base::trace_event::TraceEventHandle | 1446 static inline base::trace_event::TraceEventHandle |
| 1433 AddTraceEventWithThreadIdAndTimestamp( | 1447 AddTraceEventWithThreadIdAndTimestamp( |
| 1434 char phase, | 1448 char phase, |
| 1435 const unsigned char* category_group_enabled, | 1449 const unsigned char* category_group_enabled, |
| 1436 const char* name, | 1450 const char* name, |
| 1437 unsigned long long id, | 1451 unsigned long long id, |
| 1438 int thread_id, | 1452 int thread_id, |
| 1439 const base::TimeTicks& timestamp, | 1453 const base::TraceTicks& timestamp, |
| 1440 unsigned char flags, | 1454 unsigned char flags, |
| 1441 const char* arg1_name, | 1455 const char* arg1_name, |
| 1442 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& arg1_val, | 1456 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& arg1_val, |
| 1443 const char* arg2_name, | 1457 const char* arg2_name, |
| 1444 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& | 1458 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& |
| 1445 arg2_val) { | 1459 arg2_val) { |
| 1446 const int num_args = 2; | 1460 const int num_args = 2; |
| 1447 const char* arg_names[2] = { arg1_name, arg2_name }; | 1461 const char* arg_names[2] = { arg1_name, arg2_name }; |
| 1448 unsigned char arg_types[2] = | 1462 unsigned char arg_types[2] = |
| 1449 { TRACE_VALUE_TYPE_CONVERTABLE, TRACE_VALUE_TYPE_CONVERTABLE }; | 1463 { TRACE_VALUE_TYPE_CONVERTABLE, TRACE_VALUE_TYPE_CONVERTABLE }; |
| 1450 scoped_refptr<base::trace_event::ConvertableToTraceFormat> | 1464 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
| 1451 convertable_values[2] = {arg1_val, arg2_val}; | 1465 convertable_values[2] = {arg1_val, arg2_val}; |
| 1452 | 1466 |
| 1453 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 1467 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
| 1454 phase, category_group_enabled, name, id, thread_id, timestamp, | 1468 phase, category_group_enabled, name, id, thread_id, timestamp, |
| 1455 num_args, arg_names, arg_types, NULL, convertable_values, flags); | 1469 num_args, arg_names, arg_types, NULL, convertable_values, flags); |
| 1456 } | 1470 } |
| 1457 | 1471 |
| 1458 static inline base::trace_event::TraceEventHandle | 1472 static inline base::trace_event::TraceEventHandle |
| 1459 AddTraceEventWithThreadIdAndTimestamp( | 1473 AddTraceEventWithThreadIdAndTimestamp( |
| 1460 char phase, | 1474 char phase, |
| 1461 const unsigned char* category_group_enabled, | 1475 const unsigned char* category_group_enabled, |
| 1462 const char* name, | 1476 const char* name, |
| 1463 unsigned long long id, | 1477 unsigned long long id, |
| 1464 int thread_id, | 1478 int thread_id, |
| 1465 const base::TimeTicks& timestamp, | 1479 const base::TraceTicks& timestamp, |
| 1466 unsigned char flags) { | 1480 unsigned char flags) { |
| 1467 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 1481 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
| 1468 phase, category_group_enabled, name, id, thread_id, timestamp, | 1482 phase, category_group_enabled, name, id, thread_id, timestamp, |
| 1469 kZeroNumArgs, NULL, NULL, NULL, NULL, flags); | 1483 kZeroNumArgs, NULL, NULL, NULL, NULL, flags); |
| 1470 } | 1484 } |
| 1471 | 1485 |
| 1472 static inline base::trace_event::TraceEventHandle AddTraceEvent( | 1486 static inline base::trace_event::TraceEventHandle AddTraceEvent( |
| 1473 char phase, | 1487 char phase, |
| 1474 const unsigned char* category_group_enabled, | 1488 const unsigned char* category_group_enabled, |
| 1475 const char* name, | 1489 const char* name, |
| 1476 unsigned long long id, | 1490 unsigned long long id, |
| 1477 unsigned char flags) { | 1491 unsigned char flags) { |
| 1478 const int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); | 1492 const int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); |
| 1479 const base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime(); | 1493 const base::TraceTicks now = base::TraceTicks::Now(); |
| 1480 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, | 1494 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, |
| 1481 name, id, thread_id, now, flags); | 1495 name, id, thread_id, now, flags); |
| 1482 } | 1496 } |
| 1483 | 1497 |
| 1484 template<class ARG1_TYPE> | 1498 template<class ARG1_TYPE> |
| 1485 static inline base::trace_event::TraceEventHandle | 1499 static inline base::trace_event::TraceEventHandle |
| 1486 AddTraceEventWithThreadIdAndTimestamp( | 1500 AddTraceEventWithThreadIdAndTimestamp( |
| 1487 char phase, | 1501 char phase, |
| 1488 const unsigned char* category_group_enabled, | 1502 const unsigned char* category_group_enabled, |
| 1489 const char* name, | 1503 const char* name, |
| 1490 unsigned long long id, | 1504 unsigned long long id, |
| 1491 int thread_id, | 1505 int thread_id, |
| 1492 const base::TimeTicks& timestamp, | 1506 const base::TraceTicks& timestamp, |
| 1493 unsigned char flags, | 1507 unsigned char flags, |
| 1494 const char* arg1_name, | 1508 const char* arg1_name, |
| 1495 const ARG1_TYPE& arg1_val) { | 1509 const ARG1_TYPE& arg1_val) { |
| 1496 const int num_args = 1; | 1510 const int num_args = 1; |
| 1497 unsigned char arg_types[1]; | 1511 unsigned char arg_types[1]; |
| 1498 unsigned long long arg_values[1]; | 1512 unsigned long long arg_values[1]; |
| 1499 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); | 1513 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); |
| 1500 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 1514 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
| 1501 phase, category_group_enabled, name, id, thread_id, timestamp, | 1515 phase, category_group_enabled, name, id, thread_id, timestamp, |
| 1502 num_args, &arg1_name, arg_types, arg_values, NULL, flags); | 1516 num_args, &arg1_name, arg_types, arg_values, NULL, flags); |
| 1503 } | 1517 } |
| 1504 | 1518 |
| 1505 template<class ARG1_TYPE> | 1519 template<class ARG1_TYPE> |
| 1506 static inline base::trace_event::TraceEventHandle AddTraceEvent( | 1520 static inline base::trace_event::TraceEventHandle AddTraceEvent( |
| 1507 char phase, | 1521 char phase, |
| 1508 const unsigned char* category_group_enabled, | 1522 const unsigned char* category_group_enabled, |
| 1509 const char* name, | 1523 const char* name, |
| 1510 unsigned long long id, | 1524 unsigned long long id, |
| 1511 unsigned char flags, | 1525 unsigned char flags, |
| 1512 const char* arg1_name, | 1526 const char* arg1_name, |
| 1513 const ARG1_TYPE& arg1_val) { | 1527 const ARG1_TYPE& arg1_val) { |
| 1514 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); | 1528 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); |
| 1515 base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime(); | 1529 base::TraceTicks now = base::TraceTicks::Now(); |
| 1516 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, | 1530 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, |
| 1517 name, id, thread_id, now, flags, | 1531 name, id, thread_id, now, flags, |
| 1518 arg1_name, arg1_val); | 1532 arg1_name, arg1_val); |
| 1519 } | 1533 } |
| 1520 | 1534 |
| 1521 template<class ARG1_TYPE, class ARG2_TYPE> | 1535 template<class ARG1_TYPE, class ARG2_TYPE> |
| 1522 static inline base::trace_event::TraceEventHandle | 1536 static inline base::trace_event::TraceEventHandle |
| 1523 AddTraceEventWithThreadIdAndTimestamp( | 1537 AddTraceEventWithThreadIdAndTimestamp( |
| 1524 char phase, | 1538 char phase, |
| 1525 const unsigned char* category_group_enabled, | 1539 const unsigned char* category_group_enabled, |
| 1526 const char* name, | 1540 const char* name, |
| 1527 unsigned long long id, | 1541 unsigned long long id, |
| 1528 int thread_id, | 1542 int thread_id, |
| 1529 const base::TimeTicks& timestamp, | 1543 const base::TraceTicks& timestamp, |
| 1530 unsigned char flags, | 1544 unsigned char flags, |
| 1531 const char* arg1_name, | 1545 const char* arg1_name, |
| 1532 const ARG1_TYPE& arg1_val, | 1546 const ARG1_TYPE& arg1_val, |
| 1533 const char* arg2_name, | 1547 const char* arg2_name, |
| 1534 const ARG2_TYPE& arg2_val) { | 1548 const ARG2_TYPE& arg2_val) { |
| 1535 const int num_args = 2; | 1549 const int num_args = 2; |
| 1536 const char* arg_names[2] = { arg1_name, arg2_name }; | 1550 const char* arg_names[2] = { arg1_name, arg2_name }; |
| 1537 unsigned char arg_types[2]; | 1551 unsigned char arg_types[2]; |
| 1538 unsigned long long arg_values[2]; | 1552 unsigned long long arg_values[2]; |
| 1539 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); | 1553 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); |
| 1540 SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]); | 1554 SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]); |
| 1541 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 1555 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
| 1542 phase, category_group_enabled, name, id, thread_id, timestamp, | 1556 phase, category_group_enabled, name, id, thread_id, timestamp, |
| 1543 num_args, arg_names, arg_types, arg_values, NULL, flags); | 1557 num_args, arg_names, arg_types, arg_values, NULL, flags); |
| 1544 } | 1558 } |
| 1545 | 1559 |
| 1546 template<class ARG1_TYPE, class ARG2_TYPE> | 1560 template<class ARG1_TYPE, class ARG2_TYPE> |
| 1547 static inline base::trace_event::TraceEventHandle AddTraceEvent( | 1561 static inline base::trace_event::TraceEventHandle AddTraceEvent( |
| 1548 char phase, | 1562 char phase, |
| 1549 const unsigned char* category_group_enabled, | 1563 const unsigned char* category_group_enabled, |
| 1550 const char* name, | 1564 const char* name, |
| 1551 unsigned long long id, | 1565 unsigned long long id, |
| 1552 unsigned char flags, | 1566 unsigned char flags, |
| 1553 const char* arg1_name, | 1567 const char* arg1_name, |
| 1554 const ARG1_TYPE& arg1_val, | 1568 const ARG1_TYPE& arg1_val, |
| 1555 const char* arg2_name, | 1569 const char* arg2_name, |
| 1556 const ARG2_TYPE& arg2_val) { | 1570 const ARG2_TYPE& arg2_val) { |
| 1557 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); | 1571 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); |
| 1558 base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime(); | 1572 base::TraceTicks now = base::TraceTicks::Now(); |
| 1559 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, | 1573 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, |
| 1560 name, id, thread_id, now, flags, | 1574 name, id, thread_id, now, flags, |
| 1561 arg1_name, arg1_val, | 1575 arg1_name, arg1_val, |
| 1562 arg2_name, arg2_val); | 1576 arg2_name, arg2_val); |
| 1563 } | 1577 } |
| 1564 | 1578 |
| 1565 // Used by TRACE_EVENTx macros. Do not use directly. | 1579 // Used by TRACE_EVENTx macros. Do not use directly. |
| 1566 class TRACE_EVENT_API_CLASS_EXPORT ScopedTracer { | 1580 class TRACE_EVENT_API_CLASS_EXPORT ScopedTracer { |
| 1567 public: | 1581 public: |
| 1568 // Note: members of data_ intentionally left uninitialized. See Initialize. | 1582 // 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_; | 1692 const char* name_; |
| 1679 IDType id_; | 1693 IDType id_; |
| 1680 | 1694 |
| 1681 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); | 1695 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); |
| 1682 }; | 1696 }; |
| 1683 | 1697 |
| 1684 } // namespace trace_event | 1698 } // namespace trace_event |
| 1685 } // namespace base | 1699 } // namespace base |
| 1686 | 1700 |
| 1687 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ | 1701 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ |
| OLD | NEW |