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

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

Issue 1950313005: [tracing] Move and rename TRACE_EVENT_API_TASK_EXECUTION_EVENT (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add_missing_task
Patch Set: Created 4 years, 7 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
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 #ifndef BASE_TRACE_EVENT_TRACE_EVENT_H_ 5 #ifndef BASE_TRACE_EVENT_TRACE_EVENT_H_
6 #define BASE_TRACE_EVENT_TRACE_EVENT_H_ 6 #define BASE_TRACE_EVENT_TRACE_EVENT_H_
7 7
8 // This header file defines implementation details of how the trace macros in 8 // This header file defines implementation details of how the trace macros in
9 // trace_event_common.h collect and store trace events. Anything not 9 // trace_event_common.h collect and store trace events. Anything not
10 // implementation-specific should go in trace_event_common.h instead of here. 10 // implementation-specific should go in trace_event_common.h instead of here.
11 11
12 #include <stddef.h> 12 #include <stddef.h>
13 #include <stdint.h> 13 #include <stdint.h>
14 14
15 #include <string> 15 #include <string>
16 16
17 #include "base/atomicops.h" 17 #include "base/atomicops.h"
18 #include "base/macros.h" 18 #include "base/macros.h"
19 #include "base/time/time.h" 19 #include "base/time/time.h"
20 #include "base/trace_event/common/trace_event_common.h" 20 #include "base/trace_event/common/trace_event_common.h"
21 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" 21 #include "base/trace_event/heap_profiler.h" // For SCOPED_TASK_EXECUTION_EVENT
Primiano Tucci (use gerrit) 2016/05/09 17:36:45 Hmm this should go to base/trace_event/common/trac
ssid 2016/05/09 23:49:11 trace_event_common.h cannot include any file form
Primiano Tucci (use gerrit) 2016/05/10 16:03:53 Oh you are right about trace_event_common.h But th
22 #include "base/trace_event/trace_event_system_stats_monitor.h" 22 #include "base/trace_event/trace_event_system_stats_monitor.h"
23 #include "base/trace_event/trace_log.h" 23 #include "base/trace_event/trace_log.h"
24 #include "build/build_config.h" 24 #include "build/build_config.h"
25 25
26 // By default, const char* argument values are assumed to have long-lived scope 26 // By default, const char* argument values are assumed to have long-lived scope
27 // and will not be copied. Use this macro to force a const char* to be copied. 27 // and will not be copied. Use this macro to force a const char* to be copied.
28 #define TRACE_STR_COPY(str) \ 28 #define TRACE_STR_COPY(str) \
29 trace_event_internal::TraceStringWithCopy(str) 29 trace_event_internal::TraceStringWithCopy(str)
30 30
31 // By default, uint64_t ID argument values are not mangled with the Process ID 31 // By default, uint64_t ID argument values are not mangled with the Process ID
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 // Defines visibility for classes in trace_event.h 204 // Defines visibility for classes in trace_event.h
205 #define TRACE_EVENT_API_CLASS_EXPORT BASE_EXPORT 205 #define TRACE_EVENT_API_CLASS_EXPORT BASE_EXPORT
206 206
207 // The thread buckets for the sampling profiler. 207 // The thread buckets for the sampling profiler.
208 TRACE_EVENT_API_CLASS_EXPORT extern \ 208 TRACE_EVENT_API_CLASS_EXPORT extern \
209 TRACE_EVENT_API_ATOMIC_WORD g_trace_state[3]; 209 TRACE_EVENT_API_ATOMIC_WORD g_trace_state[3];
210 210
211 #define TRACE_EVENT_API_THREAD_BUCKET(thread_bucket) \ 211 #define TRACE_EVENT_API_THREAD_BUCKET(thread_bucket) \
212 g_trace_state[thread_bucket] 212 g_trace_state[thread_bucket]
213 213
214 // Scoped tracker for task execution context in the heap profiler.
215 #define TRACE_EVENT_API_SCOPED_TASK_EXECUTION_EVENT \
216 trace_event_internal::ScopedTaskExecutionEvent
217
218 //////////////////////////////////////////////////////////////////////////////// 214 ////////////////////////////////////////////////////////////////////////////////
219 215
220 // Implementation detail: trace event macros create temporary variables 216 // Implementation detail: trace event macros create temporary variables
221 // to keep instrumentation overhead low. These macros give each temporary 217 // to keep instrumentation overhead low. These macros give each temporary
222 // variable a unique name based on the line number to prevent name collisions. 218 // variable a unique name based on the line number to prevent name collisions.
223 #define INTERNAL_TRACE_EVENT_UID3(a,b) \ 219 #define INTERNAL_TRACE_EVENT_UID3(a,b) \
224 trace_event_unique_##a##b 220 trace_event_unique_##a##b
225 #define INTERNAL_TRACE_EVENT_UID2(a,b) \ 221 #define INTERNAL_TRACE_EVENT_UID2(a,b) \
226 INTERNAL_TRACE_EVENT_UID3(a,b) 222 INTERNAL_TRACE_EVENT_UID3(a,b)
227 #define INTERNAL_TRACE_EVENT_UID(name_prefix) \ 223 #define INTERNAL_TRACE_EVENT_UID(name_prefix) \
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 TRACE_EVENT_API_ATOMIC_STORE( 1039 TRACE_EVENT_API_ATOMIC_STORE(
1044 g_trace_state[BucketNumber], 1040 g_trace_state[BucketNumber],
1045 reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD>( 1041 reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD>(
1046 const_cast<char*>(category_and_name))); 1042 const_cast<char*>(category_and_name)));
1047 } 1043 }
1048 1044
1049 private: 1045 private:
1050 const char* previous_state_; 1046 const char* previous_state_;
1051 }; 1047 };
1052 1048
1053 // ScopedTaskExecutionEvent records the current task's context in the heap
1054 // profiler.
1055 class ScopedTaskExecutionEvent {
1056 public:
1057 explicit ScopedTaskExecutionEvent(const char* task_context)
1058 : context_(task_context) {
1059 if (UNLIKELY(
1060 base::trace_event::AllocationContextTracker::capture_enabled())) {
1061 base::trace_event::AllocationContextTracker::GetInstanceForCurrentThread()
1062 ->PushCurrentTaskContext(context_);
1063 }
1064 }
1065
1066 ~ScopedTaskExecutionEvent() {
1067 if (UNLIKELY(
1068 base::trace_event::AllocationContextTracker::capture_enabled())) {
1069 base::trace_event::AllocationContextTracker::GetInstanceForCurrentThread()
1070 ->PopCurrentTaskContext(context_);
1071 }
1072 }
1073
1074 private:
1075 const char* context_;
1076 };
1077
1078 } // namespace trace_event_internal 1049 } // namespace trace_event_internal
1079 1050
1080 namespace base { 1051 namespace base {
1081 namespace trace_event { 1052 namespace trace_event {
1082 1053
1083 template<typename IDType> class TraceScopedTrackableObject { 1054 template<typename IDType> class TraceScopedTrackableObject {
1084 public: 1055 public:
1085 TraceScopedTrackableObject(const char* category_group, const char* name, 1056 TraceScopedTrackableObject(const char* category_group, const char* name,
1086 IDType id) 1057 IDType id)
1087 : category_group_(category_group), 1058 : category_group_(category_group),
(...skipping 15 matching lines...) Expand all
1103 const char* name_; 1074 const char* name_;
1104 IDType id_; 1075 IDType id_;
1105 1076
1106 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); 1077 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject);
1107 }; 1078 };
1108 1079
1109 } // namespace trace_event 1080 } // namespace trace_event
1110 } // namespace base 1081 } // namespace base
1111 1082
1112 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ 1083 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_
OLDNEW
« base/trace_event/common/trace_event_common.h ('K') | « base/trace_event/heap_profiler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698