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

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

Issue 1239593002: Implement a new flow event API that allows binding flow events and regular events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove a redundant macro. Created 5 years, 5 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 5
6 #ifndef BASE_TRACE_EVENT_TRACE_EVENT_IMPL_H_ 6 #ifndef BASE_TRACE_EVENT_TRACE_EVENT_IMPL_H_
7 #define BASE_TRACE_EVENT_TRACE_EVENT_IMPL_H_ 7 #define BASE_TRACE_EVENT_TRACE_EVENT_IMPL_H_
8 8
9 #include <stack> 9 #include <stack>
10 #include <string> 10 #include <string>
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 unsigned long long as_uint; 97 unsigned long long as_uint;
98 long long as_int; 98 long long as_int;
99 double as_double; 99 double as_double;
100 const void* as_pointer; 100 const void* as_pointer;
101 const char* as_string; 101 const char* as_string;
102 }; 102 };
103 103
104 TraceEvent(); 104 TraceEvent();
105 ~TraceEvent(); 105 ~TraceEvent();
106 106
107 void appendFlowEvent(TraceEvent *flowEvent) {
108 flowEvent_ = flowEvent;
109 }
110
107 // We don't need to copy TraceEvent except when TraceEventBuffer is cloned. 111 // We don't need to copy TraceEvent except when TraceEventBuffer is cloned.
108 // Use explicit copy method to avoid accidentally misuse of copy. 112 // Use explicit copy method to avoid accidentally misuse of copy.
109 void CopyFrom(const TraceEvent& other); 113 void CopyFrom(const TraceEvent& other);
110 114
111 void Initialize( 115 void Initialize(
112 int thread_id, 116 int thread_id,
113 TraceTicks timestamp, 117 TraceTicks timestamp,
114 ThreadTicks thread_timestamp, 118 ThreadTicks thread_timestamp,
115 char phase, 119 char phase,
116 const unsigned char* category_group_enabled, 120 const unsigned char* category_group_enabled,
(...skipping 25 matching lines...) Expand all
142 std::string* out); 146 std::string* out);
143 147
144 TraceTicks timestamp() const { return timestamp_; } 148 TraceTicks timestamp() const { return timestamp_; }
145 ThreadTicks thread_timestamp() const { return thread_timestamp_; } 149 ThreadTicks thread_timestamp() const { return thread_timestamp_; }
146 char phase() const { return phase_; } 150 char phase() const { return phase_; }
147 int thread_id() const { return thread_id_; } 151 int thread_id() const { return thread_id_; }
148 TimeDelta duration() const { return duration_; } 152 TimeDelta duration() const { return duration_; }
149 TimeDelta thread_duration() const { return thread_duration_; } 153 TimeDelta thread_duration() const { return thread_duration_; }
150 unsigned long long id() const { return id_; } 154 unsigned long long id() const { return id_; }
151 unsigned char flags() const { return flags_; } 155 unsigned char flags() const { return flags_; }
156 bool isFlowEvent() const;
152 157
153 // Exposed for unittesting: 158 // Exposed for unittesting:
154 159
155 const base::RefCountedString* parameter_copy_storage() const { 160 const base::RefCountedString* parameter_copy_storage() const {
156 return parameter_copy_storage_.get(); 161 return parameter_copy_storage_.get();
157 } 162 }
158 163
159 const unsigned char* category_group_enabled() const { 164 const unsigned char* category_group_enabled() const {
160 return category_group_enabled_; 165 return category_group_enabled_;
161 } 166 }
(...skipping 16 matching lines...) Expand all
178 TraceValue arg_values_[kTraceMaxNumArgs]; 183 TraceValue arg_values_[kTraceMaxNumArgs];
179 const char* arg_names_[kTraceMaxNumArgs]; 184 const char* arg_names_[kTraceMaxNumArgs];
180 scoped_refptr<ConvertableToTraceFormat> convertable_values_[kTraceMaxNumArgs]; 185 scoped_refptr<ConvertableToTraceFormat> convertable_values_[kTraceMaxNumArgs];
181 const unsigned char* category_group_enabled_; 186 const unsigned char* category_group_enabled_;
182 const char* name_; 187 const char* name_;
183 scoped_refptr<base::RefCountedString> parameter_copy_storage_; 188 scoped_refptr<base::RefCountedString> parameter_copy_storage_;
184 int thread_id_; 189 int thread_id_;
185 char phase_; 190 char phase_;
186 unsigned char flags_; 191 unsigned char flags_;
187 unsigned char arg_types_[kTraceMaxNumArgs]; 192 unsigned char arg_types_[kTraceMaxNumArgs];
193 TraceEvent *flowEvent_;
188 194
189 DISALLOW_COPY_AND_ASSIGN(TraceEvent); 195 DISALLOW_COPY_AND_ASSIGN(TraceEvent);
190 }; 196 };
191 197
192 // TraceBufferChunk is the basic unit of TraceBuffer. 198 // TraceBufferChunk is the basic unit of TraceBuffer.
193 class BASE_EXPORT TraceBufferChunk { 199 class BASE_EXPORT TraceBufferChunk {
194 public: 200 public:
195 explicit TraceBufferChunk(uint32 seq); 201 explicit TraceBufferChunk(uint32 seq);
196 ~TraceBufferChunk(); 202 ~TraceBufferChunk();
197 203
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 // Set when asynchronous Flush is in progress. 708 // Set when asynchronous Flush is in progress.
703 OutputCallback flush_output_callback_; 709 OutputCallback flush_output_callback_;
704 scoped_refptr<SingleThreadTaskRunner> flush_task_runner_; 710 scoped_refptr<SingleThreadTaskRunner> flush_task_runner_;
705 TraceEvent::ArgumentFilterPredicate argument_filter_predicate_; 711 TraceEvent::ArgumentFilterPredicate argument_filter_predicate_;
706 subtle::AtomicWord generation_; 712 subtle::AtomicWord generation_;
707 bool use_worker_thread_; 713 bool use_worker_thread_;
708 714
709 DISALLOW_COPY_AND_ASSIGN(TraceLog); 715 DISALLOW_COPY_AND_ASSIGN(TraceLog);
710 }; 716 };
711 717
718 class TraceEventHandleWrapper {
719 public:
720 TraceEventHandleWrapper() {
721 handle_ = {0, 0, 0};
722 event_ = NULL;
723 }
724 TraceEventHandleWrapper(TraceEventHandle h) {
725 handle_ = h;
726 TraceLog* tracer = base::trace_event::TraceLog::GetInstance();
727 event_ = tracer->GetEventByHandle(h);
728 }
729
730 void appendFlowEvent(TraceEventHandle h) {
731 if (event_) {
732 TraceLog* tracer = base::trace_event::TraceLog::GetInstance();
733 TraceEvent *flowEvent = tracer->GetEventByHandle(h);
734 event_->appendFlowEvent(flowEvent);
735 }
736 }
737
738 private:
739 TraceEventHandle handle_;
740 TraceEvent *event_;
741 };
742
743
712 } // namespace trace_event 744 } // namespace trace_event
713 } // namespace base 745 } // namespace base
714 746
715 #endif // BASE_TRACE_EVENT_TRACE_EVENT_IMPL_H_ 747 #endif // BASE_TRACE_EVENT_TRACE_EVENT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698