| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 virtual void OnTraceLogEnabled() = 0; | 112 virtual void OnTraceLogEnabled() = 0; |
| 113 | 113 |
| 114 // Called just after the tracing system disables, outside of the |lock_|. | 114 // Called just after the tracing system disables, outside of the |lock_|. |
| 115 // TraceLog::IsEnabled() is false at this point. | 115 // TraceLog::IsEnabled() is false at this point. |
| 116 virtual void OnTraceLogDisabled() = 0; | 116 virtual void OnTraceLogDisabled() = 0; |
| 117 }; | 117 }; |
| 118 void AddEnabledStateObserver(EnabledStateObserver* listener); | 118 void AddEnabledStateObserver(EnabledStateObserver* listener); |
| 119 void RemoveEnabledStateObserver(EnabledStateObserver* listener); | 119 void RemoveEnabledStateObserver(EnabledStateObserver* listener); |
| 120 bool HasEnabledStateObserver(EnabledStateObserver* listener) const; | 120 bool HasEnabledStateObserver(EnabledStateObserver* listener) const; |
| 121 | 121 |
| 122 // Asynchronous enabled state listeners. When tracing is enabled or disabled, |
| 123 // for each observer, a task for invoking its appropriate callback is posted |
| 124 // to the thread from which AddAsyncEnabledStateObserver() was called. This |
| 125 // allows the observer to be safely destroyed, provided that it happens on the |
| 126 // same thread that invoked AddAsyncEnabledStateObserver(). |
| 127 class BASE_EXPORT AsyncEnabledStateObserver { |
| 128 public: |
| 129 virtual ~AsyncEnabledStateObserver() = default; |
| 130 |
| 131 // Posted just after the tracing system becomes enabled, outside |lock_|. |
| 132 // TraceLog::IsEnabled() is true at this point. |
| 133 virtual void OnTraceLogEnabled() = 0; |
| 134 |
| 135 // Posted just after the tracing system becomes disabled, outside |lock_|. |
| 136 // TraceLog::IsEnabled() is false at this point. |
| 137 virtual void OnTraceLogDisabled() = 0; |
| 138 }; |
| 139 void AddAsyncEnabledStateObserver( |
| 140 WeakPtr<AsyncEnabledStateObserver> listener); |
| 141 void RemoveAsyncEnabledStateObserver(AsyncEnabledStateObserver* listener); |
| 142 bool HasAsyncEnabledStateObserver(AsyncEnabledStateObserver* listener) const; |
| 143 |
| 122 TraceLogStatus GetStatus() const; | 144 TraceLogStatus GetStatus() const; |
| 123 bool BufferIsFull() const; | 145 bool BufferIsFull() const; |
| 124 | 146 |
| 125 // Computes an estimate of the size of the TraceLog including all the retained | 147 // Computes an estimate of the size of the TraceLog including all the retained |
| 126 // objects. | 148 // objects. |
| 127 void EstimateTraceMemoryOverhead(TraceEventMemoryOverhead* overhead); | 149 void EstimateTraceMemoryOverhead(TraceEventMemoryOverhead* overhead); |
| 128 | 150 |
| 129 // Not using base::Callback because of its limited by 7 parameters. | 151 // Not using base::Callback because of its limited by 7 parameters. |
| 130 // Also, using primitive type allows directly passing callback from WebCore. | 152 // Also, using primitive type allows directly passing callback from WebCore. |
| 131 // WARNING: It is possible for the previously set callback to be called | 153 // WARNING: It is possible for the previously set callback to be called |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 | 380 |
| 359 // Configure synthetic delays based on the values set in the current | 381 // Configure synthetic delays based on the values set in the current |
| 360 // trace config. | 382 // trace config. |
| 361 void UpdateSyntheticDelaysFromTraceConfig(); | 383 void UpdateSyntheticDelaysFromTraceConfig(); |
| 362 | 384 |
| 363 InternalTraceOptions GetInternalOptionsFromTraceConfig( | 385 InternalTraceOptions GetInternalOptionsFromTraceConfig( |
| 364 const TraceConfig& config); | 386 const TraceConfig& config); |
| 365 | 387 |
| 366 class ThreadLocalEventBuffer; | 388 class ThreadLocalEventBuffer; |
| 367 class OptionalAutoLock; | 389 class OptionalAutoLock; |
| 390 struct RegisteredAsyncObserver; |
| 368 | 391 |
| 369 TraceLog(); | 392 TraceLog(); |
| 370 ~TraceLog() override; | 393 ~TraceLog() override; |
| 371 const unsigned char* GetCategoryGroupEnabledInternal(const char* name); | 394 const unsigned char* GetCategoryGroupEnabledInternal(const char* name); |
| 372 void AddMetadataEventsWhileLocked(); | 395 void AddMetadataEventsWhileLocked(); |
| 373 | 396 |
| 374 InternalTraceOptions trace_options() const { | 397 InternalTraceOptions trace_options() const { |
| 375 return static_cast<InternalTraceOptions>( | 398 return static_cast<InternalTraceOptions>( |
| 376 subtle::NoBarrier_Load(&trace_options_)); | 399 subtle::NoBarrier_Load(&trace_options_)); |
| 377 } | 400 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 // This lock protects accesses to thread_names_, thread_event_start_times_ | 458 // This lock protects accesses to thread_names_, thread_event_start_times_ |
| 436 // and thread_colors_. | 459 // and thread_colors_. |
| 437 Lock thread_info_lock_; | 460 Lock thread_info_lock_; |
| 438 Mode mode_; | 461 Mode mode_; |
| 439 int num_traces_recorded_; | 462 int num_traces_recorded_; |
| 440 std::unique_ptr<TraceBuffer> logged_events_; | 463 std::unique_ptr<TraceBuffer> logged_events_; |
| 441 std::vector<std::unique_ptr<TraceEvent>> metadata_events_; | 464 std::vector<std::unique_ptr<TraceEvent>> metadata_events_; |
| 442 subtle::AtomicWord /* EventCallback */ event_callback_; | 465 subtle::AtomicWord /* EventCallback */ event_callback_; |
| 443 bool dispatching_to_observer_list_; | 466 bool dispatching_to_observer_list_; |
| 444 std::vector<EnabledStateObserver*> enabled_state_observer_list_; | 467 std::vector<EnabledStateObserver*> enabled_state_observer_list_; |
| 468 std::map<AsyncEnabledStateObserver*, RegisteredAsyncObserver> |
| 469 async_observers_; |
| 445 | 470 |
| 446 std::string process_name_; | 471 std::string process_name_; |
| 447 base::hash_map<int, std::string> process_labels_; | 472 base::hash_map<int, std::string> process_labels_; |
| 448 int process_sort_index_; | 473 int process_sort_index_; |
| 449 base::hash_map<int, int> thread_sort_indices_; | 474 base::hash_map<int, int> thread_sort_indices_; |
| 450 base::hash_map<int, std::string> thread_names_; | 475 base::hash_map<int, std::string> thread_names_; |
| 451 | 476 |
| 452 // The following two maps are used only when ECHO_TO_CONSOLE. | 477 // The following two maps are used only when ECHO_TO_CONSOLE. |
| 453 base::hash_map<int, std::stack<TimeTicks>> thread_event_start_times_; | 478 base::hash_map<int, std::stack<TimeTicks>> thread_event_start_times_; |
| 454 base::hash_map<std::string, int> thread_colors_; | 479 base::hash_map<std::string, int> thread_colors_; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 subtle::AtomicWord generation_; | 522 subtle::AtomicWord generation_; |
| 498 bool use_worker_thread_; | 523 bool use_worker_thread_; |
| 499 | 524 |
| 500 DISALLOW_COPY_AND_ASSIGN(TraceLog); | 525 DISALLOW_COPY_AND_ASSIGN(TraceLog); |
| 501 }; | 526 }; |
| 502 | 527 |
| 503 } // namespace trace_event | 528 } // namespace trace_event |
| 504 } // namespace base | 529 } // namespace base |
| 505 | 530 |
| 506 #endif // BASE_TRACE_EVENT_TRACE_LOG_H_ | 531 #endif // BASE_TRACE_EVENT_TRACE_LOG_H_ |
| OLD | NEW |