Chromium Code Reviews| Index: components/scheduler/renderer/throttled_time_domain.cc |
| diff --git a/components/scheduler/renderer/throttled_time_domain.cc b/components/scheduler/renderer/throttled_time_domain.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..76a94a2a01a0a17de431057ffa03918254806c73 |
| --- /dev/null |
| +++ b/components/scheduler/renderer/throttled_time_domain.cc |
| @@ -0,0 +1,31 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "components/scheduler/renderer/throttled_time_domain.h" |
| + |
| +#include "base/time/tick_clock.h" |
| + |
| +namespace scheduler { |
| + |
| +ThrottledTimeDomain::ThrottledTimeDomain(TimeDomain::Observer* observer, |
| + base::TickClock* tick_clock) |
| + : VirtualTimeDomain(observer, tick_clock->NowTicks()), |
| + tick_clock_(tick_clock) {} |
| + |
| +ThrottledTimeDomain::~ThrottledTimeDomain() {} |
| + |
| +base::TimeTicks ThrottledTimeDomain::ComputeDelayedRunTime( |
| + base::TimeTicks, |
| + base::TimeDelta delay) const { |
| + // We ignore the |time_domain_now| parameter since its the virtual time but we |
| + // need to use the current real time when computing the delayed runtime. If |
| + // don't do that, throttled timers may fire sooner than expected. |
| + return tick_clock_->NowTicks() + delay; |
|
Sami
2016/02/23 11:41:22
Do we need a lock for |tick_clock_|?
alex clarke (OOO till 29th)
2016/02/23 14:02:31
No because it's only set via the constructor and t
|
| +} |
| + |
| +const char* ThrottledTimeDomain::GetName() const { |
| + return "ThrottledTimeDomain"; |
| +} |
| + |
| +} // namespace scheduler |