summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/glue/sync_backend_host.cc
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-12 03:04:13 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-12 03:04:13 +0000
commite3b0ee5f1dc1647f3f00439c9a7f9bb7e97345dd (patch)
tree1a3d69ff713b154f619f2115aab7284bbe6cac5e /chrome/browser/sync/glue/sync_backend_host.cc
parent8c9add0068743ba549a235e4748e686d8622f3b3 (diff)
downloadchromium_src-e3b0ee5f1dc1647f3f00439c9a7f9bb7e97345dd.zip
chromium_src-e3b0ee5f1dc1647f3f00439c9a7f9bb7e97345dd.tar.gz
chromium_src-e3b0ee5f1dc1647f3f00439c9a7f9bb7e97345dd.tar.bz2
[Sync] Persist invalidation versions to preferences
Define InvalidationVersionTracker interface and make SyncPrefs inherit from it. Pass down SyncPrefs (as InvalidationVersionTracker) all the way down to ChromeInvalidationClient and call it when there is a new max invalidation version. Pass SyncBackendHost a WeakPtr instead of a raw pointer to SyncPrefs. Made sync_listen_notifications work again. BUG=85286 TEST= Review URL: http://codereview.chromium.org/8188006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104983 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync/glue/sync_backend_host.cc')
-rw-r--r--chrome/browser/sync/glue/sync_backend_host.cc23
1 files changed, 14 insertions, 9 deletions
diff --git a/chrome/browser/sync/glue/sync_backend_host.cc b/chrome/browser/sync/glue/sync_backend_host.cc
index 1a322cb..4e6c7c4 100644
--- a/chrome/browser/sync/glue/sync_backend_host.cc
+++ b/chrome/browser/sync/glue/sync_backend_host.cc
@@ -58,7 +58,7 @@ using sync_api::SyncCredentials;
SyncBackendHost::SyncBackendHost(const std::string& name,
Profile* profile,
- SyncPrefs* sync_prefs)
+ const base::WeakPtr<SyncPrefs>& sync_prefs)
: core_(new Core(name, ALLOW_THIS_IN_INITIALIZER_LIST(this))),
initialization_state_(NOT_ATTEMPTED),
sync_thread_("Chrome_SyncThread"),
@@ -66,14 +66,15 @@ SyncBackendHost::SyncBackendHost(const std::string& name,
profile_(profile),
sync_prefs_(sync_prefs),
name_(name),
- sync_notifier_factory_(webkit_glue::GetUserAgent(GURL()),
- profile_->GetRequestContext(),
- *CommandLine::ForCurrentProcess()),
+ sync_notifier_factory_(
+ webkit_glue::GetUserAgent(GURL()),
+ profile_->GetRequestContext(),
+ sync_prefs,
+ *CommandLine::ForCurrentProcess()),
frontend_(NULL),
sync_data_folder_path_(
profile_->GetPath().Append(kSyncDataFolderName)),
last_auth_error_(AuthError::None()) {
- CHECK(sync_prefs_);
}
SyncBackendHost::SyncBackendHost()
@@ -81,11 +82,12 @@ SyncBackendHost::SyncBackendHost()
sync_thread_("Chrome_SyncThread"),
frontend_loop_(MessageLoop::current()),
profile_(NULL),
- sync_prefs_(NULL),
name_("Unknown"),
- sync_notifier_factory_(webkit_glue::GetUserAgent(GURL()),
- NULL,
- *CommandLine::ForCurrentProcess()),
+ sync_notifier_factory_(
+ webkit_glue::GetUserAgent(GURL()),
+ NULL,
+ base::WeakPtr<sync_notifier::InvalidationVersionTracker>(),
+ *CommandLine::ForCurrentProcess()),
frontend_(NULL),
last_auth_error_(AuthError::None()) {
}
@@ -109,6 +111,7 @@ void SyncBackendHost::Initialize(
DCHECK(frontend);
syncable::ModelTypeSet initial_types_with_nigori(initial_types);
+ CHECK(sync_prefs_.get());
if (sync_prefs_->HasSyncSetupCompleted()) {
initial_types_with_nigori.insert(syncable::NIGORI);
}
@@ -884,6 +887,7 @@ void SyncBackendHost::HandleInitializationCompletedOnFrontendLoop(
// If setup has completed, start off in DOWNLOADING_NIGORI so that
// we start off by refreshing encryption.
+ CHECK(sync_prefs_.get());
if (sync_prefs_->HasSyncSetupCompleted() &&
initialization_state_ < DOWNLOADING_NIGORI) {
initialization_state_ = DOWNLOADING_NIGORI;
@@ -994,6 +998,7 @@ sync_api::HttpPostProviderFactory* SyncBackendHost::MakeHttpBridgeFactory(
void SyncBackendHost::PersistEncryptionBootstrapToken(
const std::string& token) {
+ CHECK(sync_prefs_.get());
sync_prefs_->SetEncryptionBootstrapToken(token);
}