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

Unified Diff: extensions/browser/extension_function.cc

Issue 2118473002: 😴 Skip some KeepAlive registrations on shutdown. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 5 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
« no previous file with comments | « extensions/browser/extension_function.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/extension_function.cc
diff --git a/extensions/browser/extension_function.cc b/extensions/browser/extension_function.cc
index ffe138477f03b2c38d0e7c0731f7041dfe69463d..8f737df200df1c93f460422afb50ebb1464137aa 100644
--- a/extensions/browser/extension_function.cc
+++ b/extensions/browser/extension_function.cc
@@ -488,6 +488,26 @@ UIThreadExtensionFunction::AsUIThreadExtensionFunction() {
return this;
}
+bool UIThreadExtensionFunction::PreRunValidation(std::string* error) {
+ if (!ExtensionFunction::PreRunValidation(error))
+ return false;
+
+ // TODO(crbug.com/625646) This is a partial fix to avoid crashes when certain
+ // extension functions run during shutdown. Browser or Notification creation
+ // for example create a ScopedKeepAlive, which hit a CHECK if the browser is
+ // shutting down. This fixes the current problem as the known issues happen
+ // through synchronous calls from Run(), but posted tasks will not be covered.
+ // A possible fix would involve refactoring ExtensionFunction: unrefcount
+ // here and use weakptrs for the tasks, then have it owned by something that
+ // will be destroyed naturally in the course of shut down.
+ if (extensions::ExtensionsBrowserClient::Get()->IsShuttingDown()) {
+ *error = "The browser is shutting down.";
+ return false;
+ }
+
+ return true;
+}
+
bool UIThreadExtensionFunction::OnMessageReceived(const IPC::Message& message) {
return false;
}
« no previous file with comments | « extensions/browser/extension_function.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698