Chromium Code Reviews| 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 |