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

Unified Diff: chrome/browser/profiles/profile_destroyer.cc

Issue 653633004: Shutdown Service Workers before the profile is destroyed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
Index: chrome/browser/profiles/profile_destroyer.cc
diff --git a/chrome/browser/profiles/profile_destroyer.cc b/chrome/browser/profiles/profile_destroyer.cc
index 50513a733e2551fb89d2ef2d79d89b1fe9cd907e..eb7890c7796e1aabbcb1dc979e766642c43552f6 100644
--- a/chrome/browser/profiles/profile_destroyer.cc
+++ b/chrome/browser/profiles/profile_destroyer.cc
@@ -10,6 +10,8 @@
#include "base/message_loop/message_loop.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/render_process_host.h"
+#include "content/public/browser/service_worker_context.h"
+#include "content/public/browser/storage_partition.h"
namespace {
@@ -25,6 +27,10 @@ const int64 kTimerDelaySeconds = 1;
ProfileDestroyer::DestroyerSet* ProfileDestroyer::pending_destroyers_ = NULL;
+static void ShutdownServiceWorkerContext(content::StoragePartition* partition) {
+ partition->GetServiceWorkerContext()->Terminate();
+}
+
// static
void ProfileDestroyer::DestroyProfileWhenAppropriate(Profile* const profile) {
TRACE_EVENT0("shutdown", "ProfileDestroyer::DestroyProfileWhenAppropriate");
@@ -32,6 +38,12 @@ void ProfileDestroyer::DestroyProfileWhenAppropriate(Profile* const profile) {
DCHECK(profile);
profile->MaybeSendDestroyedNotification();
+ // Service Workers must shutdown before the profile is destroyed, since they
+ // keep render process hosts alive and code assumes that render process hosts
+ // die before the profile dies.
+ content::BrowserContext::ForEachStoragePartition(
+ profile, base::Bind(ShutdownServiceWorkerContext));
falken 2014/10/21 09:36:36 I'm not sure all codepaths that destroy a Profile
michaeln 2014/10/21 23:24:13 Profile::MaybeSendDestroyedNotification() could ca
falken 2014/10/22 01:27:12 That sounds promising and more bulletproof than ho
+
HostSet hosts;
// Testing profiles can simply be deleted directly. Some tests don't setup
// RenderProcessHost correctly and don't necessary run on the UI thread

Powered by Google App Engine
This is Rietveld 408576698