Commit 739f7372 authored by Sylvain Defresne's avatar Sylvain Defresne Committed by Commit Bot

Use PrefService support of base::Time

base::Time::{To,From}InternalValue is deprecated. Use the
new (https://crrev.com/c/865569) methods of PrefService to
register and manipulation the preference as base::Time.

Bug: 634507
Change-Id: I4093149e776d6924d7aaa49a617d4b01c2f3d862
Reviewed-on: https://chromium-review.googlesource.com/1188308Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585809}
parent faf33a48
...@@ -64,7 +64,8 @@ AccountFetcherService::~AccountFetcherService() { ...@@ -64,7 +64,8 @@ AccountFetcherService::~AccountFetcherService() {
// static // static
void AccountFetcherService::RegisterPrefs( void AccountFetcherService::RegisterPrefs(
user_prefs::PrefRegistrySyncable* user_prefs) { user_prefs::PrefRegistrySyncable* user_prefs) {
user_prefs->RegisterInt64Pref(kLastUpdatePref, 0); user_prefs->RegisterTimePref(AccountFetcherService::kLastUpdatePref,
base::Time());
} }
void AccountFetcherService::Initialize( void AccountFetcherService::Initialize(
...@@ -85,9 +86,8 @@ void AccountFetcherService::Initialize( ...@@ -85,9 +86,8 @@ void AccountFetcherService::Initialize(
DCHECK(image_decoder); DCHECK(image_decoder);
DCHECK(!image_decoder_); DCHECK(!image_decoder_);
image_decoder_ = std::move(image_decoder); image_decoder_ = std::move(image_decoder);
last_updated_ = signin_client_->GetPrefs()->GetTime(
last_updated_ = base::Time::FromInternalValue( AccountFetcherService::kLastUpdatePref);
signin_client_->GetPrefs()->GetInt64(kLastUpdatePref));
} }
void AccountFetcherService::Shutdown() { void AccountFetcherService::Shutdown() {
...@@ -176,8 +176,8 @@ void AccountFetcherService::RefreshAllAccountsAndScheduleNext() { ...@@ -176,8 +176,8 @@ void AccountFetcherService::RefreshAllAccountsAndScheduleNext() {
DCHECK(network_fetches_enabled_); DCHECK(network_fetches_enabled_);
RefreshAllAccountInfo(false); RefreshAllAccountInfo(false);
last_updated_ = base::Time::Now(); last_updated_ = base::Time::Now();
signin_client_->GetPrefs()->SetInt64(kLastUpdatePref, signin_client_->GetPrefs()->SetTime(AccountFetcherService::kLastUpdatePref,
last_updated_.ToInternalValue()); last_updated_);
ScheduleNextRefresh(); ScheduleNextRefresh();
} }
......
...@@ -290,8 +290,8 @@ class AccountTrackerServiceTest : public testing::Test { ...@@ -290,8 +290,8 @@ class AccountTrackerServiceTest : public testing::Test {
pref_service_.registry()->RegisterIntegerPref( pref_service_.registry()->RegisterIntegerPref(
prefs::kAccountIdMigrationState, prefs::kAccountIdMigrationState,
AccountTrackerService::MIGRATION_NOT_STARTED); AccountTrackerService::MIGRATION_NOT_STARTED);
pref_service_.registry()->RegisterInt64Pref( pref_service_.registry()->RegisterTimePref(
AccountFetcherService::kLastUpdatePref, 0); AccountFetcherService::kLastUpdatePref, base::Time());
signin_client_.reset(new TestSigninClient(&pref_service_)); signin_client_.reset(new TestSigninClient(&pref_service_));
account_tracker_.reset(new AccountTrackerService()); account_tracker_.reset(new AccountTrackerService());
...@@ -893,9 +893,8 @@ TEST_F(AccountTrackerServiceTest, TimerRefresh) { ...@@ -893,9 +893,8 @@ TEST_F(AccountTrackerServiceTest, TimerRefresh) {
// Rewind the time by half a day, which shouldn't be enough to trigger a // Rewind the time by half a day, which shouldn't be enough to trigger a
// network refresh. // network refresh.
base::Time fake_update = base::Time::Now() - base::TimeDelta::FromHours(12); base::Time fake_update = base::Time::Now() - base::TimeDelta::FromHours(12);
signin_client()->GetPrefs()->SetInt64( signin_client()->GetPrefs()->SetTime(AccountFetcherService::kLastUpdatePref,
AccountFetcherService::kLastUpdatePref, fake_update);
fake_update.ToInternalValue());
// Instantiate a new ATS, making sure the persisted accounts are still there // Instantiate a new ATS, making sure the persisted accounts are still there
// and that no network fetches happen. // and that no network fetches happen.
...@@ -920,9 +919,8 @@ TEST_F(AccountTrackerServiceTest, TimerRefresh) { ...@@ -920,9 +919,8 @@ TEST_F(AccountTrackerServiceTest, TimerRefresh) {
// Rewind the last updated time enough to trigger a network refresh. // Rewind the last updated time enough to trigger a network refresh.
fake_update = base::Time::Now() - base::TimeDelta::FromHours(25); fake_update = base::Time::Now() - base::TimeDelta::FromHours(25);
signin_client()->GetPrefs()->SetInt64( signin_client()->GetPrefs()->SetTime(AccountFetcherService::kLastUpdatePref,
AccountFetcherService::kLastUpdatePref, fake_update);
fake_update.ToInternalValue());
// Instantiate a new tracker and validate that even though the AccountInfos // Instantiate a new tracker and validate that even though the AccountInfos
// are still valid, the network fetches are started. // are still valid, the network fetches are started.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment