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

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

Issue 1850603002: [tracing] Use trace event profiling for heap profiling Base URL: https://chromium.googlesource.com/chromium/src.git@all_categories
Patch Set: Created 4 years, 8 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_log.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 #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.
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 arg_values, nullptr, TRACE_EVENT_FLAG_NONE); 979 arg_values, nullptr, TRACE_EVENT_FLAG_NONE);
980 } 980 }
981 981
982 // Used by TRACE_EVENTx macros. Do not use directly. 982 // Used by TRACE_EVENTx macros. Do not use directly.
983 class TRACE_EVENT_API_CLASS_EXPORT ScopedTracer { 983 class TRACE_EVENT_API_CLASS_EXPORT ScopedTracer {
984 public: 984 public:
985 // Note: members of data_ intentionally left uninitialized. See Initialize. 985 // Note: members of data_ intentionally left uninitialized. See Initialize.
986 ScopedTracer() : p_data_(NULL) {} 986 ScopedTracer() : p_data_(NULL) {}
987 987
988 ~ScopedTracer() { 988 ~ScopedTracer() {
989 if (p_data_ && *data_.category_group_enabled) { 989 if (data_.name) {
990 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( 990 if (p_data_ && *data_.category_group_enabled) {
991 data_.category_group_enabled, data_.name, data_.event_handle); 991 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(
992 data_.category_group_enabled, data_.name, data_.event_handle);
993 }
994 if (data_.initialized_for_profiling) {
995 base::trace_event::AllocationContextTracker::
996 GetInstanceForCurrentThread()
997 ->PopPseudoStackFrame(data_.name);
998 }
992 } 999 }
993 // TODO(ssid): Pop the frame from the pseudo stack if initialized for
994 // profiling is true, after adding profiling mode in skia and Blink
995 // crbug.com/598426.
996 } 1000 }
997 1001
998 void Initialize(const unsigned char* category_group_enabled, 1002 void Initialize(const unsigned char* category_group_enabled,
999 const char* name, 1003 const char* name,
1000 base::trace_event::TraceEventHandle event_handle) { 1004 base::trace_event::TraceEventHandle event_handle) {
1001 data_.category_group_enabled = category_group_enabled; 1005 data_.category_group_enabled = category_group_enabled;
1002 data_.name = name; 1006 data_.name = name;
1003 data_.event_handle = event_handle; 1007 data_.event_handle = event_handle;
1004 p_data_ = &data_; 1008 p_data_ = &data_;
1005 } 1009 }
1006 1010
1007 void InitializeForHeapProfiling(const char* name, unsigned int flags) { 1011 void InitializeForHeapProfiling(const char* name, unsigned int flags) {
1008 if (!(flags & TRACE_EVENT_FLAG_COPY)) { 1012 if (!(flags & TRACE_EVENT_FLAG_COPY)) {
1009 data_.initialized_for_profiling = true; 1013 data_.initialized_for_profiling = true;
1010 data_.name = name; 1014 data_.name = name;
1011 // TODO(ssid): Add the frame to the pseudo stack after adding profiling 1015 base::trace_event::AllocationContextTracker::GetInstanceForCurrentThread()
1012 // mode in skia and Blink crbug.com/598426. 1016 ->PushPseudoStackFrame(name);
1013 } 1017 }
1014 } 1018 }
1015 1019
1016 private: 1020 private:
1017 // This Data struct workaround is to avoid initializing all the members 1021 // This Data struct workaround is to avoid initializing all the members
1018 // in Data during construction of this object, since this object is always 1022 // in Data during construction of this object, since this object is always
1019 // constructed, even when tracing is disabled. If the members of Data were 1023 // constructed, even when tracing is disabled. If the members of Data were
1020 // members of this class instead, compiler warnings occur about potential 1024 // members of this class instead, compiler warnings occur about potential
1021 // uninitialized accesses. 1025 // uninitialized accesses.
1022 struct Data { 1026 struct Data {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 const char* name_; 1113 const char* name_;
1110 IDType id_; 1114 IDType id_;
1111 1115
1112 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); 1116 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject);
1113 }; 1117 };
1114 1118
1115 } // namespace trace_event 1119 } // namespace trace_event
1116 } // namespace base 1120 } // namespace base
1117 1121
1118 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ 1122 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_
OLDNEW
« no previous file with comments | « no previous file | base/trace_event/trace_log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698