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

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

Issue 2569963002: MemoryCoordinator checks if ServiceWorker exists on the suspending process (Closed)
Patch Set: Created 4 years 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 e090465bde26b3b389346bd4206085a71c4ef255..a205a6a31b93a8295acc55e76a1f74509691e6ce 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -1370,20 +1370,24 @@ bool RenderProcessHostImpl::IsProcessBackgrounded() const {
return is_process_backgrounded_;
}
+size_t RenderProcessHostImpl::GetWorkerRefCount() const {
+ return service_worker_ref_count_ + shared_worker_ref_count_;
horo 2016/12/13 06:29:33 DCHECK_CURRENTLY_ON(BrowserThread::UI);
shimazu 2016/12/13 07:24:50 Done.
+}
+
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();
+ if (GetWorkerRefCount() > max_worker_count_)
+ max_worker_count_ = GetWorkerRefCount();
}
void RenderProcessHostImpl::DecrementServiceWorkerRefCount() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(!is_worker_ref_count_disabled_);
- DCHECK_GT(worker_ref_count(), 0U);
+ DCHECK_GT(GetWorkerRefCount(), 0U);
--service_worker_ref_count_;
- if (worker_ref_count() == 0)
+ if (GetWorkerRefCount() == 0)
Cleanup();
}
@@ -1391,16 +1395,16 @@ 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();
+ if (GetWorkerRefCount() > max_worker_count_)
+ max_worker_count_ = GetWorkerRefCount();
}
void RenderProcessHostImpl::DecrementSharedWorkerRefCount() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(!is_worker_ref_count_disabled_);
- DCHECK_GT(worker_ref_count(), 0U);
+ DCHECK_GT(GetWorkerRefCount(), 0U);
--shared_worker_ref_count_;
- if (worker_ref_count() == 0)
+ if (GetWorkerRefCount() == 0)
Cleanup();
}
@@ -1408,7 +1412,7 @@ void RenderProcessHostImpl::ForceReleaseWorkerRefCounts() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(!is_worker_ref_count_disabled_);
is_worker_ref_count_disabled_ = true;
- if (!worker_ref_count())
+ if (!GetWorkerRefCount())
return;
service_worker_ref_count_ = 0;
shared_worker_ref_count_ = 0;
@@ -1934,7 +1938,7 @@ bool RenderProcessHostImpl::FastShutdownIfPossible() {
if (!SuddenTerminationAllowed())
return false;
- if (worker_ref_count() != 0) {
+ if (GetWorkerRefCount() != 0) {
if (survive_for_worker_start_time_.is_null())
survive_for_worker_start_time_ = base::TimeTicks::Now();
return false;
@@ -2112,13 +2116,13 @@ void RenderProcessHostImpl::Cleanup() {
delayed_cleanup_needed_ = false;
// Records the time when the process starts surviving for workers for UMA.
- if (listeners_.IsEmpty() && worker_ref_count() > 0 &&
+ if (listeners_.IsEmpty() && GetWorkerRefCount() > 0 &&
survive_for_worker_start_time_.is_null()) {
survive_for_worker_start_time_ = base::TimeTicks::Now();
}
// Until there are no other owners of this object, we can't delete ourselves.
- if (!listeners_.IsEmpty() || worker_ref_count() != 0)
+ if (!listeners_.IsEmpty() || GetWorkerRefCount() != 0)
return;
#if BUILDFLAG(ENABLE_WEBRTC)

Powered by Google App Engine
This is Rietveld 408576698