| 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 16 matching lines...) Expand all Loading... |
| 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 TraceBuffer; | 33 class TraceBuffer; |
| 34 class TraceBufferChunk; | 34 class TraceBufferChunk; |
| 35 class TraceEvent; | 35 class TraceEvent; |
| 36 class TraceEventMemoryOverhead; | 36 class TraceEventMemoryOverhead; |
| 37 class TraceSamplingThread; | |
| 38 | 37 |
| 39 struct BASE_EXPORT TraceLogStatus { | 38 struct BASE_EXPORT TraceLogStatus { |
| 40 TraceLogStatus(); | 39 TraceLogStatus(); |
| 41 ~TraceLogStatus(); | 40 ~TraceLogStatus(); |
| 42 uint32_t event_capacity; | 41 uint32_t event_capacity; |
| 43 uint32_t event_count; | 42 uint32_t event_count; |
| 44 }; | 43 }; |
| 45 | 44 |
| 46 class BASE_EXPORT TraceLog : public MemoryDumpProvider { | 45 class BASE_EXPORT TraceLog : public MemoryDumpProvider { |
| 47 public: | 46 public: |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 // Cancel the watch event. If tracing is enabled, this may race with the | 299 // Cancel the watch event. If tracing is enabled, this may race with the |
| 301 // watch event notification firing. | 300 // watch event notification firing. |
| 302 void CancelWatchEvent(); | 301 void CancelWatchEvent(); |
| 303 | 302 |
| 304 int process_id() const { return process_id_; } | 303 int process_id() const { return process_id_; } |
| 305 | 304 |
| 306 uint64_t MangleEventId(uint64_t id); | 305 uint64_t MangleEventId(uint64_t id); |
| 307 | 306 |
| 308 // Exposed for unittesting: | 307 // Exposed for unittesting: |
| 309 | 308 |
| 310 void WaitSamplingEventForTesting(); | |
| 311 | |
| 312 // Allows deleting our singleton instance. | 309 // Allows deleting our singleton instance. |
| 313 static void DeleteForTesting(); | 310 static void DeleteForTesting(); |
| 314 | 311 |
| 315 class BASE_EXPORT TraceEventFilter { | 312 class BASE_EXPORT TraceEventFilter { |
| 316 public: | 313 public: |
| 317 static const char* const kEventWhitelistPredicate; | 314 static const char* const kEventWhitelistPredicate; |
| 318 static const char* const kHeapProfilerPredicate; | 315 static const char* const kHeapProfilerPredicate; |
| 319 | 316 |
| 320 TraceEventFilter() {} | 317 TraceEventFilter() {} |
| 321 virtual ~TraceEventFilter() {} | 318 virtual ~TraceEventFilter() {} |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 TimeTicks OffsetTimestamp(const TimeTicks& timestamp) const { | 465 TimeTicks OffsetTimestamp(const TimeTicks& timestamp) const { |
| 469 return timestamp - time_offset_; | 466 return timestamp - time_offset_; |
| 470 } | 467 } |
| 471 | 468 |
| 472 // Internal representation of trace options since we store the currently used | 469 // Internal representation of trace options since we store the currently used |
| 473 // trace option as an AtomicWord. | 470 // trace option as an AtomicWord. |
| 474 static const InternalTraceOptions kInternalNone; | 471 static const InternalTraceOptions kInternalNone; |
| 475 static const InternalTraceOptions kInternalRecordUntilFull; | 472 static const InternalTraceOptions kInternalRecordUntilFull; |
| 476 static const InternalTraceOptions kInternalRecordContinuously; | 473 static const InternalTraceOptions kInternalRecordContinuously; |
| 477 static const InternalTraceOptions kInternalEchoToConsole; | 474 static const InternalTraceOptions kInternalEchoToConsole; |
| 478 static const InternalTraceOptions kInternalEnableSampling; | |
| 479 static const InternalTraceOptions kInternalRecordAsMuchAsPossible; | 475 static const InternalTraceOptions kInternalRecordAsMuchAsPossible; |
| 480 static const InternalTraceOptions kInternalEnableArgumentFilter; | 476 static const InternalTraceOptions kInternalEnableArgumentFilter; |
| 481 | 477 |
| 482 // This lock protects TraceLog member accesses (except for members protected | 478 // This lock protects TraceLog member accesses (except for members protected |
| 483 // by thread_info_lock_) from arbitrary threads. | 479 // by thread_info_lock_) from arbitrary threads. |
| 484 mutable Lock lock_; | 480 mutable Lock lock_; |
| 485 // This lock protects accesses to thread_names_, thread_event_start_times_ | 481 // This lock protects accesses to thread_names_, thread_event_start_times_ |
| 486 // and thread_colors_. | 482 // and thread_colors_. |
| 487 Lock thread_info_lock_; | 483 Lock thread_info_lock_; |
| 488 Mode mode_; | 484 Mode mode_; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 514 | 510 |
| 515 TimeDelta time_offset_; | 511 TimeDelta time_offset_; |
| 516 | 512 |
| 517 // Allow tests to wake up when certain events occur. | 513 // Allow tests to wake up when certain events occur. |
| 518 WatchEventCallback watch_event_callback_; | 514 WatchEventCallback watch_event_callback_; |
| 519 subtle::AtomicWord /* const unsigned char* */ watch_category_; | 515 subtle::AtomicWord /* const unsigned char* */ watch_category_; |
| 520 std::string watch_event_name_; | 516 std::string watch_event_name_; |
| 521 | 517 |
| 522 subtle::AtomicWord /* Options */ trace_options_; | 518 subtle::AtomicWord /* Options */ trace_options_; |
| 523 | 519 |
| 524 // Sampling thread handles. | |
| 525 std::unique_ptr<TraceSamplingThread> sampling_thread_; | |
| 526 PlatformThreadHandle sampling_thread_handle_; | |
| 527 | |
| 528 TraceConfig trace_config_; | 520 TraceConfig trace_config_; |
| 529 TraceConfig event_callback_trace_config_; | 521 TraceConfig event_callback_trace_config_; |
| 530 | 522 |
| 531 ThreadLocalPointer<ThreadLocalEventBuffer> thread_local_event_buffer_; | 523 ThreadLocalPointer<ThreadLocalEventBuffer> thread_local_event_buffer_; |
| 532 ThreadLocalBoolean thread_blocks_message_loop_; | 524 ThreadLocalBoolean thread_blocks_message_loop_; |
| 533 ThreadLocalBoolean thread_is_in_trace_event_; | 525 ThreadLocalBoolean thread_is_in_trace_event_; |
| 534 | 526 |
| 535 // Contains the message loops of threads that have had at least one event | 527 // Contains the message loops of threads that have had at least one event |
| 536 // added into the local event buffer. Not using SingleThreadTaskRunner | 528 // added into the local event buffer. Not using SingleThreadTaskRunner |
| 537 // because we need to know the life time of the message loops. | 529 // because we need to know the life time of the message loops. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 549 subtle::AtomicWord generation_; | 541 subtle::AtomicWord generation_; |
| 550 bool use_worker_thread_; | 542 bool use_worker_thread_; |
| 551 | 543 |
| 552 DISALLOW_COPY_AND_ASSIGN(TraceLog); | 544 DISALLOW_COPY_AND_ASSIGN(TraceLog); |
| 553 }; | 545 }; |
| 554 | 546 |
| 555 } // namespace trace_event | 547 } // namespace trace_event |
| 556 } // namespace base | 548 } // namespace base |
| 557 | 549 |
| 558 #endif // BASE_TRACE_EVENT_TRACE_LOG_H_ | 550 #endif // BASE_TRACE_EVENT_TRACE_LOG_H_ |
| OLD | NEW |