| 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 "components/scheduler/renderer/web_frame_scheduler_impl.h" | 5 #include "components/scheduler/renderer/web_frame_scheduler_impl.h" |
| 6 | 6 |
| 7 #include "base/trace_event/blame_context.h" | 7 #include "base/trace_event/blame_context.h" |
| 8 #include "components/scheduler/base/real_time_domain.h" | 8 #include "components/scheduler/base/real_time_domain.h" |
| 9 #include "components/scheduler/base/virtual_time_domain.h" | 9 #include "components/scheduler/base/virtual_time_domain.h" |
| 10 #include "components/scheduler/child/web_task_runner_impl.h" | 10 #include "components/scheduler/child/web_task_runner_impl.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 frame_visible_ = frame_visible; | 54 frame_visible_ = frame_visible; |
| 55 // TODO(alexclarke): Do something with this flag. | 55 // TODO(alexclarke): Do something with this flag. |
| 56 } | 56 } |
| 57 | 57 |
| 58 blink::WebTaskRunner* WebFrameSchedulerImpl::loadingTaskRunner() { | 58 blink::WebTaskRunner* WebFrameSchedulerImpl::loadingTaskRunner() { |
| 59 DCHECK(parent_web_view_scheduler_); | 59 DCHECK(parent_web_view_scheduler_); |
| 60 if (!loading_web_task_runner_) { | 60 if (!loading_web_task_runner_) { |
| 61 loading_task_queue_ = | 61 loading_task_queue_ = |
| 62 renderer_scheduler_->NewLoadingTaskRunner("frame_loading_tq"); | 62 renderer_scheduler_->NewLoadingTaskRunner("frame_loading_tq"); |
| 63 loading_task_queue_->SetBlameContext(blame_context_); | 63 loading_task_queue_->SetBlameContext(blame_context_); |
| 64 if (parent_web_view_scheduler_->virtual_time_domain()) { | |
| 65 loading_task_queue_->SetTimeDomain( | |
| 66 parent_web_view_scheduler_->virtual_time_domain()); | |
| 67 } | |
| 68 loading_web_task_runner_.reset(new WebTaskRunnerImpl(loading_task_queue_)); | 64 loading_web_task_runner_.reset(new WebTaskRunnerImpl(loading_task_queue_)); |
| 69 } | 65 } |
| 70 return loading_web_task_runner_.get(); | 66 return loading_web_task_runner_.get(); |
| 71 } | 67 } |
| 72 | 68 |
| 73 blink::WebTaskRunner* WebFrameSchedulerImpl::timerTaskRunner() { | 69 blink::WebTaskRunner* WebFrameSchedulerImpl::timerTaskRunner() { |
| 74 DCHECK(parent_web_view_scheduler_); | 70 DCHECK(parent_web_view_scheduler_); |
| 75 if (!timer_web_task_runner_) { | 71 if (!timer_web_task_runner_) { |
| 76 timer_task_queue_ = | 72 timer_task_queue_ = |
| 77 renderer_scheduler_->NewTimerTaskRunner("frame_timer_tq"); | 73 renderer_scheduler_->NewTimerTaskRunner("frame_timer_tq"); |
| 78 timer_task_queue_->SetBlameContext(blame_context_); | 74 timer_task_queue_->SetBlameContext(blame_context_); |
| 79 if (parent_web_view_scheduler_->virtual_time_domain()) { | 75 if (!page_visible_) { |
| 80 timer_task_queue_->SetTimeDomain( | |
| 81 parent_web_view_scheduler_->virtual_time_domain()); | |
| 82 } else if (!page_visible_) { | |
| 83 renderer_scheduler_->throttling_helper()->IncreaseThrottleRefCount( | 76 renderer_scheduler_->throttling_helper()->IncreaseThrottleRefCount( |
| 84 timer_task_queue_.get()); | 77 timer_task_queue_.get()); |
| 85 } | 78 } |
| 86 timer_web_task_runner_.reset(new WebTaskRunnerImpl(timer_task_queue_)); | 79 timer_web_task_runner_.reset(new WebTaskRunnerImpl(timer_task_queue_)); |
| 87 } | 80 } |
| 88 return timer_web_task_runner_.get(); | 81 return timer_web_task_runner_.get(); |
| 89 } | 82 } |
| 90 | 83 |
| 91 blink::WebTaskRunner* WebFrameSchedulerImpl::unthrottledTaskRunner() { | 84 blink::WebTaskRunner* WebFrameSchedulerImpl::unthrottledTaskRunner() { |
| 92 DCHECK(parent_web_view_scheduler_); | 85 DCHECK(parent_web_view_scheduler_); |
| 93 if (!unthrottled_web_task_runner_) { | 86 if (!unthrottled_web_task_runner_) { |
| 94 unthrottled_task_queue_ = | 87 unthrottled_task_queue_ = |
| 95 renderer_scheduler_->NewUnthrottledTaskRunner("frame_unthrottled_tq"); | 88 renderer_scheduler_->NewUnthrottledTaskRunner("frame_unthrottled_tq"); |
| 96 unthrottled_task_queue_->SetBlameContext(blame_context_); | 89 unthrottled_task_queue_->SetBlameContext(blame_context_); |
| 97 if (parent_web_view_scheduler_->virtual_time_domain()) { | |
| 98 unthrottled_task_queue_->SetTimeDomain( | |
| 99 parent_web_view_scheduler_->virtual_time_domain()); | |
| 100 } | |
| 101 unthrottled_web_task_runner_.reset( | 90 unthrottled_web_task_runner_.reset( |
| 102 new WebTaskRunnerImpl(unthrottled_task_queue_)); | 91 new WebTaskRunnerImpl(unthrottled_task_queue_)); |
| 103 } | 92 } |
| 104 return unthrottled_web_task_runner_.get(); | 93 return unthrottled_web_task_runner_.get(); |
| 105 } | 94 } |
| 106 | 95 |
| 107 blink::WebViewScheduler* WebFrameSchedulerImpl::webViewScheduler() { | 96 blink::WebViewScheduler* WebFrameSchedulerImpl::webViewScheduler() { |
| 108 return parent_web_view_scheduler_; | 97 return parent_web_view_scheduler_; |
| 109 } | 98 } |
| 110 | 99 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 126 parent_web_view_scheduler_->DecrementBackgroundParserCount(); | 115 parent_web_view_scheduler_->DecrementBackgroundParserCount(); |
| 127 } | 116 } |
| 128 | 117 |
| 129 void WebFrameSchedulerImpl::setPageVisible(bool page_visible) { | 118 void WebFrameSchedulerImpl::setPageVisible(bool page_visible) { |
| 130 DCHECK(parent_web_view_scheduler_); | 119 DCHECK(parent_web_view_scheduler_); |
| 131 if (page_visible_ == page_visible) | 120 if (page_visible_ == page_visible) |
| 132 return; | 121 return; |
| 133 | 122 |
| 134 page_visible_ = page_visible; | 123 page_visible_ = page_visible; |
| 135 | 124 |
| 136 if (!timer_web_task_runner_ || | 125 if (!timer_web_task_runner_) |
| 137 parent_web_view_scheduler_->virtual_time_domain()) { | |
| 138 return; | 126 return; |
| 139 } | |
| 140 | 127 |
| 141 if (page_visible_) { | 128 if (page_visible_) { |
| 142 renderer_scheduler_->throttling_helper()->DecreaseThrottleRefCount( | 129 renderer_scheduler_->throttling_helper()->DecreaseThrottleRefCount( |
| 143 timer_task_queue_.get()); | 130 timer_task_queue_.get()); |
| 144 } else { | 131 } else { |
| 145 renderer_scheduler_->throttling_helper()->IncreaseThrottleRefCount( | 132 renderer_scheduler_->throttling_helper()->IncreaseThrottleRefCount( |
| 146 timer_task_queue_.get()); | 133 timer_task_queue_.get()); |
| 147 } | 134 } |
| 148 } | 135 } |
| 149 | 136 |
| 150 void WebFrameSchedulerImpl::OnVirtualTimeDomainChanged() { | |
| 151 DCHECK(parent_web_view_scheduler_); | |
| 152 DCHECK(parent_web_view_scheduler_->virtual_time_domain()); | |
| 153 | |
| 154 if (timer_task_queue_) { | |
| 155 renderer_scheduler_->throttling_helper()->UnregisterTaskQueue( | |
| 156 timer_task_queue_.get()); | |
| 157 timer_task_queue_->SetTimeDomain( | |
| 158 parent_web_view_scheduler_->virtual_time_domain()); | |
| 159 } | |
| 160 | |
| 161 if (loading_task_queue_) { | |
| 162 loading_task_queue_->SetTimeDomain( | |
| 163 parent_web_view_scheduler_->virtual_time_domain()); | |
| 164 } | |
| 165 } | |
| 166 | |
| 167 } // namespace scheduler | 137 } // namespace scheduler |
| OLD | NEW |