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

Unified Diff: content/browser/browser_context.cc

Issue 2342523002: Forcibly clear worker ref counts on shutdown. (Closed)
Patch Set: rebase Created 4 years, 3 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 26985096c5d7b24a9ab73fd89f7da0bb69a59af0..f5ec433add25adc2d7006cebb2225733007f7ffb 100644
--- a/content/browser/browser_context.cc
+++ b/content/browser/browser_context.cc
@@ -29,6 +29,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,18 @@ void BrowserContext::NotifyWillBeDestroyed(BrowserContext* browser_context) {
// render process hosts die before their profile (browser context) dies.
ForEachStoragePartition(browser_context,
base::Bind(ShutdownServiceWorkerContext));
+
+ // Shared workers also keep render process hosts alive, and are expected to
+ // return ref counts to 0 after documents close. However, shared worker
+ // bookkeeping is done on the IO thread and we want to ensure the hosts are
+ // destructed now, so forcibly release their ref counts here.
+ for (RenderProcessHost::iterator host_iterator =
+ RenderProcessHost::AllHostsIterator();
+ !host_iterator.IsAtEnd(); host_iterator.Advance()) {
+ RenderProcessHost* host = host_iterator.GetCurrentValue();
+ if (host->GetBrowserContext() == browser_context)
+ host->ForceReleaseWorkerRefCounts();
+ }
}
void BrowserContext::EnsureResourceContextInitialized(BrowserContext* context) {
« no previous file with comments | « chrome/browser/ui/views/first_run_bubble_unittest.cc ('k') | content/browser/renderer_host/render_process_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698