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() {
// static
void AccountFetcherService::RegisterPrefs(
user_prefs::PrefRegistrySyncable* user_prefs) {
user_prefs->RegisterInt64Pref(kLastUpdatePref, 0);
user_prefs->RegisterTimePref(AccountFetcherService::kLastUpdatePref,
base::Time());
}
void AccountFetcherService::Initialize(
......@@ -85,9 +86,8 @@ void AccountFetcherService::Initialize(
DCHECK(image_decoder);
DCHECK(!image_decoder_);
image_decoder_ = std::move(image_decoder);
last_updated_ = base::Time::FromInternalValue(
signin_client_->GetPrefs()->GetInt64(kLastUpdatePref));
last_updated_ = signin_client_->GetPrefs()->GetTime(
AccountFetcherService::kLastUpdatePref);
}
void AccountFetcherService::Shutdown() {
......@@ -176,8 +176,8 @@ void AccountFetcherService::RefreshAllAccountsAndScheduleNext() {
DCHECK(network_fetches_enabled_);
RefreshAllAccountInfo(false);
last_updated_ = base::Time::Now();
signin_client_->GetPrefs()->SetInt64(kLastUpdatePref,
last_updated_.ToInternalValue());
signin_client_->GetPrefs()->SetTime(AccountFetcherService::kLastUpdatePref,
last_updated_);
ScheduleNextRefresh();
}
......
......@@ -290,8 +290,8 @@ class AccountTrackerServiceTest : public testing::Test {
pref_service_.registry()->RegisterIntegerPref(
prefs::kAccountIdMigrationState,
AccountTrackerService::MIGRATION_NOT_STARTED);
pref_service_.registry()->RegisterInt64Pref(
AccountFetcherService::kLastUpdatePref, 0);
pref_service_.registry()->RegisterTimePref(
AccountFetcherService::kLastUpdatePref, base::Time());
signin_client_.reset(new TestSigninClient(&pref_service_));
account_tracker_.reset(new AccountTrackerService());
......@@ -893,9 +893,8 @@ TEST_F(AccountTrackerServiceTest, TimerRefresh) {
// Rewind the time by half a day, which shouldn't be enough to trigger a
// network refresh.
base::Time fake_update = base::Time::Now() - base::TimeDelta::FromHours(12);
signin_client()->GetPrefs()->SetInt64(
AccountFetcherService::kLastUpdatePref,
fake_update.ToInternalValue());
signin_client()->GetPrefs()->SetTime(AccountFetcherService::kLastUpdatePref,
fake_update);
// Instantiate a new ATS, making sure the persisted accounts are still there
// and that no network fetches happen.
......@@ -920,9 +919,8 @@ TEST_F(AccountTrackerServiceTest, TimerRefresh) {
// Rewind the last updated time enough to trigger a network refresh.
fake_update = base::Time::Now() - base::TimeDelta::FromHours(25);
signin_client()->GetPrefs()->SetInt64(
AccountFetcherService::kLastUpdatePref,
fake_update.ToInternalValue());
signin_client()->GetPrefs()->SetTime(AccountFetcherService::kLastUpdatePref,
fake_update);
// Instantiate a new tracker and validate that even though the AccountInfos
// 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