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

Side by Side Diff: public/platform/WebScheduler.h

Issue 1029803002: Move IdleTask to WebThread side 3/3 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 9 months 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 | « Source/platform/scheduler/SchedulerTest.cpp ('k') | 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef WebScheduler_h 5 #ifndef WebScheduler_h
6 #define WebScheduler_h 6 #define WebScheduler_h
7 7
8 #include "WebCommon.h" 8 #include "WebCommon.h"
9 #include "public/platform/WebThread.h" 9 #include "public/platform/WebThread.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 class WebTraceLocation; 13 class WebTraceLocation;
14 14
15 // This class is used to submit tasks and pass other information from Blink to 15 // This class is used to submit tasks and pass other information from Blink to
16 // the platform's scheduler. 16 // the platform's scheduler.
17 class BLINK_PLATFORM_EXPORT WebScheduler { 17 class BLINK_PLATFORM_EXPORT WebScheduler {
18 public: 18 public:
19 virtual ~WebScheduler() { } 19 virtual ~WebScheduler() { }
20 20
21 typedef WebThread::IdleTask IdleTask;
22
23 // Returns true if there is high priority work pending on the main thread 21 // Returns true if there is high priority work pending on the main thread
24 // and the caller should yield to let the scheduler service that work. 22 // and the caller should yield to let the scheduler service that work.
25 // Must be called on the main thread. 23 // Must be called on the main thread.
26 virtual bool shouldYieldForHighPriorityWork() { return false; } 24 virtual bool shouldYieldForHighPriorityWork() { return false; }
27 25
28 // Returns true if a currently running idle task could exceed its deadline 26 // Returns true if a currently running idle task could exceed its deadline
29 // without impacting user experience too much. This should only be used if 27 // without impacting user experience too much. This should only be used if
30 // there is a task which cannot be pre-empted and is likely to take longer 28 // there is a task which cannot be pre-empted and is likely to take longer
31 // than the largest expected idle task deadline. It should NOT be polled to 29 // than the largest expected idle task deadline. It should NOT be polled to
32 // check whether more work can be performed on the current idle task after 30 // check whether more work can be performed on the current idle task after
33 // its deadline has expired - post a new idle task for the continuation of 31 // its deadline has expired - post a new idle task for the continuation of
34 // the work in this case. 32 // the work in this case.
35 // Must be called from the main thread. 33 // Must be called from the main thread.
36 virtual bool canExceedIdleDeadlineIfRequired() { return false; } 34 virtual bool canExceedIdleDeadlineIfRequired() { return false; }
37 35
38 // Schedule an idle task to run the Blink main thread. For non-critical 36 // Schedule an idle task to run the Blink main thread. For non-critical
39 // tasks which may be reordered relative to other task types and may be 37 // tasks which may be reordered relative to other task types and may be
40 // starved for an arbitrarily long time if no idle time is available. 38 // starved for an arbitrarily long time if no idle time is available.
41 // Takes ownership of |IdleTask|. Can be called from any thread. 39 // Takes ownership of |IdleTask|. Can be called from any thread.
42 virtual void postIdleTask(const WebTraceLocation&, IdleTask*) { } 40 virtual void postIdleTask(const WebTraceLocation&, WebThread::IdleTask*) { }
43 41
44 // Like postIdleTask but guarantees that the posted task will not run 42 // Like postIdleTask but guarantees that the posted task will not run
45 // nested within an already-running task. Posting an idle task as 43 // nested within an already-running task. Posting an idle task as
46 // non-nestable may not affect when the task gets run, or it could 44 // non-nestable may not affect when the task gets run, or it could
47 // make it run later than it normally would, but it won't make it 45 // make it run later than it normally would, but it won't make it
48 // run earlier than it normally would. 46 // run earlier than it normally would.
49 virtual void postNonNestableIdleTask(const WebTraceLocation&, IdleTask*) { } 47 virtual void postNonNestableIdleTask(const WebTraceLocation&, WebThread::Idl eTask*) { }
50 48
51 // Like postIdleTask but does not run the idle task until after some other 49 // Like postIdleTask but does not run the idle task until after some other
52 // task has run. This enables posting of a task which won't stop the Blink 50 // task has run. This enables posting of a task which won't stop the Blink
53 // main thread from sleeping, but will start running after it wakes up. 51 // main thread from sleeping, but will start running after it wakes up.
54 // Takes ownership of |IdleTask|. Can be called from any thread. 52 // Takes ownership of |IdleTask|. Can be called from any thread.
55 virtual void postIdleTaskAfterWakeup(const WebTraceLocation&, IdleTask*) { } 53 virtual void postIdleTaskAfterWakeup(const WebTraceLocation&, WebThread::Idl eTask*) { }
56 54
57 // Schedule a loading task to be run on the Blink main thread. Loading 55 // Schedule a loading task to be run on the Blink main thread. Loading
58 // tasks usually have the default priority, but may be deprioritised 56 // tasks usually have the default priority, but may be deprioritised
59 // when the user is interacting with the device. 57 // when the user is interacting with the device.
60 // Takes ownership of |WebThread::Task|. Can be called from any thread. 58 // Takes ownership of |WebThread::Task|. Can be called from any thread.
61 virtual void postLoadingTask(const WebTraceLocation&, WebThread::Task*) { } 59 virtual void postLoadingTask(const WebTraceLocation&, WebThread::Task*) { }
62 }; 60 };
63 61
64 } // namespace blink 62 } // namespace blink
65 63
66 #endif // WebScheduler_h 64 #endif // WebScheduler_h
OLDNEW
« no previous file with comments | « Source/platform/scheduler/SchedulerTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698