Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: base/trace_event/trace_event.h

Issue 904573002: Revert of Move tracing namespace from base::debug to base::trace_event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_trace_part1
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | base/trace_event/trace_event_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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::trace_event::ConvertableToTraceFormat { 144 // class MyData : public base::debug::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 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_SNAPSHOT_OBJECT, \ 788 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_SNAPSHOT_OBJECT, \
789 category_group, name, TRACE_ID_DONT_MANGLE(id), TRACE_EVENT_FLAG_NONE,\ 789 category_group, name, TRACE_ID_DONT_MANGLE(id), TRACE_EVENT_FLAG_NONE,\
790 "snapshot", snapshot) 790 "snapshot", snapshot)
791 791
792 #define TRACE_EVENT_OBJECT_DELETED_WITH_ID(category_group, name, id) \ 792 #define TRACE_EVENT_OBJECT_DELETED_WITH_ID(category_group, name, id) \
793 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_DELETE_OBJECT, \ 793 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_DELETE_OBJECT, \
794 category_group, name, TRACE_ID_DONT_MANGLE(id), TRACE_EVENT_FLAG_NONE) 794 category_group, name, TRACE_ID_DONT_MANGLE(id), TRACE_EVENT_FLAG_NONE)
795 795
796 #define INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE() \ 796 #define INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE() \
797 UNLIKELY(*INTERNAL_TRACE_EVENT_UID(category_group_enabled) & \ 797 UNLIKELY(*INTERNAL_TRACE_EVENT_UID(category_group_enabled) & \
798 (base::trace_event::TraceLog::ENABLED_FOR_RECORDING | \ 798 (base::debug::TraceLog::ENABLED_FOR_RECORDING | \
799 base::trace_event::TraceLog::ENABLED_FOR_EVENT_CALLBACK)) 799 base::debug::TraceLog::ENABLED_FOR_EVENT_CALLBACK))
800 800
801 // Macro to efficiently determine if a given category group is enabled. 801 // Macro to efficiently determine if a given category group is enabled.
802 #define TRACE_EVENT_CATEGORY_GROUP_ENABLED(category_group, ret) \ 802 #define TRACE_EVENT_CATEGORY_GROUP_ENABLED(category_group, ret) \
803 do { \ 803 do { \
804 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ 804 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \
805 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ 805 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \
806 *ret = true; \ 806 *ret = true; \
807 } else { \ 807 } else { \
808 *ret = false; \ 808 *ret = false; \
809 } \ 809 } \
(...skipping 22 matching lines...) Expand all
832 // long-lived literal strings should be given as the category group. The 832 // 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 833 // 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, 834 // 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 835 // 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 836 // 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 837 // TRACE_EVENT_API_ADD_TRACE_EVENT, because this flag only provides an early out
838 // for best performance when tracing is disabled. 838 // for best performance when tracing is disabled.
839 // const unsigned char* 839 // const unsigned char*
840 // TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(const char* category_group) 840 // TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(const char* category_group)
841 #define TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED \ 841 #define TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED \
842 base::trace_event::TraceLog::GetCategoryGroupEnabled 842 base::debug::TraceLog::GetCategoryGroupEnabled
843 843
844 // Get the number of times traces have been recorded. This is used to implement 844 // Get the number of times traces have been recorded. This is used to implement
845 // the TRACE_EVENT_IS_NEW_TRACE facility. 845 // the TRACE_EVENT_IS_NEW_TRACE facility.
846 // unsigned int TRACE_EVENT_API_GET_NUM_TRACES_RECORDED() 846 // unsigned int TRACE_EVENT_API_GET_NUM_TRACES_RECORDED()
847 #define TRACE_EVENT_API_GET_NUM_TRACES_RECORDED \ 847 #define TRACE_EVENT_API_GET_NUM_TRACES_RECORDED \
848 base::trace_event::TraceLog::GetInstance()->GetNumTracesRecorded 848 base::debug::TraceLog::GetInstance()->GetNumTracesRecorded
849 849
850 // Add a trace event to the platform tracing system. 850 // Add a trace event to the platform tracing system.
851 // base::trace_event::TraceEventHandle TRACE_EVENT_API_ADD_TRACE_EVENT( 851 // base::debug::TraceEventHandle TRACE_EVENT_API_ADD_TRACE_EVENT(
852 // char phase, 852 // char phase,
853 // const unsigned char* category_group_enabled, 853 // const unsigned char* category_group_enabled,
854 // const char* name, 854 // const char* name,
855 // unsigned long long id, 855 // unsigned long long id,
856 // int num_args, 856 // int num_args,
857 // const char** arg_names, 857 // const char** arg_names,
858 // const unsigned char* arg_types, 858 // const unsigned char* arg_types,
859 // const unsigned long long* arg_values, 859 // const unsigned long long* arg_values,
860 // unsigned char flags) 860 // unsigned char flags)
861 #define TRACE_EVENT_API_ADD_TRACE_EVENT \ 861 #define TRACE_EVENT_API_ADD_TRACE_EVENT \
862 base::trace_event::TraceLog::GetInstance()->AddTraceEvent 862 base::debug::TraceLog::GetInstance()->AddTraceEvent
863 863
864 // Add a trace event to the platform tracing system. 864 // Add a trace event to the platform tracing system.
865 // base::trace_event::TraceEventHandle 865 // base::debug::TraceEventHandle TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_TIMESTAMP(
866 // TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_TIMESTAMP(
867 // char phase, 866 // char phase,
868 // const unsigned char* category_group_enabled, 867 // const unsigned char* category_group_enabled,
869 // const char* name, 868 // const char* name,
870 // unsigned long long id, 869 // unsigned long long id,
871 // int thread_id, 870 // int thread_id,
872 // const TimeTicks& timestamp, 871 // const TimeTicks& timestamp,
873 // int num_args, 872 // int num_args,
874 // const char** arg_names, 873 // const char** arg_names,
875 // const unsigned char* arg_types, 874 // const unsigned char* arg_types,
876 // const unsigned long long* arg_values, 875 // const unsigned long long* arg_values,
877 // unsigned char flags) 876 // unsigned char flags)
878 #define TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP \ 877 #define TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP \
879 base::trace_event::TraceLog::GetInstance() \ 878 base::debug::TraceLog::GetInstance()->AddTraceEventWithThreadIdAndTimestamp
880 ->AddTraceEventWithThreadIdAndTimestamp
881 879
882 // Set the duration field of a COMPLETE trace event. 880 // Set the duration field of a COMPLETE trace event.
883 // void TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( 881 // void TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(
884 // const unsigned char* category_group_enabled, 882 // const unsigned char* category_group_enabled,
885 // const char* name, 883 // const char* name,
886 // base::trace_event::TraceEventHandle id) 884 // base::debug::TraceEventHandle id)
887 #define TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION \ 885 #define TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION \
888 base::trace_event::TraceLog::GetInstance()->UpdateTraceEventDuration 886 base::debug::TraceLog::GetInstance()->UpdateTraceEventDuration
889 887
890 // Defines atomic operations used internally by the tracing system. 888 // Defines atomic operations used internally by the tracing system.
891 #define TRACE_EVENT_API_ATOMIC_WORD base::subtle::AtomicWord 889 #define TRACE_EVENT_API_ATOMIC_WORD base::subtle::AtomicWord
892 #define TRACE_EVENT_API_ATOMIC_LOAD(var) base::subtle::NoBarrier_Load(&(var)) 890 #define TRACE_EVENT_API_ATOMIC_LOAD(var) base::subtle::NoBarrier_Load(&(var))
893 #define TRACE_EVENT_API_ATOMIC_STORE(var, value) \ 891 #define TRACE_EVENT_API_ATOMIC_STORE(var, value) \
894 base::subtle::NoBarrier_Store(&(var), (value)) 892 base::subtle::NoBarrier_Store(&(var), (value))
895 893
896 // Defines visibility for classes in trace_event.h 894 // Defines visibility for classes in trace_event.h
897 #define TRACE_EVENT_API_CLASS_EXPORT BASE_EXPORT 895 #define TRACE_EVENT_API_CLASS_EXPORT BASE_EXPORT
898 896
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 } \ 949 } \
952 } while (0) 950 } while (0)
953 951
954 // Implementation detail: internal macro to create static category and add begin 952 // Implementation detail: internal macro to create static category and add begin
955 // event if the category is enabled. Also adds the end event when the scope 953 // event if the category is enabled. Also adds the end event when the scope
956 // ends. 954 // ends.
957 #define INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, ...) \ 955 #define INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, ...) \
958 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ 956 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \
959 trace_event_internal::ScopedTracer INTERNAL_TRACE_EVENT_UID(tracer); \ 957 trace_event_internal::ScopedTracer INTERNAL_TRACE_EVENT_UID(tracer); \
960 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ 958 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \
961 base::trace_event::TraceEventHandle h = \ 959 base::debug::TraceEventHandle h = trace_event_internal::AddTraceEvent( \
962 trace_event_internal::AddTraceEvent( \ 960 TRACE_EVENT_PHASE_COMPLETE, \
963 TRACE_EVENT_PHASE_COMPLETE, \ 961 INTERNAL_TRACE_EVENT_UID(category_group_enabled), \
964 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ 962 name, trace_event_internal::kNoEventId, \
965 trace_event_internal::kNoEventId, TRACE_EVENT_FLAG_NONE, \ 963 TRACE_EVENT_FLAG_NONE, ##__VA_ARGS__); \
966 ##__VA_ARGS__); \
967 INTERNAL_TRACE_EVENT_UID(tracer).Initialize( \ 964 INTERNAL_TRACE_EVENT_UID(tracer).Initialize( \
968 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, h); \ 965 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, h); \
969 } 966 }
970 967
971 // Implementation detail: internal macro to create static category and add 968 // Implementation detail: internal macro to create static category and add
972 // event if the category is enabled. 969 // event if the category is enabled.
973 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category_group, name, id, \ 970 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category_group, name, id, \
974 flags, ...) \ 971 flags, ...) \
975 do { \ 972 do { \
976 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ 973 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 *type = TRACE_VALUE_TYPE_INT; 1246 *type = TRACE_VALUE_TYPE_INT;
1250 *value = arg.ToInternalValue(); 1247 *value = arg.ToInternalValue();
1251 } 1248 }
1252 1249
1253 // These AddTraceEvent and AddTraceEventWithThreadIdAndTimestamp template 1250 // These AddTraceEvent and AddTraceEventWithThreadIdAndTimestamp template
1254 // functions are defined here instead of in the macro, because the arg_values 1251 // functions are defined here instead of in the macro, because the arg_values
1255 // could be temporary objects, such as std::string. In order to store 1252 // could be temporary objects, such as std::string. In order to store
1256 // pointers to the internal c_str and pass through to the tracing API, 1253 // pointers to the internal c_str and pass through to the tracing API,
1257 // the arg_values must live throughout these procedures. 1254 // the arg_values must live throughout these procedures.
1258 1255
1259 static inline base::trace_event::TraceEventHandle 1256 static inline base::debug::TraceEventHandle
1260 AddTraceEventWithThreadIdAndTimestamp( 1257 AddTraceEventWithThreadIdAndTimestamp(
1261 char phase, 1258 char phase,
1262 const unsigned char* category_group_enabled, 1259 const unsigned char* category_group_enabled,
1263 const char* name, 1260 const char* name,
1264 unsigned long long id, 1261 unsigned long long id,
1265 int thread_id, 1262 int thread_id,
1266 const base::TimeTicks& timestamp, 1263 const base::TimeTicks& timestamp,
1267 unsigned char flags, 1264 unsigned char flags,
1268 const char* arg1_name, 1265 const char* arg1_name,
1269 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& 1266 const scoped_refptr<base::debug::ConvertableToTraceFormat>& arg1_val) {
1270 arg1_val) {
1271 const int num_args = 1; 1267 const int num_args = 1;
1272 unsigned char arg_types[1] = { TRACE_VALUE_TYPE_CONVERTABLE }; 1268 unsigned char arg_types[1] = { TRACE_VALUE_TYPE_CONVERTABLE };
1273 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( 1269 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(
1274 phase, category_group_enabled, name, id, thread_id, timestamp, 1270 phase, category_group_enabled, name, id, thread_id, timestamp,
1275 num_args, &arg1_name, arg_types, NULL, &arg1_val, flags); 1271 num_args, &arg1_name, arg_types, NULL, &arg1_val, flags);
1276 } 1272 }
1277 1273
1278 template<class ARG1_TYPE> 1274 template<class ARG1_TYPE>
1279 static inline base::trace_event::TraceEventHandle 1275 static inline base::debug::TraceEventHandle
1280 AddTraceEventWithThreadIdAndTimestamp( 1276 AddTraceEventWithThreadIdAndTimestamp(
1281 char phase, 1277 char phase,
1282 const unsigned char* category_group_enabled, 1278 const unsigned char* category_group_enabled,
1283 const char* name, 1279 const char* name,
1284 unsigned long long id, 1280 unsigned long long id,
1285 int thread_id, 1281 int thread_id,
1286 const base::TimeTicks& timestamp, 1282 const base::TimeTicks& timestamp,
1287 unsigned char flags, 1283 unsigned char flags,
1288 const char* arg1_name, 1284 const char* arg1_name,
1289 const ARG1_TYPE& arg1_val, 1285 const ARG1_TYPE& arg1_val,
1290 const char* arg2_name, 1286 const char* arg2_name,
1291 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& 1287 const scoped_refptr<base::debug::ConvertableToTraceFormat>& arg2_val) {
1292 arg2_val) {
1293 const int num_args = 2; 1288 const int num_args = 2;
1294 const char* arg_names[2] = { arg1_name, arg2_name }; 1289 const char* arg_names[2] = { arg1_name, arg2_name };
1295 1290
1296 unsigned char arg_types[2]; 1291 unsigned char arg_types[2];
1297 unsigned long long arg_values[2]; 1292 unsigned long long arg_values[2];
1298 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); 1293 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]);
1299 arg_types[1] = TRACE_VALUE_TYPE_CONVERTABLE; 1294 arg_types[1] = TRACE_VALUE_TYPE_CONVERTABLE;
1300 1295
1301 scoped_refptr<base::trace_event::ConvertableToTraceFormat> 1296 scoped_refptr<base::debug::ConvertableToTraceFormat> convertable_values[2];
1302 convertable_values[2];
1303 convertable_values[1] = arg2_val; 1297 convertable_values[1] = arg2_val;
1304 1298
1305 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( 1299 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(
1306 phase, category_group_enabled, name, id, thread_id, timestamp, 1300 phase, category_group_enabled, name, id, thread_id, timestamp,
1307 num_args, arg_names, arg_types, arg_values, convertable_values, flags); 1301 num_args, arg_names, arg_types, arg_values, convertable_values, flags);
1308 } 1302 }
1309 1303
1310 template<class ARG2_TYPE> 1304 template<class ARG2_TYPE>
1311 static inline base::trace_event::TraceEventHandle 1305 static inline base::debug::TraceEventHandle
1312 AddTraceEventWithThreadIdAndTimestamp( 1306 AddTraceEventWithThreadIdAndTimestamp(
1313 char phase, 1307 char phase,
1314 const unsigned char* category_group_enabled, 1308 const unsigned char* category_group_enabled,
1315 const char* name, 1309 const char* name,
1316 unsigned long long id, 1310 unsigned long long id,
1317 int thread_id, 1311 int thread_id,
1318 const base::TimeTicks& timestamp, 1312 const base::TimeTicks& timestamp,
1319 unsigned char flags, 1313 unsigned char flags,
1320 const char* arg1_name, 1314 const char* arg1_name,
1321 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& arg1_val, 1315 const scoped_refptr<base::debug::ConvertableToTraceFormat>& arg1_val,
1322 const char* arg2_name, 1316 const char* arg2_name,
1323 const ARG2_TYPE& arg2_val) { 1317 const ARG2_TYPE& arg2_val) {
1324 const int num_args = 2; 1318 const int num_args = 2;
1325 const char* arg_names[2] = { arg1_name, arg2_name }; 1319 const char* arg_names[2] = { arg1_name, arg2_name };
1326 1320
1327 unsigned char arg_types[2]; 1321 unsigned char arg_types[2];
1328 unsigned long long arg_values[2]; 1322 unsigned long long arg_values[2];
1329 arg_types[0] = TRACE_VALUE_TYPE_CONVERTABLE; 1323 arg_types[0] = TRACE_VALUE_TYPE_CONVERTABLE;
1330 arg_values[0] = 0; 1324 arg_values[0] = 0;
1331 SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]); 1325 SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]);
1332 1326
1333 scoped_refptr<base::trace_event::ConvertableToTraceFormat> 1327 scoped_refptr<base::debug::ConvertableToTraceFormat> convertable_values[2];
1334 convertable_values[2];
1335 convertable_values[0] = arg1_val; 1328 convertable_values[0] = arg1_val;
1336 1329
1337 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( 1330 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(
1338 phase, category_group_enabled, name, id, thread_id, timestamp, 1331 phase, category_group_enabled, name, id, thread_id, timestamp,
1339 num_args, arg_names, arg_types, arg_values, convertable_values, flags); 1332 num_args, arg_names, arg_types, arg_values, convertable_values, flags);
1340 } 1333 }
1341 1334
1342 static inline base::trace_event::TraceEventHandle 1335 static inline base::debug::TraceEventHandle
1343 AddTraceEventWithThreadIdAndTimestamp( 1336 AddTraceEventWithThreadIdAndTimestamp(
1344 char phase, 1337 char phase,
1345 const unsigned char* category_group_enabled, 1338 const unsigned char* category_group_enabled,
1346 const char* name, 1339 const char* name,
1347 unsigned long long id, 1340 unsigned long long id,
1348 int thread_id, 1341 int thread_id,
1349 const base::TimeTicks& timestamp, 1342 const base::TimeTicks& timestamp,
1350 unsigned char flags, 1343 unsigned char flags,
1351 const char* arg1_name, 1344 const char* arg1_name,
1352 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& arg1_val, 1345 const scoped_refptr<base::debug::ConvertableToTraceFormat>& arg1_val,
1353 const char* arg2_name, 1346 const char* arg2_name,
1354 const scoped_refptr<base::trace_event::ConvertableToTraceFormat>& 1347 const scoped_refptr<base::debug::ConvertableToTraceFormat>& arg2_val) {
1355 arg2_val) {
1356 const int num_args = 2; 1348 const int num_args = 2;
1357 const char* arg_names[2] = { arg1_name, arg2_name }; 1349 const char* arg_names[2] = { arg1_name, arg2_name };
1358 unsigned char arg_types[2] = 1350 unsigned char arg_types[2] =
1359 { TRACE_VALUE_TYPE_CONVERTABLE, TRACE_VALUE_TYPE_CONVERTABLE }; 1351 { TRACE_VALUE_TYPE_CONVERTABLE, TRACE_VALUE_TYPE_CONVERTABLE };
1360 scoped_refptr<base::trace_event::ConvertableToTraceFormat> 1352 scoped_refptr<base::debug::ConvertableToTraceFormat> convertable_values[2] =
1361 convertable_values[2] = {arg1_val, arg2_val}; 1353 { arg1_val, arg2_val };
1362 1354
1363 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( 1355 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(
1364 phase, category_group_enabled, name, id, thread_id, timestamp, 1356 phase, category_group_enabled, name, id, thread_id, timestamp,
1365 num_args, arg_names, arg_types, NULL, convertable_values, flags); 1357 num_args, arg_names, arg_types, NULL, convertable_values, flags);
1366 } 1358 }
1367 1359
1368 static inline base::trace_event::TraceEventHandle 1360 static inline base::debug::TraceEventHandle
1369 AddTraceEventWithThreadIdAndTimestamp( 1361 AddTraceEventWithThreadIdAndTimestamp(
1370 char phase, 1362 char phase,
1371 const unsigned char* category_group_enabled, 1363 const unsigned char* category_group_enabled,
1372 const char* name, 1364 const char* name,
1373 unsigned long long id, 1365 unsigned long long id,
1374 int thread_id, 1366 int thread_id,
1375 const base::TimeTicks& timestamp, 1367 const base::TimeTicks& timestamp,
1376 unsigned char flags) { 1368 unsigned char flags) {
1377 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( 1369 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(
1378 phase, category_group_enabled, name, id, thread_id, timestamp, 1370 phase, category_group_enabled, name, id, thread_id, timestamp,
1379 kZeroNumArgs, NULL, NULL, NULL, NULL, flags); 1371 kZeroNumArgs, NULL, NULL, NULL, NULL, flags);
1380 } 1372 }
1381 1373
1382 static inline base::trace_event::TraceEventHandle AddTraceEvent( 1374 static inline base::debug::TraceEventHandle AddTraceEvent(
1383 char phase, 1375 char phase,
1384 const unsigned char* category_group_enabled, 1376 const unsigned char* category_group_enabled,
1385 const char* name, 1377 const char* name,
1386 unsigned long long id, 1378 unsigned long long id,
1387 unsigned char flags) { 1379 unsigned char flags) {
1388 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); 1380 int thread_id = static_cast<int>(base::PlatformThread::CurrentId());
1389 base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime(); 1381 base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime();
1390 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, 1382 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled,
1391 name, id, thread_id, now, flags); 1383 name, id, thread_id, now, flags);
1392 } 1384 }
1393 1385
1394 template<class ARG1_TYPE> 1386 template<class ARG1_TYPE>
1395 static inline base::trace_event::TraceEventHandle 1387 static inline base::debug::TraceEventHandle
1396 AddTraceEventWithThreadIdAndTimestamp( 1388 AddTraceEventWithThreadIdAndTimestamp(
1397 char phase, 1389 char phase,
1398 const unsigned char* category_group_enabled, 1390 const unsigned char* category_group_enabled,
1399 const char* name, 1391 const char* name,
1400 unsigned long long id, 1392 unsigned long long id,
1401 int thread_id, 1393 int thread_id,
1402 const base::TimeTicks& timestamp, 1394 const base::TimeTicks& timestamp,
1403 unsigned char flags, 1395 unsigned char flags,
1404 const char* arg1_name, 1396 const char* arg1_name,
1405 const ARG1_TYPE& arg1_val) { 1397 const ARG1_TYPE& arg1_val) {
1406 const int num_args = 1; 1398 const int num_args = 1;
1407 unsigned char arg_types[1]; 1399 unsigned char arg_types[1];
1408 unsigned long long arg_values[1]; 1400 unsigned long long arg_values[1];
1409 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); 1401 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]);
1410 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( 1402 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(
1411 phase, category_group_enabled, name, id, thread_id, timestamp, 1403 phase, category_group_enabled, name, id, thread_id, timestamp,
1412 num_args, &arg1_name, arg_types, arg_values, NULL, flags); 1404 num_args, &arg1_name, arg_types, arg_values, NULL, flags);
1413 } 1405 }
1414 1406
1415 template<class ARG1_TYPE> 1407 template<class ARG1_TYPE>
1416 static inline base::trace_event::TraceEventHandle AddTraceEvent( 1408 static inline base::debug::TraceEventHandle AddTraceEvent(
1417 char phase, 1409 char phase,
1418 const unsigned char* category_group_enabled, 1410 const unsigned char* category_group_enabled,
1419 const char* name, 1411 const char* name,
1420 unsigned long long id, 1412 unsigned long long id,
1421 unsigned char flags, 1413 unsigned char flags,
1422 const char* arg1_name, 1414 const char* arg1_name,
1423 const ARG1_TYPE& arg1_val) { 1415 const ARG1_TYPE& arg1_val) {
1424 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); 1416 int thread_id = static_cast<int>(base::PlatformThread::CurrentId());
1425 base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime(); 1417 base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime();
1426 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, 1418 return AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled,
1427 name, id, thread_id, now, flags, 1419 name, id, thread_id, now, flags,
1428 arg1_name, arg1_val); 1420 arg1_name, arg1_val);
1429 } 1421 }
1430 1422
1431 template<class ARG1_TYPE, class ARG2_TYPE> 1423 template<class ARG1_TYPE, class ARG2_TYPE>
1432 static inline base::trace_event::TraceEventHandle 1424 static inline base::debug::TraceEventHandle
1433 AddTraceEventWithThreadIdAndTimestamp( 1425 AddTraceEventWithThreadIdAndTimestamp(
1434 char phase, 1426 char phase,
1435 const unsigned char* category_group_enabled, 1427 const unsigned char* category_group_enabled,
1436 const char* name, 1428 const char* name,
1437 unsigned long long id, 1429 unsigned long long id,
1438 int thread_id, 1430 int thread_id,
1439 const base::TimeTicks& timestamp, 1431 const base::TimeTicks& timestamp,
1440 unsigned char flags, 1432 unsigned char flags,
1441 const char* arg1_name, 1433 const char* arg1_name,
1442 const ARG1_TYPE& arg1_val, 1434 const ARG1_TYPE& arg1_val,
1443 const char* arg2_name, 1435 const char* arg2_name,
1444 const ARG2_TYPE& arg2_val) { 1436 const ARG2_TYPE& arg2_val) {
1445 const int num_args = 2; 1437 const int num_args = 2;
1446 const char* arg_names[2] = { arg1_name, arg2_name }; 1438 const char* arg_names[2] = { arg1_name, arg2_name };
1447 unsigned char arg_types[2]; 1439 unsigned char arg_types[2];
1448 unsigned long long arg_values[2]; 1440 unsigned long long arg_values[2];
1449 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); 1441 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]);
1450 SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]); 1442 SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]);
1451 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( 1443 return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(
1452 phase, category_group_enabled, name, id, thread_id, timestamp, 1444 phase, category_group_enabled, name, id, thread_id, timestamp,
1453 num_args, arg_names, arg_types, arg_values, NULL, flags); 1445 num_args, arg_names, arg_types, arg_values, NULL, flags);
1454 } 1446 }
1455 1447
1456 template<class ARG1_TYPE, class ARG2_TYPE> 1448 template<class ARG1_TYPE, class ARG2_TYPE>
1457 static inline base::trace_event::TraceEventHandle AddTraceEvent( 1449 static inline base::debug::TraceEventHandle AddTraceEvent(
1458 char phase, 1450 char phase,
1459 const unsigned char* category_group_enabled, 1451 const unsigned char* category_group_enabled,
1460 const char* name, 1452 const char* name,
1461 unsigned long long id, 1453 unsigned long long id,
1462 unsigned char flags, 1454 unsigned char flags,
1463 const char* arg1_name, 1455 const char* arg1_name,
1464 const ARG1_TYPE& arg1_val, 1456 const ARG1_TYPE& arg1_val,
1465 const char* arg2_name, 1457 const char* arg2_name,
1466 const ARG2_TYPE& arg2_val) { 1458 const ARG2_TYPE& arg2_val) {
1467 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); 1459 int thread_id = static_cast<int>(base::PlatformThread::CurrentId());
(...skipping 11 matching lines...) Expand all
1479 ScopedTracer() : p_data_(NULL) {} 1471 ScopedTracer() : p_data_(NULL) {}
1480 1472
1481 ~ScopedTracer() { 1473 ~ScopedTracer() {
1482 if (p_data_ && *data_.category_group_enabled) 1474 if (p_data_ && *data_.category_group_enabled)
1483 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( 1475 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(
1484 data_.category_group_enabled, data_.name, data_.event_handle); 1476 data_.category_group_enabled, data_.name, data_.event_handle);
1485 } 1477 }
1486 1478
1487 void Initialize(const unsigned char* category_group_enabled, 1479 void Initialize(const unsigned char* category_group_enabled,
1488 const char* name, 1480 const char* name,
1489 base::trace_event::TraceEventHandle event_handle) { 1481 base::debug::TraceEventHandle event_handle) {
1490 data_.category_group_enabled = category_group_enabled; 1482 data_.category_group_enabled = category_group_enabled;
1491 data_.name = name; 1483 data_.name = name;
1492 data_.event_handle = event_handle; 1484 data_.event_handle = event_handle;
1493 p_data_ = &data_; 1485 p_data_ = &data_;
1494 } 1486 }
1495 1487
1496 private: 1488 private:
1497 // This Data struct workaround is to avoid initializing all the members 1489 // This Data struct workaround is to avoid initializing all the members
1498 // in Data during construction of this object, since this object is always 1490 // in Data during construction of this object, since this object is always
1499 // constructed, even when tracing is disabled. If the members of Data were 1491 // constructed, even when tracing is disabled. If the members of Data were
1500 // members of this class instead, compiler warnings occur about potential 1492 // members of this class instead, compiler warnings occur about potential
1501 // uninitialized accesses. 1493 // uninitialized accesses.
1502 struct Data { 1494 struct Data {
1503 const unsigned char* category_group_enabled; 1495 const unsigned char* category_group_enabled;
1504 const char* name; 1496 const char* name;
1505 base::trace_event::TraceEventHandle event_handle; 1497 base::debug::TraceEventHandle event_handle;
1506 }; 1498 };
1507 Data* p_data_; 1499 Data* p_data_;
1508 Data data_; 1500 Data data_;
1509 }; 1501 };
1510 1502
1511 // Used by TRACE_EVENT_BINARY_EFFICIENTx macro. Do not use directly. 1503 // Used by TRACE_EVENT_BINARY_EFFICIENTx macro. Do not use directly.
1512 class TRACE_EVENT_API_CLASS_EXPORT ScopedTraceBinaryEfficient { 1504 class TRACE_EVENT_API_CLASS_EXPORT ScopedTraceBinaryEfficient {
1513 public: 1505 public:
1514 ScopedTraceBinaryEfficient(const char* category_group, const char* name); 1506 ScopedTraceBinaryEfficient(const char* category_group, const char* name);
1515 ~ScopedTraceBinaryEfficient(); 1507 ~ScopedTraceBinaryEfficient();
1516 1508
1517 private: 1509 private:
1518 const unsigned char* category_group_enabled_; 1510 const unsigned char* category_group_enabled_;
1519 const char* name_; 1511 const char* name_;
1520 base::trace_event::TraceEventHandle event_handle_; 1512 base::debug::TraceEventHandle event_handle_;
1521 }; 1513 };
1522 1514
1523 // This macro generates less code then TRACE_EVENT0 but is also 1515 // This macro generates less code then TRACE_EVENT0 but is also
1524 // slower to execute when tracing is off. It should generally only be 1516 // slower to execute when tracing is off. It should generally only be
1525 // used with code that is seldom executed or conditionally executed 1517 // used with code that is seldom executed or conditionally executed
1526 // when debugging. 1518 // when debugging.
1527 // For now the category_group must be "gpu". 1519 // For now the category_group must be "gpu".
1528 #define TRACE_EVENT_BINARY_EFFICIENT0(category_group, name) \ 1520 #define TRACE_EVENT_BINARY_EFFICIENT0(category_group, name) \
1529 trace_event_internal::ScopedTraceBinaryEfficient \ 1521 trace_event_internal::ScopedTraceBinaryEfficient \
1530 INTERNAL_TRACE_EVENT_UID(scoped_trace)(category_group, name); 1522 INTERNAL_TRACE_EVENT_UID(scoped_trace)(category_group, name);
(...skipping 25 matching lines...) Expand all
1556 const_cast<char*>(category_and_name))); 1548 const_cast<char*>(category_and_name)));
1557 } 1549 }
1558 1550
1559 private: 1551 private:
1560 const char* previous_state_; 1552 const char* previous_state_;
1561 }; 1553 };
1562 1554
1563 } // namespace trace_event_internal 1555 } // namespace trace_event_internal
1564 1556
1565 namespace base { 1557 namespace base {
1566 namespace trace_event { 1558 namespace debug {
1567 1559
1568 template<typename IDType> class TraceScopedTrackableObject { 1560 template<typename IDType> class TraceScopedTrackableObject {
1569 public: 1561 public:
1570 TraceScopedTrackableObject(const char* category_group, const char* name, 1562 TraceScopedTrackableObject(const char* category_group, const char* name,
1571 IDType id) 1563 IDType id)
1572 : category_group_(category_group), 1564 : category_group_(category_group),
1573 name_(name), 1565 name_(name),
1574 id_(id) { 1566 id_(id) {
1575 TRACE_EVENT_OBJECT_CREATED_WITH_ID(category_group_, name_, id_); 1567 TRACE_EVENT_OBJECT_CREATED_WITH_ID(category_group_, name_, id_);
1576 } 1568 }
1577 1569
1578 template <typename ArgType> void snapshot(ArgType snapshot) { 1570 template <typename ArgType> void snapshot(ArgType snapshot) {
1579 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(category_group_, name_, id_, snapshot); 1571 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(category_group_, name_, id_, snapshot);
1580 } 1572 }
1581 1573
1582 ~TraceScopedTrackableObject() { 1574 ~TraceScopedTrackableObject() {
1583 TRACE_EVENT_OBJECT_DELETED_WITH_ID(category_group_, name_, id_); 1575 TRACE_EVENT_OBJECT_DELETED_WITH_ID(category_group_, name_, id_);
1584 } 1576 }
1585 1577
1586 private: 1578 private:
1587 const char* category_group_; 1579 const char* category_group_;
1588 const char* name_; 1580 const char* name_;
1589 IDType id_; 1581 IDType id_;
1590 1582
1591 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); 1583 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject);
1592 }; 1584 };
1593 1585
1594 } // namespace trace_event 1586 } // namespace debug
1595 } // namespace base 1587 } // namespace base
1596
1597 // TODO(ssid): remove these aliases after the tracing clients are moved to the
1598 // new trace_event namespace. See crbug.com/451032. ETA: March 2015.
1599 namespace base {
1600 namespace debug {
1601 using base::trace_event::TraceScopedTrackableObject;
1602 } // namespace debug
1603 } // namespace base
1604 1588
1605 #endif /* BASE_TRACE_EVENT_TRACE_EVENT_H_ */ 1589 #endif /* BASE_TRACE_EVENT_TRACE_EVENT_H_ */
OLDNEW
« no previous file with comments | « no previous file | base/trace_event/trace_event_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698