Chromium Code Reviews| Index: components/doodle/doodle_service.h |
| diff --git a/components/doodle/doodle_service.h b/components/doodle/doodle_service.h |
| index 8913fbf144b8f76005fe457ebcfc947b723f1530..ac20c542dca487719f2405109ae422fb95dec47c 100644 |
| --- a/components/doodle/doodle_service.h |
| +++ b/components/doodle/doodle_service.h |
| @@ -10,10 +10,14 @@ |
| #include "base/macros.h" |
| #include "base/observer_list.h" |
| #include "base/optional.h" |
| +#include "base/time/clock.h" |
| #include "base/timer/timer.h" |
| #include "components/doodle/doodle_fetcher.h" |
| #include "components/doodle/doodle_types.h" |
| +class PrefRegistrySimple; |
| +class PrefService; |
| + |
| namespace base { |
| class TimeDelta; |
| } |
| @@ -27,9 +31,13 @@ class DoodleService { |
| virtual void OnDoodleConfigUpdated(const base::Optional<DoodleConfig>&) = 0; |
| }; |
| - // Both |fetcher| and |expiry_timer| must be non-null. |
| - DoodleService(std::unique_ptr<DoodleFetcher> fetcher, |
| - std::unique_ptr<base::OneShotTimer> expiry_timer); |
| + static void RegisterProfilePrefs(PrefRegistrySimple* pref_registry); |
| + |
| + // All parameters must be non-null. |
| + DoodleService(PrefService* pref_service, |
| + std::unique_ptr<DoodleFetcher> fetcher, |
| + std::unique_ptr<base::OneShotTimer> expiry_timer, |
| + base::Clock* clock); |
|
Bernhard Bauer
2017/03/13 14:38:33
Passing the clock in as a raw pointer is a bit str
Marc Treib
2017/03/13 14:51:37
Indeed, good catch. Done.
|
| ~DoodleService(); |
| // Returns the current (cached) config, if any. |
| @@ -54,15 +62,19 @@ class DoodleService { |
| base::TimeDelta time_to_live, |
| const base::Optional<DoodleConfig>& doodle_config); |
| - void UpdateTimeToLive(base::TimeDelta time_to_live); |
| + void UpdateCachedConfig(base::TimeDelta time_to_live, |
| + const base::Optional<DoodleConfig>& doodle_config); |
| // Callback for the expiry timer. |
| void DoodleExpired(); |
| + PrefService* pref_service_; |
| + |
| // The fetcher for getting fresh DoodleConfigs from the network. |
| std::unique_ptr<DoodleFetcher> fetcher_; |
| std::unique_ptr<base::OneShotTimer> expiry_timer_; |
| + base::Clock* clock_; |
| // The result of the last network fetch. |
| base::Optional<DoodleConfig> cached_config_; |