| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef WebViewScheduler_h | |
| 6 #define WebViewScheduler_h | |
| 7 | |
| 8 #include "WebCommon.h" | |
| 9 #include "public/platform/BlameContext.h" | |
| 10 | |
| 11 #include <memory> | |
| 12 | |
| 13 namespace blink { | |
| 14 | |
| 15 class WebFrameScheduler; | |
| 16 | |
| 17 class BLINK_PLATFORM_EXPORT WebViewScheduler { | |
| 18 public: | |
| 19 // Helper interface to plumb settings from WebSettings to scheduler. | |
| 20 class BLINK_PLATFORM_EXPORT WebViewSchedulerSettings { | |
| 21 public: | |
| 22 virtual ~WebViewSchedulerSettings() {} | |
| 23 | |
| 24 // Background throttling aggressiveness settings. | |
| 25 virtual float ExpensiveBackgroundThrottlingCPUBudget() = 0; | |
| 26 virtual float ExpensiveBackgroundThrottlingInitialBudget() = 0; | |
| 27 virtual float ExpensiveBackgroundThrottlingMaxBudget() = 0; | |
| 28 virtual float ExpensiveBackgroundThrottlingMaxDelay() = 0; | |
| 29 }; | |
| 30 | |
| 31 virtual ~WebViewScheduler() {} | |
| 32 | |
| 33 // The scheduler may throttle tasks associated with background pages. | |
| 34 virtual void SetPageVisible(bool) = 0; | |
| 35 | |
| 36 // Creates a new WebFrameScheduler. The caller is responsible for deleting | |
| 37 // it. All tasks executed by the frame scheduler will be attributed to | |
| 38 // |BlameContext|. | |
| 39 virtual std::unique_ptr<WebFrameScheduler> CreateFrameScheduler( | |
| 40 BlameContext*) = 0; | |
| 41 | |
| 42 // Instructs this WebViewScheduler to use virtual time. When virtual time is | |
| 43 // enabled the system doesn't actually sleep for the delays between tasks | |
| 44 // before executing them. E.g: A-E are delayed tasks | |
| 45 // | |
| 46 // | A B C D E (normal) | |
| 47 // |-----------------------------> time | |
| 48 // | |
| 49 // |ABCDE (virtual time) | |
| 50 // |-----------------------------> time | |
| 51 virtual void EnableVirtualTime() = 0; | |
| 52 | |
| 53 // Disables virtual time. Note that this is only used for testing, because | |
| 54 // there's no reason to do this in production. | |
| 55 virtual void DisableVirtualTimeForTesting() = 0; | |
| 56 | |
| 57 // Returns true if virtual time is currently allowed to advance. | |
| 58 virtual bool VirtualTimeAllowedToAdvance() const = 0; | |
| 59 | |
| 60 enum class VirtualTimePolicy { | |
| 61 // In this policy virtual time is allowed to advance. If the blink scheduler | |
| 62 // runs out of immediate work, the virtual timebase will be incremented so | |
| 63 // that the next sceduled timer may fire. NOTE Tasks will be run in time | |
| 64 // order (as usual). | |
| 65 ADVANCE, | |
| 66 | |
| 67 // In this policy virtual time is not allowed to advance. Delayed tasks | |
| 68 // posted to WebTaskRunners owned by any child WebFrameSchedulers will be | |
| 69 // paused, unless their scheduled run time is less than or equal to the | |
| 70 // current virtual time. Note non-delayed tasks will run as normal. | |
| 71 PAUSE, | |
| 72 | |
| 73 // In this policy virtual time is allowed to advance unless there are | |
| 74 // pending network fetches associated any child WebFrameScheduler, or a | |
| 75 // document is being parsed on a background thread. Initially virtual time | |
| 76 // is not allowed to advance until we have seen at least one load. The aim | |
| 77 // being to try and make loading (more) deterministic. | |
| 78 DETERMINISTIC_LOADING | |
| 79 }; | |
| 80 | |
| 81 // Sets the virtual time policy, which is applied imemdiatly to all child | |
| 82 // WebFrameSchedulers. | |
| 83 virtual void SetVirtualTimePolicy(VirtualTimePolicy) = 0; | |
| 84 | |
| 85 virtual void AudioStateChanged(bool is_audio_playing) = 0; | |
| 86 | |
| 87 virtual bool HasActiveConnectionForTest() const = 0; | |
| 88 }; | |
| 89 | |
| 90 } // namespace blink | |
| 91 | |
| 92 #endif // WebViewScheduler | |
| OLD | NEW |