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

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

Issue 1923533004: Tracing pre-filtering (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review fixes Created 4 years, 4 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 | « base/trace_event/trace_event_unittest.cc ('k') | 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_LOG_H_ 5 #ifndef BASE_TRACE_EVENT_TRACE_LOG_H_
6 #define BASE_TRACE_EVENT_TRACE_LOG_H_ 6 #define BASE_TRACE_EVENT_TRACE_LOG_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 // The pointer returned from GetCategoryGroupEnabledInternal() points to a 53 // The pointer returned from GetCategoryGroupEnabledInternal() points to a
54 // value with zero or more of the following bits. Used in this class only. 54 // value with zero or more of the following bits. Used in this class only.
55 // The TRACE_EVENT macros should only use the value as a bool. 55 // The TRACE_EVENT macros should only use the value as a bool.
56 // These values must be in sync with macro values in TraceEvent.h in Blink. 56 // These values must be in sync with macro values in TraceEvent.h in Blink.
57 enum CategoryGroupEnabledFlags { 57 enum CategoryGroupEnabledFlags {
58 // Category group enabled for the recording mode. 58 // Category group enabled for the recording mode.
59 ENABLED_FOR_RECORDING = 1 << 0, 59 ENABLED_FOR_RECORDING = 1 << 0,
60 // Category group enabled by SetEventCallbackEnabled(). 60 // Category group enabled by SetEventCallbackEnabled().
61 ENABLED_FOR_EVENT_CALLBACK = 1 << 2, 61 ENABLED_FOR_EVENT_CALLBACK = 1 << 2,
62 // Category group enabled to export events to ETW. 62 // Category group enabled to export events to ETW.
63 ENABLED_FOR_ETW_EXPORT = 1 << 3 63 ENABLED_FOR_ETW_EXPORT = 1 << 3,
64 // Category group being filtered before logged.
65 ENABLED_FOR_FILTERING = 1 << 4
64 }; 66 };
65 67
66 static TraceLog* GetInstance(); 68 static TraceLog* GetInstance();
67 69
68 // Get set of known category groups. This can change as new code paths are 70 // Get set of known category groups. This can change as new code paths are
69 // reached. The known category groups are inserted into |category_groups|. 71 // reached. The known category groups are inserted into |category_groups|.
70 void GetKnownCategoryGroups(std::vector<std::string>* category_groups); 72 void GetKnownCategoryGroups(std::vector<std::string>* category_groups);
71 73
72 // Retrieves a copy (for thread-safety) of the current TraceConfig. 74 // Retrieves a copy (for thread-safety) of the current TraceConfig.
73 TraceConfig GetCurrentTraceConfig() const; 75 TraceConfig GetCurrentTraceConfig() const;
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 const char** arg_names, 281 const char** arg_names,
280 const unsigned char* arg_types, 282 const unsigned char* arg_types,
281 const unsigned long long* arg_values, 283 const unsigned long long* arg_values,
282 std::unique_ptr<ConvertableToTraceFormat>* convertable_values, 284 std::unique_ptr<ConvertableToTraceFormat>* convertable_values,
283 unsigned int flags); 285 unsigned int flags);
284 286
285 void UpdateTraceEventDuration(const unsigned char* category_group_enabled, 287 void UpdateTraceEventDuration(const unsigned char* category_group_enabled,
286 const char* name, 288 const char* name,
287 TraceEventHandle handle); 289 TraceEventHandle handle);
288 290
291 void EndFilteredEvent(const unsigned char* category_group_enabled,
292 const char* name,
293 TraceEventHandle handle);
294
289 // For every matching event, the callback will be called. 295 // For every matching event, the callback will be called.
290 typedef base::Callback<void()> WatchEventCallback; 296 typedef base::Callback<void()> WatchEventCallback;
291 void SetWatchEvent(const std::string& category_name, 297 void SetWatchEvent(const std::string& category_name,
292 const std::string& event_name, 298 const std::string& event_name,
293 const WatchEventCallback& callback); 299 const WatchEventCallback& callback);
294 // Cancel the watch event. If tracing is enabled, this may race with the 300 // Cancel the watch event. If tracing is enabled, this may race with the
295 // watch event notification firing. 301 // watch event notification firing.
296 void CancelWatchEvent(); 302 void CancelWatchEvent();
297 303
298 int process_id() const { return process_id_; } 304 int process_id() const { return process_id_; }
299 305
300 uint64_t MangleEventId(uint64_t id); 306 uint64_t MangleEventId(uint64_t id);
301 307
302 // Exposed for unittesting: 308 // Exposed for unittesting:
303 309
304 void WaitSamplingEventForTesting(); 310 void WaitSamplingEventForTesting();
305 311
306 // Allows deleting our singleton instance. 312 // Allows deleting our singleton instance.
307 static void DeleteForTesting(); 313 static void DeleteForTesting();
308 314
315 class TraceEventFilter {
316 public:
317 TraceEventFilter() {}
318 virtual ~TraceEventFilter() {}
319 virtual bool FilterTraceEvent(const TraceEvent& trace_event) const = 0;
320 virtual void EndEvent(const char* category_group, const char* name) {}
321
322 private:
323 DISALLOW_COPY_AND_ASSIGN(TraceEventFilter);
324 };
325 typedef std::unique_ptr<TraceEventFilter> (
326 *TraceEventFilterConstructorForTesting)(void);
327 static void SetTraceEventFilterConstructorForTesting(
328 TraceEventFilterConstructorForTesting predicate);
329
309 // Allow tests to inspect TraceEvents. 330 // Allow tests to inspect TraceEvents.
310 TraceEvent* GetEventByHandle(TraceEventHandle handle); 331 TraceEvent* GetEventByHandle(TraceEventHandle handle);
311 332
312 void SetProcessID(int process_id); 333 void SetProcessID(int process_id);
313 334
314 // Process sort indices, if set, override the order of a process will appear 335 // Process sort indices, if set, override the order of a process will appear
315 // relative to other processes in the trace viewer. Processes are sorted first 336 // relative to other processes in the trace viewer. Processes are sorted first
316 // on their sort index, ascending, then by their name, and then tid. 337 // on their sort index, ascending, then by their name, and then tid.
317 void SetProcessSortIndex(int sort_index); 338 void SetProcessSortIndex(int sort_index);
318 339
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 subtle::AtomicWord generation_; 544 subtle::AtomicWord generation_;
524 bool use_worker_thread_; 545 bool use_worker_thread_;
525 546
526 DISALLOW_COPY_AND_ASSIGN(TraceLog); 547 DISALLOW_COPY_AND_ASSIGN(TraceLog);
527 }; 548 };
528 549
529 } // namespace trace_event 550 } // namespace trace_event
530 } // namespace base 551 } // namespace base
531 552
532 #endif // BASE_TRACE_EVENT_TRACE_LOG_H_ 553 #endif // BASE_TRACE_EVENT_TRACE_LOG_H_
OLDNEW
« no previous file with comments | « base/trace_event/trace_event_unittest.cc ('k') | base/trace_event/trace_log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698