Chromium Code Reviews| Index: content/browser/browser_context.cc |
| diff --git a/content/browser/browser_context.cc b/content/browser/browser_context.cc |
| index 26985096c5d7b24a9ab73fd89f7da0bb69a59af0..7ecada46be8295165aa7d19f7091580018751f18 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,22 @@ 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 and don't necessarily run |
| + // on the UI thread anyway, so we can't use the AllHostIterator. |
|
jam
2016/09/14 17:10:49
how many tests is this for? can't we just add test
falken
2016/09/21 08:59:43
Done, removed this and added testbundles.
|
| + if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) |
| + return; |
| + |
| + // Shared workers also keep render process hosts alive. 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. |
| + for (content::RenderProcessHost::iterator host_iterator = |
|
jam
2016/09/14 17:10:49
here and below, no "content::"
falken
2016/09/21 08:59:43
Done.
|
| + content::RenderProcessHost::AllHostsIterator(); |
| + !host_iterator.IsAtEnd(); host_iterator.Advance()) { |
| + content::RenderProcessHost* host = host_iterator.GetCurrentValue(); |
| + if (host->GetBrowserContext() == browser_context) |
| + host->ForceReleaseWorkerRefCounts(); |
| + } |
| } |
| void BrowserContext::EnsureResourceContextInitialized(BrowserContext* context) { |