| 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 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 base::trace_event::TraceLog::GetInstance()->AddTraceEvent | 919 base::trace_event::TraceLog::GetInstance()->AddTraceEvent |
| 920 | 920 |
| 921 // Add a trace event to the platform tracing system. | 921 // Add a trace event to the platform tracing system. |
| 922 // base::trace_event::TraceEventHandle | 922 // base::trace_event::TraceEventHandle |
| 923 // TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_TIMESTAMP( | 923 // TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_TIMESTAMP( |
| 924 // char phase, | 924 // char phase, |
| 925 // const unsigned char* category_group_enabled, | 925 // const unsigned char* category_group_enabled, |
| 926 // const char* name, | 926 // const char* name, |
| 927 // unsigned long long id, | 927 // unsigned long long id, |
| 928 // int thread_id, | 928 // int thread_id, |
| 929 // const TimeTicks& timestamp, | 929 // const TraceTicks& timestamp, |
| 930 // int num_args, | 930 // int num_args, |
| 931 // const char** arg_names, | 931 // const char** arg_names, |
| 932 // const unsigned char* arg_types, | 932 // const unsigned char* arg_types, |
| 933 // const unsigned long long* arg_values, | 933 // const unsigned long long* arg_values, |
| 934 // unsigned char flags) | 934 // unsigned char flags) |
| 935 #define TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP \ | 935 #define TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP \ |
| 936 base::trace_event::TraceLog::GetInstance() \ | 936 base::trace_event::TraceLog::GetInstance() \ |
| 937 ->AddTraceEventWithThreadIdAndTimestamp | 937 ->AddTraceEventWithThreadIdAndTimestamp |
| 938 | 938 |
| 939 // Set the duration field of a COMPLETE trace event. | 939 // Set the duration field of a COMPLETE trace event. |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 category_group, name, id, thread_id, timestamp, flags, ...) \ | 1048 category_group, name, id, thread_id, timestamp, flags, ...) \ |
| 1049 do { \ | 1049 do { \ |
| 1050 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ | 1050 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
| 1051 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ | 1051 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ |
| 1052 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ | 1052 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ |
| 1053 trace_event_internal::TraceID trace_event_trace_id( \ | 1053 trace_event_internal::TraceID trace_event_trace_id( \ |
| 1054 id, &trace_event_flags); \ | 1054 id, &trace_event_flags); \ |
| 1055 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ | 1055 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ |
| 1056 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ | 1056 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ |
| 1057 name, trace_event_trace_id.data(), \ | 1057 name, trace_event_trace_id.data(), \ |
| 1058 thread_id, base::TimeTicks::FromInternalValue(timestamp), \ | 1058 thread_id, base::TraceTicks::FromInternalValue(timestamp), \ |
| 1059 trace_event_flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \ | 1059 trace_event_flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \ |
| 1060 ##__VA_ARGS__); \ | 1060 ##__VA_ARGS__); \ |
| 1061 } \ | 1061 } \ |
| 1062 } while (0) | 1062 } while (0) |
| 1063 | 1063 |
| 1064 // Notes regarding the following definitions: | 1064 // Notes regarding the following definitions: |
| 1065 // New values can be added and propagated to third party libraries, but existing | 1065 // New values can be added and propagated to third party libraries, but existing |
| 1066 // definitions must never be changed, because third party libraries may use old | 1066 // definitions must never be changed, because third party libraries may use old |
| 1067 // definitions. | 1067 // definitions. |
| 1068 | 1068 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1288 // std::string version of SetTraceValue so that trace arguments can be strings. | 1288 // std::string version of SetTraceValue so that trace arguments can be strings. |
| 1289 static inline void SetTraceValue(const std::string& arg, | 1289 static inline void SetTraceValue(const std::string& arg, |
| 1290 unsigned char* type, | 1290 unsigned char* type, |
| 1291 unsigned long long* value) { | 1291 unsigned long long* value) { |
| 1292 TraceValueUnion type_value; | 1292 TraceValueUnion type_value; |
| 1293 type_value.as_string = arg.c_str(); | 1293 type_value.as_string = arg.c_str(); |
| 1294 *type = TRACE_VALUE_TYPE_COPY_STRING; | 1294 *type = TRACE_VALUE_TYPE_COPY_STRING; |
| 1295 *value = type_value.as_uint; | 1295 *value = type_value.as_uint; |
| 1296 } | 1296 } |
| 1297 | 1297 |
| 1298 // base::Time and base::TimeTicks version of SetTraceValue to make it easier to | 1298 // base::Time, base::TimeTicks, etc. versions of SetTraceValue to make it easier |
| 1299 // trace these types. | 1299 // to trace these types. |
| 1300 static inline void SetTraceValue(const base::Time arg, | 1300 static inline void SetTraceValue(const base::Time arg, |
| 1301 unsigned char* type, | 1301 unsigned char* type, |
| 1302 unsigned long long* value) { | 1302 unsigned long long* value) { |
| 1303 *type = TRACE_VALUE_TYPE_INT; | 1303 *type = TRACE_VALUE_TYPE_INT; |
| 1304 *value = arg.ToInternalValue(); | 1304 *value = arg.ToInternalValue(); |
| 1305 } | 1305 } |
| 1306 | 1306 |
| 1307 static inline void SetTraceValue(const base::TimeTicks arg, | 1307 static inline void SetTraceValue(const base::TimeTicks arg, |
| 1308 unsigned char* type, | 1308 unsigned char* type, |
| 1309 unsigned long long* value) { | 1309 unsigned long long* value) { |
| 1310 *type = TRACE_VALUE_TYPE_INT; | 1310 *type = TRACE_VALUE_TYPE_INT; |
| 1311 *value = arg.ToInternalValue(); | 1311 *value = arg.ToInternalValue(); |
| 1312 } | 1312 } |
| 1313 | 1313 |
| 1314 static inline void SetTraceValue(const base::ThreadTicks arg, |
| 1315 unsigned char* type, |
| 1316 unsigned long long* value) { |
| 1317 *type = TRACE_VALUE_TYPE_INT; |
| 1318 *value = arg.ToInternalValue(); |
| 1319 } |
| 1320 |
| 1321 static inline void SetTraceValue(const base::TraceTicks arg, |
| 1322 unsigned char* type, |
| 1323 unsigned long long* value) { |
| 1324 *type = TRACE_VALUE_TYPE_INT; |
| 1325 *value = arg.ToInternalValue(); |
| 1326 } |
| 1327 |
| 1314 // These AddTraceEvent and AddTraceEventWithThreadIdAndTimestamp template | 1328 // These AddTraceEvent and AddTraceEventWithThreadIdAndTimestamp template |
| 1315 // functions are defined here instead of in the macro, because the arg_values | 1329 // functions are defined here instead of in the macro, because the arg_values |
| 1316 // could be temporary objects, such as std::string. In order to store | 1330 // could be temporary objects, such as std::string. In order to store |
| 1317 // pointers to the internal c_str and pass through to the tracing API, | 1331 // pointers to the internal c_str and pass through to the tracing API, |
| 1318 // the arg_values must live throughout these procedures. | 1332 // the arg_values must live throughout these procedures. |
| 1319 | 1333 |
| 1320 static inline base::trace_event::TraceEventHandle | 1334 static inline base::trace_event::TraceEventHandle |
| 1321 AddTraceEventWithThreadIdAndTimestamp( | 1335 AddTraceEventWithThreadIdAndTimestamp( |
| 1322 char phase, | 1336 char phase, |
| 1323 const unsigned char* category_group_enabled, | 1337 const unsigned char* category_group_enabled, |
| 1324 const char* name, | 1338 const char* name, |
| 1325 unsigned long long id, | 1339 unsigned long long id, |
| 1326 int thread_id, | 1340 int thread_id, |
| 1327 const base::TimeTicks& timestamp, | 1341 const base::TraceTicks& timestamp, |
| 1328 unsigned char flags, | 1342 unsigned char flags, |
| 1329 const char* arg1_name, | 1343 const char* arg1_name, |
| 1330 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& | 1344 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& |
| 1331 arg1_val) { | 1345 arg1_val) { |
| 1332 const int num_args = 1; | 1346 const int num_args = 1; |
| 1333 unsigned char arg_types[1] = { TRACE_VALUE_TYPE_CONVERTABLE }; | 1347 unsigned char arg_types[1] = { TRACE_VALUE_TYPE_CONVERTABLE }; |
| 1334 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 1348 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
| 1335 phase, category_group_enabled, name, id, thread_id, timestamp, | 1349 phase, category_group_enabled, name, id, thread_id, timestamp, |
| 1336 num_args, &arg1_name, arg_types, NULL, &arg1_val, flags); | 1350 num_args, &arg1_name, arg_types, NULL, &arg1_val, flags); |
| 1337 } | 1351 } |
| 1338 | 1352 |
| 1339 template<class ARG1_TYPE> | 1353 template<class ARG1_TYPE> |
| 1340 static inline base::trace_event::TraceEventHandle | 1354 static inline base::trace_event::TraceEventHandle |
| 1341 AddTraceEventWithThreadIdAndTimestamp( | 1355 AddTraceEventWithThreadIdAndTimestamp( |
| 1342 char phase, | 1356 char phase, |
| 1343 const unsigned char* category_group_enabled, | 1357 const unsigned char* category_group_enabled, |
| 1344 const char* name, | 1358 const char* name, |
| 1345 unsigned long long id, | 1359 unsigned long long id, |
| 1346 int thread_id, | 1360 int thread_id, |
| 1347 const base::TimeTicks& timestamp, | 1361 const base::TraceTicks& timestamp, |
| 1348 unsigned char flags, | 1362 unsigned char flags, |
| 1349 const char* arg1_name, | 1363 const char* arg1_name, |
| 1350 const ARG1_TYPE& arg1_val, | 1364 const ARG1_TYPE& arg1_val, |
| 1351 const char* arg2_name, | 1365 const char* arg2_name, |
| 1352 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& | 1366 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& |
| 1353 arg2_val) { | 1367 arg2_val) { |
| 1354 const int num_args = 2; | 1368 const int num_args = 2; |
| 1355 const char* arg_names[2] = { arg1_name, arg2_name }; | 1369 const char* arg_names[2] = { arg1_name, arg2_name }; |
| 1356 | 1370 |
| 1357 unsigned char arg_types[2]; | 1371 unsigned char arg_types[2]; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1369 } | 1383 } |
| 1370 | 1384 |
| 1371 template<class ARG2_TYPE> | 1385 template<class ARG2_TYPE> |
| 1372 static inline base::trace_event::TraceEventHandle | 1386 static inline base::trace_event::TraceEventHandle |
| 1373 AddTraceEventWithThreadIdAndTimestamp( | 1387 AddTraceEventWithThreadIdAndTimestamp( |
| 1374 char phase, | 1388 char phase, |
| 1375 const unsigned char* category_group_enabled, | 1389 const unsigned char* category_group_enabled, |
| 1376 const char* name, | 1390 const char* name, |
| 1377 unsigned long long id, | 1391 unsigned long long id, |
| 1378 int thread_id, | 1392 int thread_id, |
| 1379 const base::TimeTicks& timestamp, | 1393 const base::TraceTicks& timestamp, |
| 1380 unsigned char flags, | 1394 unsigned char flags, |
| 1381 const char* arg1_name, | 1395 const char* arg1_name, |
| 1382 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& arg1_val, | 1396 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& arg1_val, |
| 1383 const char* arg2_name, | 1397 const char* arg2_name, |
| 1384 const ARG2_TYPE& arg2_val) { | 1398 const ARG2_TYPE& arg2_val) { |
| 1385 const int num_args = 2; | 1399 const int num_args = 2; |
| 1386 const char* arg_names[2] = { arg1_name, arg2_name }; | 1400 const char* arg_names[2] = { arg1_name, arg2_name }; |
| 1387 | 1401 |
| 1388 unsigned char arg_types[2]; | 1402 unsigned char arg_types[2]; |
| 1389 unsigned long long arg_values[2]; | 1403 unsigned long long arg_values[2]; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1400 num_args, arg_names, arg_types, arg_values, convertable_values, flags); | 1414 num_args, arg_names, arg_types, arg_values, convertable_values, flags); |
| 1401 } | 1415 } |
| 1402 | 1416 |
| 1403 static inline base::trace_event::TraceEventHandle | 1417 static inline base::trace_event::TraceEventHandle |
| 1404 AddTraceEventWithThreadIdAndTimestamp( | 1418 AddTraceEventWithThreadIdAndTimestamp( |
| 1405 char phase, | 1419 char phase, |
| 1406 const unsigned char* category_group_enabled, | 1420 const unsigned char* category_group_enabled, |
| 1407 const char* name, | 1421 const char* name, |
| 1408 unsigned long long id, | 1422 unsigned long long id, |
| 1409 int thread_id, | 1423 int thread_id, |
| 1410 const base::TimeTicks& timestamp, | 1424 const base::TraceTicks& timestamp, |
| 1411 unsigned char flags, | 1425 unsigned char flags, |
| 1412 const char* arg1_name, | 1426 const char* arg1_name, |
| 1413 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& arg1_val, | 1427 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& arg1_val, |
| 1414 const char* arg2_name, | 1428 const char* arg2_name, |
| 1415 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& | 1429 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& |
| 1416 arg2_val) { | 1430 arg2_val) { |
| 1417 const int num_args = 2; | 1431 const int num_args = 2; |
| 1418 const char* arg_names[2] = { arg1_name, arg2_name }; | 1432 const char* arg_names[2] = { arg1_name, arg2_name }; |
| 1419 unsigned char arg_types[2] = | 1433 unsigned char arg_types[2] = |
| 1420 { TRACE_VALUE_TYPE_CONVERTABLE, TRACE_VALUE_TYPE_CONVERTABLE }; | 1434 { TRACE_VALUE_TYPE_CONVERTABLE, TRACE_VALUE_TYPE_CONVERTABLE }; |
| 1421 scoped_refptr<base::trace_event::ConvertableToTraceFormat> | 1435 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
| 1422 convertable_values[2] = {arg1_val, arg2_val}; | 1436 convertable_values[2] = {arg1_val, arg2_val}; |
| 1423 | 1437 |
| 1424 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 1438 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
| 1425 phase, category_group_enabled, name, id, thread_id, timestamp, | 1439 phase, category_group_enabled, name, id, thread_id, timestamp, |
| 1426 num_args, arg_names, arg_types, NULL, convertable_values, flags); | 1440 num_args, arg_names, arg_types, NULL, convertable_values, flags); |
| 1427 } | 1441 } |
| 1428 | 1442 |
| 1429 static inline base::trace_event::TraceEventHandle | 1443 static inline base::trace_event::TraceEventHandle |
| 1430 AddTraceEventWithThreadIdAndTimestamp( | 1444 AddTraceEventWithThreadIdAndTimestamp( |
| 1431 char phase, | 1445 char phase, |
| 1432 const unsigned char* category_group_enabled, | 1446 const unsigned char* category_group_enabled, |
| 1433 const char* name, | 1447 const char* name, |
| 1434 unsigned long long id, | 1448 unsigned long long id, |
| 1435 int thread_id, | 1449 int thread_id, |
| 1436 const base::TimeTicks& timestamp, | 1450 const base::TraceTicks& timestamp, |
| 1437 unsigned char flags) { | 1451 unsigned char flags) { |
| 1438 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 1452 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
| 1439 phase, category_group_enabled, name, id, thread_id, timestamp, | 1453 phase, category_group_enabled, name, id, thread_id, timestamp, |
| 1440 kZeroNumArgs, NULL, NULL, NULL, NULL, flags); | 1454 kZeroNumArgs, NULL, NULL, NULL, NULL, flags); |
| 1441 } | 1455 } |
| 1442 | 1456 |
| 1443 static inline base::trace_event::TraceEventHandle AddTraceEvent( | 1457 static inline base::trace_event::TraceEventHandle AddTraceEvent( |
| 1444 char phase, | 1458 char phase, |
| 1445 const unsigned char* category_group_enabled, | 1459 const unsigned char* category_group_enabled, |
| 1446 const char* name, | 1460 const char* name, |
| 1447 unsigned long long id, | 1461 unsigned long long id, |
| 1448 unsigned char flags) { | 1462 unsigned char flags) { |
| 1449 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); | 1463 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); |
| 1450 base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime(); | 1464 base::TraceTicks now = base::TraceTicks::Now(); |
| 1451 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, | 1465 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, |
| 1452 name, id, thread_id, now, flags); | 1466 name, id, thread_id, now, flags); |
| 1453 } | 1467 } |
| 1454 | 1468 |
| 1455 template<class ARG1_TYPE> | 1469 template<class ARG1_TYPE> |
| 1456 static inline base::trace_event::TraceEventHandle | 1470 static inline base::trace_event::TraceEventHandle |
| 1457 AddTraceEventWithThreadIdAndTimestamp( | 1471 AddTraceEventWithThreadIdAndTimestamp( |
| 1458 char phase, | 1472 char phase, |
| 1459 const unsigned char* category_group_enabled, | 1473 const unsigned char* category_group_enabled, |
| 1460 const char* name, | 1474 const char* name, |
| 1461 unsigned long long id, | 1475 unsigned long long id, |
| 1462 int thread_id, | 1476 int thread_id, |
| 1463 const base::TimeTicks& timestamp, | 1477 const base::TraceTicks& timestamp, |
| 1464 unsigned char flags, | 1478 unsigned char flags, |
| 1465 const char* arg1_name, | 1479 const char* arg1_name, |
| 1466 const ARG1_TYPE& arg1_val) { | 1480 const ARG1_TYPE& arg1_val) { |
| 1467 const int num_args = 1; | 1481 const int num_args = 1; |
| 1468 unsigned char arg_types[1]; | 1482 unsigned char arg_types[1]; |
| 1469 unsigned long long arg_values[1]; | 1483 unsigned long long arg_values[1]; |
| 1470 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); | 1484 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); |
| 1471 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 1485 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
| 1472 phase, category_group_enabled, name, id, thread_id, timestamp, | 1486 phase, category_group_enabled, name, id, thread_id, timestamp, |
| 1473 num_args, &arg1_name, arg_types, arg_values, NULL, flags); | 1487 num_args, &arg1_name, arg_types, arg_values, NULL, flags); |
| 1474 } | 1488 } |
| 1475 | 1489 |
| 1476 template<class ARG1_TYPE> | 1490 template<class ARG1_TYPE> |
| 1477 static inline base::trace_event::TraceEventHandle AddTraceEvent( | 1491 static inline base::trace_event::TraceEventHandle AddTraceEvent( |
| 1478 char phase, | 1492 char phase, |
| 1479 const unsigned char* category_group_enabled, | 1493 const unsigned char* category_group_enabled, |
| 1480 const char* name, | 1494 const char* name, |
| 1481 unsigned long long id, | 1495 unsigned long long id, |
| 1482 unsigned char flags, | 1496 unsigned char flags, |
| 1483 const char* arg1_name, | 1497 const char* arg1_name, |
| 1484 const ARG1_TYPE& arg1_val) { | 1498 const ARG1_TYPE& arg1_val) { |
| 1485 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); | 1499 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); |
| 1486 base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime(); | 1500 base::TraceTicks now = base::TraceTicks::Now(); |
| 1487 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, | 1501 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, |
| 1488 name, id, thread_id, now, flags, | 1502 name, id, thread_id, now, flags, |
| 1489 arg1_name, arg1_val); | 1503 arg1_name, arg1_val); |
| 1490 } | 1504 } |
| 1491 | 1505 |
| 1492 template<class ARG1_TYPE, class ARG2_TYPE> | 1506 template<class ARG1_TYPE, class ARG2_TYPE> |
| 1493 static inline base::trace_event::TraceEventHandle | 1507 static inline base::trace_event::TraceEventHandle |
| 1494 AddTraceEventWithThreadIdAndTimestamp( | 1508 AddTraceEventWithThreadIdAndTimestamp( |
| 1495 char phase, | 1509 char phase, |
| 1496 const unsigned char* category_group_enabled, | 1510 const unsigned char* category_group_enabled, |
| 1497 const char* name, | 1511 const char* name, |
| 1498 unsigned long long id, | 1512 unsigned long long id, |
| 1499 int thread_id, | 1513 int thread_id, |
| 1500 const base::TimeTicks& timestamp, | 1514 const base::TraceTicks& timestamp, |
| 1501 unsigned char flags, | 1515 unsigned char flags, |
| 1502 const char* arg1_name, | 1516 const char* arg1_name, |
| 1503 const ARG1_TYPE& arg1_val, | 1517 const ARG1_TYPE& arg1_val, |
| 1504 const char* arg2_name, | 1518 const char* arg2_name, |
| 1505 const ARG2_TYPE& arg2_val) { | 1519 const ARG2_TYPE& arg2_val) { |
| 1506 const int num_args = 2; | 1520 const int num_args = 2; |
| 1507 const char* arg_names[2] = { arg1_name, arg2_name }; | 1521 const char* arg_names[2] = { arg1_name, arg2_name }; |
| 1508 unsigned char arg_types[2]; | 1522 unsigned char arg_types[2]; |
| 1509 unsigned long long arg_values[2]; | 1523 unsigned long long arg_values[2]; |
| 1510 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); | 1524 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); |
| 1511 SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]); | 1525 SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]); |
| 1512 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( |
| 1513 phase, category_group_enabled, name, id, thread_id, timestamp, | 1527 phase, category_group_enabled, name, id, thread_id, timestamp, |
| 1514 num_args, arg_names, arg_types, arg_values, NULL, flags); | 1528 num_args, arg_names, arg_types, arg_values, NULL, flags); |
| 1515 } | 1529 } |
| 1516 | 1530 |
| 1517 template<class ARG1_TYPE, class ARG2_TYPE> | 1531 template<class ARG1_TYPE, class ARG2_TYPE> |
| 1518 static inline base::trace_event::TraceEventHandle AddTraceEvent( | 1532 static inline base::trace_event::TraceEventHandle AddTraceEvent( |
| 1519 char phase, | 1533 char phase, |
| 1520 const unsigned char* category_group_enabled, | 1534 const unsigned char* category_group_enabled, |
| 1521 const char* name, | 1535 const char* name, |
| 1522 unsigned long long id, | 1536 unsigned long long id, |
| 1523 unsigned char flags, | 1537 unsigned char flags, |
| 1524 const char* arg1_name, | 1538 const char* arg1_name, |
| 1525 const ARG1_TYPE& arg1_val, | 1539 const ARG1_TYPE& arg1_val, |
| 1526 const char* arg2_name, | 1540 const char* arg2_name, |
| 1527 const ARG2_TYPE& arg2_val) { | 1541 const ARG2_TYPE& arg2_val) { |
| 1528 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); | 1542 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); |
| 1529 base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime(); | 1543 base::TraceTicks now = base::TraceTicks::Now(); |
| 1530 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, | 1544 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, |
| 1531 name, id, thread_id, now, flags, | 1545 name, id, thread_id, now, flags, |
| 1532 arg1_name, arg1_val, | 1546 arg1_name, arg1_val, |
| 1533 arg2_name, arg2_val); | 1547 arg2_name, arg2_val); |
| 1534 } | 1548 } |
| 1535 | 1549 |
| 1536 // Used by TRACE_EVENTx macros. Do not use directly. | 1550 // Used by TRACE_EVENTx macros. Do not use directly. |
| 1537 class TRACE_EVENT_API_CLASS_EXPORT ScopedTracer { | 1551 class TRACE_EVENT_API_CLASS_EXPORT ScopedTracer { |
| 1538 public: | 1552 public: |
| 1539 // Note: members of data_ intentionally left uninitialized. See Initialize. | 1553 // Note: members of data_ intentionally left uninitialized. See Initialize. |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1649 const char* name_; | 1663 const char* name_; |
| 1650 IDType id_; | 1664 IDType id_; |
| 1651 | 1665 |
| 1652 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); | 1666 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); |
| 1653 }; | 1667 }; |
| 1654 | 1668 |
| 1655 } // namespace trace_event | 1669 } // namespace trace_event |
| 1656 } // namespace base | 1670 } // namespace base |
| 1657 | 1671 |
| 1658 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ | 1672 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ |
| OLD | NEW |