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

Unified Diff: apps/shell/shell_browser_main_parts.cc

Issue 118043003: Fix app_shell shutdown crash due to BrowserContextKeyedServices (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: delegate out ExtensionSystem creation (shutdown_crash) Created 6 years, 11 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 | « apps/shell/shell_browser_context.cc ('k') | apps/shell/shell_extensions_browser_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: apps/shell/shell_browser_main_parts.cc
diff --git a/apps/shell/shell_browser_main_parts.cc b/apps/shell/shell_browser_main_parts.cc
index 06fecad8485cf9fe606feff56226fa7e6aaf8bf5..7643a0969058c29c1ce749adead35a3e45eafefd 100644
--- a/apps/shell/shell_browser_main_parts.cc
+++ b/apps/shell/shell_browser_main_parts.cc
@@ -13,9 +13,11 @@
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "base/run_loop.h"
-#include "chrome/browser/extensions/extension_system_factory.h"
+#include "chrome/browser/extensions/extension_prefs_factory.h"
+#include "chrome/browser/extensions/extension_system.h"
#include "chrome/common/chrome_paths.h"
#include "chromeos/chromeos_paths.h"
+#include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
#include "content/public/common/result_codes.h"
#include "extensions/common/extension_paths.h"
#include "ui/aura/env.h"
@@ -27,8 +29,19 @@
using content::BrowserContext;
using extensions::Extension;
+using extensions::ExtensionSystem;
+using extensions::ShellExtensionSystem;
namespace apps {
+namespace {
+
+// TODO(jamescook): Register additional BrowserContextKeyedService factories
+// here. See ChromeBrowserMainExtraPartsProfiles for details.
+void EnsureBrowserContextKeyedServiceFactoriesBuilt() {
+ extensions::ExtensionPrefsFactory::GetInstance();
Yoyo Zhou 2014/01/08 02:29:42 Is there some reason this can't be declared as a D
James Cook 2014/01/08 17:37:02 Yeah, it should be done there. Chrome does it in b
+}
+
+} // namespace
ShellBrowserMainParts::ShellBrowserMainParts(
const content::MainFunctionParams& parameters)
@@ -80,12 +93,13 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() {
new ShellExtensionsBrowserClient(browser_context_.get()));
extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get());
- // TODO(jamescook): Initialize policy::ProfilePolicyConnector.
-
+ // Create our custom ExtensionSystem first because other
+ // BrowserContextKeyedServices depend on it.
CreateExtensionSystem();
- // TODO(jamescook): Create the rest of the services using
- // BrowserContextDependencyManager::CreateBrowserContextServices.
+ EnsureBrowserContextKeyedServiceFactoriesBuilt();
+ BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices(
+ browser_context_.get());
CreateRootWindow();
@@ -111,16 +125,13 @@ bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) {
void ShellBrowserMainParts::PostMainMessageLoopRun() {
DestroyRootWindow();
- // TODO(jamescook): Destroy the rest of the services with
- // BrowserContextDependencyManager::DestroyBrowserContextServices.
+ BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices(
+ browser_context_.get());
+ extension_system_ = NULL;
extensions::ExtensionsBrowserClient::Set(NULL);
extensions_browser_client_.reset();
browser_context_.reset();
aura::Env::DeleteInstance();
-
- LOG(WARNING) << "-----------------------------------";
- LOG(WARNING) << "app_shell is expected to crash now.";
- LOG(WARNING) << "-----------------------------------";
}
void ShellBrowserMainParts::OnRootWindowHostCloseRequested(
@@ -149,12 +160,8 @@ void ShellBrowserMainParts::DestroyRootWindow() {
void ShellBrowserMainParts::CreateExtensionSystem() {
DCHECK(browser_context_);
- extension_system_ =
- new extensions::ShellExtensionSystem(browser_context_.get());
- extensions::ExtensionSystemFactory::GetInstance()->SetCustomInstance(
- extension_system_);
- // Must occur after setting the instance above, as it will end up calling
- // ExtensionSystem::Get().
+ extension_system_ = static_cast<ShellExtensionSystem*>(
+ ExtensionSystem::GetForBrowserContext(browser_context_.get()));
extension_system_->InitForRegularProfile(true);
}
« no previous file with comments | « apps/shell/shell_browser_context.cc ('k') | apps/shell/shell_extensions_browser_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698