Chromium Code Reviews| Index: components/scheduler/renderer/coarse_duration_timer.h |
| diff --git a/components/scheduler/renderer/coarse_duration_timer.h b/components/scheduler/renderer/coarse_duration_timer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bdb44d8b1c4da3bd2b5825af2a9d065bb8b8aa2a |
| --- /dev/null |
| +++ b/components/scheduler/renderer/coarse_duration_timer.h |
| @@ -0,0 +1,38 @@ |
| +// 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. |
| + |
| +#ifndef COMPONENTS_SCHEDULER_RENDERER_COARSE_DURATION_TIMER_H_ |
| +#define COMPONENTS_SCHEDULER_RENDERER_COARSE_DURATION_TIMER_H_ |
| + |
| +#include "base/message_loop/message_loop.h" |
| +#include "base/optional.h" |
| +#include "base/time/time.h" |
| + |
| +namespace scheduler { |
| + |
| +// TODO - add locking things. |
|
tdresser
2016/05/30 19:07:46
^
|
| +class CoarseDurationTimer : public base::MessageLoop::RecentTimeObserver { |
| + public: |
| + // RecentTimeObserver implementation: |
| + void OnUpdateRecentTime(base::TimeTicks time) override; |
| + |
| + void BeginInterval(); |
| + base::TimeDelta EndInterval(); |
| + base::TimeTicks most_recent_time() { return most_recent_time_; } |
| + |
| + private: |
| + enum class State { |
| + OUTSIDE_INTERVAL, |
| + WITHIN_INTERVAL_NEEDS_START, |
| + WITHIN_INTERVAL |
| + }; |
| + |
| + State state_; |
| + base::TimeTicks start_time_; |
| + base::TimeTicks most_recent_time_; |
| +}; |
| + |
| +} // namespace scheduler |
| + |
| +#endif // COMPONENTS_SCHEDULER_RENDERER_COARSE_DURATION_TIMER_H_ |