Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1205)

Unified Diff: third_party/WebKit/Source/platform/scheduler/renderer/web_view_scheduler_impl.cc

Issue 2652973002: [scheduler] Plumb websocket information to scheduler (Closed)
Patch Set: Introduce WebFrameScheduler::ActiveConnectionHandle Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/scheduler/renderer/web_view_scheduler_impl.cc
diff --git a/third_party/WebKit/Source/platform/scheduler/renderer/web_view_scheduler_impl.cc b/third_party/WebKit/Source/platform/scheduler/renderer/web_view_scheduler_impl.cc
index a5ccc87bfc7c57fbcffe72fb3dbe1e4020adb2d5..47a2d802a9a45e164b14ddc68eff173d6ad21d45 100644
--- a/third_party/WebKit/Source/platform/scheduler/renderer/web_view_scheduler_impl.cc
+++ b/third_party/WebKit/Source/platform/scheduler/renderer/web_view_scheduler_impl.cc
@@ -108,6 +108,7 @@ WebViewSchedulerImpl::WebViewSchedulerImpl(
virtual_time_(false),
is_audio_playing_(false),
reported_background_throttling_since_navigation_(false),
+ has_active_connection_(false),
background_time_budget_pool_(nullptr),
settings_(settings) {
renderer_scheduler->AddWebViewScheduler(this);
@@ -255,6 +256,18 @@ bool WebViewSchedulerImpl::IsAudioPlaying() const {
return is_audio_playing_;
}
+void WebViewSchedulerImpl::OnConnectionUpdated() {
+ bool has_active_connection = false;
+ for (WebFrameSchedulerImpl* frame_scheduler : frame_schedulers_) {
+ has_active_connection |= frame_scheduler->has_active_connection();
+ }
+
+ if (has_active_connection_ != has_active_connection) {
+ has_active_connection_ = has_active_connection;
+ UpdateBackgroundThrottlingState();
+ }
+}
+
void WebViewSchedulerImpl::AsValueInto(
base::trace_event::TracedValue* state) const {
state->SetDouble("pending_loads", pending_loads_.size());
@@ -335,10 +348,7 @@ void WebViewSchedulerImpl::EnableBackgroundThrottling() {
for (WebFrameSchedulerImpl* frame_scheduler : frame_schedulers_) {
frame_scheduler->setPageThrottled(true);
}
- if (background_time_budget_pool_) {
- LazyNow lazy_now(renderer_scheduler_->tick_clock());
- background_time_budget_pool_->EnableThrottling(&lazy_now);
- }
+ UpdateBackgroundBudgetPoolThrottlingState();
}
void WebViewSchedulerImpl::UpdateBackgroundThrottlingState() {
@@ -349,15 +359,29 @@ void WebViewSchedulerImpl::UpdateBackgroundThrottlingState() {
for (WebFrameSchedulerImpl* frame_scheduler : frame_schedulers_) {
frame_scheduler->setPageThrottled(false);
}
- if (background_time_budget_pool_) {
- LazyNow lazy_now(renderer_scheduler_->tick_clock());
- background_time_budget_pool_->DisableThrottling(&lazy_now);
+ UpdateBackgroundBudgetPoolThrottlingState();
+ } else {
+ if (has_active_connection_) {
+ // If websocket is active, update state immediately to stop throttling.
Sami 2017/01/26 15:53:34 Ditto about WebSockets.
altimin 2017/02/08 15:56:54 Done.
+ UpdateBackgroundBudgetPoolThrottlingState();
+ } else {
+ // TODO(altimin): Consider moving this logic into PumpThrottledTasks.
+ renderer_scheduler_->ControlTaskRunner()->PostDelayedTask(
+ FROM_HERE, delayed_background_throttling_enabler_.callback(),
+ kBackgroundThrottlingGracePeriod);
}
+ }
+}
+
+void WebViewSchedulerImpl::UpdateBackgroundBudgetPoolThrottlingState() {
+ if (!background_time_budget_pool_)
+ return;
+
+ LazyNow lazy_now(renderer_scheduler_->tick_clock());
+ if (page_visible_ || has_active_connection_) {
+ background_time_budget_pool_->DisableThrottling(&lazy_now);
} else {
- // TODO(altimin): Consider moving this logic into PumpThrottledTasks.
- renderer_scheduler_->ControlTaskRunner()->PostDelayedTask(
- FROM_HERE, delayed_background_throttling_enabler_.callback(),
- kBackgroundThrottlingGracePeriod);
+ background_time_budget_pool_->EnableThrottling(&lazy_now);
}
}

Powered by Google App Engine
This is Rietveld 408576698