OLD | NEW |
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 #ifndef WebFrameScheduler_h | 5 #ifndef WebFrameScheduler_h |
6 #define WebFrameScheduler_h | 6 #define WebFrameScheduler_h |
7 | 7 |
| 8 #include "wtf/RefPtr.h" |
| 9 |
8 namespace blink { | 10 namespace blink { |
9 | 11 |
10 class WebTaskRunner; | 12 class WebTaskRunner; |
11 class WebViewScheduler; | 13 class WebViewScheduler; |
12 | 14 |
13 class WebFrameScheduler { | 15 class WebFrameScheduler { |
14 public: | 16 public: |
15 virtual ~WebFrameScheduler() {} | 17 virtual ~WebFrameScheduler() {} |
16 | 18 |
17 // The scheduler may throttle tasks associated with offscreen frames. | 19 // The scheduler may throttle tasks associated with offscreen frames. |
18 virtual void setFrameVisible(bool) {} | 20 virtual void setFrameVisible(bool) {} |
19 | 21 |
20 // Tells the scheduler that the page this frame belongs to is not visible. | 22 // Tells the scheduler that the page this frame belongs to is not visible. |
21 // The scheduler may throttle tasks associated with pages that are not | 23 // The scheduler may throttle tasks associated with pages that are not |
22 // visible. | 24 // visible. |
23 virtual void setPageVisible(bool) {} | 25 virtual void setPageVisible(bool) {} |
24 | 26 |
25 // Set whether this frame is suspended. Only unthrottledTaskRunner tasks are | 27 // Set whether this frame is suspended. Only unthrottledTaskRunner tasks are |
26 // allowed to run on a suspended frame. | 28 // allowed to run on a suspended frame. |
27 virtual void setSuspended(bool) {} | 29 virtual void setSuspended(bool) {} |
28 | 30 |
29 // Set whether this frame is cross origin w.r.t. the top level frame. Cross | 31 // Set whether this frame is cross origin w.r.t. the top level frame. Cross |
30 // origin frames may use a different scheduling policy from same origin | 32 // origin frames may use a different scheduling policy from same origin |
31 // frames. | 33 // frames. |
32 virtual void setCrossOrigin(bool) {} | 34 virtual void setCrossOrigin(bool) {} |
33 | 35 |
34 // Returns the WebTaskRunner for loading tasks. | 36 // Returns the WebTaskRunner for loading tasks. |
35 // WebFrameScheduler owns the returned WebTaskRunner. | 37 // WebFrameScheduler owns the returned WebTaskRunner. |
36 virtual WebTaskRunner* loadingTaskRunner() { return nullptr; } | 38 virtual RefPtr<WebTaskRunner> loadingTaskRunner() = 0; |
37 | 39 |
38 // Returns the WebTaskRunner for timer tasks. | 40 // Returns the WebTaskRunner for timer tasks. |
39 // WebFrameScheduler owns the returned WebTaskRunner. | 41 // WebFrameScheduler owns the returned WebTaskRunner. |
40 virtual WebTaskRunner* timerTaskRunner() { return nullptr; } | 42 virtual RefPtr<WebTaskRunner> timerTaskRunner() = 0; |
41 | 43 |
42 // Returns the WebTaskRunner for tasks which should never get throttled. | 44 // Returns the WebTaskRunner for tasks which should never get throttled. |
43 // This is generally used for executing internal browser tasks which should | 45 // This is generally used for executing internal browser tasks which should |
44 // never be throttled. Ideally only tasks whose performance characteristics | 46 // never be throttled. Ideally only tasks whose performance characteristics |
45 // are known should be posted to this task runner; for example user | 47 // are known should be posted to this task runner; for example user |
46 // JavaScript is discouraged. WebFrameScheduler owns the returned | 48 // JavaScript is discouraged. WebFrameScheduler owns the returned |
47 // WebTaskRunner. | 49 // WebTaskRunner. |
48 virtual WebTaskRunner* unthrottledTaskRunner() { return nullptr; } | 50 virtual RefPtr<WebTaskRunner> unthrottledTaskRunner() = 0; |
49 | 51 |
50 // Returns the parent WebViewScheduler. | 52 // Returns the parent WebViewScheduler. |
51 virtual WebViewScheduler* webViewScheduler() { return nullptr; } | 53 virtual WebViewScheduler* webViewScheduler() { return nullptr; } |
52 | 54 |
53 // Tells the scheduler a resource load has started. The scheduler may make | 55 // Tells the scheduler a resource load has started. The scheduler may make |
54 // policy decisions based on this. | 56 // policy decisions based on this. |
55 virtual void didStartLoading(unsigned long identifier) {} | 57 virtual void didStartLoading(unsigned long identifier) {} |
56 | 58 |
57 // Tells the scheduler a resource load has stopped. The scheduler may make | 59 // Tells the scheduler a resource load has stopped. The scheduler may make |
58 // policy decisions based on this. | 60 // policy decisions based on this. |
59 virtual void didStopLoading(unsigned long identifier) {} | 61 virtual void didStopLoading(unsigned long identifier) {} |
60 | 62 |
61 // Tells the scheduler if we are parsing a document on another thread. This | 63 // Tells the scheduler if we are parsing a document on another thread. This |
62 // tells the scheduler not to advance virtual time if it's using the | 64 // tells the scheduler not to advance virtual time if it's using the |
63 // DETERMINISTIC_LOADING policy. | 65 // DETERMINISTIC_LOADING policy. |
64 virtual void setDocumentParsingInBackground(bool) {} | 66 virtual void setDocumentParsingInBackground(bool) {} |
65 | 67 |
66 // Tells the scheduler that the first meaningful paint has occured for this | 68 // Tells the scheduler that the first meaningful paint has occured for this |
67 // frame. | 69 // frame. |
68 virtual void onFirstMeaningfulPaint() {} | 70 virtual void onFirstMeaningfulPaint() {} |
69 }; | 71 }; |
70 | 72 |
71 } // namespace blink | 73 } // namespace blink |
72 | 74 |
73 #endif // WebFrameScheduler_h | 75 #endif // WebFrameScheduler_h |
OLD | NEW |