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

Unified Diff: content/browser/shared_worker/shared_worker_service_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/shared_worker/shared_worker_service_impl.cc
diff --git a/content/browser/shared_worker/shared_worker_service_impl.cc b/content/browser/shared_worker/shared_worker_service_impl.cc
index 3b63787d2df4a152bdf83f26a34892030dabadea..6d6e00e2a41f4eb5b971450cdffec2a9d0282158 100644
--- a/content/browser/shared_worker/shared_worker_service_impl.cc
+++ b/content/browser/shared_worker/shared_worker_service_impl.cc
@@ -31,6 +31,11 @@ WorkerService* WorkerService::GetInstance() {
return SharedWorkerServiceImpl::GetInstance();
}
+bool IsHostAlive(RenderProcessHost* host) {
+ return host && !host->FastShutdownStarted() &&
+ !host->IsWorkerRefCountDisabled();
+}
+
namespace {
class ScopedWorkerDependencyChecker {
@@ -57,14 +62,14 @@ void UpdateWorkerDependencyOnUI(const std::vector<int>& added_ids,
for (int id : added_ids) {
RenderProcessHostImpl* render_process_host_impl =
static_cast<RenderProcessHostImpl*>(RenderProcessHost::FromID(id));
- if (!render_process_host_impl)
+ if (!IsHostAlive(render_process_host_impl))
continue;
render_process_host_impl->IncrementSharedWorkerRefCount();
}
for (int id : removed_ids) {
RenderProcessHostImpl* render_process_host_impl =
static_cast<RenderProcessHostImpl*>(RenderProcessHost::FromID(id));
- if (!render_process_host_impl)
+ if (!IsHostAlive(render_process_host_impl))
continue;
render_process_host_impl->DecrementSharedWorkerRefCount();
}
@@ -88,14 +93,14 @@ void DecrementWorkerRefCount(int process_id) {
RenderProcessHostImpl* render_process_host_impl =
static_cast<RenderProcessHostImpl*>(
RenderProcessHost::FromID(process_id));
- if (render_process_host_impl)
+ if (IsHostAlive(render_process_host_impl))
render_process_host_impl->DecrementSharedWorkerRefCount();
}
bool TryIncrementWorkerRefCount(int worker_process_id) {
RenderProcessHostImpl* render_process = static_cast<RenderProcessHostImpl*>(
RenderProcessHost::FromID(worker_process_id));
- if (!render_process || render_process->FastShutdownStarted())
+ if (!IsHostAlive(render_process))
return false;
render_process->IncrementSharedWorkerRefCount();
return true;

Powered by Google App Engine
This is Rietveld 408576698