| 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 COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_H_ | 5 #ifndef COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_H_ |
| 6 #define COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_H_ | 6 #define COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_H_ |
| 7 | 7 |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "components/scheduler/child/child_scheduler.h" | 9 #include "components/scheduler/child/child_scheduler.h" |
| 10 #include "components/scheduler/child/single_thread_idle_task_runner.h" | 10 #include "components/scheduler/child/single_thread_idle_task_runner.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // driven by this process. A stricter condition than |OnRendererHidden()|, the | 99 // driven by this process. A stricter condition than |OnRendererHidden()|, the |
| 100 // process is assumed to be foregrounded when the scheduler is constructed. | 100 // process is assumed to be foregrounded when the scheduler is constructed. |
| 101 // Must be called on the main thread. | 101 // Must be called on the main thread. |
| 102 virtual void OnRendererBackgrounded() = 0; | 102 virtual void OnRendererBackgrounded() = 0; |
| 103 | 103 |
| 104 // Tells the scheduler that the renderer process has been foregrounded. | 104 // Tells the scheduler that the renderer process has been foregrounded. |
| 105 // This is the assumed state when the scheduler is constructed. | 105 // This is the assumed state when the scheduler is constructed. |
| 106 // Must be called on the main thread. | 106 // Must be called on the main thread. |
| 107 virtual void OnRendererForegrounded() = 0; | 107 virtual void OnRendererForegrounded() = 0; |
| 108 | 108 |
| 109 // Tells the scheduler that a page load has started. The scheduler will | 109 // Tells the scheduler that a navigation is expected. The scheduler will |
| 110 // ensure that loading tasks are not blocked even if they are expensive. |
| 111 // This mode lasts until either OnNavigationStarted or OnNavigationCanceled is |
| 112 // called. |
| 113 virtual void OnNavigationExpected() = 0; |
| 114 |
| 115 // Tells the scheduler that an expected navigation was canceled. The |
| 116 // scheduler may now block expensive tasks. |
| 117 virtual void OnNavigationCanceled() = 0; |
| 118 |
| 119 // Tells the scheduler that a navigation has started. The scheduler will |
| 110 // prioritize loading tasks for a short duration afterwards. | 120 // prioritize loading tasks for a short duration afterwards. |
| 111 // Must be called from the main thread. | 121 // Must be called from the main thread. |
| 112 virtual void OnPageLoadStarted() = 0; | 122 virtual void OnNavigationStarted() = 0; |
| 113 | 123 |
| 114 // Returns true if the scheduler has reason to believe that high priority work | 124 // Returns true if the scheduler has reason to believe that high priority work |
| 115 // may soon arrive on the main thread, e.g., if gesture events were observed | 125 // may soon arrive on the main thread, e.g., if gesture events were observed |
| 116 // recently. | 126 // recently. |
| 117 // Must be called from the main thread. | 127 // Must be called from the main thread. |
| 118 virtual bool IsHighPriorityWorkAnticipated() = 0; | 128 virtual bool IsHighPriorityWorkAnticipated() = 0; |
| 119 | 129 |
| 120 // Suspends the timer queue and increments the timer queue suspension count. | 130 // Suspends the timer queue and increments the timer queue suspension count. |
| 121 // May only be called from the main thread. | 131 // May only be called from the main thread. |
| 122 virtual void SuspendTimerQueue() = 0; | 132 virtual void SuspendTimerQueue() = 0; |
| 123 | 133 |
| 124 // Decrements the timer queue suspension count and re-enables the timer queue | 134 // Decrements the timer queue suspension count and re-enables the timer queue |
| 125 // if the suspension count is zero and the current schduler policy allows it. | 135 // if the suspension count is zero and the current schduler policy allows it. |
| 126 virtual void ResumeTimerQueue() = 0; | 136 virtual void ResumeTimerQueue() = 0; |
| 127 | 137 |
| 128 // Sets whether to allow suspension of timers after the backgrounded signal is | 138 // Sets whether to allow suspension of timers after the backgrounded signal is |
| 129 // received via OnRendererBackgrounded. Defaults to disabled. | 139 // received via OnRendererBackgrounded. Defaults to disabled. |
| 130 virtual void SetTimerQueueSuspensionWhenBackgroundedEnabled(bool enabled) = 0; | 140 virtual void SetTimerQueueSuspensionWhenBackgroundedEnabled(bool enabled) = 0; |
| 131 | 141 |
| 132 protected: | 142 protected: |
| 133 RendererScheduler(); | 143 RendererScheduler(); |
| 134 DISALLOW_COPY_AND_ASSIGN(RendererScheduler); | 144 DISALLOW_COPY_AND_ASSIGN(RendererScheduler); |
| 135 }; | 145 }; |
| 136 | 146 |
| 137 } // namespace scheduler | 147 } // namespace scheduler |
| 138 | 148 |
| 139 #endif // COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_H_ | 149 #endif // COMPONENTS_SCHEDULER_RENDERER_RENDERER_SCHEDULER_H_ |
| OLD | NEW |