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 #include "platform/scheduler/renderer/web_frame_scheduler_impl.h" | 5 #include "platform/scheduler/renderer/web_frame_scheduler_impl.h" |
6 | 6 |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "base/trace_event/blame_context.h" | 8 #include "base/trace_event/blame_context.h" |
9 #include "platform/scheduler/base/real_time_domain.h" | 9 #include "platform/scheduler/base/real_time_domain.h" |
10 #include "platform/scheduler/base/virtual_time_domain.h" | 10 #include "platform/scheduler/base/virtual_time_domain.h" |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 if (loading_queue_enabled_voter_) | 217 if (loading_queue_enabled_voter_) |
218 loading_queue_enabled_voter_->SetQueueEnabled(!frame_suspended); | 218 loading_queue_enabled_voter_->SetQueueEnabled(!frame_suspended); |
219 if (timer_queue_enabled_voter_) | 219 if (timer_queue_enabled_voter_) |
220 timer_queue_enabled_voter_->SetQueueEnabled(!frame_suspended); | 220 timer_queue_enabled_voter_->SetQueueEnabled(!frame_suspended); |
221 } | 221 } |
222 | 222 |
223 void WebFrameSchedulerImpl::onFirstMeaningfulPaint() { | 223 void WebFrameSchedulerImpl::onFirstMeaningfulPaint() { |
224 renderer_scheduler_->OnFirstMeaningfulPaint(); | 224 renderer_scheduler_->OnFirstMeaningfulPaint(); |
225 } | 225 } |
226 | 226 |
| 227 void WebFrameSchedulerImpl::setMaximumPriorityForLabTest() { |
| 228 loadingTaskRunner(); |
| 229 loading_task_queue_->SetQueuePriority(TaskQueue::CONTROL_PRIORITY); |
| 230 timerTaskRunner(); |
| 231 timer_task_queue_->SetQueuePriority(TaskQueue::CONTROL_PRIORITY); |
| 232 unthrottledTaskRunner(); |
| 233 unthrottled_task_queue_->SetQueuePriority(TaskQueue::CONTROL_PRIORITY); |
| 234 } |
| 235 |
227 bool WebFrameSchedulerImpl::ShouldThrottleTimers() const { | 236 bool WebFrameSchedulerImpl::ShouldThrottleTimers() const { |
228 if (page_throttled_) | 237 if (page_throttled_) |
229 return true; | 238 return true; |
230 return RuntimeEnabledFeatures::timerThrottlingForHiddenFramesEnabled() && | 239 return RuntimeEnabledFeatures::timerThrottlingForHiddenFramesEnabled() && |
231 !frame_visible_ && cross_origin_; | 240 !frame_visible_ && cross_origin_; |
232 } | 241 } |
233 | 242 |
234 void WebFrameSchedulerImpl::UpdateTimerThrottling(bool was_throttled) { | 243 void WebFrameSchedulerImpl::UpdateTimerThrottling(bool was_throttled) { |
235 bool should_throttle = ShouldThrottleTimers(); | 244 bool should_throttle = ShouldThrottleTimers(); |
236 if (was_throttled == should_throttle || !timer_web_task_runner_) | 245 if (was_throttled == should_throttle || !timer_web_task_runner_) |
237 return; | 246 return; |
238 if (should_throttle) { | 247 if (should_throttle) { |
239 renderer_scheduler_->task_queue_throttler()->IncreaseThrottleRefCount( | 248 renderer_scheduler_->task_queue_throttler()->IncreaseThrottleRefCount( |
240 timer_task_queue_.get()); | 249 timer_task_queue_.get()); |
241 } else { | 250 } else { |
242 renderer_scheduler_->task_queue_throttler()->DecreaseThrottleRefCount( | 251 renderer_scheduler_->task_queue_throttler()->DecreaseThrottleRefCount( |
243 timer_task_queue_.get()); | 252 timer_task_queue_.get()); |
244 } | 253 } |
245 } | 254 } |
246 | 255 |
247 } // namespace scheduler | 256 } // namespace scheduler |
248 } // namespace blink | 257 } // namespace blink |
OLD | NEW |