Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: mc/scheduler/timer.h

Issue 731893002: Add a simple scheduler for animation frames (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Fix math Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mc/scheduler/time_interval.cc ('k') | mc/scheduler/timer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MC_SCHEDULER_TIMER_H_
6 #define MC_SCHEDULER_TIMER_H_
7
8 #include "base/memory/weak_ptr.h"
9 #include "base/single_thread_task_runner.h"
10 #include "base/time/time.h"
11 #include "mc/scheduler/time_interval.h"
12
13 namespace mc {
14
15 class Timer {
16 public:
17 class Client {
18 public:
19 virtual void OnTimerTick(base::TimeTicks now) = 0;
20
21 protected:
22 virtual ~Client();
23 };
24
25 Timer(Client* client,
26 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
27 ~Timer();
28
29 void SetInterval(const TimeInterval& parameters);
30 void SetEnabled(bool enabled);
31
32 private:
33 base::TimeTicks NextTickTarget(base::TimeTicks now);
34 void ScheduleNextTick(base::TimeTicks now);
35 void PostTickTask(base::TimeTicks now, base::TimeTicks target);
36 void OnTimerFired();
37
38 Client* client_;
39 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
40
41 TimeInterval interval_;
42 base::TimeTicks last_tick_;
43 base::TimeTicks current_target_;
44
45 bool enabled_;
46
47 base::WeakPtrFactory<Timer> weak_factory_;
48 };
49 }
50
51 #endif // MC_SCHEDULER_TIMER_H_
OLDNEW
« no previous file with comments | « mc/scheduler/time_interval.cc ('k') | mc/scheduler/timer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698