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

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

Issue 690153002: [Sync] Fix bug where DeviceInfo is missing a backup timestamp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2171
Patch Set: 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 1f8f9eb259ca7e01b29c678427d635009cb2195f..51411f99032ded47d652ace2bd8eef15612e49dd 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -310,8 +310,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()) {
@@ -909,8 +907,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() {
@@ -1034,9 +1031,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();
}
@@ -1706,16 +1703,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(
@@ -2686,10 +2685,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