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 #include "base/debug/trace_event_synthetic_delay.h" | |
6 #include "base/memory/singleton.h" | 5 #include "base/memory/singleton.h" |
| 6 #include "base/trace_event/trace_event_synthetic_delay.h" |
7 | 7 |
8 namespace { | 8 namespace { |
9 const int kMaxSyntheticDelays = 32; | 9 const int kMaxSyntheticDelays = 32; |
10 } // namespace | 10 } // namespace |
11 | 11 |
12 namespace base { | 12 namespace base { |
13 namespace debug { | 13 namespace debug { |
14 | 14 |
15 TraceEventSyntheticDelayClock::TraceEventSyntheticDelayClock() {} | 15 TraceEventSyntheticDelayClock::TraceEventSyntheticDelayClock() {} |
16 TraceEventSyntheticDelayClock::~TraceEventSyntheticDelayClock() {} | 16 TraceEventSyntheticDelayClock::~TraceEventSyntheticDelayClock() {} |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 << "must increase kMaxSyntheticDelays"; | 177 << "must increase kMaxSyntheticDelays"; |
178 if (delay_count >= kMaxSyntheticDelays) | 178 if (delay_count >= kMaxSyntheticDelays) |
179 return &dummy_delay_; | 179 return &dummy_delay_; |
180 | 180 |
181 delays_[delay_count].Initialize(std::string(name), this); | 181 delays_[delay_count].Initialize(std::string(name), this); |
182 base::subtle::Release_Store(&delay_count_, delay_count + 1); | 182 base::subtle::Release_Store(&delay_count_, delay_count + 1); |
183 return &delays_[delay_count]; | 183 return &delays_[delay_count]; |
184 } | 184 } |
185 | 185 |
186 base::TimeTicks TraceEventSyntheticDelayRegistry::Now() { | 186 base::TimeTicks TraceEventSyntheticDelayRegistry::Now() { |
187 return base::TimeTicks::HighResNow(); | 187 return base::TimeTicks::Now(); |
188 } | 188 } |
189 | 189 |
190 void TraceEventSyntheticDelayRegistry::ResetAllDelays() { | 190 void TraceEventSyntheticDelayRegistry::ResetAllDelays() { |
191 AutoLock lock(lock_); | 191 AutoLock lock(lock_); |
192 int delay_count = base::subtle::Acquire_Load(&delay_count_); | 192 int delay_count = base::subtle::Acquire_Load(&delay_count_); |
193 for (int i = 0; i < delay_count; ++i) { | 193 for (int i = 0; i < delay_count; ++i) { |
194 delays_[i].SetTargetDuration(base::TimeDelta()); | 194 delays_[i].SetTargetDuration(base::TimeDelta()); |
195 delays_[i].SetClock(this); | 195 delays_[i].SetClock(this); |
196 } | 196 } |
197 } | 197 } |
(...skipping 26 matching lines...) Expand all Loading... |
224 if (!delay_impl) { | 224 if (!delay_impl) { |
225 delay_impl = base::debug::TraceEventSyntheticDelayRegistry::GetInstance() | 225 delay_impl = base::debug::TraceEventSyntheticDelayRegistry::GetInstance() |
226 ->GetOrCreateDelay(name); | 226 ->GetOrCreateDelay(name); |
227 base::subtle::Release_Store( | 227 base::subtle::Release_Store( |
228 impl_ptr, reinterpret_cast<base::subtle::AtomicWord>(delay_impl)); | 228 impl_ptr, reinterpret_cast<base::subtle::AtomicWord>(delay_impl)); |
229 } | 229 } |
230 return delay_impl; | 230 return delay_impl; |
231 } | 231 } |
232 | 232 |
233 } // namespace trace_event_internal | 233 } // namespace trace_event_internal |
OLD | NEW |