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

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: Add a test for the behavior within a Post()ed callback 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
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | chrome/browser/extensions/extension_system.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_service.cc
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index a7a1652eadaca842494b6901385256ae0fc5a75d..5456d53aaea0ee4f295db58f4a89414be8e0c92a 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -337,7 +337,8 @@ ExtensionService::ExtensionService(Profile* profile,
extensions::ExtensionPrefs* extension_prefs,
extensions::Blacklist* blacklist,
bool autoupdate_enabled,
- bool extensions_enabled)
+ bool extensions_enabled,
+ extensions::OneShotEvent* ready)
: extensions::Blacklist::Observer(blacklist),
profile_(profile),
system_(extensions::ExtensionSystem::Get(profile)),
@@ -349,7 +350,7 @@ ExtensionService::ExtensionService(Profile* profile,
extensions_enabled_(extensions_enabled),
show_extensions_prompts_(true),
install_updates_when_idle_(true),
- ready_(false),
+ ready_(ready),
toolbar_model_(this),
menu_manager_(profile),
event_routers_initialized_(false),
@@ -561,7 +562,7 @@ const Extension* ExtensionService::GetExtensionById(
void ExtensionService::Init() {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK(!ready_); // Can't redo init.
+ DCHECK(!is_ready()); // Can't redo init.
DCHECK_EQ(extensions_.size(), 0u);
const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
@@ -584,12 +585,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,7 +1236,7 @@ extensions::ContentSettingsStore* ExtensionService::GetContentSettingsStore() {
}
bool ExtensionService::is_ready() {
- return ready_;
+ return ready_->is_signaled();
}
base::SequencedTaskRunner* ExtensionService::GetFileTaskRunner() {
@@ -1958,6 +1960,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() {
@@ -2016,7 +2020,7 @@ void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) {
}
void ExtensionService::SetReadyAndNotifyListeners() {
- ready_ = true;
+ ready_->Signal();
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_EXTENSIONS_READY,
content::Source<Profile>(profile_),
@@ -2028,8 +2032,6 @@ void ExtensionService::OnLoadedInstalledExtensions() {
updater_->Start();
OnBlacklistUpdated();
-
- SetReadyAndNotifyListeners();
}
void ExtensionService::AddExtension(const Extension* extension) {
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | chrome/browser/extensions/extension_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698