| 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 12 matching lines...) Expand all Loading... |
| 23 #include "build/build_config.h" | 23 #include "build/build_config.h" |
| 24 | 24 |
| 25 namespace base { | 25 namespace base { |
| 26 | 26 |
| 27 template <typename Type> | 27 template <typename Type> |
| 28 struct DefaultSingletonTraits; | 28 struct DefaultSingletonTraits; |
| 29 class RefCountedString; | 29 class RefCountedString; |
| 30 | 30 |
| 31 namespace trace_event { | 31 namespace trace_event { |
| 32 | 32 |
| 33 class TraceCategory; |
| 33 class TraceBuffer; | 34 class TraceBuffer; |
| 34 class TraceBufferChunk; | 35 class TraceBufferChunk; |
| 35 class TraceEvent; | 36 class TraceEvent; |
| 36 class TraceEventMemoryOverhead; | 37 class TraceEventMemoryOverhead; |
| 37 | 38 |
| 38 struct BASE_EXPORT TraceLogStatus { | 39 struct BASE_EXPORT TraceLogStatus { |
| 39 TraceLogStatus(); | 40 TraceLogStatus(); |
| 40 ~TraceLogStatus(); | 41 ~TraceLogStatus(); |
| 41 uint32_t event_capacity; | 42 uint32_t event_capacity; |
| 42 uint32_t event_count; | 43 uint32_t event_count; |
| 43 }; | 44 }; |
| 44 | 45 |
| 45 class BASE_EXPORT TraceLog : public MemoryDumpProvider { | 46 class BASE_EXPORT TraceLog : public MemoryDumpProvider { |
| 46 public: | 47 public: |
| 47 // Argument passed to TraceLog::SetEnabled. | 48 // Argument passed to TraceLog::SetEnabled. |
| 48 enum Mode : uint8_t { | 49 enum Mode : uint8_t { |
| 49 // Enables normal tracing (recording trace events in the trace buffer). | 50 // Enables normal tracing (recording trace events in the trace buffer). |
| 50 RECORDING_MODE = 1 << 0, | 51 RECORDING_MODE = 1 << 0, |
| 51 | 52 |
| 52 // Trace events are enabled just for filtering but not for recording. Only | 53 // Trace events are enabled just for filtering but not for recording. Only |
| 53 // event filters config of |trace_config| argument is used. | 54 // event filters config of |trace_config| argument is used. |
| 54 FILTERING_MODE = 1 << 1 | 55 FILTERING_MODE = 1 << 1 |
| 55 }; | 56 }; |
| 56 | 57 |
| 57 // The pointer returned from GetCategoryGroupEnabledInternal() points to a | |
| 58 // value with zero or more of the following bits. Used in this class only. | |
| 59 // The TRACE_EVENT macros should only use the value as a bool. | |
| 60 // These values must be in sync with macro values in TraceEvent.h in Blink. | |
| 61 enum CategoryGroupEnabledFlags { | |
| 62 // Category group enabled for the recording mode. | |
| 63 ENABLED_FOR_RECORDING = 1 << 0, | |
| 64 // 1 << 2 was used for ENABLED_FOR_EVENT_CALLBACK. | |
| 65 | |
| 66 // Category group enabled to export events to ETW. | |
| 67 ENABLED_FOR_ETW_EXPORT = 1 << 3, | |
| 68 // Category group being filtered before logged. | |
| 69 ENABLED_FOR_FILTERING = 1 << 4 | |
| 70 }; | |
| 71 | |
| 72 static TraceLog* GetInstance(); | 58 static TraceLog* GetInstance(); |
| 73 | 59 |
| 74 // Get set of known category groups. This can change as new code paths are | 60 // Get set of known category groups. This can change as new code paths are |
| 75 // reached. The known category groups are inserted into |category_groups|. | 61 // reached. The known category groups are inserted into |category_groups|. |
| 76 void GetKnownCategoryGroups(std::vector<std::string>* category_groups); | 62 void GetKnownCategoryGroups(std::vector<std::string>* category_groups); |
| 77 | 63 |
| 78 // Retrieves a copy (for thread-safety) of the current TraceConfig. | 64 // Retrieves a copy (for thread-safety) of the current TraceConfig. |
| 79 TraceConfig GetCurrentTraceConfig() const; | 65 TraceConfig GetCurrentTraceConfig() const; |
| 80 | 66 |
| 81 // Initializes the thread-local event buffer, if not already initialized and | 67 // Initializes the thread-local event buffer, if not already initialized and |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 | 361 |
| 376 // MemoryDumpProvider implementation. | 362 // MemoryDumpProvider implementation. |
| 377 bool OnMemoryDump(const MemoryDumpArgs& args, | 363 bool OnMemoryDump(const MemoryDumpArgs& args, |
| 378 ProcessMemoryDump* pmd) override; | 364 ProcessMemoryDump* pmd) override; |
| 379 | 365 |
| 380 // Enable/disable each category group based on the current mode_, | 366 // Enable/disable each category group based on the current mode_, |
| 381 // category_filter_ and event_filters_enabled_. | 367 // category_filter_ and event_filters_enabled_. |
| 382 // Enable the category group in the recording mode if category_filter_ matches | 368 // Enable the category group in the recording mode if category_filter_ matches |
| 383 // the category group, is not null. Enable category for filtering if any | 369 // the category group, is not null. Enable category for filtering if any |
| 384 // filter in event_filters_enabled_ enables it. | 370 // filter in event_filters_enabled_ enables it. |
| 385 void UpdateCategoryGroupEnabledFlags(); | 371 void UpdateCategoryRegistry(); |
| 386 void UpdateCategoryGroupEnabledFlag(size_t category_index); | 372 void UpdateCategoryState(TraceCategory* category); |
| 387 | 373 |
| 388 void CreateFiltersForTraceConfig(); | 374 void CreateFiltersForTraceConfig(); |
| 389 | 375 |
| 390 // Configure synthetic delays based on the values set in the current | 376 // Configure synthetic delays based on the values set in the current |
| 391 // trace config. | 377 // trace config. |
| 392 void UpdateSyntheticDelaysFromTraceConfig(); | 378 void UpdateSyntheticDelaysFromTraceConfig(); |
| 393 | 379 |
| 394 InternalTraceOptions GetInternalOptionsFromTraceConfig( | 380 InternalTraceOptions GetInternalOptionsFromTraceConfig( |
| 395 const TraceConfig& config); | 381 const TraceConfig& config); |
| 396 | 382 |
| 397 class ThreadLocalEventBuffer; | 383 class ThreadLocalEventBuffer; |
| 398 class OptionalAutoLock; | 384 class OptionalAutoLock; |
| 399 struct RegisteredAsyncObserver; | 385 struct RegisteredAsyncObserver; |
| 400 | 386 |
| 401 TraceLog(); | 387 TraceLog(); |
| 402 ~TraceLog() override; | 388 ~TraceLog() override; |
| 403 const unsigned char* GetCategoryGroupEnabledInternal(const char* name); | |
| 404 void AddMetadataEventsWhileLocked(); | 389 void AddMetadataEventsWhileLocked(); |
| 405 | 390 |
| 406 InternalTraceOptions trace_options() const { | 391 InternalTraceOptions trace_options() const { |
| 407 return static_cast<InternalTraceOptions>( | 392 return static_cast<InternalTraceOptions>( |
| 408 subtle::NoBarrier_Load(&trace_options_)); | 393 subtle::NoBarrier_Load(&trace_options_)); |
| 409 } | 394 } |
| 410 | 395 |
| 411 TraceBuffer* trace_buffer() const { return logged_events_.get(); } | 396 TraceBuffer* trace_buffer() const { return logged_events_.get(); } |
| 412 TraceBuffer* CreateTraceBuffer(); | 397 TraceBuffer* CreateTraceBuffer(); |
| 413 | 398 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 subtle::AtomicWord generation_; | 505 subtle::AtomicWord generation_; |
| 521 bool use_worker_thread_; | 506 bool use_worker_thread_; |
| 522 | 507 |
| 523 DISALLOW_COPY_AND_ASSIGN(TraceLog); | 508 DISALLOW_COPY_AND_ASSIGN(TraceLog); |
| 524 }; | 509 }; |
| 525 | 510 |
| 526 } // namespace trace_event | 511 } // namespace trace_event |
| 527 } // namespace base | 512 } // namespace base |
| 528 | 513 |
| 529 #endif // BASE_TRACE_EVENT_TRACE_LOG_H_ | 514 #endif // BASE_TRACE_EVENT_TRACE_LOG_H_ |
| OLD | NEW |