Chromium Code Reviews| 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 is designed to give you trace_event macros without specifying | 5 // This header is designed to give you 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 // event to some other universe, you can copy-and-paste this file, | 7 // event to some other universe, you can copy-and-paste this file, |
| 8 // implement the TRACE_EVENT_API macros, and do any other necessary fixup for | 8 // implement the TRACE_EVENT_API macros, and do any other necessary fixup for |
| 9 // the target platform. The end result is that multiple libraries can funnel | 9 // the target platform. The end result is that multiple libraries can funnel |
| 10 // events through to a shared trace event collector. | 10 // events through to a shared trace event collector. |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 category, name, TRACE_EVENT_FLAG_COPY) | 258 category, name, TRACE_EVENT_FLAG_COPY) |
| 259 #define TRACE_EVENT_COPY_BEGIN1(category, name, arg1_name, arg1_val) \ | 259 #define TRACE_EVENT_COPY_BEGIN1(category, name, arg1_name, arg1_val) \ |
| 260 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ | 260 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ |
| 261 category, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val) | 261 category, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val) |
| 262 #define TRACE_EVENT_COPY_BEGIN2(category, name, arg1_name, arg1_val, \ | 262 #define TRACE_EVENT_COPY_BEGIN2(category, name, arg1_name, arg1_val, \ |
| 263 arg2_name, arg2_val) \ | 263 arg2_name, arg2_val) \ |
| 264 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ | 264 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ |
| 265 category, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \ | 265 category, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \ |
| 266 arg2_name, arg2_val) | 266 arg2_name, arg2_val) |
| 267 | 267 |
| 268 // Similar to TRACE_EVENT_BEGINx but with a custom |at| timestamp provided. | |
| 269 // - |id| is used to match the _BEGIN event with the _END event. | |
| 270 // Events are considered to match if their category, name and id values all | |
| 271 // match. |id| must either be a pointer or an integer value up to 64 bits. If | |
| 272 // it's a pointer, the bits will be xored with a hash of the process ID so | |
| 273 // that the same pointer on two different processes will not collide. | |
| 274 #define TRACE_EVENT_BEGIN_WITH_ID_TID_AND_TIMESTAMP0(category, \ | |
| 275 name, id, tid, ts) \ | |
| 276 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ | |
| 277 TRACE_EVENT_PHASE_ASYNC_BEGIN, category, name, id, tid, ts, \ | |
| 278 TRACE_EVENT_FLAG_NONE) | |
| 279 #define TRACE_EVENT_COPY_BEGIN_WITH_ID_TID_AND_TIMESTAMP0( \ | |
| 280 category, name, id, tid, ts) \ | |
| 281 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ | |
| 282 TRACE_EVENT_PHASE_ASYNC_BEGIN, category, name, id, tid, ts, \ | |
| 283 TRACE_EVENT_FLAG_COPY) | |
| 284 | |
| 268 // Records a single END event for "name" immediately. If the category | 285 // Records a single END event for "name" immediately. If the category |
| 269 // is not enabled, then this does nothing. | 286 // is not enabled, then this does nothing. |
| 270 // - category and name strings must have application lifetime (statics or | 287 // - category and name strings must have application lifetime (statics or |
| 271 // literals). They may not include " chars. | 288 // literals). They may not include " chars. |
| 272 #define TRACE_EVENT_END0(category, name) \ | 289 #define TRACE_EVENT_END0(category, name) \ |
| 273 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ | 290 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
| 274 category, name, TRACE_EVENT_FLAG_NONE) | 291 category, name, TRACE_EVENT_FLAG_NONE) |
| 275 #define TRACE_EVENT_END1(category, name, arg1_name, arg1_val) \ | 292 #define TRACE_EVENT_END1(category, name, arg1_name, arg1_val) \ |
| 276 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ | 293 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
| 277 category, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) | 294 category, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) |
| 278 #define TRACE_EVENT_END2(category, name, arg1_name, arg1_val, \ | 295 #define TRACE_EVENT_END2(category, name, arg1_name, arg1_val, \ |
| 279 arg2_name, arg2_val) \ | 296 arg2_name, arg2_val) \ |
| 280 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ | 297 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
| 281 category, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ | 298 category, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ |
| 282 arg2_name, arg2_val) | 299 arg2_name, arg2_val) |
| 283 #define TRACE_EVENT_COPY_END0(category, name) \ | 300 #define TRACE_EVENT_COPY_END0(category, name) \ |
| 284 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ | 301 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
| 285 category, name, TRACE_EVENT_FLAG_COPY) | 302 category, name, TRACE_EVENT_FLAG_COPY) |
| 286 #define TRACE_EVENT_COPY_END1(category, name, arg1_name, arg1_val) \ | 303 #define TRACE_EVENT_COPY_END1(category, name, arg1_name, arg1_val) \ |
| 287 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ | 304 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
| 288 category, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val) | 305 category, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val) |
| 289 #define TRACE_EVENT_COPY_END2(category, name, arg1_name, arg1_val, \ | 306 #define TRACE_EVENT_COPY_END2(category, name, arg1_name, arg1_val, \ |
| 290 arg2_name, arg2_val) \ | 307 arg2_name, arg2_val) \ |
| 291 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ | 308 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
| 292 category, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \ | 309 category, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \ |
| 293 arg2_name, arg2_val) | 310 arg2_name, arg2_val) |
| 294 | 311 |
| 312 // Similar to TRACE_EVENT_ENDx but with a custom |at| timestamp provided. | |
| 313 // - |id| is used to match the _BEGIN event with the _END event. | |
| 314 // Events are considered to match if their category, name and id values all | |
| 315 // match. |id| must either be a pointer or an integer value up to 64 bits. If | |
| 316 // it's a pointer, the bits will be xored with a hash of the process ID so | |
| 317 // that the same pointer on two different processes will not collide. | |
| 318 #define TRACE_EVENT_END_WITH_ID_TID_AND_TIMESTAMP0(category, \ | |
| 319 name, id, tid, ts) \ | |
| 320 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ | |
| 321 TRACE_EVENT_PHASE_ASYNC_END, category, name, id, tid, ts, \ | |
| 322 TRACE_EVENT_FLAG_NONE) | |
| 323 #define TRACE_EVENT_COPY_END_WITH_ID_TID_AND_TIMESTAMP0( \ | |
| 324 category, name, id, tid, ts) \ | |
| 325 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ | |
| 326 TRACE_EVENT_PHASE_ASYNC_END, category, name, id, tid, ts, \ | |
| 327 TRACE_EVENT_FLAG_COPY) | |
| 328 | |
| 295 // Records the value of a counter called "name" immediately. Value | 329 // Records the value of a counter called "name" immediately. Value |
| 296 // must be representable as a 32 bit integer. | 330 // must be representable as a 32 bit integer. |
| 297 // - category and name strings must have application lifetime (statics or | 331 // - category and name strings must have application lifetime (statics or |
| 298 // literals). They may not include " chars. | 332 // literals). They may not include " chars. |
| 299 #define TRACE_COUNTER1(category, name, value) \ | 333 #define TRACE_COUNTER1(category, name, value) \ |
| 300 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, \ | 334 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, \ |
| 301 category, name, TRACE_EVENT_FLAG_NONE, \ | 335 category, name, TRACE_EVENT_FLAG_NONE, \ |
| 302 "value", static_cast<int>(value)) | 336 "value", static_cast<int>(value)) |
| 303 #define TRACE_COPY_COUNTER1(category, name, value) \ | 337 #define TRACE_COPY_COUNTER1(category, name, value) \ |
| 304 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, \ | 338 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, \ |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 554 // unsigned char is non-zero, tracing is enabled. If tracing is enabled, | 588 // unsigned char is non-zero, tracing is enabled. If tracing is enabled, |
| 555 // TRACE_EVENT_API_ADD_TRACE_EVENT can be called. It's OK if tracing is disabled | 589 // TRACE_EVENT_API_ADD_TRACE_EVENT can be called. It's OK if tracing is disabled |
| 556 // between the load of the tracing state and the call to | 590 // between the load of the tracing state and the call to |
| 557 // TRACE_EVENT_API_ADD_TRACE_EVENT, because this flag only provides an early out | 591 // TRACE_EVENT_API_ADD_TRACE_EVENT, because this flag only provides an early out |
| 558 // for best performance when tracing is disabled. | 592 // for best performance when tracing is disabled. |
| 559 // const unsigned char* | 593 // const unsigned char* |
| 560 // TRACE_EVENT_API_GET_CATEGORY_ENABLED(const char* category_name) | 594 // TRACE_EVENT_API_GET_CATEGORY_ENABLED(const char* category_name) |
| 561 #define TRACE_EVENT_API_GET_CATEGORY_ENABLED \ | 595 #define TRACE_EVENT_API_GET_CATEGORY_ENABLED \ |
| 562 base::debug::TraceLog::GetCategoryEnabled | 596 base::debug::TraceLog::GetCategoryEnabled |
| 563 | 597 |
| 564 // Add a trace event to the platform tracing system. | 598 // Add a trace event to the platform tracing system. Returns thresholdBeginId |
| 565 // void TRACE_EVENT_API_ADD_TRACE_EVENT( | 599 // for use in a corresponding end TRACE_EVENT_API_ADD_TRACE_EVENT call. |
| 600 // int TRACE_EVENT_API_ADD_TRACE_EVENT( | |
| 566 // char phase, | 601 // char phase, |
| 567 // const unsigned char* category_enabled, | 602 // const unsigned char* category_enabled, |
| 568 // const char* name, | 603 // const char* name, |
| 569 // unsigned long long id, | 604 // unsigned long long id, |
| 605 // int thread_id, | |
| 606 // int64 timestamp, | |
| 570 // int num_args, | 607 // int num_args, |
| 571 // const char** arg_names, | 608 // const char** arg_names, |
| 572 // const unsigned char* arg_types, | 609 // const unsigned char* arg_types, |
| 573 // const unsigned long long* arg_values, | 610 // const unsigned long long* arg_values, |
| 574 // unsigned char flags) | 611 // unsigned char flags) |
| 575 #define TRACE_EVENT_API_ADD_TRACE_EVENT \ | 612 #define TRACE_EVENT_API_ADD_TRACE_EVENT \ |
| 576 base::debug::TraceLog::GetInstance()->AddTraceEvent | 613 base::debug::TraceLog::GetInstance()->AddTraceEvent |
| 577 | 614 |
| 578 //////////////////////////////////////////////////////////////////////////////// | 615 //////////////////////////////////////////////////////////////////////////////// |
| 579 | 616 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 643 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ | 680 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ |
| 644 trace_event_internal::TraceID trace_event_trace_id( \ | 681 trace_event_internal::TraceID trace_event_trace_id( \ |
| 645 id, &trace_event_flags); \ | 682 id, &trace_event_flags); \ |
| 646 trace_event_internal::AddTraceEvent( \ | 683 trace_event_internal::AddTraceEvent( \ |
| 647 phase, INTERNAL_TRACE_EVENT_UID(catstatic), \ | 684 phase, INTERNAL_TRACE_EVENT_UID(catstatic), \ |
| 648 name, trace_event_trace_id.data(), trace_event_flags, \ | 685 name, trace_event_trace_id.data(), trace_event_flags, \ |
| 649 ##__VA_ARGS__); \ | 686 ##__VA_ARGS__); \ |
| 650 } \ | 687 } \ |
| 651 } while (0) | 688 } while (0) |
| 652 | 689 |
| 690 // Implementation detail: internal macro to create static category and add | |
| 691 // event if the category is enabled. | |
| 692 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP(phase, category, \ | |
| 693 name, id, tid, ts, flags, ...) \ | |
| 694 do { \ | |
| 695 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ | |
| 696 if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ | |
| 697 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ | |
| 698 trace_event_internal::TraceID trace_event_trace_id( \ | |
| 699 id, &trace_event_flags); \ | |
| 700 trace_event_internal::AddTraceEvent( \ | |
| 701 phase, INTERNAL_TRACE_EVENT_UID(catstatic), \ | |
| 702 name, trace_event_trace_id.data(), tid, ts, \ | |
| 703 trace_event_flags, ##__VA_ARGS__); \ | |
| 704 } \ | |
| 705 } while (0) | |
| 706 | |
| 653 // Notes regarding the following definitions: | 707 // Notes regarding the following definitions: |
| 654 // New values can be added and propagated to third party libraries, but existing | 708 // New values can be added and propagated to third party libraries, but existing |
| 655 // definitions must never be changed, because third party libraries may use old | 709 // definitions must never be changed, because third party libraries may use old |
| 656 // definitions. | 710 // definitions. |
| 657 | 711 |
| 658 // Phase indicates the nature of an event entry. E.g. part of a begin/end pair. | 712 // Phase indicates the nature of an event entry. E.g. part of a begin/end pair. |
| 659 #define TRACE_EVENT_PHASE_BEGIN ('B') | 713 #define TRACE_EVENT_PHASE_BEGIN ('B') |
| 660 #define TRACE_EVENT_PHASE_END ('E') | 714 #define TRACE_EVENT_PHASE_END ('E') |
| 661 #define TRACE_EVENT_PHASE_INSTANT ('I') | 715 #define TRACE_EVENT_PHASE_INSTANT ('I') |
| 662 #define TRACE_EVENT_PHASE_ASYNC_BEGIN ('S') | 716 #define TRACE_EVENT_PHASE_ASYNC_BEGIN ('S') |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 829 *value = type_value.as_uint; | 883 *value = type_value.as_uint; |
| 830 } | 884 } |
| 831 | 885 |
| 832 // These AddTraceEvent template functions are defined here instead of in the | 886 // These AddTraceEvent template functions are defined here instead of in the |
| 833 // macro, because the arg_values could be temporary objects, such as | 887 // macro, because the arg_values could be temporary objects, such as |
| 834 // std::string. In order to store pointers to the internal c_str and pass | 888 // std::string. In order to store pointers to the internal c_str and pass |
| 835 // through to the tracing API, the arg_values must live throughout | 889 // through to the tracing API, the arg_values must live throughout |
| 836 // these procedures. | 890 // these procedures. |
| 837 | 891 |
| 838 static inline void AddTraceEvent(char phase, | 892 static inline void AddTraceEvent(char phase, |
| 839 const unsigned char* category_enabled, | 893 const unsigned char* category_enabled, |
| 840 const char* name, | 894 const char* name, |
| 841 unsigned long long id, | 895 unsigned long long id, |
| 842 unsigned char flags) { | 896 int thread_id, |
| 897 int64 timestamp, | |
| 898 unsigned char flags) { | |
| 843 TRACE_EVENT_API_ADD_TRACE_EVENT( | 899 TRACE_EVENT_API_ADD_TRACE_EVENT( |
| 844 phase, category_enabled, name, id, | 900 phase, category_enabled, name, id, thread_id, timestamp, |
| 845 kZeroNumArgs, NULL, NULL, NULL, | 901 kZeroNumArgs, NULL, NULL, NULL, |
| 846 flags); | 902 flags); |
| 847 } | 903 } |
| 848 | 904 |
| 905 static inline void AddTraceEvent(char phase, | |
| 906 const unsigned char* category_enabled, | |
| 907 const char* name, | |
| 908 unsigned long long id, | |
| 909 unsigned char flags) { | |
| 910 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); | |
| 911 base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime() - | |
|
nduca
2012/12/20 20:19:27
Can we take off the TimeOffset inside the TraceLog
dsinclair
2013/01/28 16:45:07
Done.
| |
| 912 base::debug::TraceLog::GetInstance()->GetTimeOffset(); | |
| 913 AddTraceEvent(phase, category_enabled, name, id, thread_id, | |
| 914 now.ToInternalValue(), flags); | |
| 915 } | |
| 916 | |
| 917 template<class ARG1_TYPE> | |
| 918 static inline void AddTraceEvent(char phase, | |
| 919 const unsigned char* category_enabled, | |
| 920 const char* name, | |
| 921 unsigned long long id, | |
| 922 int thread_id, | |
| 923 int64 timestamp, | |
| 924 unsigned char flags, | |
| 925 const char* arg1_name, | |
| 926 const ARG1_TYPE& arg1_val) { | |
| 927 const int num_args = 1; | |
| 928 unsigned char arg_types[1]; | |
| 929 unsigned long long arg_values[1]; | |
| 930 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); | |
| 931 TRACE_EVENT_API_ADD_TRACE_EVENT( | |
| 932 phase, category_enabled, name, id, thread_id, timestamp, | |
| 933 num_args, &arg1_name, arg_types, arg_values, | |
| 934 flags); | |
| 935 } | |
| 936 | |
| 849 template<class ARG1_TYPE> | 937 template<class ARG1_TYPE> |
| 850 static inline void AddTraceEvent(char phase, | 938 static inline void AddTraceEvent(char phase, |
| 851 const unsigned char* category_enabled, | 939 const unsigned char* category_enabled, |
| 852 const char* name, | 940 const char* name, |
| 853 unsigned long long id, | 941 unsigned long long id, |
| 854 unsigned char flags, | 942 unsigned char flags, |
| 855 const char* arg1_name, | 943 const char* arg1_name, |
| 856 const ARG1_TYPE& arg1_val) { | 944 const ARG1_TYPE& arg1_val) { |
| 857 const int num_args = 1; | 945 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); |
| 858 unsigned char arg_types[1]; | 946 base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime() - |
| 859 unsigned long long arg_values[1]; | 947 base::debug::TraceLog::GetInstance()->GetTimeOffset(); |
| 860 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); | 948 AddTraceEvent(phase, category_enabled, name, id, thread_id, |
| 861 TRACE_EVENT_API_ADD_TRACE_EVENT( | 949 now.ToInternalValue(), flags, |
| 862 phase, category_enabled, name, id, | 950 arg1_name, arg1_val); |
| 863 num_args, &arg1_name, arg_types, arg_values, | |
| 864 flags); | |
| 865 } | 951 } |
| 866 | 952 |
| 867 template<class ARG1_TYPE, class ARG2_TYPE> | 953 template<class ARG1_TYPE, class ARG2_TYPE> |
| 868 static inline void AddTraceEvent(char phase, | 954 static inline void AddTraceEvent(char phase, |
| 869 const unsigned char* category_enabled, | 955 const unsigned char* category_enabled, |
| 870 const char* name, | 956 const char* name, |
| 871 unsigned long long id, | 957 unsigned long long id, |
| 872 unsigned char flags, | 958 int thread_id, |
| 873 const char* arg1_name, | 959 int64 timestamp, |
| 874 const ARG1_TYPE& arg1_val, | 960 unsigned char flags, |
| 875 const char* arg2_name, | 961 const char* arg1_name, |
| 876 const ARG2_TYPE& arg2_val) { | 962 const ARG1_TYPE& arg1_val, |
| 963 const char* arg2_name, | |
| 964 const ARG2_TYPE& arg2_val) { | |
| 877 const int num_args = 2; | 965 const int num_args = 2; |
| 878 const char* arg_names[2] = { arg1_name, arg2_name }; | 966 const char* arg_names[2] = { arg1_name, arg2_name }; |
| 879 unsigned char arg_types[2]; | 967 unsigned char arg_types[2]; |
| 880 unsigned long long arg_values[2]; | 968 unsigned long long arg_values[2]; |
| 881 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); | 969 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); |
| 882 SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]); | 970 SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]); |
| 883 TRACE_EVENT_API_ADD_TRACE_EVENT( | 971 TRACE_EVENT_API_ADD_TRACE_EVENT( |
| 884 phase, category_enabled, name, id, | 972 phase, category_enabled, name, id, thread_id, timestamp, |
| 885 num_args, arg_names, arg_types, arg_values, | 973 num_args, arg_names, arg_types, arg_values, |
| 886 flags); | 974 flags); |
| 887 } | 975 } |
| 888 | 976 |
| 977 template<class ARG1_TYPE, class ARG2_TYPE> | |
| 978 static inline void AddTraceEvent(char phase, | |
| 979 const unsigned char* category_enabled, | |
| 980 const char* name, | |
| 981 unsigned long long id, | |
| 982 unsigned char flags, | |
| 983 const char* arg1_name, | |
| 984 const ARG1_TYPE& arg1_val, | |
| 985 const char* arg2_name, | |
| 986 const ARG2_TYPE& arg2_val) { | |
| 987 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); | |
| 988 base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime() - | |
| 989 base::debug::TraceLog::GetInstance()->GetTimeOffset(); | |
| 990 AddTraceEvent(phase, category_enabled, name, id, thread_id, | |
| 991 now.ToInternalValue(), flags, | |
| 992 arg1_name, arg1_val, arg2_name, arg2_val); | |
| 993 } | |
| 994 | |
| 889 // Used by TRACE_EVENTx macro. Do not use directly. | 995 // Used by TRACE_EVENTx macro. Do not use directly. |
| 890 class BASE_EXPORT TraceEndOnScopeClose { | 996 class BASE_EXPORT TraceEndOnScopeClose { |
| 891 public: | 997 public: |
| 892 // Note: members of data_ intentionally left uninitialized. See Initialize. | 998 // Note: members of data_ intentionally left uninitialized. See Initialize. |
| 893 TraceEndOnScopeClose() : p_data_(NULL) {} | 999 TraceEndOnScopeClose() : p_data_(NULL) {} |
| 894 ~TraceEndOnScopeClose() { | 1000 ~TraceEndOnScopeClose() { |
| 895 if (p_data_) | 1001 if (p_data_) |
| 896 AddEventIfEnabled(); | 1002 AddEventIfEnabled(); |
| 897 } | 1003 } |
| 898 | 1004 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 913 const char* name; | 1019 const char* name; |
| 914 }; | 1020 }; |
| 915 Data* p_data_; | 1021 Data* p_data_; |
| 916 Data data_; | 1022 Data data_; |
| 917 }; | 1023 }; |
| 918 | 1024 |
| 919 | 1025 |
| 920 } // namespace trace_event_internal | 1026 } // namespace trace_event_internal |
| 921 | 1027 |
| 922 #endif // BASE_DEBUG_TRACE_EVENT_H_ | 1028 #endif // BASE_DEBUG_TRACE_EVENT_H_ |
| OLD | NEW |