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

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

Issue 2516493002: requestIdleCallback: Yield for high priority work (Closed)
Patch Set: Added a test 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 // 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 {
16 double timeRemaining = m_deadlineSeconds - monotonicallyIncreasingTime(); 18 double timeRemaining = m_deadlineSeconds - monotonicallyIncreasingTime();
17 if (timeRemaining < 0) 19 if (timeRemaining < 0) {
18 timeRemaining = 0; 20 timeRemaining = 0;
esprehn 2016/11/21 20:32:27 Early return in blink. if (timeRemaining < 0) r
21 } else if (Platform::current()
22 ->currentThread()
23 ->scheduler()
24 ->shouldYieldForHighPriorityWork()) {
25 timeRemaining = 0;
26 }
19 27
20 return 1000.0 * PerformanceBase::clampTimeResolution(timeRemaining); 28 return 1000.0 * PerformanceBase::clampTimeResolution(timeRemaining);
21 } 29 }
22 30
23 } // namespace blink 31 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/IdleDeadline.h ('k') | third_party/WebKit/Source/core/dom/IdleDeadlineTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698