summaryrefslogtreecommitdiffstats
path: root/chrome/browser/profiles
diff options
context:
space:
mode:
authoraltimofeev@chromium.org <altimofeev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-11 10:14:43 +0000
committeraltimofeev@chromium.org <altimofeev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-11 10:14:43 +0000
commit845b43a8e2652e74447fedd648216769e3d1e566 (patch)
tree8a4743d8b59866de832b3719d44b9113a8c5a67a /chrome/browser/profiles
parent837c88b9a8072ca14f9a32b4ed369e499d64eac4 (diff)
downloadchromium_src-845b43a8e2652e74447fedd648216769e3d1e566.zip
chromium_src-845b43a8e2652e74447fedd648216769e3d1e566.tar.gz
chromium_src-845b43a8e2652e74447fedd648216769e3d1e566.tar.bz2
Adds async interface method, which is used by JsonPrefStore. Also see the bug description for more info.
BUG=chromium-os:14289 TEST=JsonPrefStoreTest.* Review URL: http://codereview.chromium.org/6894020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84962 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/profiles')
-rw-r--r--chrome/browser/profiles/profile_impl.cc95
-rw-r--r--chrome/browser/profiles/profile_impl.h8
2 files changed, 60 insertions, 43 deletions
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index e168882..7b73fe5 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -292,18 +292,23 @@ ProfileImpl::ProfileImpl(const FilePath& path,
&ProfileImpl::EnsureSessionServiceCreated);
if (delegate_) {
- prefs_.reset(PrefService::CreatePrefServiceAsync(
+ prefs_.reset(PrefService::CreatePrefService(
GetPrefFilePath(),
new ExtensionPrefStore(GetExtensionPrefValueMap(), false),
GetOriginalProfile(),
- this)); // Ask to notify us in the end.
+ true));
+ // Wait for the notifcation that prefs has been loaded (successfully or
+ // not).
+ registrar_.Add(this, NotificationType::PREF_INITIALIZATION_COMPLETED,
+ Source<PrefService>(prefs_.get()));
} else {
// Load prefs synchronously.
prefs_.reset(PrefService::CreatePrefService(
GetPrefFilePath(),
new ExtensionPrefStore(GetExtensionPrefValueMap(), false),
- GetOriginalProfile()));
- OnPrefsLoaded(prefs_.get(), true);
+ GetOriginalProfile(),
+ false));
+ OnPrefsLoaded(true);
}
}
@@ -803,9 +808,7 @@ net::TransportSecurityState*
return transport_security_state_.get();
}
-void ProfileImpl::OnPrefsLoaded(PrefService* prefs, bool success) {
- DCHECK(prefs == prefs_.get());
-
+void ProfileImpl::OnPrefsLoaded(bool success) {
if (!success) {
DCHECK(delegate_);
delegate_->OnProfileCreated(this, false);
@@ -1319,39 +1322,55 @@ void ProfileImpl::MarkAsCleanShutdown() {
void ProfileImpl::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
- if (NotificationType::PREF_CHANGED == type) {
- std::string* pref_name_in = Details<std::string>(details).ptr();
- PrefService* prefs = Source<PrefService>(source).ptr();
- DCHECK(pref_name_in && prefs);
- if (*pref_name_in == prefs::kSpellCheckDictionary ||
- *pref_name_in == prefs::kEnableSpellCheck) {
- ReinitializeSpellCheckHost(true);
- } else if (*pref_name_in == prefs::kEnableAutoSpellCorrect) {
- bool enabled = prefs->GetBoolean(prefs::kEnableAutoSpellCorrect);
- for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator());
- !i.IsAtEnd(); i.Advance()) {
- RenderProcessHost* process = i.GetCurrentValue();
- process->Send(new SpellCheckMsg_EnableAutoSpellCorrect(enabled));
- }
- } else if (*pref_name_in == prefs::kClearSiteDataOnExit) {
- clear_local_state_on_exit_ =
- prefs->GetBoolean(prefs::kClearSiteDataOnExit);
- if (webkit_context_) {
- webkit_context_->set_clear_local_state_on_exit(
- clear_local_state_on_exit_);
- }
- if (appcache_service_) {
- appcache_service_->SetClearLocalStateOnExit(
- clear_local_state_on_exit_);
+ switch (type.value) {
+ case NotificationType::PREF_INITIALIZATION_COMPLETED: {
+ bool* succeeded = Details<bool>(details).ptr();
+ PrefService *prefs = Source<PrefService>(source).ptr();
+ DCHECK(prefs == prefs_.get());
+ registrar_.Remove(this, NotificationType::PREF_INITIALIZATION_COMPLETED,
+ Source<PrefService>(prefs));
+ OnPrefsLoaded(*succeeded);
+ break;
+ }
+ case NotificationType::PREF_CHANGED: {
+ std::string* pref_name_in = Details<std::string>(details).ptr();
+ PrefService* prefs = Source<PrefService>(source).ptr();
+ DCHECK(pref_name_in && prefs);
+ if (*pref_name_in == prefs::kSpellCheckDictionary ||
+ *pref_name_in == prefs::kEnableSpellCheck) {
+ ReinitializeSpellCheckHost(true);
+ } else if (*pref_name_in == prefs::kEnableAutoSpellCorrect) {
+ bool enabled = prefs->GetBoolean(prefs::kEnableAutoSpellCorrect);
+ for (RenderProcessHost::iterator
+ i(RenderProcessHost::AllHostsIterator());
+ !i.IsAtEnd(); i.Advance()) {
+ RenderProcessHost* process = i.GetCurrentValue();
+ process->Send(new SpellCheckMsg_EnableAutoSpellCorrect(enabled));
+ }
+ } else if (*pref_name_in == prefs::kClearSiteDataOnExit) {
+ clear_local_state_on_exit_ =
+ prefs->GetBoolean(prefs::kClearSiteDataOnExit);
+ if (webkit_context_) {
+ webkit_context_->set_clear_local_state_on_exit(
+ clear_local_state_on_exit_);
+ }
+ if (appcache_service_) {
+ appcache_service_->SetClearLocalStateOnExit(
+ clear_local_state_on_exit_);
+ }
+ } else if (*pref_name_in == prefs::kGoogleServicesUsername) {
+ ProfileManager* profile_manager = g_browser_process->profile_manager();
+ profile_manager->RegisterProfileName(this);
}
- } else if (*pref_name_in == prefs::kGoogleServicesUsername) {
- ProfileManager* profile_manager = g_browser_process->profile_manager();
- profile_manager->RegisterProfileName(this);
+ break;
}
- } else if (NotificationType::BOOKMARK_MODEL_LOADED == type) {
- GetProfileSyncService(); // Causes lazy-load if sync is enabled.
- registrar_.Remove(this, NotificationType::BOOKMARK_MODEL_LOADED,
- Source<Profile>(this));
+ case NotificationType::BOOKMARK_MODEL_LOADED:
+ GetProfileSyncService(); // Causes lazy-load if sync is enabled.
+ registrar_.Remove(this, NotificationType::BOOKMARK_MODEL_LOADED,
+ Source<Profile>(this));
+ break;
+ default:
+ NOTREACHED();
}
}
diff --git a/chrome/browser/profiles/profile_impl.h b/chrome/browser/profiles/profile_impl.h
index 0809482..f5eb627 100644
--- a/chrome/browser/profiles/profile_impl.h
+++ b/chrome/browser/profiles/profile_impl.h
@@ -36,8 +36,7 @@ class NetPrefObserver;
// The default profile implementation.
class ProfileImpl : public Profile,
public SpellCheckHostObserver,
- public NotificationObserver,
- public PrefServiceDelegate {
+ public NotificationObserver {
public:
virtual ~ProfileImpl();
@@ -158,9 +157,8 @@ class ProfileImpl : public Profile,
// Does final initialization. Should be called after prefs were loaded.
void DoFinalInit();
- // PrefServiceDelegate implementation. Does final prefs initialization and
- // calls Init().
- virtual void OnPrefsLoaded(PrefService* prefs, bool success);
+ // Does final prefs initialization and calls Init().
+ void OnPrefsLoaded(bool success);
void CreateWebDataService();
FilePath GetPrefFilePath();