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

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

Issue 1115343002: Added a whitelist for trace events that are known to be PII-less. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review fixes Created 5 years, 7 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 const unsigned char* arg_types, 116 const unsigned char* arg_types,
117 const unsigned long long* arg_values, 117 const unsigned long long* arg_values,
118 const scoped_refptr<ConvertableToTraceFormat>* convertable_values, 118 const scoped_refptr<ConvertableToTraceFormat>* convertable_values,
119 unsigned char flags); 119 unsigned char flags);
120 120
121 void Reset(); 121 void Reset();
122 122
123 void UpdateDuration(const TimeTicks& now, const TimeTicks& thread_now); 123 void UpdateDuration(const TimeTicks& now, const TimeTicks& thread_now);
124 124
125 // Serialize event data to JSON 125 // Serialize event data to JSON
126 void AppendAsJSON(std::string* out) const; 126 typedef base::Callback<bool(const char* category_group_name,
127 const char* event_name)> ArgumentFilterPredicate;
128 void AppendAsJSON(
129 std::string* out,
130 const ArgumentFilterPredicate& argument_filter_predicate) const;
127 void AppendPrettyPrinted(std::ostringstream* out) const; 131 void AppendPrettyPrinted(std::ostringstream* out) const;
128 132
129 static void AppendValueAsJSON(unsigned char type, 133 static void AppendValueAsJSON(unsigned char type,
130 TraceValue value, 134 TraceValue value,
131 std::string* out); 135 std::string* out);
132 136
133 TimeTicks timestamp() const { return timestamp_; } 137 TimeTicks timestamp() const { return timestamp_; }
134 TimeTicks thread_timestamp() const { return thread_timestamp_; } 138 TimeTicks thread_timestamp() const { return thread_timestamp_; }
135 char phase() const { return phase_; } 139 char phase() const { return phase_; }
136 int thread_id() const { return thread_id_; } 140 int thread_id() const { return thread_id_; }
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 ECHO_TO_CONSOLE, 381 ECHO_TO_CONSOLE,
378 382
379 // Record until the trace buffer is full, but with a huge buffer size. 383 // Record until the trace buffer is full, but with a huge buffer size.
380 RECORD_AS_MUCH_AS_POSSIBLE 384 RECORD_AS_MUCH_AS_POSSIBLE
381 }; 385 };
382 386
383 struct BASE_EXPORT TraceOptions { 387 struct BASE_EXPORT TraceOptions {
384 TraceOptions() 388 TraceOptions()
385 : record_mode(RECORD_UNTIL_FULL), 389 : record_mode(RECORD_UNTIL_FULL),
386 enable_sampling(false), 390 enable_sampling(false),
387 enable_systrace(false) {} 391 enable_systrace(false),
392 enable_argument_filter(false) {}
388 393
389 explicit TraceOptions(TraceRecordMode record_mode) 394 explicit TraceOptions(TraceRecordMode record_mode)
390 : record_mode(record_mode), 395 : record_mode(record_mode),
391 enable_sampling(false), 396 enable_sampling(false),
392 enable_systrace(false) {} 397 enable_systrace(false),
398 enable_argument_filter(false) {}
393 399
394 // |options_string| is a comma-delimited list of trace options. 400 // |options_string| is a comma-delimited list of trace options.
395 // Possible options are: "record-until-full", "record-continuously", 401 // Possible options are: "record-until-full", "record-continuously",
396 // "trace-to-console", "enable-sampling" and "enable-systrace". 402 // "trace-to-console", "enable-sampling" and "enable-systrace".
397 // The first 3 options are trace recoding modes and hence 403 // The first 3 options are trace recoding modes and hence
398 // mutually exclusive. If more than one trace recording modes appear in the 404 // mutually exclusive. If more than one trace recording modes appear in the
399 // options_string, the last one takes precedence. If none of the trace 405 // options_string, the last one takes precedence. If none of the trace
400 // recording mode is specified, recording mode is RECORD_UNTIL_FULL. 406 // recording mode is specified, recording mode is RECORD_UNTIL_FULL.
401 // 407 //
402 // The trace option will first be reset to the default option 408 // The trace option will first be reset to the default option
(...skipping 10 matching lines...) Expand all
413 // will set ECHO_TO_CONSOLE as the recording mode. 419 // will set ECHO_TO_CONSOLE as the recording mode.
414 // 420 //
415 // Returns true on success. 421 // Returns true on success.
416 bool SetFromString(const std::string& options_string); 422 bool SetFromString(const std::string& options_string);
417 423
418 std::string ToString() const; 424 std::string ToString() const;
419 425
420 TraceRecordMode record_mode; 426 TraceRecordMode record_mode;
421 bool enable_sampling; 427 bool enable_sampling;
422 bool enable_systrace; 428 bool enable_systrace;
429 bool enable_argument_filter;
423 }; 430 };
424 431
425 struct BASE_EXPORT TraceLogStatus { 432 struct BASE_EXPORT TraceLogStatus {
426 TraceLogStatus(); 433 TraceLogStatus();
427 ~TraceLogStatus(); 434 ~TraceLogStatus();
428 size_t event_capacity; 435 size_t event_capacity;
429 size_t event_count; 436 size_t event_count;
430 }; 437 };
431 438
432 class BASE_EXPORT TraceLog { 439 class BASE_EXPORT TraceLog {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 int num_args, 533 int num_args,
527 const char* const arg_names[], 534 const char* const arg_names[],
528 const unsigned char arg_types[], 535 const unsigned char arg_types[],
529 const unsigned long long arg_values[], 536 const unsigned long long arg_values[],
530 unsigned char flags); 537 unsigned char flags);
531 538
532 // Enable tracing for EventCallback. 539 // Enable tracing for EventCallback.
533 void SetEventCallbackEnabled(const CategoryFilter& category_filter, 540 void SetEventCallbackEnabled(const CategoryFilter& category_filter,
534 EventCallback cb); 541 EventCallback cb);
535 void SetEventCallbackDisabled(); 542 void SetEventCallbackDisabled();
543 void SetArgumentFilterPredicate(
544 const TraceEvent::ArgumentFilterPredicate& argument_filter_predicate);
536 545
537 // Flush all collected events to the given output callback. The callback will 546 // Flush all collected events to the given output callback. The callback will
538 // be called one or more times either synchronously or asynchronously from 547 // be called one or more times either synchronously or asynchronously from
539 // the current thread with IPC-bite-size chunks. The string format is 548 // the current thread with IPC-bite-size chunks. The string format is
540 // undefined. Use TraceResultBuffer to convert one or more trace strings to 549 // undefined. Use TraceResultBuffer to convert one or more trace strings to
541 // JSON. The callback can be null if the caller doesn't want any data. 550 // JSON. The callback can be null if the caller doesn't want any data.
542 // Due to the implementation of thread-local buffers, flush can't be 551 // Due to the implementation of thread-local buffers, flush can't be
543 // done when tracing is enabled. If called when tracing is enabled, the 552 // done when tracing is enabled. If called when tracing is enabled, the
544 // callback will be called directly with (empty_string, false) to indicate 553 // callback will be called directly with (empty_string, false) to indicate
545 // the end of this unsuccessful flush. Flush does the serialization 554 // the end of this unsuccessful flush. Flush does the serialization
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 722
714 TraceEvent* GetEventByHandleInternal(TraceEventHandle handle, 723 TraceEvent* GetEventByHandleInternal(TraceEventHandle handle,
715 OptionalAutoLock* lock); 724 OptionalAutoLock* lock);
716 725
717 // |generation| is used in the following callbacks to check if the callback 726 // |generation| is used in the following callbacks to check if the callback
718 // is called for the flush of the current |logged_events_|. 727 // is called for the flush of the current |logged_events_|.
719 void FlushCurrentThread(int generation); 728 void FlushCurrentThread(int generation);
720 // Usually it runs on a different thread. 729 // Usually it runs on a different thread.
721 static void ConvertTraceEventsToTraceFormat( 730 static void ConvertTraceEventsToTraceFormat(
722 scoped_ptr<TraceBuffer> logged_events, 731 scoped_ptr<TraceBuffer> logged_events,
723 const TraceLog::OutputCallback& flush_output_callback); 732 const TraceLog::OutputCallback& flush_output_callback,
733 const TraceEvent::ArgumentFilterPredicate& argument_filter_predicate);
724 void FinishFlush(int generation); 734 void FinishFlush(int generation);
725 void OnFlushTimeout(int generation); 735 void OnFlushTimeout(int generation);
726 736
727 int generation() const { 737 int generation() const {
728 return static_cast<int>(subtle::NoBarrier_Load(&generation_)); 738 return static_cast<int>(subtle::NoBarrier_Load(&generation_));
729 } 739 }
730 bool CheckGeneration(int generation) const { 740 bool CheckGeneration(int generation) const {
731 return generation == this->generation(); 741 return generation == this->generation();
732 } 742 }
733 void UseNextTraceBuffer(); 743 void UseNextTraceBuffer();
734 744
735 TimeTicks OffsetNow() const { 745 TimeTicks OffsetNow() const {
736 return OffsetTimestamp(TimeTicks::NowFromSystemTraceTime()); 746 return OffsetTimestamp(TimeTicks::NowFromSystemTraceTime());
737 } 747 }
738 TimeTicks OffsetTimestamp(const TimeTicks& timestamp) const { 748 TimeTicks OffsetTimestamp(const TimeTicks& timestamp) const {
739 return timestamp - time_offset_; 749 return timestamp - time_offset_;
740 } 750 }
741 751
742 // Internal representation of trace options since we store the currently used 752 // Internal representation of trace options since we store the currently used
743 // trace option as an AtomicWord. 753 // trace option as an AtomicWord.
744 static const InternalTraceOptions kInternalNone; 754 static const InternalTraceOptions kInternalNone;
745 static const InternalTraceOptions kInternalRecordUntilFull; 755 static const InternalTraceOptions kInternalRecordUntilFull;
746 static const InternalTraceOptions kInternalRecordContinuously; 756 static const InternalTraceOptions kInternalRecordContinuously;
747 static const InternalTraceOptions kInternalEchoToConsole; 757 static const InternalTraceOptions kInternalEchoToConsole;
748 static const InternalTraceOptions kInternalEnableSampling; 758 static const InternalTraceOptions kInternalEnableSampling;
749 static const InternalTraceOptions kInternalRecordAsMuchAsPossible; 759 static const InternalTraceOptions kInternalRecordAsMuchAsPossible;
760 static const InternalTraceOptions kInternalEnableArgumentFilter;
750 761
751 // This lock protects TraceLog member accesses (except for members protected 762 // This lock protects TraceLog member accesses (except for members protected
752 // by thread_info_lock_) from arbitrary threads. 763 // by thread_info_lock_) from arbitrary threads.
753 mutable Lock lock_; 764 mutable Lock lock_;
754 // This lock protects accesses to thread_names_, thread_event_start_times_ 765 // This lock protects accesses to thread_names_, thread_event_start_times_
755 // and thread_colors_. 766 // and thread_colors_.
756 Lock thread_info_lock_; 767 Lock thread_info_lock_;
757 Mode mode_; 768 Mode mode_;
758 int num_traces_recorded_; 769 int num_traces_recorded_;
759 scoped_ptr<TraceBuffer> logged_events_; 770 scoped_ptr<TraceBuffer> logged_events_;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 hash_set<MessageLoop*> thread_message_loops_; 815 hash_set<MessageLoop*> thread_message_loops_;
805 816
806 // For events which can't be added into the thread local buffer, e.g. events 817 // For events which can't be added into the thread local buffer, e.g. events
807 // from threads without a message loop. 818 // from threads without a message loop.
808 scoped_ptr<TraceBufferChunk> thread_shared_chunk_; 819 scoped_ptr<TraceBufferChunk> thread_shared_chunk_;
809 size_t thread_shared_chunk_index_; 820 size_t thread_shared_chunk_index_;
810 821
811 // Set when asynchronous Flush is in progress. 822 // Set when asynchronous Flush is in progress.
812 OutputCallback flush_output_callback_; 823 OutputCallback flush_output_callback_;
813 scoped_refptr<SingleThreadTaskRunner> flush_task_runner_; 824 scoped_refptr<SingleThreadTaskRunner> flush_task_runner_;
825 TraceEvent::ArgumentFilterPredicate argument_filter_predicate_;
814 subtle::AtomicWord generation_; 826 subtle::AtomicWord generation_;
815 bool use_worker_thread_; 827 bool use_worker_thread_;
816 828
817 DISALLOW_COPY_AND_ASSIGN(TraceLog); 829 DISALLOW_COPY_AND_ASSIGN(TraceLog);
818 }; 830 };
819 831
820 } // namespace trace_event 832 } // namespace trace_event
821 } // namespace base 833 } // namespace base
822 834
823 #endif // BASE_TRACE_EVENT_TRACE_EVENT_IMPL_H_ 835 #endif // BASE_TRACE_EVENT_TRACE_EVENT_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | base/trace_event/trace_event_impl.cc » ('j') | chrome/common/trace_event_args_whitelist.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698