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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Google Inc. All rights reserved. 3 * Copyright (C) 2009 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } 78 }
79 79
80 double TimerBase::nextFireInterval() const { 80 double TimerBase::nextFireInterval() const {
81 ASSERT(isActive()); 81 ASSERT(isActive());
82 double current = timerMonotonicallyIncreasingTime(); 82 double current = timerMonotonicallyIncreasingTime();
83 if (m_nextFireTime < current) 83 if (m_nextFireTime < current)
84 return 0; 84 return 0;
85 return m_nextFireTime - current; 85 return m_nextFireTime - current;
86 } 86 }
87 87
88 void TimerBase::moveToNewTaskRunner(WebTaskRunner* taskRunner) {
89 #if DCHECK_IS_ON()
90 DCHECK_EQ(m_thread, currentThread());
91 DCHECK(taskRunner->runsTasksOnCurrentThread());
92 #endif
93 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.
94
95 m_weakPtrFactory.revokeAll();
96
97 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.
98
99 double now = timerMonotonicallyIncreasingTime();
100 double nextFireTime = m_nextFireTime;
101 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
102
103 setNextFireTime(now, nextFireTime - now);
104 }
105
88 // static 106 // static
89 WebTaskRunner* TimerBase::getTimerTaskRunner() { 107 WebTaskRunner* TimerBase::getTimerTaskRunner() {
90 return Platform::current()->currentThread()->scheduler()->timerTaskRunner(); 108 return Platform::current()->currentThread()->scheduler()->timerTaskRunner();
91 } 109 }
92 110
93 // static 111 // static
94 WebTaskRunner* TimerBase::getUnthrottledTaskRunner() { 112 WebTaskRunner* TimerBase::getUnthrottledTaskRunner() {
95 return Platform::current()->currentThread()->getWebTaskRunner(); 113 return Platform::current()->currentThread()->getWebTaskRunner();
96 } 114 }
97 115
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 const TimerBase* b) const { 171 const TimerBase* b) const {
154 return a->m_nextFireTime < b->m_nextFireTime; 172 return a->m_nextFireTime < b->m_nextFireTime;
155 } 173 }
156 174
157 // static 175 // static
158 double TimerBase::timerMonotonicallyIncreasingTime() const { 176 double TimerBase::timerMonotonicallyIncreasingTime() const {
159 return timerTaskRunner()->monotonicallyIncreasingVirtualTimeSeconds(); 177 return timerTaskRunner()->monotonicallyIncreasingVirtualTimeSeconds();
160 } 178 }
161 179
162 } // namespace blink 180 } // namespace blink
OLDNEW
« 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