Chromium Code Reviews| Index: components/suggestions/suggestions_store.cc |
| diff --git a/components/suggestions/suggestions_store.cc b/components/suggestions/suggestions_store.cc |
| index 01c8e97050cf99a3f31ca5660348597cf50acaec..08a7ec538a4b005c6bdd50524b057d93c3e5f951 100644 |
| --- a/components/suggestions/suggestions_store.cc |
| +++ b/components/suggestions/suggestions_store.cc |
| @@ -8,6 +8,7 @@ |
| #include "base/base64.h" |
| #include "base/prefs/pref_service.h" |
| +#include "base/time/default_clock.h" |
| #include "base/time/time.h" |
| #include "components/pref_registry/pref_registry_syncable.h" |
| #include "components/suggestions/suggestions_pref_names.h" |
| @@ -15,12 +16,19 @@ |
| namespace suggestions { |
| SuggestionsStore::SuggestionsStore(PrefService* profile_prefs) |
| - : pref_service_(profile_prefs) { |
| + : pref_service_(profile_prefs), |
| + clock_(new base::DefaultClock()) { |
|
Matt Giuca
2014/12/18 22:51:13
Nit: Indentation is wrong. (Run git cl format?)
gayane -on leave until 09-2017
2014/12/22 16:29:38
Done.
|
| DCHECK(profile_prefs); |
| } |
| +SuggestionsStore::SuggestionsStore() {} |
| + |
| SuggestionsStore::~SuggestionsStore() {} |
| +void SuggestionsStore::SetClockForTesting(scoped_ptr<base::Clock> test_clock) { |
| + this->clock_ = test_clock.Pass(); |
| +} |
| + |
| bool SuggestionsStore::LoadSuggestions(SuggestionsProfile* suggestions) { |
| DCHECK(suggestions); |
| @@ -61,7 +69,7 @@ bool SuggestionsStore::LoadSuggestions(SuggestionsProfile* suggestions) { |
| void SuggestionsStore::FilterExpiredSuggestions( |
| SuggestionsProfile* suggestions) { |
| SuggestionsProfile filtered_suggestions; |
| - int64 now_usec = (base::Time::NowFromSystemTime() - base::Time::UnixEpoch()) |
| + int64 now_usec = (this->clock_->Now() - base::Time::UnixEpoch()) |
| .ToInternalValue(); |
| for (int i = 0; i < suggestions->suggestions_size(); ++i) { |