| 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 THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDULER
_H_ | 5 #ifndef THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDULER
_H_ |
| 6 #define THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDULER
_H_ | 6 #define THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDULER
_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // driven by this process. A stricter condition than |OnRendererHidden()|, the | 111 // driven by this process. A stricter condition than |OnRendererHidden()|, the |
| 112 // process is assumed to be foregrounded when the scheduler is constructed. | 112 // process is assumed to be foregrounded when the scheduler is constructed. |
| 113 // Must be called on the main thread. | 113 // Must be called on the main thread. |
| 114 virtual void OnRendererBackgrounded() = 0; | 114 virtual void OnRendererBackgrounded() = 0; |
| 115 | 115 |
| 116 // Tells the scheduler that the renderer process has been foregrounded. | 116 // Tells the scheduler that the renderer process has been foregrounded. |
| 117 // This is the assumed state when the scheduler is constructed. | 117 // This is the assumed state when the scheduler is constructed. |
| 118 // Must be called on the main thread. | 118 // Must be called on the main thread. |
| 119 virtual void OnRendererForegrounded() = 0; | 119 virtual void OnRendererForegrounded() = 0; |
| 120 | 120 |
| 121 // Tells the scheduler that the render process should be suspended. This can | |
| 122 // only be done when the renderer is backgrounded. The renderer will be | |
| 123 // automatically resumed when foregrounded. | |
| 124 virtual void SuspendRenderer() = 0; | |
| 125 | |
| 126 // Tells the scheduler that the render process should be resumed. This can | |
| 127 // only be done when the renderer is suspended. TabManager (in the future, | |
| 128 // MemoryCoordinator) will suspend the renderer again if continuously | |
| 129 // backgrounded. | |
| 130 virtual void ResumeRenderer() = 0; | |
| 131 | |
| 132 enum class NavigatingFrameType { kMainFrame, kChildFrame }; | 121 enum class NavigatingFrameType { kMainFrame, kChildFrame }; |
| 133 | 122 |
| 134 // Tells the scheduler that a navigation task is pending. While any main-frame | 123 // Tells the scheduler that a navigation task is pending. While any main-frame |
| 135 // navigation tasks are pending, the scheduler will ensure that loading tasks | 124 // navigation tasks are pending, the scheduler will ensure that loading tasks |
| 136 // are not blocked even if they are expensive. Must be called on the main | 125 // are not blocked even if they are expensive. Must be called on the main |
| 137 // thread. | 126 // thread. |
| 138 virtual void AddPendingNavigation(NavigatingFrameType type) = 0; | 127 virtual void AddPendingNavigation(NavigatingFrameType type) = 0; |
| 139 | 128 |
| 140 // Tells the scheduler that a navigation task is no longer pending. | 129 // Tells the scheduler that a navigation task is no longer pending. |
| 141 // Must be called on the main thread. | 130 // Must be called on the main thread. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 153 virtual bool IsHighPriorityWorkAnticipated() = 0; | 142 virtual bool IsHighPriorityWorkAnticipated() = 0; |
| 154 | 143 |
| 155 // Suspends the timer queue and increments the timer queue suspension count. | 144 // Suspends the timer queue and increments the timer queue suspension count. |
| 156 // May only be called from the main thread. | 145 // May only be called from the main thread. |
| 157 virtual void SuspendTimerQueue() = 0; | 146 virtual void SuspendTimerQueue() = 0; |
| 158 | 147 |
| 159 // Decrements the timer queue suspension count and re-enables the timer queue | 148 // Decrements the timer queue suspension count and re-enables the timer queue |
| 160 // if the suspension count is zero and the current schduler policy allows it. | 149 // if the suspension count is zero and the current schduler policy allows it. |
| 161 virtual void ResumeTimerQueue() = 0; | 150 virtual void ResumeTimerQueue() = 0; |
| 162 | 151 |
| 163 // Sets whether to allow suspension of timers after the backgrounded signal is | |
| 164 // received via OnRendererBackgrounded. Defaults to disabled. | |
| 165 virtual void SetTimerQueueSuspensionWhenBackgroundedEnabled(bool enabled) = 0; | |
| 166 | |
| 167 // Sets the default blame context to which top level work should be | 152 // Sets the default blame context to which top level work should be |
| 168 // attributed in this renderer. |blame_context| must outlive this scheduler. | 153 // attributed in this renderer. |blame_context| must outlive this scheduler. |
| 169 virtual void SetTopLevelBlameContext( | 154 virtual void SetTopLevelBlameContext( |
| 170 base::trace_event::BlameContext* blame_context) = 0; | 155 base::trace_event::BlameContext* blame_context) = 0; |
| 171 | 156 |
| 172 // The renderer scheduler maintains an estimated RAIL mode[1]. This observer | 157 // The renderer scheduler maintains an estimated RAIL mode[1]. This observer |
| 173 // can be used to get notified when the mode changes. The observer will be | 158 // can be used to get notified when the mode changes. The observer will be |
| 174 // called on the main thread and must outlive this class. | 159 // called on the main thread and must outlive this class. |
| 175 // [1] | 160 // [1] |
| 176 // https://developers.google.com/web/tools/chrome-devtools/profile/evaluate-pe
rformance/rail | 161 // https://developers.google.com/web/tools/chrome-devtools/profile/evaluate-pe
rformance/rail |
| 177 virtual void SetRAILModeObserver(RAILModeObserver* observer) = 0; | 162 virtual void SetRAILModeObserver(RAILModeObserver* observer) = 0; |
| 178 | 163 |
| 179 // Returns whether or not the main thread appears unresponsive, based on the | 164 // Returns whether or not the main thread appears unresponsive, based on the |
| 180 // length and frequency of recent main thread tasks. To be called from the | 165 // length and frequency of recent main thread tasks. To be called from the |
| 181 // compositor thread. | 166 // compositor thread. |
| 182 virtual bool MainThreadSeemsUnresponsive( | 167 virtual bool MainThreadSeemsUnresponsive( |
| 183 base::TimeDelta main_thread_responsiveness_threshold) = 0; | 168 base::TimeDelta main_thread_responsiveness_threshold) = 0; |
| 184 | 169 |
| 185 protected: | 170 protected: |
| 186 RendererScheduler(); | 171 RendererScheduler(); |
| 187 DISALLOW_COPY_AND_ASSIGN(RendererScheduler); | 172 DISALLOW_COPY_AND_ASSIGN(RendererScheduler); |
| 188 }; | 173 }; |
| 189 | 174 |
| 190 } // namespace scheduler | 175 } // namespace scheduler |
| 191 } // namespace blink | 176 } // namespace blink |
| 192 | 177 |
| 193 #endif // THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDU
LER_H_ | 178 #endif // THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_RENDERER_RENDERER_SCHEDU
LER_H_ |
| OLD | NEW |