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

Unified Diff: content/browser/browser_context.cc

Issue 2248583003: Force release the worker ref count to release the process in BrowserContext::NotifyWillBeDestroyed() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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/browser_context.cc
diff --git a/content/browser/browser_context.cc b/content/browser/browser_context.cc
index 6ca86e7466eabfaebe409351bac63468cce016a8..4dd3de040224e738f7516953bed8d43e422ca0df 100644
--- a/content/browser/browser_context.cc
+++ b/content/browser/browser_context.cc
@@ -30,6 +30,7 @@
#include "content/public/browser/blob_handle.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
+#include "content/public/browser/render_process_host.h"
#include "content/public/browser/site_instance.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/mojo_shell_connection.h"
@@ -332,6 +333,21 @@ void BrowserContext::NotifyWillBeDestroyed(BrowserContext* browser_context) {
// render process hosts die before their profile (browser context) dies.
ForEachStoragePartition(browser_context,
base::Bind(ShutdownServiceWorkerContext));
+
+ // Some tests don't setup RenderProcessHost correctly and don't necessary run
+ // on the UI thread anyway, so we can't use the AllHostIterator.
+ if (!BrowserThread::CurrentlyOn(BrowserThread::UI))
+ return;
+
+ // Force release the worker ref count to release the render process which have
+ // been kept alive for shared workers.
+ for (content::RenderProcessHost::iterator host_iterator =
+ content::RenderProcessHost::AllHostsIterator();
+ !host_iterator.IsAtEnd(); host_iterator.Advance()) {
+ content::RenderProcessHost* host = host_iterator.GetCurrentValue();
+ if (host->GetBrowserContext() == browser_context)
+ host->ForceReleaseWorkerRefCount();
+ }
}
void BrowserContext::EnsureResourceContextInitialized(BrowserContext* context) {

Powered by Google App Engine
This is Rietveld 408576698