Ensure BrowserThread::CurrentlyOn is correct through MessageLoop teardown
Changes BrowserThread::CurrentlyOn (and thus
BrowserThreadTaskRunner::RunsTasksOnCurrentThread()) to correctly report
a BrowserThread's association during MessageLoop destruction notification.
Also adds an explicit Start() to BrowserThreadImpl as there are tests which
call it and which incorrectly assumed base::Thread's implementation would
call BrowserThreadImpl::StartWithOptions (which it wouldn't since the latter
is not a virtual function.)
This change provokes many tests to delete ExtensionFunction instances that
were otherwise being leaked because UIThreadExtensionFunction::Destroy was
incorrectly deferring destruction when run on the UI thread during shutdown.
This in turn revealed a few small bugs which have also been fixed here.
BUG=631093
[email protected]
Committed: https://crrev.com/b02da29fb9116d1a1fb4fd0476628f333ff6bd1a
Review-Url: https://codereview.chromium.org/2180253003
Cr-Original-Commit-Position: refs/heads/master@{#408295}
Cr-Commit-Position: refs/heads/master@{#408411}
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index c70b465..aadf06ee 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -256,6 +256,10 @@
}
BrowserProcessImpl::~BrowserProcessImpl() {
+#if defined(ENABLE_EXTENSIONS)
+ extensions::ExtensionsBrowserClient::Set(nullptr);
+#endif
+
#if !defined(OS_ANDROID)
KeepAliveRegistry::GetInstance()->RemoveObserver(this);
#endif // !defined(OS_ANDROID)