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

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

Issue 2556053004: [blink] Support moving timers between WebTaskRunners (Closed)
Patch Set: 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..022329002b560e085d494d7aeac285143bd3dd1d 100644
--- a/third_party/WebKit/Source/platform/Timer.cpp
+++ b/third_party/WebKit/Source/platform/Timer.cpp
@@ -85,6 +85,24 @@ 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
+ TRACE_EVENT0("blink", "TimerBase::moveToNewTaskRunner");
Sami 2016/12/07 18:58:13 Might want to check if we're already on |taskRunne
haraken 2016/12/08 01:37:20 Do you really want to have the trace event? moveTo
altimin 2016/12/08 14:14:38 Done.
altimin 2016/12/08 14:14:38 Agreed, removed.
+
+ m_weakPtrFactory.revokeAll();
+
+ m_webTaskRunner = std::unique_ptr<WebTaskRunner>(taskRunner->clone());
dcheng 2016/12/07 18:59:57 Nit: clone() already returns a unique_ptr, doesn't
altimin 2016/12/08 14:14:38 Thanks.
+
+ double now = timerMonotonicallyIncreasingTime();
+ double nextFireTime = m_nextFireTime;
+ m_nextFireTime = 0;
haraken 2016/12/08 01:37:20 Line 100 and 101 wouldn't be needed. I think you c
altimin 2016/12/08 14:14:38 They are needed because of line 127. setNextFireTi
+
+ 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