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

Unified Diff: content/browser/browser_context.cc

Issue 653633004: Shutdown Service Workers before the profile is destroyed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync Created 6 years, 2 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 | « chrome/browser/profiles/profile.cc ('k') | content/browser/service_worker/service_worker_context_wrapper.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/browser_context.cc
diff --git a/content/browser/browser_context.cc b/content/browser/browser_context.cc
index 064b2097fd8a9a744a23ca8076ec88f3a39fd68d..5557719408c4745e4f880157c28e1a151e483f64 100644
--- a/content/browser/browser_context.cc
+++ b/content/browser/browser_context.cc
@@ -84,6 +84,13 @@ void SaveSessionStateOnIndexedDBThread(
indexed_db_context->SetForceKeepSessionState();
}
+void ShutdownServiceWorkerContext(StoragePartition* partition) {
+ ServiceWorkerContextWrapper* wrapper =
+ static_cast<ServiceWorkerContextWrapper*>(
+ partition->GetServiceWorkerContext());
+ wrapper->process_manager()->Shutdown();
+}
+
} // namespace
// static
@@ -225,6 +232,15 @@ void BrowserContext::DeliverPushMessage(
browser_context, origin, service_worker_registration_id, data, callback);
}
+// static
+void BrowserContext::NotifyWillBeDestroyed(BrowserContext* browser_context) {
+ // Service Workers must shutdown before the browser context is destroyed,
+ // since they keep render process hosts alive and the codebase assumes that
+ // render process hosts die before their profile (browser context) dies.
+ ForEachStoragePartition(browser_context,
+ base::Bind(ShutdownServiceWorkerContext));
+}
+
void BrowserContext::EnsureResourceContextInitialized(BrowserContext* context) {
// This will be enough to tickle initialization of BrowserContext if
// necessary, which initializes ResourceContext. The reason we don't call
« no previous file with comments | « chrome/browser/profiles/profile.cc ('k') | content/browser/service_worker/service_worker_context_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698