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

Unified Diff: chrome/browser/extensions/extension_service.cc

Issue 14757022: Add a non-blocking "OneShotEvent" class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: dcronin's comments; ExtensionSystem::ready; and WeakPtr support Created 7 years, 7 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
Index: chrome/browser/extensions/extension_service.cc
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 2cfc14495d5feff32ae24d9208049e49ab16d2bc..b4bfde998af0ab8f78bf2f361192d6436859fb82 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -350,7 +350,6 @@ ExtensionService::ExtensionService(Profile* profile,
extensions_enabled_(extensions_enabled),
show_extensions_prompts_(true),
install_updates_when_idle_(true),
- ready_(false),
toolbar_model_(this),
menu_manager_(profile),
event_routers_initialized_(false),
@@ -562,7 +561,7 @@ const Extension* ExtensionService::GetExtensionById(
void ExtensionService::Init() {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK(!ready_); // Can't redo init.
+ DCHECK(!ready_.has_happened()); // Can't redo init.
DCHECK_EQ(extensions_.size(), 0u);
const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
@@ -585,12 +584,13 @@ void ExtensionService::Init() {
// import process.
extensions::InstalledLoader(this).LoadAllExtensions();
+ SetReadyAndNotifyListeners();
RegisterForImportFinished();
} else {
- // In this case, LoadAllExtensions() calls OnLoadedInstalledExtensions(),
- // which calls SetReadyAndNotifyListeners().
+ // In this case, LoadAllExtensions() calls OnLoadedInstalledExtensions().
component_loader_->LoadAll();
extensions::InstalledLoader(this).LoadAllExtensions();
+ SetReadyAndNotifyListeners();
// TODO(erikkay) this should probably be deferred to a future point
// rather than running immediately at startup.
@@ -1234,10 +1234,6 @@ extensions::ContentSettingsStore* ExtensionService::GetContentSettingsStore() {
return extension_prefs()->content_settings_store();
}
-bool ExtensionService::is_ready() {
- return ready_;
-}
-
base::SequencedTaskRunner* ExtensionService::GetFileTaskRunner() {
if (file_task_runner_)
return file_task_runner_;
@@ -1959,6 +1955,8 @@ void ExtensionService::ReloadExtensions() {
UnloadAllExtensions();
component_loader_->LoadAll();
extensions::InstalledLoader(this).LoadAllExtensions();
+ // Don't call SetReadyAndNotifyListeners() since tests call this multiple
+ // times.
}
void ExtensionService::GarbageCollectExtensions() {
@@ -2017,7 +2015,7 @@ void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) {
}
void ExtensionService::SetReadyAndNotifyListeners() {
- ready_ = true;
+ ready_.MarkHappened();
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_EXTENSIONS_READY,
content::Source<Profile>(profile_),
@@ -2029,8 +2027,6 @@ void ExtensionService::OnLoadedInstalledExtensions() {
updater_->Start();
OnBlacklistUpdated();
-
- SetReadyAndNotifyListeners();
}
void ExtensionService::AddExtension(const Extension* extension) {

Powered by Google App Engine
This is Rietveld 408576698