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

Unified Diff: content/browser/service_worker/service_worker_process_manager.cc

Issue 2781443006: ServiceWorker: Fix crash during shutdown in single-process mode (Closed)
Patch Set: ServiceWorker: Fix crash during shutdown in single-process mode Created 3 years, 8 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
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/service_worker/service_worker_process_manager.cc
diff --git a/content/browser/service_worker/service_worker_process_manager.cc b/content/browser/service_worker/service_worker_process_manager.cc
index f3ff0482c8fea21f03f94af83e4555d9e8fd1687..9056e76f03596ef69ab275846ef148da8d92c87c 100644
--- a/content/browser/service_worker/service_worker_process_manager.cc
+++ b/content/browser/service_worker/service_worker_process_manager.cc
@@ -77,11 +77,16 @@ void ServiceWorkerProcessManager::Shutdown() {
browser_context_ = nullptr;
}
- for (std::map<int, ProcessInfo>::const_iterator it = instance_info_.begin();
- it != instance_info_.end();
- ++it) {
- RenderProcessHost::FromID(it->second.process_id)
- ->DecrementServiceWorkerRefCount();
+ // In single-process mode, Shutdown() is called when deleting the default
+ // browser context, which is itself destroyed after the RenderProcessHost,
+ // and RenderProcessHost::FromID() just returns a nullptr.
+ // The refcount decrement can be skipped anyway since there's only one process
+ if (!RenderProcessHost::run_renderer_in_process()) {
+ for (std::map<int, ProcessInfo>::const_iterator it = instance_info_.begin();
+ it != instance_info_.end(); ++it) {
+ RenderProcessHost::FromID(it->second.process_id)
+ ->DecrementServiceWorkerRefCount();
+ }
}
instance_info_.clear();
}
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698