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

Side by Side Diff: third_party/WebKit/Source/core/dom/IdleDeadline.cpp

Issue 2516493002: requestIdleCallback: Yield for high priority work (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/dom/IdleDeadline.h" 5 #include "core/dom/IdleDeadline.h"
6 6
7 #include "core/timing/PerformanceBase.h" 7 #include "core/timing/PerformanceBase.h"
8 #include "public/platform/Platform.h"
9 #include "public/platform/WebScheduler.h"
8 #include "wtf/CurrentTime.h" 10 #include "wtf/CurrentTime.h"
9 11
10 namespace blink { 12 namespace blink {
11 13
12 IdleDeadline::IdleDeadline(double deadlineSeconds, CallbackType callbackType) 14 IdleDeadline::IdleDeadline(double deadlineSeconds, CallbackType callbackType)
13 : m_deadlineSeconds(deadlineSeconds), m_callbackType(callbackType) {} 15 : m_deadlineSeconds(deadlineSeconds), m_callbackType(callbackType) {}
14 16
15 double IdleDeadline::timeRemaining() const { 17 double IdleDeadline::timeRemaining() const {
18 if (Platform::current()
19 ->currentThread()
20 ->scheduler()
21 ->shouldYieldForHighPriorityWork()) {
22 return 0;
23 }
rmcilroy 2016/11/18 09:13:51 nit - how about just setting timeRemaining to zero
Sami 2016/11/21 11:28:02 Good idea, done.
24
16 double timeRemaining = m_deadlineSeconds - monotonicallyIncreasingTime(); 25 double timeRemaining = m_deadlineSeconds - monotonicallyIncreasingTime();
17 if (timeRemaining < 0) 26 if (timeRemaining < 0)
18 timeRemaining = 0; 27 timeRemaining = 0;
19 28
20 return 1000.0 * PerformanceBase::clampTimeResolution(timeRemaining); 29 return 1000.0 * PerformanceBase::clampTimeResolution(timeRemaining);
21 } 30 }
22 31
23 } // namespace blink 32 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698