Clean up a few startup and shutdown dependencies which should fix some of the extension
browser_tests. Specifically, this includes:
* make ExtensionsService own ExtensionProcessManager so that they have the same lifetime
* git rid of notifications from unload all to avoid treating these notifications like real unload / uninstall events
* fix teardown logic in ExtensionShelfModelTest
* ExtensionView removes itself from the view hierarchy on destruction
* ExtensionProcessManager waits for EXTENSIONS_READY to load background pages
BUG=15080
TEST=browser_tests.exe --gtest_filter=ExtensionShelfModelTest
Review URL: http://codereview.chromium.org/147051
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19122 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index 48dc8d8..affb542 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -215,6 +215,7 @@
MessageLoop* frontend_loop,
MessageLoop* backend_loop)
: extension_prefs_(new ExtensionPrefs(profile->GetPrefs())),
+ extension_process_manager_(new ExtensionProcessManager(profile)),
backend_loop_(backend_loop),
install_directory_(profile->GetPath().AppendASCII(kInstallDirectoryName)),
extensions_enabled_(false),
@@ -244,6 +245,7 @@
}
void ExtensionsService::Init() {
+ DCHECK(!ready_);
DCHECK(extensions_.size() == 0);
// Start up the extension event routers.
@@ -354,7 +356,7 @@
// Tell other services the extension is gone.
NotificationService::current()->Notify(NotificationType::EXTENSION_UNLOADED,
- NotificationService::AllSources(),
+ Source<ExtensionsService>(this),
Details<Extension>(extension));
delete extension;
@@ -362,14 +364,13 @@
void ExtensionsService::UnloadAllExtensions() {
ExtensionList::iterator iter;
- for (iter = extensions_.begin(); iter != extensions_.end(); ++iter) {
- // Tell other services the extension is gone.
- NotificationService::current()->Notify(NotificationType::EXTENSION_UNLOADED,
- NotificationService::AllSources(),
- Details<Extension>(*iter));
+ for (iter = extensions_.begin(); iter != extensions_.end(); ++iter)
delete *iter;
- }
extensions_.clear();
+
+ // TODO(erikkay) should there be a notification for this? We can't use
+ // EXTENSION_UNLOADED since that implies that the extension has been disabled
+ // or uninstalled, and UnloadAll is just part of shutdown.
}
void ExtensionsService::ReloadExtensions() {
@@ -428,7 +429,7 @@
if (enabled_extensions.size()) {
NotificationService::current()->Notify(
NotificationType::EXTENSIONS_LOADED,
- NotificationService::AllSources(),
+ Source<ExtensionsService>(this),
Details<ExtensionList>(&enabled_extensions));
}
}
@@ -443,12 +444,12 @@
if (extension->IsTheme()) {
NotificationService::current()->Notify(
NotificationType::THEME_INSTALLED,
- NotificationService::AllSources(),
+ Source<ExtensionsService>(this),
Details<Extension>(extension));
} else {
NotificationService::current()->Notify(
NotificationType::EXTENSION_INSTALLED,
- NotificationService::AllSources(),
+ Source<ExtensionsService>(this),
Details<Extension>(extension));
}
}
@@ -474,7 +475,7 @@
if (extension && extension->IsTheme()) {
NotificationService::current()->Notify(
NotificationType::THEME_INSTALLED,
- NotificationService::AllSources(),
+ Source<ExtensionsService>(this),
Details<Extension>(extension));
}
}