| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // The synthetic delay framework makes it possible to dynamically inject | 5 // The synthetic delay framework makes it possible to dynamically inject |
| 6 // arbitrary delays into into different parts of the codebase. This can be used, | 6 // arbitrary delays into into different parts of the codebase. This can be used, |
| 7 // for instance, for testing various task scheduling algorithms. | 7 // for instance, for testing various task scheduling algorithms. |
| 8 // | 8 // |
| 9 // The delays are specified in terms of a target duration for a given block of | 9 // The delays are specified in terms of a target duration for a given block of |
| 10 // code. If the code executes faster than the duration, the thread is made to | 10 // code. If the code executes faster than the duration, the thread is made to |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 55 |
| 56 // End a named delay. The delay is applied only if this call matches the | 56 // End a named delay. The delay is applied only if this call matches the |
| 57 // first corresponding call to TRACE_EVENT_SYNTHETIC_DELAY_BEGIN with the | 57 // first corresponding call to TRACE_EVENT_SYNTHETIC_DELAY_BEGIN with the |
| 58 // same delay. | 58 // same delay. |
| 59 #define TRACE_EVENT_SYNTHETIC_DELAY_END(name) \ | 59 #define TRACE_EVENT_SYNTHETIC_DELAY_END(name) \ |
| 60 do { \ | 60 do { \ |
| 61 static base::subtle::AtomicWord impl_ptr = 0; \ | 61 static base::subtle::AtomicWord impl_ptr = 0; \ |
| 62 trace_event_internal::GetOrCreateDelay(name, &impl_ptr)->End(); \ | 62 trace_event_internal::GetOrCreateDelay(name, &impl_ptr)->End(); \ |
| 63 } while (false) | 63 } while (false) |
| 64 | 64 |
| 65 template <typename Type> | |
| 66 struct DefaultSingletonTraits; | |
| 67 | |
| 68 namespace base { | 65 namespace base { |
| 69 namespace trace_event { | 66 namespace trace_event { |
| 70 | 67 |
| 71 // Time source for computing delay durations. Used for testing. | 68 // Time source for computing delay durations. Used for testing. |
| 72 class TRACE_EVENT_API_CLASS_EXPORT TraceEventSyntheticDelayClock { | 69 class TRACE_EVENT_API_CLASS_EXPORT TraceEventSyntheticDelayClock { |
| 73 public: | 70 public: |
| 74 TraceEventSyntheticDelayClock(); | 71 TraceEventSyntheticDelayClock(); |
| 75 virtual ~TraceEventSyntheticDelayClock(); | 72 virtual ~TraceEventSyntheticDelayClock(); |
| 76 virtual base::TimeTicks Now() = 0; | 73 virtual base::TimeTicks Now() = 0; |
| 77 | 74 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 DISALLOW_COPY_AND_ASSIGN(ScopedSyntheticDelay); | 155 DISALLOW_COPY_AND_ASSIGN(ScopedSyntheticDelay); |
| 159 }; | 156 }; |
| 160 | 157 |
| 161 // Helper for registering delays. Do not use directly. | 158 // Helper for registering delays. Do not use directly. |
| 162 TRACE_EVENT_API_CLASS_EXPORT base::trace_event::TraceEventSyntheticDelay* | 159 TRACE_EVENT_API_CLASS_EXPORT base::trace_event::TraceEventSyntheticDelay* |
| 163 GetOrCreateDelay(const char* name, base::subtle::AtomicWord* impl_ptr); | 160 GetOrCreateDelay(const char* name, base::subtle::AtomicWord* impl_ptr); |
| 164 | 161 |
| 165 } // namespace trace_event_internal | 162 } // namespace trace_event_internal |
| 166 | 163 |
| 167 #endif // BASE_TRACE_EVENT_TRACE_EVENT_SYNTHETIC_DELAY_H_ | 164 #endif // BASE_TRACE_EVENT_TRACE_EVENT_SYNTHETIC_DELAY_H_ |
| OLD | NEW |