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 WebViewScheduler_h | 5 #ifndef WebViewScheduler_h |
6 #define WebViewScheduler_h | 6 #define WebViewScheduler_h |
7 | 7 |
8 #include "WebCommon.h" | 8 #include "WebCommon.h" |
9 #include "public/platform/BlameContext.h" | 9 #include "public/platform/BlameContext.h" |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 class WebFrameScheduler; | 15 class WebFrameScheduler; |
16 | 16 |
17 class BLINK_PLATFORM_EXPORT WebViewScheduler { | 17 class BLINK_PLATFORM_EXPORT WebViewScheduler { |
18 public: | 18 public: |
19 virtual ~WebViewScheduler() {} | 19 virtual ~WebViewScheduler() {} |
20 | 20 |
21 // The scheduler may throttle tasks associated with background pages. | 21 // The scheduler may throttle tasks associated with background pages. |
22 virtual void setPageVisible(bool) = 0; | 22 virtual void setPageVisible(bool) = 0; |
23 | 23 |
24 // Creates a new WebFrameScheduler. The caller is responsible for deleting | 24 // Creates a new WebFrameScheduler. The caller is responsible for deleting |
25 // it. All tasks executed by the frame scheduler will be attributed to | 25 // it. All tasks executed by the frame scheduler will be attributed to |
26 // |BlameContext|. | 26 // |BlameContext|. |
27 virtual std::unique_ptr<WebFrameScheduler> createFrameScheduler( | 27 virtual std::unique_ptr<WebFrameScheduler> createFrameScheduler( |
28 BlameContext*) = 0; | 28 BlameContext*) = 0; |
29 | 29 |
30 // Instructs this WebViewScheduler to use virtual time. When virtual time is e
nabled | 30 // Instructs this WebViewScheduler to use virtual time. When virtual time is |
31 // the system doesn't actually sleep for the delays between tasks before execu
ting | 31 // enabled the system doesn't actually sleep for the delays between tasks |
32 // them. E.g: A-E are delayed tasks | 32 // before executing them. E.g: A-E are delayed tasks |
33 // | 33 // |
34 // | A B C D E (normal) | 34 // | A B C D E (normal) |
35 // |-----------------------------> time | 35 // |-----------------------------> time |
36 // | 36 // |
37 // |ABCDE (virtual time) | 37 // |ABCDE (virtual time) |
38 // |-----------------------------> time | 38 // |-----------------------------> time |
39 virtual void enableVirtualTime() = 0; | 39 virtual void enableVirtualTime() = 0; |
40 | 40 |
41 // Returns true if virtual time is currently allowed to advance. | 41 // Returns true if virtual time is currently allowed to advance. |
42 virtual bool virtualTimeAllowedToAdvance() const = 0; | 42 virtual bool virtualTimeAllowedToAdvance() const = 0; |
43 | 43 |
44 enum class VirtualTimePolicy { | 44 enum class VirtualTimePolicy { |
45 // In this policy virtual time is allowed to advance. If the blink scheduler
runs out of | 45 // In this policy virtual time is allowed to advance. If the blink scheduler |
46 // immediate work, the virtual timebase will be incremented so that the next
sceduled | 46 // runs out of immediate work, the virtual timebase will be incremented so |
47 // timer may fire. NOTE Tasks will be run in time order (as usual). | 47 // that the next sceduled timer may fire. NOTE Tasks will be run in time |
| 48 // order (as usual). |
48 ADVANCE, | 49 ADVANCE, |
49 | 50 |
50 // In this policy virtual time is not allowed to advance. Delayed tasks post
ed to | 51 // In this policy virtual time is not allowed to advance. Delayed tasks |
51 // WebTaskRunners owned by any child WebFrameSchedulers will be paused, unle
ss their | 52 // posted to WebTaskRunners owned by any child WebFrameSchedulers will be |
52 // scheduled run time is less than or equal to the current virtual time. No
te non-delayed | 53 // paused, unless their scheduled run time is less than or equal to the |
53 // tasks will run as normal. | 54 // current virtual time. Note non-delayed tasks will run as normal. |
54 PAUSE, | 55 PAUSE, |
55 | 56 |
56 // In this policy virtual time is allowed to advance unless there are pendin
g network | 57 // In this policy virtual time is allowed to advance unless there are |
57 // fetches associated any child WebFrameScheduler, or a document is being pa
rsed on a | 58 // pending network fetches associated any child WebFrameScheduler, or a |
58 // background thread. Initially virtual time is not allowed to advance until
we have seen | 59 // document is being parsed on a background thread. Initially virtual time |
59 // at least one load. The aim being to try and make loading (more) determini
stic. | 60 // is not allowed to advance until we have seen at least one load. The aim |
| 61 // being to try and make loading (more) deterministic. |
60 DETERMINISTIC_LOADING | 62 DETERMINISTIC_LOADING |
61 }; | 63 }; |
62 | 64 |
63 // Sets the virtual time policy, which is applied imemdiatly to all child WebF
rameSchedulers. | 65 // Sets the virtual time policy, which is applied imemdiatly to all child |
| 66 // WebFrameSchedulers. |
64 virtual void setVirtualTimePolicy(VirtualTimePolicy) = 0; | 67 virtual void setVirtualTimePolicy(VirtualTimePolicy) = 0; |
65 }; | 68 }; |
66 | 69 |
67 } // namespace blink | 70 } // namespace blink |
68 | 71 |
69 #endif // WebViewScheduler | 72 #endif // WebViewScheduler |
OLD | NEW |