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 | 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 88 |
89 TraceEvent(); | 89 TraceEvent(); |
90 ~TraceEvent(); | 90 ~TraceEvent(); |
91 | 91 |
92 // We don't need to copy TraceEvent except when TraceEventBuffer is cloned. | 92 // We don't need to copy TraceEvent except when TraceEventBuffer is cloned. |
93 // Use explicit copy method to avoid accidentally misuse of copy. | 93 // Use explicit copy method to avoid accidentally misuse of copy. |
94 void CopyFrom(const TraceEvent& other); | 94 void CopyFrom(const TraceEvent& other); |
95 | 95 |
96 void Initialize( | 96 void Initialize( |
97 int thread_id, | 97 int thread_id, |
98 TraceTicks timestamp, | 98 TimeTicks timestamp, |
99 ThreadTicks thread_timestamp, | 99 ThreadTicks thread_timestamp, |
100 char phase, | 100 char phase, |
101 const unsigned char* category_group_enabled, | 101 const unsigned char* category_group_enabled, |
102 const char* name, | 102 const char* name, |
103 unsigned long long id, | 103 unsigned long long id, |
104 unsigned long long context_id, | 104 unsigned long long context_id, |
105 unsigned long long bind_id, | 105 unsigned long long bind_id, |
106 int num_args, | 106 int num_args, |
107 const char** arg_names, | 107 const char** arg_names, |
108 const unsigned char* arg_types, | 108 const unsigned char* arg_types, |
109 const unsigned long long* arg_values, | 109 const unsigned long long* arg_values, |
110 const scoped_refptr<ConvertableToTraceFormat>* convertable_values, | 110 const scoped_refptr<ConvertableToTraceFormat>* convertable_values, |
111 unsigned int flags); | 111 unsigned int flags); |
112 | 112 |
113 void Reset(); | 113 void Reset(); |
114 | 114 |
115 void UpdateDuration(const TraceTicks& now, const ThreadTicks& thread_now); | 115 void UpdateDuration(const TimeTicks& now, const ThreadTicks& thread_now); |
116 | 116 |
117 void EstimateTraceMemoryOverhead(TraceEventMemoryOverhead* overhead); | 117 void EstimateTraceMemoryOverhead(TraceEventMemoryOverhead* overhead); |
118 | 118 |
119 // Serialize event data to JSON | 119 // Serialize event data to JSON |
120 void AppendAsJSON( | 120 void AppendAsJSON( |
121 std::string* out, | 121 std::string* out, |
122 const ArgumentFilterPredicate& argument_filter_predicate) const; | 122 const ArgumentFilterPredicate& argument_filter_predicate) const; |
123 void AppendPrettyPrinted(std::ostringstream* out) const; | 123 void AppendPrettyPrinted(std::ostringstream* out) const; |
124 | 124 |
125 static void AppendValueAsJSON(unsigned char type, | 125 static void AppendValueAsJSON(unsigned char type, |
126 TraceValue value, | 126 TraceValue value, |
127 std::string* out); | 127 std::string* out); |
128 | 128 |
129 TraceTicks timestamp() const { return timestamp_; } | 129 TimeTicks timestamp() const { return timestamp_; } |
130 ThreadTicks thread_timestamp() const { return thread_timestamp_; } | 130 ThreadTicks thread_timestamp() const { return thread_timestamp_; } |
131 char phase() const { return phase_; } | 131 char phase() const { return phase_; } |
132 int thread_id() const { return thread_id_; } | 132 int thread_id() const { return thread_id_; } |
133 TimeDelta duration() const { return duration_; } | 133 TimeDelta duration() const { return duration_; } |
134 TimeDelta thread_duration() const { return thread_duration_; } | 134 TimeDelta thread_duration() const { return thread_duration_; } |
135 unsigned long long id() const { return id_; } | 135 unsigned long long id() const { return id_; } |
136 unsigned long long context_id() const { return context_id_; } | 136 unsigned long long context_id() const { return context_id_; } |
137 unsigned int flags() const { return flags_; } | 137 unsigned int flags() const { return flags_; } |
138 | 138 |
139 // Exposed for unittesting: | 139 // Exposed for unittesting: |
140 | 140 |
141 const base::RefCountedString* parameter_copy_storage() const { | 141 const base::RefCountedString* parameter_copy_storage() const { |
142 return parameter_copy_storage_.get(); | 142 return parameter_copy_storage_.get(); |
143 } | 143 } |
144 | 144 |
145 const unsigned char* category_group_enabled() const { | 145 const unsigned char* category_group_enabled() const { |
146 return category_group_enabled_; | 146 return category_group_enabled_; |
147 } | 147 } |
148 | 148 |
149 const char* name() const { return name_; } | 149 const char* name() const { return name_; } |
150 | 150 |
151 #if defined(OS_ANDROID) | 151 #if defined(OS_ANDROID) |
152 void SendToATrace(); | 152 void SendToATrace(); |
153 #endif | 153 #endif |
154 | 154 |
155 private: | 155 private: |
156 // Note: these are ordered by size (largest first) for optimal packing. | 156 // Note: these are ordered by size (largest first) for optimal packing. |
157 TraceTicks timestamp_; | 157 TimeTicks timestamp_; |
158 ThreadTicks thread_timestamp_; | 158 ThreadTicks thread_timestamp_; |
159 TimeDelta duration_; | 159 TimeDelta duration_; |
160 TimeDelta thread_duration_; | 160 TimeDelta thread_duration_; |
161 // id_ can be used to store phase-specific data. | 161 // id_ can be used to store phase-specific data. |
162 unsigned long long id_; | 162 unsigned long long id_; |
163 // context_id_ is used to store context information. | 163 // context_id_ is used to store context information. |
164 unsigned long long context_id_; | 164 unsigned long long context_id_; |
165 TraceValue arg_values_[kTraceMaxNumArgs]; | 165 TraceValue arg_values_[kTraceMaxNumArgs]; |
166 const char* arg_names_[kTraceMaxNumArgs]; | 166 const char* arg_names_[kTraceMaxNumArgs]; |
167 scoped_refptr<ConvertableToTraceFormat> convertable_values_[kTraceMaxNumArgs]; | 167 scoped_refptr<ConvertableToTraceFormat> convertable_values_[kTraceMaxNumArgs]; |
(...skipping 12 matching lines...) Expand all Loading... |
180 unsigned char arg_types_[kTraceMaxNumArgs]; | 180 unsigned char arg_types_[kTraceMaxNumArgs]; |
181 char phase_; | 181 char phase_; |
182 | 182 |
183 DISALLOW_COPY_AND_ASSIGN(TraceEvent); | 183 DISALLOW_COPY_AND_ASSIGN(TraceEvent); |
184 }; | 184 }; |
185 | 185 |
186 } // namespace trace_event | 186 } // namespace trace_event |
187 } // namespace base | 187 } // namespace base |
188 | 188 |
189 #endif // BASE_TRACE_EVENT_TRACE_EVENT_IMPL_H_ | 189 #endif // BASE_TRACE_EVENT_TRACE_EVENT_IMPL_H_ |
OLD | NEW |