OLD | NEW |
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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 // disabled. This can be used to tie into other library's tracing systems | 106 // disabled. This can be used to tie into other library's tracing systems |
107 // on-demand. | 107 // on-demand. |
108 class BASE_EXPORT EnabledStateObserver { | 108 class BASE_EXPORT EnabledStateObserver { |
109 public: | 109 public: |
110 virtual ~EnabledStateObserver() = default; | 110 virtual ~EnabledStateObserver() = default; |
111 | 111 |
112 // Called just after the tracing system becomes enabled, outside of the | 112 // Called just after the tracing system becomes enabled, outside of the |
113 // |lock_|. TraceLog::IsEnabled() is true at this point. | 113 // |lock_|. TraceLog::IsEnabled() is true at this point. |
114 virtual void OnTraceLogEnabled() = 0; | 114 virtual void OnTraceLogEnabled() = 0; |
115 | 115 |
| 116 // Called just before the tracing system disables, outside of the |lock_|. |
| 117 // TraceLog::IsEnabled() is true at this point. It is still possible to |
| 118 // emit trace events from the observer. |
| 119 virtual void OnBeforeTraceLogDisabled() {} |
| 120 |
116 // Called just after the tracing system disables, outside of the |lock_|. | 121 // Called just after the tracing system disables, outside of the |lock_|. |
117 // TraceLog::IsEnabled() is false at this point. | 122 // TraceLog::IsEnabled() is false at this point. |
118 virtual void OnTraceLogDisabled() = 0; | 123 virtual void OnTraceLogDisabled() = 0; |
119 }; | 124 }; |
120 void AddEnabledStateObserver(EnabledStateObserver* listener); | 125 void AddEnabledStateObserver(EnabledStateObserver* listener); |
121 void RemoveEnabledStateObserver(EnabledStateObserver* listener); | 126 void RemoveEnabledStateObserver(EnabledStateObserver* listener); |
122 bool HasEnabledStateObserver(EnabledStateObserver* listener) const; | 127 bool HasEnabledStateObserver(EnabledStateObserver* listener) const; |
123 | 128 |
124 // Asynchronous enabled state listeners. When tracing is enabled or disabled, | 129 // Asynchronous enabled state listeners. When tracing is enabled or disabled, |
125 // for each observer, a task for invoking its appropriate callback is posted | 130 // for each observer, a task for invoking its appropriate callback is posted |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 static const InternalTraceOptions kInternalRecordUntilFull; | 478 static const InternalTraceOptions kInternalRecordUntilFull; |
474 static const InternalTraceOptions kInternalRecordContinuously; | 479 static const InternalTraceOptions kInternalRecordContinuously; |
475 static const InternalTraceOptions kInternalEchoToConsole; | 480 static const InternalTraceOptions kInternalEchoToConsole; |
476 static const InternalTraceOptions kInternalEnableSampling; | 481 static const InternalTraceOptions kInternalEnableSampling; |
477 static const InternalTraceOptions kInternalRecordAsMuchAsPossible; | 482 static const InternalTraceOptions kInternalRecordAsMuchAsPossible; |
478 static const InternalTraceOptions kInternalEnableArgumentFilter; | 483 static const InternalTraceOptions kInternalEnableArgumentFilter; |
479 | 484 |
480 // This lock protects TraceLog member accesses (except for members protected | 485 // This lock protects TraceLog member accesses (except for members protected |
481 // by thread_info_lock_) from arbitrary threads. | 486 // by thread_info_lock_) from arbitrary threads. |
482 mutable Lock lock_; | 487 mutable Lock lock_; |
| 488 // This lock protects TraceLog::SetDisable from being entered by multiple |
| 489 // threads. The generic |lock_| could be unlocked during iterating over |
| 490 // EnabledStateObserver's. |
| 491 mutable Lock disabling_lock_; |
483 // This lock protects accesses to thread_names_, thread_event_start_times_ | 492 // This lock protects accesses to thread_names_, thread_event_start_times_ |
484 // and thread_colors_. | 493 // and thread_colors_. |
485 Lock thread_info_lock_; | 494 Lock thread_info_lock_; |
486 Mode mode_; | 495 Mode mode_; |
487 int num_traces_recorded_; | 496 int num_traces_recorded_; |
488 std::unique_ptr<TraceBuffer> logged_events_; | 497 std::unique_ptr<TraceBuffer> logged_events_; |
489 std::vector<std::unique_ptr<TraceEvent>> metadata_events_; | 498 std::vector<std::unique_ptr<TraceEvent>> metadata_events_; |
490 subtle::AtomicWord /* EventCallback */ event_callback_; | 499 subtle::AtomicWord /* EventCallback */ event_callback_; |
491 bool dispatching_to_observer_list_; | 500 bool dispatching_to_observer_list_; |
492 std::vector<EnabledStateObserver*> enabled_state_observer_list_; | 501 std::vector<EnabledStateObserver*> enabled_state_observer_list_; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 subtle::AtomicWord generation_; | 556 subtle::AtomicWord generation_; |
548 bool use_worker_thread_; | 557 bool use_worker_thread_; |
549 | 558 |
550 DISALLOW_COPY_AND_ASSIGN(TraceLog); | 559 DISALLOW_COPY_AND_ASSIGN(TraceLog); |
551 }; | 560 }; |
552 | 561 |
553 } // namespace trace_event | 562 } // namespace trace_event |
554 } // namespace base | 563 } // namespace base |
555 | 564 |
556 #endif // BASE_TRACE_EVENT_TRACE_LOG_H_ | 565 #endif // BASE_TRACE_EVENT_TRACE_LOG_H_ |
OLD | NEW |