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

Unified Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 2342523002: Forcibly clear worker ref counts on shutdown. (Closed)
Patch Set: Created 4 years, 3 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: content/browser/renderer_host/render_process_host_impl.cc
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 126df71c74b3b788f1836af075d0ad7733688228..54d19daa76cdb43f7d018033b5827c3866899e06 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -675,6 +675,7 @@ RenderProcessHostImpl::RenderProcessHostImpl(
child_token_(mojo::edk::GenerateRandomToken()),
service_worker_ref_count_(0),
shared_worker_ref_count_(0),
+ is_worker_ref_count_disabled_(false),
visible_widgets_(0),
is_process_backgrounded_(false),
is_initialized_(false),
@@ -1341,6 +1342,7 @@ bool RenderProcessHostImpl::IsProcessBackgrounded() const {
void RenderProcessHostImpl::IncrementServiceWorkerRefCount() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK(!is_worker_ref_count_disabled_);
++service_worker_ref_count_;
if (worker_ref_count() > max_worker_count_)
max_worker_count_ = worker_ref_count();
@@ -1348,7 +1350,8 @@ void RenderProcessHostImpl::IncrementServiceWorkerRefCount() {
void RenderProcessHostImpl::DecrementServiceWorkerRefCount() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- DCHECK_GT(worker_ref_count(), 0UL);
+ DCHECK(!is_worker_ref_count_disabled_);
+ DCHECK_GT(worker_ref_count(), 0U);
--service_worker_ref_count_;
if (worker_ref_count() == 0)
Cleanup();
@@ -1356,6 +1359,7 @@ void RenderProcessHostImpl::DecrementServiceWorkerRefCount() {
void RenderProcessHostImpl::IncrementSharedWorkerRefCount() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK(!is_worker_ref_count_disabled_);
++shared_worker_ref_count_;
if (worker_ref_count() > max_worker_count_)
max_worker_count_ = worker_ref_count();
@@ -1363,12 +1367,28 @@ void RenderProcessHostImpl::IncrementSharedWorkerRefCount() {
void RenderProcessHostImpl::DecrementSharedWorkerRefCount() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- DCHECK_GT(worker_ref_count(), 0UL);
+ DCHECK(!is_worker_ref_count_disabled_);
+ DCHECK_GT(worker_ref_count(), 0U);
--shared_worker_ref_count_;
if (worker_ref_count() == 0)
Cleanup();
}
+void RenderProcessHostImpl::ForceReleaseWorkerRefCounts() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ is_worker_ref_count_disabled_ = true;
jam 2016/09/14 17:10:49 DCHECK(!is_worker_ref_count_disabled_); before thi
falken 2016/09/21 08:59:43 Done.
+ if (!worker_ref_count())
+ return;
+ service_worker_ref_count_ = 0;
+ shared_worker_ref_count_ = 0;
+ Cleanup();
+}
+
+bool RenderProcessHostImpl::IsWorkerRefCountDisabled() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ return is_worker_ref_count_disabled_;
+}
+
void RenderProcessHostImpl::PurgeAndSuspend() {
Send(new ChildProcessMsg_PurgeAndSuspend());
}

Powered by Google App Engine
This is Rietveld 408576698