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_DEBUG_TRACE_EVENT_IMPL_H_ | 6 #ifndef BASE_DEBUG_TRACE_EVENT_IMPL_H_ |
7 #define BASE_DEBUG_TRACE_EVENT_IMPL_H_ | 7 #define BASE_DEBUG_TRACE_EVENT_IMPL_H_ |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 | 10 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 | 150 |
151 // When all fragments have been added, call Finish to complete the JSON | 151 // When all fragments have been added, call Finish to complete the JSON |
152 // formatted output. | 152 // formatted output. |
153 void Finish(); | 153 void Finish(); |
154 | 154 |
155 private: | 155 private: |
156 OutputCallback output_callback_; | 156 OutputCallback output_callback_; |
157 bool append_comma_; | 157 bool append_comma_; |
158 }; | 158 }; |
159 | 159 |
160 | |
161 class BASE_EXPORT TraceLog { | 160 class BASE_EXPORT TraceLog { |
162 public: | 161 public: |
163 // Notification is a mask of one or more of the following events. | 162 // Notification is a mask of one or more of the following events. |
164 enum Notification { | 163 enum Notification { |
165 // The trace buffer does not flush dynamically, so when it fills up, | 164 // The trace buffer does not flush dynamically, so when it fills up, |
166 // subsequent trace events will be dropped. This callback is generated when | 165 // subsequent trace events will be dropped. This callback is generated when |
167 // the trace buffer is full. The callback must be thread safe. | 166 // the trace buffer is full. The callback must be thread safe. |
168 TRACE_BUFFER_FULL = 1 << 0, | 167 TRACE_BUFFER_FULL = 1 << 0, |
169 // A subscribed trace-event occurred. | 168 // A subscribed trace-event occurred. |
170 EVENT_WATCH_NOTIFICATION = 1 << 1 | 169 EVENT_WATCH_NOTIFICATION = 1 << 1 |
171 }; | 170 }; |
172 | 171 |
172 // TraceMode determines how the trace buffer stores data. | |
173 enum TraceMode { | |
nduca
2013/02/21 05:40:16
I think TraceMode -> TraceOptions?
This is an inn
dsinclair
2013/02/21 16:26:04
Done.
Turned this into a bit field as it looks li
| |
174 UNTIL_FULL = 0 | |
nduca
2013/02/21 05:40:16
naming is kind of awks. RECORD_UNTIL_FULL, RECORD_
dsinclair
2013/02/21 16:26:04
Done.
| |
175 }; | |
176 | |
173 static TraceLog* GetInstance(); | 177 static TraceLog* GetInstance(); |
174 | 178 |
179 // Convert the given string to a trace mode. Defaults to UNTIL_FULL if | |
180 // the string is not a valid mode name. | |
181 static TraceMode TraceModeFromString(const std::string& str); | |
182 | |
183 // Converts a trace mode into it's string representation. | |
184 static const std::string StringFromTraceMode(TraceMode mode); | |
185 | |
175 // Get set of known categories. This can change as new code paths are reached. | 186 // Get set of known categories. This can change as new code paths are reached. |
176 // The known categories are inserted into |categories|. | 187 // The known categories are inserted into |categories|. |
177 void GetKnownCategories(std::vector<std::string>* categories); | 188 void GetKnownCategories(std::vector<std::string>* categories); |
178 | 189 |
179 // Enable tracing for provided list of categories. If tracing is already | 190 // Enable tracing for provided list of categories. If tracing is already |
180 // enabled, this method does nothing -- changing categories during trace is | 191 // enabled, this method does nothing -- changing categories during trace is |
181 // not supported. | 192 // not supported. |
182 // If both included_categories and excluded_categories are empty, | 193 // If both included_categories and excluded_categories are empty, |
183 // all categories are traced. | 194 // all categories are traced. |
184 // Else if included_categories is non-empty, only those are traced. | 195 // Else if included_categories is non-empty, only those are traced. |
185 // Else if excluded_categories is non-empty, everything but those are traced. | 196 // Else if excluded_categories is non-empty, everything but those are traced. |
186 // Wildcards * and ? are supported (see MatchPattern in string_util.h). | 197 // Wildcards * and ? are supported (see MatchPattern in string_util.h). |
187 void SetEnabled(const std::vector<std::string>& included_categories, | 198 void SetEnabled(const std::vector<std::string>& included_categories, |
188 const std::vector<std::string>& excluded_categories); | 199 const std::vector<std::string>& excluded_categories, |
200 TraceMode mode); | |
189 | 201 |
190 // |categories| is a comma-delimited list of category wildcards. | 202 // |categories| is a comma-delimited list of category wildcards. |
191 // A category can have an optional '-' prefix to make it an excluded category. | 203 // A category can have an optional '-' prefix to make it an excluded category. |
192 // All the same rules apply above, so for example, having both included and | 204 // All the same rules apply above, so for example, having both included and |
193 // excluded categories in the same list would not be supported. | 205 // excluded categories in the same list would not be supported. |
194 // | 206 // |
195 // Example: SetEnabled("test_MyTest*"); | 207 // Example: SetEnabled("test_MyTest*"); |
196 // Example: SetEnabled("test_MyTest*,test_OtherStuff"); | 208 // Example: SetEnabled("test_MyTest*,test_OtherStuff"); |
197 // Example: SetEnabled("-excluded_category1,-excluded_category2"); | 209 // Example: SetEnabled("-excluded_category1,-excluded_category2"); |
198 void SetEnabled(const std::string& categories); | 210 void SetEnabled(const std::string& categories, TraceMode mode); |
199 | 211 |
200 // Retieves the categories set via a prior call to SetEnabled(). Only | 212 // Retieves the categories set via a prior call to SetEnabled(). Only |
201 // meaningful if |IsEnabled()| is true. | 213 // meaningful if |IsEnabled()| is true. |
202 void GetEnabledTraceCategories(std::vector<std::string>* included_out, | 214 void GetEnabledTraceCategories(std::vector<std::string>* included_out, |
203 std::vector<std::string>* excluded_out); | 215 std::vector<std::string>* excluded_out); |
204 | 216 |
217 TraceMode GetTraceMode() { return trace_mode_; } | |
218 | |
205 // Disable tracing for all categories. | 219 // Disable tracing for all categories. |
206 void SetDisabled(); | 220 void SetDisabled(); |
207 // Helper method to enable/disable tracing for all categories. | 221 // Helper method to enable/disable tracing for all categories. |
208 void SetEnabled(bool enabled); | 222 void SetEnabled(bool enabled, TraceMode mode); |
209 bool IsEnabled() { return !!enable_count_; } | 223 bool IsEnabled() { return !!enable_count_; } |
210 | 224 |
211 #if defined(OS_ANDROID) | 225 #if defined(OS_ANDROID) |
212 void StartATrace(); | 226 void StartATrace(); |
213 void StopATrace(); | 227 void StopATrace(); |
214 #endif | 228 #endif |
215 | 229 |
216 // Enabled state listeners give a callback when tracing is enabled or | 230 // Enabled state listeners give a callback when tracing is enabled or |
217 // disabled. This can be used to tie into other library's tracing systems | 231 // disabled. This can be used to tie into other library's tracing systems |
218 // on-demand. | 232 // on-demand. |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
393 unsigned long long process_id_hash_; | 407 unsigned long long process_id_hash_; |
394 | 408 |
395 int process_id_; | 409 int process_id_; |
396 | 410 |
397 TimeDelta time_offset_; | 411 TimeDelta time_offset_; |
398 | 412 |
399 // Allow tests to wake up when certain events occur. | 413 // Allow tests to wake up when certain events occur. |
400 const unsigned char* watch_category_; | 414 const unsigned char* watch_category_; |
401 std::string watch_event_name_; | 415 std::string watch_event_name_; |
402 | 416 |
417 TraceMode trace_mode_; | |
418 | |
403 DISALLOW_COPY_AND_ASSIGN(TraceLog); | 419 DISALLOW_COPY_AND_ASSIGN(TraceLog); |
404 }; | 420 }; |
405 | 421 |
406 } // namespace debug | 422 } // namespace debug |
407 } // namespace base | 423 } // namespace base |
408 | 424 |
409 #endif // BASE_DEBUG_TRACE_EVENT_IMPL_H_ | 425 #endif // BASE_DEBUG_TRACE_EVENT_IMPL_H_ |
OLD | NEW |