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

Unified Diff: Source/platform/Timer.h

Issue 956333002: Refactor TimeBase to post tasks. Workers to use real Idle tasks. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix a bunch of stuff Created 5 years, 10 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
Index: Source/platform/Timer.h
diff --git a/Source/platform/Timer.h b/Source/platform/Timer.h
index 67d815f1bcf7a4a02568cc0488f0bd637cf62fdb..3906b3513d43912367634ceac2428c6149472c2a 100644
--- a/Source/platform/Timer.h
+++ b/Source/platform/Timer.h
@@ -28,6 +28,7 @@
#include "platform/PlatformExport.h"
#include "platform/heap/Handle.h"
+#include "platform/scheduler/CancellableTaskFactory.h"
#include "public/platform/WebTraceLocation.h"
#include "wtf/Noncopyable.h"
#include "wtf/Threading.h"
@@ -63,45 +64,27 @@ public:
double repeatInterval() const { return m_repeatInterval; }
void augmentRepeatInterval(double delta) {
- setNextFireTime(m_nextFireTime + delta);
m_repeatInterval += delta;
+ setNextFireTime(monotonicallyIncreasingTime(), m_repeatInterval);
}
- void didChangeAlignmentInterval();
+ void didChangeAlignmentInterval(double now);
static void fireTimersInNestedEventLoop();
private:
virtual void fired() = 0;
- virtual double alignedFireTime(double fireTime) const { return fireTime; }
-
- void checkConsistency() const;
- void checkHeapIndex() const;
-
- void setNextFireTime(double);
+ void firedInternal();
- bool inHeap() const { return m_heapIndex != -1; }
-
- bool hasValidHeapPosition() const;
- void updateHeapIfNeeded(double oldTime);
-
- void heapDecreaseKey();
- void heapDelete();
- void heapDeleteMin();
- void heapIncreaseKey();
- void heapInsert();
- void heapPop();
- void heapPopMin();
+ virtual double alignedFireTime(double fireTime) const { return fireTime; }
- Vector<TimerBase*>& timerHeap() const { ASSERT(m_cachedThreadGlobalTimerHeap); return *m_cachedThreadGlobalTimerHeap; }
+ void setNextFireTime(double now, double delay);
+ CancellableTaskFactory m_taskFactory;
double m_nextFireTime; // 0 if inactive
double m_unalignedNextFireTime; // m_nextFireTime not considering alignment interval
double m_repeatInterval; // 0 if not repeating
- int m_heapIndex; // -1 if not in heap
- unsigned m_heapInsertionOrder; // Used to keep order among equal-fire-time timers
- Vector<TimerBase*>* m_cachedThreadGlobalTimerHeap;
WebTraceLocation m_location;
#if ENABLE(ASSERT)
@@ -158,7 +141,7 @@ private:
inline bool TimerBase::isActive() const
{
ASSERT(m_thread == currentThread());
- return m_nextFireTime;
+ return m_taskFactory.isPending();
}
}

Powered by Google App Engine
This is Rietveld 408576698