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

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

Issue 2696483003: [scheduler] Plumb websocket information to scheduler (Closed)
Patch Set: Created 3 years, 10 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_frame_scheduler_impl.cc
diff --git a/third_party/WebKit/Source/platform/scheduler/renderer/web_frame_scheduler_impl.cc b/third_party/WebKit/Source/platform/scheduler/renderer/web_frame_scheduler_impl.cc
index 027e3b7aff4f969f4686bc6cad611023eda2f663..b14a019da30d274670644eea6981c9285234b7c8 100644
--- a/third_party/WebKit/Source/platform/scheduler/renderer/web_frame_scheduler_impl.cc
+++ b/third_party/WebKit/Source/platform/scheduler/renderer/web_frame_scheduler_impl.cc
@@ -28,6 +28,18 @@ std::string PointerToId(void* pointer) {
} // namespace
+WebFrameSchedulerImpl::ActiveConnectionHandleImpl::ActiveConnectionHandleImpl(
+ WebFrameSchedulerImpl* frame_scheduler)
+ : frame_scheduler_(frame_scheduler->AsWeakPtr()) {
+ frame_scheduler->didOpenActiveConnection();
+}
+
+WebFrameSchedulerImpl::ActiveConnectionHandleImpl::
+ ~ActiveConnectionHandleImpl() {
+ if (frame_scheduler_)
+ frame_scheduler_->didCloseActiveConnection();
+}
+
WebFrameSchedulerImpl::WebFrameSchedulerImpl(
RendererSchedulerImpl* renderer_scheduler,
WebViewSchedulerImpl* parent_web_view_scheduler,
@@ -38,9 +50,13 @@ WebFrameSchedulerImpl::WebFrameSchedulerImpl(
frame_visible_(true),
page_throttled_(true),
frame_suspended_(false),
- cross_origin_(false) {}
+ cross_origin_(false),
+ active_connection_count_(0),
+ weak_factory_(this) {}
WebFrameSchedulerImpl::~WebFrameSchedulerImpl() {
+ weak_factory_.InvalidateWeakPtrs();
+
if (loading_task_queue_) {
loading_task_queue_->UnregisterTaskQueue();
loading_task_queue_->SetBlameContext(nullptr);
@@ -57,8 +73,12 @@ WebFrameSchedulerImpl::~WebFrameSchedulerImpl() {
unthrottled_task_queue_->SetBlameContext(nullptr);
}
- if (parent_web_view_scheduler_)
+ if (parent_web_view_scheduler_) {
parent_web_view_scheduler_->Unregister(this);
+
+ if (active_connection_count_)
+ parent_web_view_scheduler_->OnConnectionUpdated();
+ }
}
void WebFrameSchedulerImpl::DetachFromWebViewScheduler() {
@@ -167,6 +187,19 @@ void WebFrameSchedulerImpl::didStopLoading(unsigned long identifier) {
parent_web_view_scheduler_->DidStopLoading(identifier);
}
+void WebFrameSchedulerImpl::didOpenActiveConnection() {
+ ++active_connection_count_;
+ if (parent_web_view_scheduler_)
+ parent_web_view_scheduler_->OnConnectionUpdated();
+}
+
+void WebFrameSchedulerImpl::didCloseActiveConnection() {
+ DCHECK_GT(active_connection_count_, 0);
+ --active_connection_count_;
+ if (parent_web_view_scheduler_)
+ parent_web_view_scheduler_->OnConnectionUpdated();
+}
+
void WebFrameSchedulerImpl::setDocumentParsingInBackground(
bool background_parser_active) {
if (background_parser_active)
@@ -224,6 +257,12 @@ void WebFrameSchedulerImpl::onFirstMeaningfulPaint() {
renderer_scheduler_->OnFirstMeaningfulPaint();
}
+std::unique_ptr<WebFrameScheduler::ActiveConnectionHandle>
+WebFrameSchedulerImpl::onActiveConnectionCreated() {
+ return base::MakeUnique<WebFrameSchedulerImpl::ActiveConnectionHandleImpl>(
+ this);
+}
+
bool WebFrameSchedulerImpl::ShouldThrottleTimers() const {
if (page_throttled_)
return true;
@@ -244,5 +283,9 @@ void WebFrameSchedulerImpl::UpdateTimerThrottling(bool was_throttled) {
}
}
+base::WeakPtr<WebFrameSchedulerImpl> WebFrameSchedulerImpl::AsWeakPtr() {
+ return weak_factory_.GetWeakPtr();
+}
+
} // namespace scheduler
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698