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

Unified Diff: third_party/WebKit/Source/platform/Timer.cpp

Issue 2556053004: [blink] Support moving timers between WebTaskRunners (Closed)
Patch Set: Address nits Created 4 years 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 | « third_party/WebKit/Source/platform/Timer.h ('k') | third_party/WebKit/Source/platform/TimerTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/Timer.cpp
diff --git a/third_party/WebKit/Source/platform/Timer.cpp b/third_party/WebKit/Source/platform/Timer.cpp
index b02e8b6c8e52b447cd9e6b50c130d73445ec50f8..252bebafbbc0fb495d2e5f2210a8b7f2f4b0d760 100644
--- a/third_party/WebKit/Source/platform/Timer.cpp
+++ b/third_party/WebKit/Source/platform/Timer.cpp
@@ -85,6 +85,28 @@ double TimerBase::nextFireInterval() const {
return m_nextFireTime - current;
}
+void TimerBase::moveToNewTaskRunner(WebTaskRunner* taskRunner) {
+#if DCHECK_IS_ON()
+ DCHECK_EQ(m_thread, currentThread());
+ DCHECK(taskRunner->runsTasksOnCurrentThread());
+#endif
+ // If the underlying task runner stays the same, ignore it.
+ if (m_webTaskRunner->toSingleThreadTaskRunner() ==
+ taskRunner->toSingleThreadTaskRunner()) {
+ return;
+ }
+
+ m_weakPtrFactory.revokeAll();
+
+ m_webTaskRunner = taskRunner->clone();
+
+ double now = timerMonotonicallyIncreasingTime();
+ double nextFireTime = m_nextFireTime;
+ m_nextFireTime = 0;
+
+ setNextFireTime(now, nextFireTime - now);
+}
+
// static
WebTaskRunner* TimerBase::getTimerTaskRunner() {
return Platform::current()->currentThread()->scheduler()->timerTaskRunner();
« no previous file with comments | « third_party/WebKit/Source/platform/Timer.h ('k') | third_party/WebKit/Source/platform/TimerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698