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

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

Issue 1325073002: Introduce WebTaskRunner Patch 1/5 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix comment Created 5 years, 3 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 | « public/BUILD.gn ('k') | public/platform/WebTaskRunner.h » ('j') | 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/WebTaskRunner.h"
9 #include "public/platform/WebThread.h" 10 #include "public/platform/WebThread.h"
10 11
11 namespace blink { 12 namespace blink {
12 13
13 class WebTraceLocation; 14 class WebTraceLocation;
14 15
15 // This class is used to submit tasks and pass other information from Blink to 16 // This class is used to submit tasks and pass other information from Blink to
16 // the platform's scheduler. 17 // the platform's scheduler.
17 class BLINK_PLATFORM_EXPORT WebScheduler { 18 class BLINK_PLATFORM_EXPORT WebScheduler {
18 public: 19 public:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 // Like postIdleTask but does not run the idle task until after some other 54 // Like postIdleTask but does not run the idle task until after some other
54 // task has run. This enables posting of a task which won't stop the Blink 55 // task has run. This enables posting of a task which won't stop the Blink
55 // main thread from sleeping, but will start running after it wakes up. 56 // main thread from sleeping, but will start running after it wakes up.
56 // Takes ownership of |IdleTask|. Can be called from any thread. 57 // Takes ownership of |IdleTask|. Can be called from any thread.
57 virtual void postIdleTaskAfterWakeup(const WebTraceLocation&, WebThread::Idl eTask*) { } 58 virtual void postIdleTaskAfterWakeup(const WebTraceLocation&, WebThread::Idl eTask*) { }
58 59
59 // Schedule a loading task to be run on the the associated WebThread. Loadin g 60 // Schedule a loading task to be run on the the associated WebThread. Loadin g
60 // tasks usually have the default priority, but may be deprioritised 61 // tasks usually have the default priority, but may be deprioritised
61 // when the user is interacting with the device. 62 // when the user is interacting with the device.
62 // Takes ownership of |WebThread::Task|. Can be called from any thread. 63 // Takes ownership of |WebThread::Task|. Can be called from any thread.
64 // TODO(alexclarke): Remove this in favour of loadingTaskRunner().
63 virtual void postLoadingTask(const WebTraceLocation&, WebThread::Task*) { } 65 virtual void postLoadingTask(const WebTraceLocation&, WebThread::Task*) { }
64 66
65 // Schedule a timer task to be run on the the associated WebThread. Timer Ta sks 67 // Schedule a timer task to be run on the the associated WebThread. Timer Ta sks
66 // tasks usually have the default priority, but may be delayed 68 // tasks usually have the default priority, but may be delayed
67 // when the user is interacting with the device. 69 // when the user is interacting with the device.
68 // Takes ownership of |WebThread::Task|. Can be called from any thread. 70 // Takes ownership of |WebThread::Task|. Can be called from any thread.
71 // TODO(alexclarke): Remove this in favour of timerTaskRunner().
69 virtual void postTimerTask(const WebTraceLocation&, WebThread::Task*, long l ong delayMs) {} 72 virtual void postTimerTask(const WebTraceLocation&, WebThread::Task*, long l ong delayMs) {}
70 73
71 // Schedule a timer task to be run on the the associated WebThread. Timer Ta sks 74 // Schedule a timer task to be run on the the associated WebThread. Timer Ta sks
72 // tasks usually have the default priority, but may be delayed 75 // tasks usually have the default priority, but may be delayed
73 // when the user is interacting with the device. 76 // when the user is interacting with the device.
74 // |monotonicTime| is in the timebase of WTF::monotonicallyIncreasingTime(). 77 // |monotonicTime| is in the timebase of WTF::monotonicallyIncreasingTime().
75 // Takes ownership of |WebThread::Task|. Can be called from any thread. 78 // Takes ownership of |WebThread::Task|. Can be called from any thread.
76 virtual void postTimerTaskAt(const WebTraceLocation&, WebThread::Task*, doub le monotonicTime) {} 79 virtual void postTimerTaskAt(const WebTraceLocation&, WebThread::Task*, doub le monotonicTime) {}
77 80
81 // Returns a WebTaskRunner for loading tasks. Can be called from any thread.
82 virtual WebTaskRunner* loadingTaskRunner() { return nullptr; }
83
84 // Returns a WebTaskRunner for timer tasks. Can be called from any thread.
85 virtual WebTaskRunner* timerTaskRunner() { return nullptr; }
86
78 // Suspends the timer queue and increments the timer queue suspension count. 87 // Suspends the timer queue and increments the timer queue suspension count.
79 // May only be called from the main thread. 88 // May only be called from the main thread.
80 virtual void suspendTimerQueue() { } 89 virtual void suspendTimerQueue() { }
81 90
82 // Decrements the timer queue suspension count and re-enables the timer queu e 91 // Decrements the timer queue suspension count and re-enables the timer queu e
83 // if the suspension count is zero and the current scheduler policy allows i t. 92 // if the suspension count is zero and the current scheduler policy allows i t.
84 virtual void resumeTimerQueue() { } 93 virtual void resumeTimerQueue() { }
85 94
86 #ifdef INSIDE_BLINK 95 #ifdef INSIDE_BLINK
87 // Helpers for posting bound functions as tasks. 96 // Helpers for posting bound functions as tasks.
88 typedef Function<void(double deadlineSeconds)> IdleTask; 97 typedef Function<void(double deadlineSeconds)> IdleTask;
89 typedef Function<void()> Task; 98 typedef Function<void()> Task;
90 99
91 void postIdleTask(const WebTraceLocation&, PassOwnPtr<IdleTask>); 100 void postIdleTask(const WebTraceLocation&, PassOwnPtr<IdleTask>);
92 void postNonNestableIdleTask(const WebTraceLocation&, PassOwnPtr<IdleTask>); 101 void postNonNestableIdleTask(const WebTraceLocation&, PassOwnPtr<IdleTask>);
93 void postIdleTaskAfterWakeup(const WebTraceLocation&, PassOwnPtr<IdleTask>); 102 void postIdleTaskAfterWakeup(const WebTraceLocation&, PassOwnPtr<IdleTask>);
94 void postLoadingTask(const WebTraceLocation&, PassOwnPtr<Task>); 103 void postLoadingTask(const WebTraceLocation&, PassOwnPtr<Task>);
95 void postTimerTask(const WebTraceLocation&, PassOwnPtr<Task>, long long dela yMs); 104 void postTimerTask(const WebTraceLocation&, PassOwnPtr<Task>, long long dela yMs);
96 #endif 105 #endif
97 }; 106 };
98 107
99 } // namespace blink 108 } // namespace blink
100 109
101 #endif // WebScheduler_h 110 #endif // WebScheduler_h
OLDNEW
« no previous file with comments | « public/BUILD.gn ('k') | public/platform/WebTaskRunner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698