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

Unified Diff: chrome/browser/sync/profile_sync_service.cc

Issue 660023003: [Sync] Fix bug where DeviceInfo is missing a backup timestamp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with master. Created 6 years, 2 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/sync/profile_sync_service.h ('k') | chrome/browser/sync/profile_sync_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/profile_sync_service.cc
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index 70d323d05c98267fb03f9e5a4038af24e2cda484..2d29fd9043f85bdcf0280d59c790cd8a37853b2d 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -311,8 +311,6 @@ void ProfileSyncService::Initialize() {
TrySyncDatatypePrefRecovery();
- last_synced_time_ = sync_prefs_.GetLastSyncedTime();
-
#if defined(OS_CHROMEOS)
std::string bootstrap_token = sync_prefs_.GetEncryptionBootstrapToken();
if (bootstrap_token.empty()) {
@@ -904,8 +902,7 @@ void ProfileSyncService::SetSyncSetupCompleted() {
}
void ProfileSyncService::UpdateLastSyncedTime() {
- last_synced_time_ = base::Time::Now();
- sync_prefs_.SetLastSyncedTime(last_synced_time_);
+ sync_prefs_.SetLastSyncedTime(base::Time::Now());
}
void ProfileSyncService::NotifyObservers() {
@@ -1028,9 +1025,9 @@ void ProfileSyncService::PostBackendInitialization() {
ConsumeCachedPassphraseIfPossible();
// The very first time the backend initializes is effectively the first time
- // we can say we successfully "synced". last_synced_time_ will only be null
- // in this case, because the pref wasn't restored on StartUp.
- if (last_synced_time_.is_null()) {
+ // we can say we successfully "synced". LastSyncedTime will only be null in
+ // this case, because the pref wasn't restored on StartUp.
+ if (sync_prefs_.GetLastSyncedTime().is_null()) {
UpdateLastSyncedTime();
}
@@ -1707,16 +1704,18 @@ bool ProfileSyncService::IsPassphraseRequiredForDecryption() const {
}
base::string16 ProfileSyncService::GetLastSyncedTimeString() const {
- if (last_synced_time_.is_null())
+ const base::Time last_synced_time = sync_prefs_.GetLastSyncedTime();
+ if (last_synced_time.is_null())
return l10n_util::GetStringUTF16(IDS_SYNC_TIME_NEVER);
- base::TimeDelta last_synced = base::Time::Now() - last_synced_time_;
+ base::TimeDelta time_since_last_sync = base::Time::Now() - last_synced_time;
- if (last_synced < base::TimeDelta::FromMinutes(1))
+ if (time_since_last_sync < base::TimeDelta::FromMinutes(1))
return l10n_util::GetStringUTF16(IDS_SYNC_TIME_JUST_NOW);
return ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_ELAPSED,
- ui::TimeFormat::LENGTH_SHORT, last_synced);
+ ui::TimeFormat::LENGTH_SHORT,
+ time_since_last_sync);
}
void ProfileSyncService::UpdateSelectedTypesHistogram(
@@ -2673,10 +2672,11 @@ void ProfileSyncService::CheckSyncBackupIfNeeded() {
DCHECK_EQ(backend_mode_, SYNC);
#if defined(ENABLE_PRE_SYNC_BACKUP)
+ const base::Time last_synced_time = sync_prefs_.GetLastSyncedTime();
// Check backup once a day.
if (!last_backup_time_ &&
- (last_synced_time_.is_null() ||
- base::Time::Now() - last_synced_time_ >=
+ (last_synced_time.is_null() ||
+ base::Time::Now() - last_synced_time >=
base::TimeDelta::FromDays(1))) {
// If sync thread is set, need to serialize check on sync thread after
// closing backup DB.
« no previous file with comments | « chrome/browser/sync/profile_sync_service.h ('k') | chrome/browser/sync/profile_sync_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698