Chromium Code Reviews| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 // TODO(ssid): Remove the default SetEnabled and IsEnabled. They should take | 83 // TODO(ssid): Remove the default SetEnabled and IsEnabled. They should take |
| 84 // Mode as argument. | 84 // Mode as argument. |
| 85 | 85 |
| 86 // Disables tracing for all categories for the specified |modes_to_disable| | 86 // Disables tracing for all categories for the specified |modes_to_disable| |
| 87 // only. Only RECORDING_MODE is taken as default |modes_to_disable|. | 87 // only. Only RECORDING_MODE is taken as default |modes_to_disable|. |
| 88 void SetDisabled(); | 88 void SetDisabled(); |
| 89 void SetDisabled(uint8_t modes_to_disable); | 89 void SetDisabled(uint8_t modes_to_disable); |
| 90 | 90 |
| 91 // Returns true if TraceLog is enabled on recording mode. | 91 // Returns true if TraceLog is enabled on recording mode. |
| 92 // Note: Returns false even if FILTERING_MODE is enabled. | 92 // Note: Returns false even if FILTERING_MODE is enabled. |
| 93 bool IsEnabled() { return enabled_modes_ & RECORDING_MODE; } | 93 virtual bool IsEnabled(); |
|
hjd
2017/04/13 14:16:59
So I can mock.
| |
| 94 | 94 |
| 95 // Returns a bitmap of enabled modes from TraceLog::Mode. | 95 // Returns a bitmap of enabled modes from TraceLog::Mode. |
| 96 uint8_t enabled_modes() { return enabled_modes_; } | 96 uint8_t enabled_modes() { return enabled_modes_; } |
| 97 | 97 |
| 98 // The number of times we have begun recording traces. If tracing is off, | 98 // The number of times we have begun recording traces. If tracing is off, |
| 99 // returns -1. If tracing is on, then it returns the number of times we have | 99 // returns -1. If tracing is on, then it returns the number of times we have |
| 100 // recorded a trace. By watching for this number to increment, you can | 100 // recorded a trace. By watching for this number to increment, you can |
| 101 // passively discover when a new trace has begun. This is then used to | 101 // passively discover when a new trace has begun. This is then used to |
| 102 // implement the TRACE_EVENT_IS_NEW_TRACE() primitive. | 102 // implement the TRACE_EVENT_IS_NEW_TRACE() primitive. |
| 103 int GetNumTracesRecorded(); | 103 int GetNumTracesRecorded(); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 116 virtual ~EnabledStateObserver() = default; | 116 virtual ~EnabledStateObserver() = default; |
| 117 | 117 |
| 118 // Called just after the tracing system becomes enabled, outside of the | 118 // Called just after the tracing system becomes enabled, outside of the |
| 119 // |lock_|. TraceLog::IsEnabled() is true at this point. | 119 // |lock_|. TraceLog::IsEnabled() is true at this point. |
| 120 virtual void OnTraceLogEnabled() = 0; | 120 virtual void OnTraceLogEnabled() = 0; |
| 121 | 121 |
| 122 // Called just after the tracing system disables, outside of the |lock_|. | 122 // Called just after the tracing system disables, outside of the |lock_|. |
| 123 // TraceLog::IsEnabled() is false at this point. | 123 // TraceLog::IsEnabled() is false at this point. |
| 124 virtual void OnTraceLogDisabled() = 0; | 124 virtual void OnTraceLogDisabled() = 0; |
| 125 }; | 125 }; |
| 126 void AddEnabledStateObserver(EnabledStateObserver* listener); | 126 virtual void AddEnabledStateObserver(EnabledStateObserver* listener); |
| 127 void RemoveEnabledStateObserver(EnabledStateObserver* listener); | 127 virtual void RemoveEnabledStateObserver(EnabledStateObserver* listener); |
|
hjd
2017/04/13 14:16:59
So I can mock.
| |
| 128 bool HasEnabledStateObserver(EnabledStateObserver* listener) const; | 128 bool HasEnabledStateObserver(EnabledStateObserver* listener) const; |
| 129 | 129 |
| 130 // Asynchronous enabled state listeners. When tracing is enabled or disabled, | 130 // Asynchronous enabled state listeners. When tracing is enabled or disabled, |
| 131 // for each observer, a task for invoking its appropriate callback is posted | 131 // for each observer, a task for invoking its appropriate callback is posted |
| 132 // to the thread from which AddAsyncEnabledStateObserver() was called. This | 132 // to the thread from which AddAsyncEnabledStateObserver() was called. This |
| 133 // allows the observer to be safely destroyed, provided that it happens on the | 133 // allows the observer to be safely destroyed, provided that it happens on the |
| 134 // same thread that invoked AddAsyncEnabledStateObserver(). | 134 // same thread that invoked AddAsyncEnabledStateObserver(). |
| 135 class BASE_EXPORT AsyncEnabledStateObserver { | 135 class BASE_EXPORT AsyncEnabledStateObserver { |
| 136 public: | 136 public: |
| 137 virtual ~AsyncEnabledStateObserver() = default; | 137 virtual ~AsyncEnabledStateObserver() = default; |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 TraceBufferRingBufferGetReturnChunk); | 338 TraceBufferRingBufferGetReturnChunk); |
| 339 FRIEND_TEST_ALL_PREFIXES(TraceEventTestFixture, | 339 FRIEND_TEST_ALL_PREFIXES(TraceEventTestFixture, |
| 340 TraceBufferRingBufferHalfIteration); | 340 TraceBufferRingBufferHalfIteration); |
| 341 FRIEND_TEST_ALL_PREFIXES(TraceEventTestFixture, | 341 FRIEND_TEST_ALL_PREFIXES(TraceEventTestFixture, |
| 342 TraceBufferRingBufferFullIteration); | 342 TraceBufferRingBufferFullIteration); |
| 343 FRIEND_TEST_ALL_PREFIXES(TraceEventTestFixture, TraceBufferVectorReportFull); | 343 FRIEND_TEST_ALL_PREFIXES(TraceEventTestFixture, TraceBufferVectorReportFull); |
| 344 FRIEND_TEST_ALL_PREFIXES(TraceEventTestFixture, | 344 FRIEND_TEST_ALL_PREFIXES(TraceEventTestFixture, |
| 345 ConvertTraceConfigToInternalOptions); | 345 ConvertTraceConfigToInternalOptions); |
| 346 FRIEND_TEST_ALL_PREFIXES(TraceEventTestFixture, | 346 FRIEND_TEST_ALL_PREFIXES(TraceEventTestFixture, |
| 347 TraceRecordAsMuchAsPossibleMode); | 347 TraceRecordAsMuchAsPossibleMode); |
| 348 friend class MockTraceLog; | |
| 348 | 349 |
| 349 // This allows constructor and destructor to be private and usable only | 350 // This allows constructor and destructor to be private and usable only |
| 350 // by the Singleton class. | 351 // by the Singleton class. |
| 351 friend struct DefaultSingletonTraits<TraceLog>; | 352 friend struct DefaultSingletonTraits<TraceLog>; |
| 352 | 353 |
| 353 // MemoryDumpProvider implementation. | 354 // MemoryDumpProvider implementation. |
| 354 bool OnMemoryDump(const MemoryDumpArgs& args, | 355 bool OnMemoryDump(const MemoryDumpArgs& args, |
| 355 ProcessMemoryDump* pmd) override; | 356 ProcessMemoryDump* pmd) override; |
| 356 | 357 |
| 357 // Enable/disable each category group based on the current mode_, | 358 // Enable/disable each category group based on the current mode_, |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 498 | 499 |
| 499 FilterFactoryForTesting filter_factory_for_testing_; | 500 FilterFactoryForTesting filter_factory_for_testing_; |
| 500 | 501 |
| 501 DISALLOW_COPY_AND_ASSIGN(TraceLog); | 502 DISALLOW_COPY_AND_ASSIGN(TraceLog); |
| 502 }; | 503 }; |
| 503 | 504 |
| 504 } // namespace trace_event | 505 } // namespace trace_event |
| 505 } // namespace base | 506 } // namespace base |
| 506 | 507 |
| 507 #endif // BASE_TRACE_EVENT_TRACE_LOG_H_ | 508 #endif // BASE_TRACE_EVENT_TRACE_LOG_H_ |
| OLD | NEW |