| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 // | 134 // |
| 135 // | 135 // |
| 136 // Convertable notes: | 136 // Convertable notes: |
| 137 // Converting a large data type to a string can be costly. To help with this, | 137 // Converting a large data type to a string can be costly. To help with this, |
| 138 // the trace framework provides an interface ConvertableToTraceFormat. If you | 138 // the trace framework provides an interface ConvertableToTraceFormat. If you |
| 139 // inherit from it and implement the AppendAsTraceFormat method the trace | 139 // inherit from it and implement the AppendAsTraceFormat method the trace |
| 140 // framework will call back to your object to convert a trace output time. This | 140 // framework will call back to your object to convert a trace output time. This |
| 141 // means, if the category for the event is disabled, the conversion will not | 141 // means, if the category for the event is disabled, the conversion will not |
| 142 // happen. | 142 // happen. |
| 143 // | 143 // |
| 144 // class MyData : public base::debug::ConvertableToTraceFormat { | 144 // class MyData : public base::trace_event::ConvertableToTraceFormat { |
| 145 // public: | 145 // public: |
| 146 // MyData() {} | 146 // MyData() {} |
| 147 // virtual void AppendAsTraceFormat(std::string* out) const override { | 147 // virtual void AppendAsTraceFormat(std::string* out) const override { |
| 148 // out->append("{\"foo\":1}"); | 148 // out->append("{\"foo\":1}"); |
| 149 // } | 149 // } |
| 150 // private: | 150 // private: |
| 151 // virtual ~MyData() {} | 151 // virtual ~MyData() {} |
| 152 // DISALLOW_COPY_AND_ASSIGN(MyData); | 152 // DISALLOW_COPY_AND_ASSIGN(MyData); |
| 153 // }; | 153 // }; |
| 154 // | 154 // |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 // ASYNC_STEP_PAST events. | 589 // ASYNC_STEP_PAST events. |
| 590 #define TRACE_EVENT_ASYNC_STEP_INTO0(category_group, name, id, step) \ | 590 #define TRACE_EVENT_ASYNC_STEP_INTO0(category_group, name, id, step) \ |
| 591 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP_INTO, \ | 591 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP_INTO, \ |
| 592 category_group, name, id, TRACE_EVENT_FLAG_NONE, "step", step) | 592 category_group, name, id, TRACE_EVENT_FLAG_NONE, "step", step) |
| 593 #define TRACE_EVENT_ASYNC_STEP_INTO1(category_group, name, id, step, \ | 593 #define TRACE_EVENT_ASYNC_STEP_INTO1(category_group, name, id, step, \ |
| 594 arg1_name, arg1_val) \ | 594 arg1_name, arg1_val) \ |
| 595 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP_INTO, \ | 595 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP_INTO, \ |
| 596 category_group, name, id, TRACE_EVENT_FLAG_NONE, "step", step, \ | 596 category_group, name, id, TRACE_EVENT_FLAG_NONE, "step", step, \ |
| 597 arg1_name, arg1_val) | 597 arg1_name, arg1_val) |
| 598 | 598 |
| 599 // Similar to TRACE_EVENT_ASYNC_STEP_INTOx but with a custom |at| timestamp |
| 600 // provided. |
| 601 #define TRACE_EVENT_ASYNC_STEP_INTO_WITH_TIMESTAMP0(category_group, name, \ |
| 602 id, step, timestamp) \ |
| 603 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ |
| 604 TRACE_EVENT_PHASE_ASYNC_STEP_INTO, category_group, name, id, \ |
| 605 static_cast<int>(base::PlatformThread::CurrentId()), \ |
| 606 timestamp, TRACE_EVENT_FLAG_NONE, "step", step) |
| 607 |
| 599 // Records a single ASYNC_STEP_PAST event for |step| immediately. If the | 608 // Records a single ASYNC_STEP_PAST event for |step| immediately. If the |
| 600 // category is not enabled, then this does nothing. The |name| and |id| must | 609 // category is not enabled, then this does nothing. The |name| and |id| must |
| 601 // match the ASYNC_BEGIN event above. The |step| param identifies this step | 610 // match the ASYNC_BEGIN event above. The |step| param identifies this step |
| 602 // within the async event. This should be called at the beginning of the next | 611 // within the async event. This should be called at the beginning of the next |
| 603 // phase of an asynchronous operation. The ASYNC_BEGIN event must not have any | 612 // phase of an asynchronous operation. The ASYNC_BEGIN event must not have any |
| 604 // ASYNC_STEP_INTO events. | 613 // ASYNC_STEP_INTO events. |
| 605 #define TRACE_EVENT_ASYNC_STEP_PAST0(category_group, name, id, step) \ | 614 #define TRACE_EVENT_ASYNC_STEP_PAST0(category_group, name, id, step) \ |
| 606 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP_PAST, \ | 615 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP_PAST, \ |
| 607 category_group, name, id, TRACE_EVENT_FLAG_NONE, "step", step) | 616 category_group, name, id, TRACE_EVENT_FLAG_NONE, "step", step) |
| 608 #define TRACE_EVENT_ASYNC_STEP_PAST1(category_group, name, id, step, \ | 617 #define TRACE_EVENT_ASYNC_STEP_PAST1(category_group, name, id, step, \ |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_SNAPSHOT_OBJECT, \ | 797 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_SNAPSHOT_OBJECT, \ |
| 789 category_group, name, TRACE_ID_DONT_MANGLE(id), TRACE_EVENT_FLAG_NONE,\ | 798 category_group, name, TRACE_ID_DONT_MANGLE(id), TRACE_EVENT_FLAG_NONE,\ |
| 790 "snapshot", snapshot) | 799 "snapshot", snapshot) |
| 791 | 800 |
| 792 #define TRACE_EVENT_OBJECT_DELETED_WITH_ID(category_group, name, id) \ | 801 #define TRACE_EVENT_OBJECT_DELETED_WITH_ID(category_group, name, id) \ |
| 793 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_DELETE_OBJECT, \ | 802 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_DELETE_OBJECT, \ |
| 794 category_group, name, TRACE_ID_DONT_MANGLE(id), TRACE_EVENT_FLAG_NONE) | 803 category_group, name, TRACE_ID_DONT_MANGLE(id), TRACE_EVENT_FLAG_NONE) |
| 795 | 804 |
| 796 #define INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE() \ | 805 #define INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE() \ |
| 797 UNLIKELY(*INTERNAL_TRACE_EVENT_UID(category_group_enabled) & \ | 806 UNLIKELY(*INTERNAL_TRACE_EVENT_UID(category_group_enabled) & \ |
| 798 (base::debug::TraceLog::ENABLED_FOR_RECORDING | \ | 807 (base::trace_event::TraceLog::ENABLED_FOR_RECORDING | \ |
| 799 base::debug::TraceLog::ENABLED_FOR_EVENT_CALLBACK)) | 808 base::trace_event::TraceLog::ENABLED_FOR_EVENT_CALLBACK)) |
| 800 | 809 |
| 801 // Macro to efficiently determine if a given category group is enabled. | 810 // Macro to efficiently determine if a given category group is enabled. |
| 802 #define TRACE_EVENT_CATEGORY_GROUP_ENABLED(category_group, ret) \ | 811 #define TRACE_EVENT_CATEGORY_GROUP_ENABLED(category_group, ret) \ |
| 803 do { \ | 812 do { \ |
| 804 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ | 813 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
| 805 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ | 814 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ |
| 806 *ret = true; \ | 815 *ret = true; \ |
| 807 } else { \ | 816 } else { \ |
| 808 *ret = false; \ | 817 *ret = false; \ |
| 809 } \ | 818 } \ |
| (...skipping 22 matching lines...) Expand all Loading... |
| 832 // long-lived literal strings should be given as the category group. The | 841 // long-lived literal strings should be given as the category group. The |
| 833 // returned pointer can be held permanently in a local static for example. If | 842 // returned pointer can be held permanently in a local static for example. If |
| 834 // the unsigned char is non-zero, tracing is enabled. If tracing is enabled, | 843 // the unsigned char is non-zero, tracing is enabled. If tracing is enabled, |
| 835 // TRACE_EVENT_API_ADD_TRACE_EVENT can be called. It's OK if tracing is disabled | 844 // TRACE_EVENT_API_ADD_TRACE_EVENT can be called. It's OK if tracing is disabled |
| 836 // between the load of the tracing state and the call to | 845 // between the load of the tracing state and the call to |
| 837 // TRACE_EVENT_API_ADD_TRACE_EVENT, because this flag only provides an early out | 846 // TRACE_EVENT_API_ADD_TRACE_EVENT, because this flag only provides an early out |
| 838 // for best performance when tracing is disabled. | 847 // for best performance when tracing is disabled. |
| 839 // const unsigned char* | 848 // const unsigned char* |
| 840 // TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(const char* category_group) | 849 // TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(const char* category_group) |
| 841 #define TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED \ | 850 #define TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED \ |
| 842 base::debug::TraceLog::GetCategoryGroupEnabled | 851 base::trace_event::TraceLog::GetCategoryGroupEnabled |
| 843 | 852 |
| 844 // Get the number of times traces have been recorded. This is used to implement | 853 // Get the number of times traces have been recorded. This is used to implement |
| 845 // the TRACE_EVENT_IS_NEW_TRACE facility. | 854 // the TRACE_EVENT_IS_NEW_TRACE facility. |
| 846 // unsigned int TRACE_EVENT_API_GET_NUM_TRACES_RECORDED() | 855 // unsigned int TRACE_EVENT_API_GET_NUM_TRACES_RECORDED() |
| 847 #define TRACE_EVENT_API_GET_NUM_TRACES_RECORDED \ | 856 #define TRACE_EVENT_API_GET_NUM_TRACES_RECORDED \ |
| 848 base::debug::TraceLog::GetInstance()->GetNumTracesRecorded | 857 base::trace_event::TraceLog::GetInstance()->GetNumTracesRecorded |
| 849 | 858 |
| 850 // Add a trace event to the platform tracing system. | 859 // Add a trace event to the platform tracing system. |
| 851 // base::debug::TraceEventHandle TRACE_EVENT_API_ADD_TRACE_EVENT( | 860 // base::trace_event::TraceEventHandle TRACE_EVENT_API_ADD_TRACE_EVENT( |
| 852 // char phase, | 861 // char phase, |
| 853 // const unsigned char* category_group_enabled, | 862 // const unsigned char* category_group_enabled, |
| 854 // const char* name, | 863 // const char* name, |
| 855 // unsigned long long id, | 864 // unsigned long long id, |
| 856 // int num_args, | 865 // int num_args, |
| 857 // const char** arg_names, | 866 // const char** arg_names, |
| 858 // const unsigned char* arg_types, | 867 // const unsigned char* arg_types, |
| 859 // const unsigned long long* arg_values, | 868 // const unsigned long long* arg_values, |
| 860 // unsigned char flags) | 869 // unsigned char flags) |
| 861 #define TRACE_EVENT_API_ADD_TRACE_EVENT \ | 870 #define TRACE_EVENT_API_ADD_TRACE_EVENT \ |
| 862 base::debug::TraceLog::GetInstance()->AddTraceEvent | 871 base::trace_event::TraceLog::GetInstance()->AddTraceEvent |
| 863 | 872 |
| 864 // Add a trace event to the platform tracing system. | 873 // Add a trace event to the platform tracing system. |
| 865 // base::debug::TraceEventHandle TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_TIMESTAMP( | 874 // base::trace_event::TraceEventHandle |
| 875 // TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_TIMESTAMP( |
| 866 // char phase, | 876 // char phase, |
| 867 // const unsigned char* category_group_enabled, | 877 // const unsigned char* category_group_enabled, |
| 868 // const char* name, | 878 // const char* name, |
| 869 // unsigned long long id, | 879 // unsigned long long id, |
| 870 // int thread_id, | 880 // int thread_id, |
| 871 // const TimeTicks& timestamp, | 881 // const TimeTicks& timestamp, |
| 872 // int num_args, | 882 // int num_args, |
| 873 // const char** arg_names, | 883 // const char** arg_names, |
| 874 // const unsigned char* arg_types, | 884 // const unsigned char* arg_types, |
| 875 // const unsigned long long* arg_values, | 885 // const unsigned long long* arg_values, |
| 876 // unsigned char flags) | 886 // unsigned char flags) |
| 877 #define TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP \ | 887 #define TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP \ |
| 878 base::debug::TraceLog::GetInstance()->AddTraceEventWithThreadIdAndTimestamp | 888 base::trace_event::TraceLog::GetInstance() \ |
| 889 ->AddTraceEventWithThreadIdAndTimestamp |
| 879 | 890 |
| 880 // Set the duration field of a COMPLETE trace event. | 891 // Set the duration field of a COMPLETE trace event. |
| 881 // void TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( | 892 // void TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( |
| 882 // const unsigned char* category_group_enabled, | 893 // const unsigned char* category_group_enabled, |
| 883 // const char* name, | 894 // const char* name, |
| 884 // base::debug::TraceEventHandle id) | 895 // base::trace_event::TraceEventHandle id) |
| 885 #define TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION \ | 896 #define TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION \ |
| 886 base::debug::TraceLog::GetInstance()->UpdateTraceEventDuration | 897 base::trace_event::TraceLog::GetInstance()->UpdateTraceEventDuration |
| 887 | 898 |
| 888 // Defines atomic operations used internally by the tracing system. | 899 // Defines atomic operations used internally by the tracing system. |
| 889 #define TRACE_EVENT_API_ATOMIC_WORD base::subtle::AtomicWord | 900 #define TRACE_EVENT_API_ATOMIC_WORD base::subtle::AtomicWord |
| 890 #define TRACE_EVENT_API_ATOMIC_LOAD(var) base::subtle::NoBarrier_Load(&(var)) | 901 #define TRACE_EVENT_API_ATOMIC_LOAD(var) base::subtle::NoBarrier_Load(&(var)) |
| 891 #define TRACE_EVENT_API_ATOMIC_STORE(var, value) \ | 902 #define TRACE_EVENT_API_ATOMIC_STORE(var, value) \ |
| 892 base::subtle::NoBarrier_Store(&(var), (value)) | 903 base::subtle::NoBarrier_Store(&(var), (value)) |
| 893 | 904 |
| 894 // Defines visibility for classes in trace_event.h | 905 // Defines visibility for classes in trace_event.h |
| 895 #define TRACE_EVENT_API_CLASS_EXPORT BASE_EXPORT | 906 #define TRACE_EVENT_API_CLASS_EXPORT BASE_EXPORT |
| 896 | 907 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 } \ | 960 } \ |
| 950 } while (0) | 961 } while (0) |
| 951 | 962 |
| 952 // Implementation detail: internal macro to create static category and add begin | 963 // Implementation detail: internal macro to create static category and add begin |
| 953 // event if the category is enabled. Also adds the end event when the scope | 964 // event if the category is enabled. Also adds the end event when the scope |
| 954 // ends. | 965 // ends. |
| 955 #define INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, ...) \ | 966 #define INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, ...) \ |
| 956 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ | 967 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
| 957 trace_event_internal::ScopedTracer INTERNAL_TRACE_EVENT_UID(tracer); \ | 968 trace_event_internal::ScopedTracer INTERNAL_TRACE_EVENT_UID(tracer); \ |
| 958 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ | 969 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ |
| 959 base::debug::TraceEventHandle h = trace_event_internal::AddTraceEvent( \ | 970 base::trace_event::TraceEventHandle h = \ |
| 960 TRACE_EVENT_PHASE_COMPLETE, \ | 971 trace_event_internal::AddTraceEvent( \ |
| 961 INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ | 972 TRACE_EVENT_PHASE_COMPLETE, \ |
| 962 name, trace_event_internal::kNoEventId, \ | 973 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ |
| 963 TRACE_EVENT_FLAG_NONE, ##__VA_ARGS__); \ | 974 trace_event_internal::kNoEventId, TRACE_EVENT_FLAG_NONE, \ |
| 975 ##__VA_ARGS__); \ |
| 964 INTERNAL_TRACE_EVENT_UID(tracer).Initialize( \ | 976 INTERNAL_TRACE_EVENT_UID(tracer).Initialize( \ |
| 965 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, h); \ | 977 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, h); \ |
| 966 } | 978 } |
| 967 | 979 |
| 968 // Implementation detail: internal macro to create static category and add | 980 // Implementation detail: internal macro to create static category and add |
| 969 // event if the category is enabled. | 981 // event if the category is enabled. |
| 970 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category_group, name, id, \ | 982 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category_group, name, id, \ |
| 971 flags, ...) \ | 983 flags, ...) \ |
| 972 do { \ | 984 do { \ |
| 973 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ | 985 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1246 *type = TRACE_VALUE_TYPE_INT; | 1258 *type = TRACE_VALUE_TYPE_INT; |
| 1247 *value = arg.ToInternalValue(); | 1259 *value = arg.ToInternalValue(); |
| 1248 } | 1260 } |
| 1249 | 1261 |
| 1250 // These AddTraceEvent and AddTraceEventWithThreadIdAndTimestamp template | 1262 // These AddTraceEvent and AddTraceEventWithThreadIdAndTimestamp template |
| 1251 // functions are defined here instead of in the macro, because the arg_values | 1263 // functions are defined here instead of in the macro, because the arg_values |
| 1252 // could be temporary objects, such as std::string. In order to store | 1264 // could be temporary objects, such as std::string. In order to store |
| 1253 // pointers to the internal c_str and pass through to the tracing API, | 1265 // pointers to the internal c_str and pass through to the tracing API, |
| 1254 // the arg_values must live throughout these procedures. | 1266 // the arg_values must live throughout these procedures. |
| 1255 | 1267 |
| 1256 static inline base::debug::TraceEventHandle | 1268 static inline base::trace_event::TraceEventHandle |
| 1257 AddTraceEventWithThreadIdAndTimestamp( | 1269 AddTraceEventWithThreadIdAndTimestamp( |
| 1258 char phase, | 1270 char phase, |
| 1259 const unsigned char* category_group_enabled, | 1271 const unsigned char* category_group_enabled, |
| 1260 const char* name, | 1272 const char* name, |
| 1261 unsigned long long id, | 1273 unsigned long long id, |
| 1262 int thread_id, | 1274 int thread_id, |
| 1263 const base::TimeTicks& timestamp, | 1275 const base::TimeTicks& timestamp, |
| 1264 unsigned char flags, | 1276 unsigned char flags, |
| 1265 const char* arg1_name, | 1277 const char* arg1_name, |
| 1266 const scoped_refptr<base::debug::ConvertableToTraceFormat>& arg1_val) { | 1278 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& |
| 1279 arg1_val) { |
| 1267 const int num_args = 1; | 1280 const int num_args = 1; |
| 1268 unsigned char arg_types[1] = { TRACE_VALUE_TYPE_CONVERTABLE }; | 1281 unsigned char arg_types[1] = { TRACE_VALUE_TYPE_CONVERTABLE }; |
| 1269 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 1282 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
| 1270 phase, category_group_enabled, name, id, thread_id, timestamp, | 1283 phase, category_group_enabled, name, id, thread_id, timestamp, |
| 1271 num_args, &arg1_name, arg_types, NULL, &arg1_val, flags); | 1284 num_args, &arg1_name, arg_types, NULL, &arg1_val, flags); |
| 1272 } | 1285 } |
| 1273 | 1286 |
| 1274 template<class ARG1_TYPE> | 1287 template<class ARG1_TYPE> |
| 1275 static inline base::debug::TraceEventHandle | 1288 static inline base::trace_event::TraceEventHandle |
| 1276 AddTraceEventWithThreadIdAndTimestamp( | 1289 AddTraceEventWithThreadIdAndTimestamp( |
| 1277 char phase, | 1290 char phase, |
| 1278 const unsigned char* category_group_enabled, | 1291 const unsigned char* category_group_enabled, |
| 1279 const char* name, | 1292 const char* name, |
| 1280 unsigned long long id, | 1293 unsigned long long id, |
| 1281 int thread_id, | 1294 int thread_id, |
| 1282 const base::TimeTicks& timestamp, | 1295 const base::TimeTicks& timestamp, |
| 1283 unsigned char flags, | 1296 unsigned char flags, |
| 1284 const char* arg1_name, | 1297 const char* arg1_name, |
| 1285 const ARG1_TYPE& arg1_val, | 1298 const ARG1_TYPE& arg1_val, |
| 1286 const char* arg2_name, | 1299 const char* arg2_name, |
| 1287 const scoped_refptr<base::debug::ConvertableToTraceFormat>& arg2_val) { | 1300 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& |
| 1301 arg2_val) { |
| 1288 const int num_args = 2; | 1302 const int num_args = 2; |
| 1289 const char* arg_names[2] = { arg1_name, arg2_name }; | 1303 const char* arg_names[2] = { arg1_name, arg2_name }; |
| 1290 | 1304 |
| 1291 unsigned char arg_types[2]; | 1305 unsigned char arg_types[2]; |
| 1292 unsigned long long arg_values[2]; | 1306 unsigned long long arg_values[2]; |
| 1293 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); | 1307 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); |
| 1294 arg_types[1] = TRACE_VALUE_TYPE_CONVERTABLE; | 1308 arg_types[1] = TRACE_VALUE_TYPE_CONVERTABLE; |
| 1295 | 1309 |
| 1296 scoped_refptr<base::debug::ConvertableToTraceFormat> convertable_values[2]; | 1310 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
| 1311 convertable_values[2]; |
| 1297 convertable_values[1] = arg2_val; | 1312 convertable_values[1] = arg2_val; |
| 1298 | 1313 |
| 1299 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 1314 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
| 1300 phase, category_group_enabled, name, id, thread_id, timestamp, | 1315 phase, category_group_enabled, name, id, thread_id, timestamp, |
| 1301 num_args, arg_names, arg_types, arg_values, convertable_values, flags); | 1316 num_args, arg_names, arg_types, arg_values, convertable_values, flags); |
| 1302 } | 1317 } |
| 1303 | 1318 |
| 1304 template<class ARG2_TYPE> | 1319 template<class ARG2_TYPE> |
| 1305 static inline base::debug::TraceEventHandle | 1320 static inline base::trace_event::TraceEventHandle |
| 1306 AddTraceEventWithThreadIdAndTimestamp( | 1321 AddTraceEventWithThreadIdAndTimestamp( |
| 1307 char phase, | 1322 char phase, |
| 1308 const unsigned char* category_group_enabled, | 1323 const unsigned char* category_group_enabled, |
| 1309 const char* name, | 1324 const char* name, |
| 1310 unsigned long long id, | 1325 unsigned long long id, |
| 1311 int thread_id, | 1326 int thread_id, |
| 1312 const base::TimeTicks& timestamp, | 1327 const base::TimeTicks& timestamp, |
| 1313 unsigned char flags, | 1328 unsigned char flags, |
| 1314 const char* arg1_name, | 1329 const char* arg1_name, |
| 1315 const scoped_refptr<base::debug::ConvertableToTraceFormat>& arg1_val, | 1330 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& arg1_val, |
| 1316 const char* arg2_name, | 1331 const char* arg2_name, |
| 1317 const ARG2_TYPE& arg2_val) { | 1332 const ARG2_TYPE& arg2_val) { |
| 1318 const int num_args = 2; | 1333 const int num_args = 2; |
| 1319 const char* arg_names[2] = { arg1_name, arg2_name }; | 1334 const char* arg_names[2] = { arg1_name, arg2_name }; |
| 1320 | 1335 |
| 1321 unsigned char arg_types[2]; | 1336 unsigned char arg_types[2]; |
| 1322 unsigned long long arg_values[2]; | 1337 unsigned long long arg_values[2]; |
| 1323 arg_types[0] = TRACE_VALUE_TYPE_CONVERTABLE; | 1338 arg_types[0] = TRACE_VALUE_TYPE_CONVERTABLE; |
| 1324 arg_values[0] = 0; | 1339 arg_values[0] = 0; |
| 1325 SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]); | 1340 SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]); |
| 1326 | 1341 |
| 1327 scoped_refptr<base::debug::ConvertableToTraceFormat> convertable_values[2]; | 1342 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
| 1343 convertable_values[2]; |
| 1328 convertable_values[0] = arg1_val; | 1344 convertable_values[0] = arg1_val; |
| 1329 | 1345 |
| 1330 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 1346 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
| 1331 phase, category_group_enabled, name, id, thread_id, timestamp, | 1347 phase, category_group_enabled, name, id, thread_id, timestamp, |
| 1332 num_args, arg_names, arg_types, arg_values, convertable_values, flags); | 1348 num_args, arg_names, arg_types, arg_values, convertable_values, flags); |
| 1333 } | 1349 } |
| 1334 | 1350 |
| 1335 static inline base::debug::TraceEventHandle | 1351 static inline base::trace_event::TraceEventHandle |
| 1336 AddTraceEventWithThreadIdAndTimestamp( | 1352 AddTraceEventWithThreadIdAndTimestamp( |
| 1337 char phase, | 1353 char phase, |
| 1338 const unsigned char* category_group_enabled, | 1354 const unsigned char* category_group_enabled, |
| 1339 const char* name, | 1355 const char* name, |
| 1340 unsigned long long id, | 1356 unsigned long long id, |
| 1341 int thread_id, | 1357 int thread_id, |
| 1342 const base::TimeTicks& timestamp, | 1358 const base::TimeTicks& timestamp, |
| 1343 unsigned char flags, | 1359 unsigned char flags, |
| 1344 const char* arg1_name, | 1360 const char* arg1_name, |
| 1345 const scoped_refptr<base::debug::ConvertableToTraceFormat>& arg1_val, | 1361 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& arg1_val, |
| 1346 const char* arg2_name, | 1362 const char* arg2_name, |
| 1347 const scoped_refptr<base::debug::ConvertableToTraceFormat>& arg2_val) { | 1363 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& |
| 1364 arg2_val) { |
| 1348 const int num_args = 2; | 1365 const int num_args = 2; |
| 1349 const char* arg_names[2] = { arg1_name, arg2_name }; | 1366 const char* arg_names[2] = { arg1_name, arg2_name }; |
| 1350 unsigned char arg_types[2] = | 1367 unsigned char arg_types[2] = |
| 1351 { TRACE_VALUE_TYPE_CONVERTABLE, TRACE_VALUE_TYPE_CONVERTABLE }; | 1368 { TRACE_VALUE_TYPE_CONVERTABLE, TRACE_VALUE_TYPE_CONVERTABLE }; |
| 1352 scoped_refptr<base::debug::ConvertableToTraceFormat> convertable_values[2] = | 1369 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
| 1353 { arg1_val, arg2_val }; | 1370 convertable_values[2] = {arg1_val, arg2_val}; |
| 1354 | 1371 |
| 1355 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 1372 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
| 1356 phase, category_group_enabled, name, id, thread_id, timestamp, | 1373 phase, category_group_enabled, name, id, thread_id, timestamp, |
| 1357 num_args, arg_names, arg_types, NULL, convertable_values, flags); | 1374 num_args, arg_names, arg_types, NULL, convertable_values, flags); |
| 1358 } | 1375 } |
| 1359 | 1376 |
| 1360 static inline base::debug::TraceEventHandle | 1377 static inline base::trace_event::TraceEventHandle |
| 1361 AddTraceEventWithThreadIdAndTimestamp( | 1378 AddTraceEventWithThreadIdAndTimestamp( |
| 1362 char phase, | 1379 char phase, |
| 1363 const unsigned char* category_group_enabled, | 1380 const unsigned char* category_group_enabled, |
| 1364 const char* name, | 1381 const char* name, |
| 1365 unsigned long long id, | 1382 unsigned long long id, |
| 1366 int thread_id, | 1383 int thread_id, |
| 1367 const base::TimeTicks& timestamp, | 1384 const base::TimeTicks& timestamp, |
| 1368 unsigned char flags) { | 1385 unsigned char flags) { |
| 1369 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 1386 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
| 1370 phase, category_group_enabled, name, id, thread_id, timestamp, | 1387 phase, category_group_enabled, name, id, thread_id, timestamp, |
| 1371 kZeroNumArgs, NULL, NULL, NULL, NULL, flags); | 1388 kZeroNumArgs, NULL, NULL, NULL, NULL, flags); |
| 1372 } | 1389 } |
| 1373 | 1390 |
| 1374 static inline base::debug::TraceEventHandle AddTraceEvent( | 1391 static inline base::trace_event::TraceEventHandle AddTraceEvent( |
| 1375 char phase, | 1392 char phase, |
| 1376 const unsigned char* category_group_enabled, | 1393 const unsigned char* category_group_enabled, |
| 1377 const char* name, | 1394 const char* name, |
| 1378 unsigned long long id, | 1395 unsigned long long id, |
| 1379 unsigned char flags) { | 1396 unsigned char flags) { |
| 1380 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); | 1397 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); |
| 1381 base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime(); | 1398 base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime(); |
| 1382 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, | 1399 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, |
| 1383 name, id, thread_id, now, flags); | 1400 name, id, thread_id, now, flags); |
| 1384 } | 1401 } |
| 1385 | 1402 |
| 1386 template<class ARG1_TYPE> | 1403 template<class ARG1_TYPE> |
| 1387 static inline base::debug::TraceEventHandle | 1404 static inline base::trace_event::TraceEventHandle |
| 1388 AddTraceEventWithThreadIdAndTimestamp( | 1405 AddTraceEventWithThreadIdAndTimestamp( |
| 1389 char phase, | 1406 char phase, |
| 1390 const unsigned char* category_group_enabled, | 1407 const unsigned char* category_group_enabled, |
| 1391 const char* name, | 1408 const char* name, |
| 1392 unsigned long long id, | 1409 unsigned long long id, |
| 1393 int thread_id, | 1410 int thread_id, |
| 1394 const base::TimeTicks& timestamp, | 1411 const base::TimeTicks& timestamp, |
| 1395 unsigned char flags, | 1412 unsigned char flags, |
| 1396 const char* arg1_name, | 1413 const char* arg1_name, |
| 1397 const ARG1_TYPE& arg1_val) { | 1414 const ARG1_TYPE& arg1_val) { |
| 1398 const int num_args = 1; | 1415 const int num_args = 1; |
| 1399 unsigned char arg_types[1]; | 1416 unsigned char arg_types[1]; |
| 1400 unsigned long long arg_values[1]; | 1417 unsigned long long arg_values[1]; |
| 1401 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); | 1418 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); |
| 1402 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 1419 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
| 1403 phase, category_group_enabled, name, id, thread_id, timestamp, | 1420 phase, category_group_enabled, name, id, thread_id, timestamp, |
| 1404 num_args, &arg1_name, arg_types, arg_values, NULL, flags); | 1421 num_args, &arg1_name, arg_types, arg_values, NULL, flags); |
| 1405 } | 1422 } |
| 1406 | 1423 |
| 1407 template<class ARG1_TYPE> | 1424 template<class ARG1_TYPE> |
| 1408 static inline base::debug::TraceEventHandle AddTraceEvent( | 1425 static inline base::trace_event::TraceEventHandle AddTraceEvent( |
| 1409 char phase, | 1426 char phase, |
| 1410 const unsigned char* category_group_enabled, | 1427 const unsigned char* category_group_enabled, |
| 1411 const char* name, | 1428 const char* name, |
| 1412 unsigned long long id, | 1429 unsigned long long id, |
| 1413 unsigned char flags, | 1430 unsigned char flags, |
| 1414 const char* arg1_name, | 1431 const char* arg1_name, |
| 1415 const ARG1_TYPE& arg1_val) { | 1432 const ARG1_TYPE& arg1_val) { |
| 1416 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); | 1433 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); |
| 1417 base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime(); | 1434 base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime(); |
| 1418 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, | 1435 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, |
| 1419 name, id, thread_id, now, flags, | 1436 name, id, thread_id, now, flags, |
| 1420 arg1_name, arg1_val); | 1437 arg1_name, arg1_val); |
| 1421 } | 1438 } |
| 1422 | 1439 |
| 1423 template<class ARG1_TYPE, class ARG2_TYPE> | 1440 template<class ARG1_TYPE, class ARG2_TYPE> |
| 1424 static inline base::debug::TraceEventHandle | 1441 static inline base::trace_event::TraceEventHandle |
| 1425 AddTraceEventWithThreadIdAndTimestamp( | 1442 AddTraceEventWithThreadIdAndTimestamp( |
| 1426 char phase, | 1443 char phase, |
| 1427 const unsigned char* category_group_enabled, | 1444 const unsigned char* category_group_enabled, |
| 1428 const char* name, | 1445 const char* name, |
| 1429 unsigned long long id, | 1446 unsigned long long id, |
| 1430 int thread_id, | 1447 int thread_id, |
| 1431 const base::TimeTicks& timestamp, | 1448 const base::TimeTicks& timestamp, |
| 1432 unsigned char flags, | 1449 unsigned char flags, |
| 1433 const char* arg1_name, | 1450 const char* arg1_name, |
| 1434 const ARG1_TYPE& arg1_val, | 1451 const ARG1_TYPE& arg1_val, |
| 1435 const char* arg2_name, | 1452 const char* arg2_name, |
| 1436 const ARG2_TYPE& arg2_val) { | 1453 const ARG2_TYPE& arg2_val) { |
| 1437 const int num_args = 2; | 1454 const int num_args = 2; |
| 1438 const char* arg_names[2] = { arg1_name, arg2_name }; | 1455 const char* arg_names[2] = { arg1_name, arg2_name }; |
| 1439 unsigned char arg_types[2]; | 1456 unsigned char arg_types[2]; |
| 1440 unsigned long long arg_values[2]; | 1457 unsigned long long arg_values[2]; |
| 1441 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); | 1458 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); |
| 1442 SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]); | 1459 SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]); |
| 1443 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 1460 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
| 1444 phase, category_group_enabled, name, id, thread_id, timestamp, | 1461 phase, category_group_enabled, name, id, thread_id, timestamp, |
| 1445 num_args, arg_names, arg_types, arg_values, NULL, flags); | 1462 num_args, arg_names, arg_types, arg_values, NULL, flags); |
| 1446 } | 1463 } |
| 1447 | 1464 |
| 1448 template<class ARG1_TYPE, class ARG2_TYPE> | 1465 template<class ARG1_TYPE, class ARG2_TYPE> |
| 1449 static inline base::debug::TraceEventHandle AddTraceEvent( | 1466 static inline base::trace_event::TraceEventHandle AddTraceEvent( |
| 1450 char phase, | 1467 char phase, |
| 1451 const unsigned char* category_group_enabled, | 1468 const unsigned char* category_group_enabled, |
| 1452 const char* name, | 1469 const char* name, |
| 1453 unsigned long long id, | 1470 unsigned long long id, |
| 1454 unsigned char flags, | 1471 unsigned char flags, |
| 1455 const char* arg1_name, | 1472 const char* arg1_name, |
| 1456 const ARG1_TYPE& arg1_val, | 1473 const ARG1_TYPE& arg1_val, |
| 1457 const char* arg2_name, | 1474 const char* arg2_name, |
| 1458 const ARG2_TYPE& arg2_val) { | 1475 const ARG2_TYPE& arg2_val) { |
| 1459 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); | 1476 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1471 ScopedTracer() : p_data_(NULL) {} | 1488 ScopedTracer() : p_data_(NULL) {} |
| 1472 | 1489 |
| 1473 ~ScopedTracer() { | 1490 ~ScopedTracer() { |
| 1474 if (p_data_ && *data_.category_group_enabled) | 1491 if (p_data_ && *data_.category_group_enabled) |
| 1475 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( | 1492 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( |
| 1476 data_.category_group_enabled, data_.name, data_.event_handle); | 1493 data_.category_group_enabled, data_.name, data_.event_handle); |
| 1477 } | 1494 } |
| 1478 | 1495 |
| 1479 void Initialize(const unsigned char* category_group_enabled, | 1496 void Initialize(const unsigned char* category_group_enabled, |
| 1480 const char* name, | 1497 const char* name, |
| 1481 base::debug::TraceEventHandle event_handle) { | 1498 base::trace_event::TraceEventHandle event_handle) { |
| 1482 data_.category_group_enabled = category_group_enabled; | 1499 data_.category_group_enabled = category_group_enabled; |
| 1483 data_.name = name; | 1500 data_.name = name; |
| 1484 data_.event_handle = event_handle; | 1501 data_.event_handle = event_handle; |
| 1485 p_data_ = &data_; | 1502 p_data_ = &data_; |
| 1486 } | 1503 } |
| 1487 | 1504 |
| 1488 private: | 1505 private: |
| 1489 // This Data struct workaround is to avoid initializing all the members | 1506 // This Data struct workaround is to avoid initializing all the members |
| 1490 // in Data during construction of this object, since this object is always | 1507 // in Data during construction of this object, since this object is always |
| 1491 // constructed, even when tracing is disabled. If the members of Data were | 1508 // constructed, even when tracing is disabled. If the members of Data were |
| 1492 // members of this class instead, compiler warnings occur about potential | 1509 // members of this class instead, compiler warnings occur about potential |
| 1493 // uninitialized accesses. | 1510 // uninitialized accesses. |
| 1494 struct Data { | 1511 struct Data { |
| 1495 const unsigned char* category_group_enabled; | 1512 const unsigned char* category_group_enabled; |
| 1496 const char* name; | 1513 const char* name; |
| 1497 base::debug::TraceEventHandle event_handle; | 1514 base::trace_event::TraceEventHandle event_handle; |
| 1498 }; | 1515 }; |
| 1499 Data* p_data_; | 1516 Data* p_data_; |
| 1500 Data data_; | 1517 Data data_; |
| 1501 }; | 1518 }; |
| 1502 | 1519 |
| 1503 // Used by TRACE_EVENT_BINARY_EFFICIENTx macro. Do not use directly. | 1520 // Used by TRACE_EVENT_BINARY_EFFICIENTx macro. Do not use directly. |
| 1504 class TRACE_EVENT_API_CLASS_EXPORT ScopedTraceBinaryEfficient { | 1521 class TRACE_EVENT_API_CLASS_EXPORT ScopedTraceBinaryEfficient { |
| 1505 public: | 1522 public: |
| 1506 ScopedTraceBinaryEfficient(const char* category_group, const char* name); | 1523 ScopedTraceBinaryEfficient(const char* category_group, const char* name); |
| 1507 ~ScopedTraceBinaryEfficient(); | 1524 ~ScopedTraceBinaryEfficient(); |
| 1508 | 1525 |
| 1509 private: | 1526 private: |
| 1510 const unsigned char* category_group_enabled_; | 1527 const unsigned char* category_group_enabled_; |
| 1511 const char* name_; | 1528 const char* name_; |
| 1512 base::debug::TraceEventHandle event_handle_; | 1529 base::trace_event::TraceEventHandle event_handle_; |
| 1513 }; | 1530 }; |
| 1514 | 1531 |
| 1515 // This macro generates less code then TRACE_EVENT0 but is also | 1532 // This macro generates less code then TRACE_EVENT0 but is also |
| 1516 // slower to execute when tracing is off. It should generally only be | 1533 // slower to execute when tracing is off. It should generally only be |
| 1517 // used with code that is seldom executed or conditionally executed | 1534 // used with code that is seldom executed or conditionally executed |
| 1518 // when debugging. | 1535 // when debugging. |
| 1519 // For now the category_group must be "gpu". | 1536 // For now the category_group must be "gpu". |
| 1520 #define TRACE_EVENT_BINARY_EFFICIENT0(category_group, name) \ | 1537 #define TRACE_EVENT_BINARY_EFFICIENT0(category_group, name) \ |
| 1521 trace_event_internal::ScopedTraceBinaryEfficient \ | 1538 trace_event_internal::ScopedTraceBinaryEfficient \ |
| 1522 INTERNAL_TRACE_EVENT_UID(scoped_trace)(category_group, name); | 1539 INTERNAL_TRACE_EVENT_UID(scoped_trace)(category_group, name); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1548 const_cast<char*>(category_and_name))); | 1565 const_cast<char*>(category_and_name))); |
| 1549 } | 1566 } |
| 1550 | 1567 |
| 1551 private: | 1568 private: |
| 1552 const char* previous_state_; | 1569 const char* previous_state_; |
| 1553 }; | 1570 }; |
| 1554 | 1571 |
| 1555 } // namespace trace_event_internal | 1572 } // namespace trace_event_internal |
| 1556 | 1573 |
| 1557 namespace base { | 1574 namespace base { |
| 1558 namespace debug { | 1575 namespace trace_event { |
| 1559 | 1576 |
| 1560 template<typename IDType> class TraceScopedTrackableObject { | 1577 template<typename IDType> class TraceScopedTrackableObject { |
| 1561 public: | 1578 public: |
| 1562 TraceScopedTrackableObject(const char* category_group, const char* name, | 1579 TraceScopedTrackableObject(const char* category_group, const char* name, |
| 1563 IDType id) | 1580 IDType id) |
| 1564 : category_group_(category_group), | 1581 : category_group_(category_group), |
| 1565 name_(name), | 1582 name_(name), |
| 1566 id_(id) { | 1583 id_(id) { |
| 1567 TRACE_EVENT_OBJECT_CREATED_WITH_ID(category_group_, name_, id_); | 1584 TRACE_EVENT_OBJECT_CREATED_WITH_ID(category_group_, name_, id_); |
| 1568 } | 1585 } |
| 1569 | 1586 |
| 1570 template <typename ArgType> void snapshot(ArgType snapshot) { | 1587 template <typename ArgType> void snapshot(ArgType snapshot) { |
| 1571 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(category_group_, name_, id_, snapshot); | 1588 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(category_group_, name_, id_, snapshot); |
| 1572 } | 1589 } |
| 1573 | 1590 |
| 1574 ~TraceScopedTrackableObject() { | 1591 ~TraceScopedTrackableObject() { |
| 1575 TRACE_EVENT_OBJECT_DELETED_WITH_ID(category_group_, name_, id_); | 1592 TRACE_EVENT_OBJECT_DELETED_WITH_ID(category_group_, name_, id_); |
| 1576 } | 1593 } |
| 1577 | 1594 |
| 1578 private: | 1595 private: |
| 1579 const char* category_group_; | 1596 const char* category_group_; |
| 1580 const char* name_; | 1597 const char* name_; |
| 1581 IDType id_; | 1598 IDType id_; |
| 1582 | 1599 |
| 1583 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); | 1600 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); |
| 1584 }; | 1601 }; |
| 1585 | 1602 |
| 1586 } // namespace debug | 1603 } // namespace trace_event |
| 1587 } // namespace base | 1604 } // namespace base |
| 1605 |
| 1606 // TODO(ssid): remove these aliases after the tracing clients are moved to the |
| 1607 // new trace_event namespace. See crbug.com/451032. ETA: March 2015. |
| 1608 namespace base { |
| 1609 namespace debug { |
| 1610 using base::trace_event::TraceScopedTrackableObject; |
| 1611 } // namespace debug |
| 1612 } // namespace base |
| 1588 | 1613 |
| 1589 #endif /* BASE_TRACE_EVENT_TRACE_EVENT_H_ */ | 1614 #endif /* BASE_TRACE_EVENT_TRACE_EVENT_H_ */ |
| OLD | NEW |