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

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

Issue 12302036: Add a mode flag to the tracing framework. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Spelling fix in content/public/browser. Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/debug/trace_event_impl.cc » ('j') | base/debug/trace_event_impl.cc » ('J')
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 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
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 // Options determines how the trace buffer stores data.
173 enum Options {
174 RECORD_UNTIL_FULL = 1 << 0
175 };
176
173 static TraceLog* GetInstance(); 177 static TraceLog* GetInstance();
174 178
179 // Convert the given string to trace options. Defaults to RECORD_UNTIL_FULL if
180 // the string does not provide valid options.
181 static int TraceOptionsFromString(const std::string& str);
jar (doing other things) 2013/02/22 19:31:28 nit: perhaps it would be nice to return Options.
dsinclair 2013/02/22 20:01:42 Done.
182
175 // Get set of known categories. This can change as new code paths are reached. 183 // Get set of known categories. This can change as new code paths are reached.
176 // The known categories are inserted into |categories|. 184 // The known categories are inserted into |categories|.
177 void GetKnownCategories(std::vector<std::string>* categories); 185 void GetKnownCategories(std::vector<std::string>* categories);
178 186
179 // Enable tracing for provided list of categories. If tracing is already 187 // Enable tracing for provided list of categories. If tracing is already
180 // enabled, this method does nothing -- changing categories during trace is 188 // enabled, this method does nothing -- changing categories during trace is
181 // not supported. 189 // not supported.
182 // If both included_categories and excluded_categories are empty, 190 // If both included_categories and excluded_categories are empty,
183 // all categories are traced. 191 // all categories are traced.
184 // Else if included_categories is non-empty, only those are traced. 192 // Else if included_categories is non-empty, only those are traced.
185 // Else if excluded_categories is non-empty, everything but those are traced. 193 // Else if excluded_categories is non-empty, everything but those are traced.
186 // Wildcards * and ? are supported (see MatchPattern in string_util.h). 194 // Wildcards * and ? are supported (see MatchPattern in string_util.h).
187 void SetEnabled(const std::vector<std::string>& included_categories, 195 void SetEnabled(const std::vector<std::string>& included_categories,
188 const std::vector<std::string>& excluded_categories); 196 const std::vector<std::string>& excluded_categories,
197 int options);
jar (doing other things) 2013/02/22 19:31:28 nit: use Options rather than int throughout in arg
dsinclair 2013/02/22 20:01:42 Done.
189 198
190 // |categories| is a comma-delimited list of category wildcards. 199 // |categories| is a comma-delimited list of category wildcards.
191 // A category can have an optional '-' prefix to make it an excluded category. 200 // 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 201 // All the same rules apply above, so for example, having both included and
193 // excluded categories in the same list would not be supported. 202 // excluded categories in the same list would not be supported.
194 // 203 //
195 // Example: SetEnabled("test_MyTest*"); 204 // Example: SetEnabled("test_MyTest*");
196 // Example: SetEnabled("test_MyTest*,test_OtherStuff"); 205 // Example: SetEnabled("test_MyTest*,test_OtherStuff");
197 // Example: SetEnabled("-excluded_category1,-excluded_category2"); 206 // Example: SetEnabled("-excluded_category1,-excluded_category2");
198 void SetEnabled(const std::string& categories); 207 void SetEnabled(const std::string& categories, int options);
199 208
200 // Retieves the categories set via a prior call to SetEnabled(). Only 209 // Retieves the categories set via a prior call to SetEnabled(). Only
201 // meaningful if |IsEnabled()| is true. 210 // meaningful if |IsEnabled()| is true.
202 void GetEnabledTraceCategories(std::vector<std::string>* included_out, 211 void GetEnabledTraceCategories(std::vector<std::string>* included_out,
203 std::vector<std::string>* excluded_out); 212 std::vector<std::string>* excluded_out);
204 213
214 int GetTraceOptions() { return trace_options_; }
nduca 2013/02/22 18:38:13 int -> Options const This is a trivial accessor,
dsinclair 2013/02/22 19:16:03 Done.
215
205 // Disable tracing for all categories. 216 // Disable tracing for all categories.
206 void SetDisabled(); 217 void SetDisabled();
207 // Helper method to enable/disable tracing for all categories. 218 // Helper method to enable/disable tracing for all categories.
208 void SetEnabled(bool enabled); 219 void SetEnabled(bool enabled, int options);
209 bool IsEnabled() { return !!enable_count_; } 220 bool IsEnabled() { return !!enable_count_; }
210 221
211 #if defined(OS_ANDROID) 222 #if defined(OS_ANDROID)
212 void StartATrace(); 223 void StartATrace();
213 void StopATrace(); 224 void StopATrace();
214 #endif 225 #endif
215 226
216 // Enabled state listeners give a callback when tracing is enabled or 227 // 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 228 // disabled. This can be used to tie into other library's tracing systems
218 // on-demand. 229 // on-demand.
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 unsigned long long process_id_hash_; 404 unsigned long long process_id_hash_;
394 405
395 int process_id_; 406 int process_id_;
396 407
397 TimeDelta time_offset_; 408 TimeDelta time_offset_;
398 409
399 // Allow tests to wake up when certain events occur. 410 // Allow tests to wake up when certain events occur.
400 const unsigned char* watch_category_; 411 const unsigned char* watch_category_;
401 std::string watch_event_name_; 412 std::string watch_event_name_;
402 413
414 int trace_options_;
415
403 DISALLOW_COPY_AND_ASSIGN(TraceLog); 416 DISALLOW_COPY_AND_ASSIGN(TraceLog);
404 }; 417 };
405 418
406 } // namespace debug 419 } // namespace debug
407 } // namespace base 420 } // namespace base
408 421
409 #endif // BASE_DEBUG_TRACE_EVENT_IMPL_H_ 422 #endif // BASE_DEBUG_TRACE_EVENT_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | base/debug/trace_event_impl.cc » ('j') | base/debug/trace_event_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698