Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "WebString.h" | 9 #include "WebString.h" |
| 10 #include "public/platform/WebThread.h" | 10 #include "public/platform/WebThread.h" |
| 11 #include "public/platform/WebTraceLocation.h" | 11 #include "public/platform/WebTraceLocation.h" |
| 12 #include "public/platform/WebViewScheduler.h" | 12 #include "public/platform/WebViewScheduler.h" |
| 13 | 13 |
| 14 #include <memory> | 14 #include <memory> |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| 17 | |
| 18 class WebTaskRunner; | 17 class WebTaskRunner; |
| 19 class WebView; | |
| 20 | 18 |
| 21 // This class is used to submit tasks and pass other information from Blink to | 19 // This class is used to submit tasks and pass other information from Blink to |
| 22 // the platform's scheduler. | 20 // the platform's scheduler. |
| 23 // TODO(skyostil): Replace this class with RendererScheduler. | 21 // TODO(skyostil): Replace this class with RendererScheduler. |
| 24 class BLINK_PLATFORM_EXPORT WebScheduler { | 22 class BLINK_PLATFORM_EXPORT WebScheduler { |
| 25 public: | 23 public: |
| 26 class BLINK_PLATFORM_EXPORT InterventionReporter { | 24 class BLINK_PLATFORM_EXPORT InterventionReporter { |
| 27 public: | 25 public: |
| 28 virtual ~InterventionReporter() {} | 26 virtual ~InterventionReporter() {} |
| 29 | 27 |
| 30 // The scheduler has performed an intervention, described by |message|, | 28 // The scheduler has performed an intervention, described by |message|, |
| 31 // which should be reported to the developer. | 29 // which should be reported to the developer. |
| 32 virtual void ReportIntervention(const WebString& message) = 0; | 30 virtual void ReportIntervention(const WebString& message) = 0; |
| 33 }; | 31 }; |
| 34 | 32 |
| 33 // Helper interface to plumb various settings from WebSettings to scheduler. | |
| 34 class BLINK_PLATFORM_EXPORT WebSchedulerSettings { | |
|
Sami
2016/11/04 16:50:28
Instead of adding this generic interface, how woul
altimin
2016/11/07 15:19:49
Per offline discussion, renamed to WebViewSchedule
| |
| 35 public: | |
| 36 virtual ~WebSchedulerSettings() {} | |
| 37 | |
| 38 // Background throttling aggressiveness settings. | |
| 39 virtual float expensiveBackgroundThrottlingCPUBudget() = 0; | |
| 40 virtual float expensiveBackgroundThrottlingInitialBudget() = 0; | |
| 41 virtual float expensiveBackgroundThrottlingMaxBudget() = 0; | |
| 42 virtual float expensiveBackgroundThrottlingMaxDelay() = 0; | |
| 43 }; | |
| 44 | |
| 35 virtual ~WebScheduler() {} | 45 virtual ~WebScheduler() {} |
| 36 | 46 |
| 37 // Called to prevent any more pending tasks from running. Must be called on | 47 // Called to prevent any more pending tasks from running. Must be called on |
| 38 // the associated WebThread. | 48 // the associated WebThread. |
| 39 virtual void shutdown() = 0; | 49 virtual void shutdown() = 0; |
| 40 | 50 |
| 41 // Returns true if there is high priority work pending on the associated | 51 // Returns true if there is high priority work pending on the associated |
| 42 // WebThread and the caller should yield to let the scheduler service that | 52 // WebThread and the caller should yield to let the scheduler service that |
| 43 // work. Must be called on the associated WebThread. | 53 // work. Must be called on the associated WebThread. |
| 44 virtual bool shouldYieldForHighPriorityWork() = 0; | 54 virtual bool shouldYieldForHighPriorityWork() = 0; |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 69 | 79 |
| 70 // Returns a WebTaskRunner for loading tasks. Can be called from any thread. | 80 // Returns a WebTaskRunner for loading tasks. Can be called from any thread. |
| 71 virtual WebTaskRunner* loadingTaskRunner() = 0; | 81 virtual WebTaskRunner* loadingTaskRunner() = 0; |
| 72 | 82 |
| 73 // Returns a WebTaskRunner for timer tasks. Can be called from any thread. | 83 // Returns a WebTaskRunner for timer tasks. Can be called from any thread. |
| 74 virtual WebTaskRunner* timerTaskRunner() = 0; | 84 virtual WebTaskRunner* timerTaskRunner() = 0; |
| 75 | 85 |
| 76 // Creates a new WebViewScheduler for a given WebView. Must be called from | 86 // Creates a new WebViewScheduler for a given WebView. Must be called from |
| 77 // the associated WebThread. | 87 // the associated WebThread. |
| 78 virtual std::unique_ptr<WebViewScheduler> createWebViewScheduler( | 88 virtual std::unique_ptr<WebViewScheduler> createWebViewScheduler( |
| 79 InterventionReporter*) = 0; | 89 InterventionReporter*, |
| 90 WebSchedulerSettings*) = 0; | |
| 80 | 91 |
| 81 // Suspends the timer queue and increments the timer queue suspension count. | 92 // Suspends the timer queue and increments the timer queue suspension count. |
| 82 // May only be called from the main thread. | 93 // May only be called from the main thread. |
| 83 virtual void suspendTimerQueue() = 0; | 94 virtual void suspendTimerQueue() = 0; |
| 84 | 95 |
| 85 // Decrements the timer queue suspension count and re-enables the timer queue | 96 // Decrements the timer queue suspension count and re-enables the timer queue |
| 86 // if the suspension count is zero and the current scheduler policy allows it. | 97 // if the suspension count is zero and the current scheduler policy allows it. |
| 87 virtual void resumeTimerQueue() = 0; | 98 virtual void resumeTimerQueue() = 0; |
| 88 | 99 |
| 89 enum class NavigatingFrameType { kMainFrame, kChildFrame }; | 100 enum class NavigatingFrameType { kMainFrame, kChildFrame }; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 104 | 115 |
| 105 void postIdleTask(const WebTraceLocation&, std::unique_ptr<IdleTask>); | 116 void postIdleTask(const WebTraceLocation&, std::unique_ptr<IdleTask>); |
| 106 void postNonNestableIdleTask(const WebTraceLocation&, | 117 void postNonNestableIdleTask(const WebTraceLocation&, |
| 107 std::unique_ptr<IdleTask>); | 118 std::unique_ptr<IdleTask>); |
| 108 #endif | 119 #endif |
| 109 }; | 120 }; |
| 110 | 121 |
| 111 } // namespace blink | 122 } // namespace blink |
| 112 | 123 |
| 113 #endif // WebScheduler_h | 124 #endif // WebScheduler_h |
| OLD | NEW |