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

Unified Diff: cc/scheduler/delay_based_time_source.h

Issue 1200113003: cc: Cleanup DelayBasedTimeSource code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@task_runner_refptr
Patch Set: mithro's review Created 5 years, 5 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/scheduler/begin_frame_source.cc ('k') | cc/scheduler/delay_based_time_source.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/scheduler/delay_based_time_source.h
diff --git a/cc/scheduler/delay_based_time_source.h b/cc/scheduler/delay_based_time_source.h
index 99df6dbafe6d42f49b0ffe4772f7125a5ccd91fb..cd474a5c807f3f66a182b55fea663e454a576001 100644
--- a/cc/scheduler/delay_based_time_source.h
+++ b/cc/scheduler/delay_based_time_source.h
@@ -7,6 +7,7 @@
#include <string>
+#include "base/cancelable_callback.h"
#include "base/memory/weak_ptr.h"
#include "base/values.h"
#include "cc/base/cc_export.h"
@@ -19,13 +20,12 @@ class SingleThreadTaskRunner;
}
namespace cc {
-
-class CC_EXPORT TimeSourceClient {
+class CC_EXPORT DelayBasedTimeSourceClient {
public:
virtual void OnTimerTick() = 0;
protected:
- virtual ~TimeSourceClient() {}
+ virtual ~DelayBasedTimeSourceClient() {}
};
// This timer implements a time source that achieves the specified interval
@@ -41,23 +41,21 @@ class CC_EXPORT DelayBasedTimeSource {
virtual ~DelayBasedTimeSource();
- virtual void SetClient(TimeSourceClient* client);
+ void SetClient(DelayBasedTimeSourceClient* client);
+
+ void SetTimebaseAndInterval(base::TimeTicks timebase,
+ base::TimeDelta interval);
- // TimeSource implementation
- virtual void SetTimebaseAndInterval(base::TimeTicks timebase,
- base::TimeDelta interval);
- base::TimeDelta Interval() const { return next_parameters_.interval; }
+ base::TimeDelta Interval() const;
- virtual base::TimeTicks SetActive(bool active);
- virtual bool Active() const;
+ // Returns the time for the last missed tick.
+ base::TimeTicks SetActive(bool active);
+ bool Active() const;
// Get the last and next tick times. NextTickTime() returns null when
// inactive.
- virtual base::TimeTicks LastTickTime() const;
- virtual base::TimeTicks NextTickTime() const;
-
- // Virtual for testing.
- virtual base::TimeTicks Now() const;
+ base::TimeTicks LastTickTime() const;
+ base::TimeTicks NextTickTime() const;
virtual void AsValueInto(base::trace_event::TracedValue* dict) const;
@@ -65,35 +63,34 @@ class CC_EXPORT DelayBasedTimeSource {
DelayBasedTimeSource(base::TimeDelta interval,
base::SingleThreadTaskRunner* task_runner);
+ // Virtual for testing.
+ virtual base::TimeTicks Now() const;
virtual std::string TypeString() const;
- base::TimeTicks NextTickTarget(base::TimeTicks now);
- void PostNextTickTask(base::TimeTicks now);
- void OnTimerFired();
+ private:
+ base::TimeTicks NextTickTarget(base::TimeTicks now) const;
- struct Parameters {
- Parameters(base::TimeDelta interval, base::TimeTicks tick_target)
- : interval(interval), tick_target(tick_target) {}
- base::TimeDelta interval;
- base::TimeTicks tick_target;
- };
+ void PostNextTickTask(base::TimeTicks now);
+ void ResetTickTask(base::TimeTicks now);
- TimeSourceClient* client_;
- base::TimeTicks last_tick_time_;
+ void OnTimerTick();
- // current_parameters_ should only be written by PostNextTickTask.
- // next_parameters_ will take effect on the next call to PostNextTickTask.
- // Maintaining a pending set of parameters allows NextTickTime() to always
- // reflect the actual time we expect OnTimerFired to be called.
- Parameters current_parameters_;
- Parameters next_parameters_;
+ DelayBasedTimeSourceClient* client_;
bool active_;
+ base::TimeTicks timebase_;
+ base::TimeDelta interval_;
+
+ base::TimeTicks last_tick_time_;
+ base::TimeTicks next_tick_time_;
+
+ base::CancelableClosure tick_closure_;
+
base::SingleThreadTaskRunner* task_runner_;
+
base::WeakPtrFactory<DelayBasedTimeSource> weak_factory_;
- private:
DISALLOW_COPY_AND_ASSIGN(DelayBasedTimeSource);
};
« no previous file with comments | « cc/scheduler/begin_frame_source.cc ('k') | cc/scheduler/delay_based_time_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698