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..b0497128f8d30fa4dcd4c5bc9c87ccc34c604957 100644 |
| --- a/components/suggestions/suggestions_store.cc |
| +++ b/components/suggestions/suggestions_store.cc |
| @@ -8,6 +8,8 @@ |
| #include "base/base64.h" |
| #include "base/prefs/pref_service.h" |
| +#include "base/time/clock.h" |
|
Mathieu
2014/12/18 20:05:28
don't need to include clock.h here, it's in the .h
gayane -on leave until 09-2017
2014/12/18 21:06:49
Done.
|
| +#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 +17,19 @@ |
| namespace suggestions { |
| SuggestionsStore::SuggestionsStore(PrefService* profile_prefs) |
| - : pref_service_(profile_prefs) { |
| + : pref_service_(profile_prefs), |
| + clock_(new base::DefaultClock()) { |
| 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 +70,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) { |