Index: components/doodle/doodle_service.h |
diff --git a/components/doodle/doodle_service.h b/components/doodle/doodle_service.h |
index ecb2ce9df14c5e277908264bb525bd8bd35b7c03..e4a9792a99149bad9e08cf054aad14232881ae96 100644 |
--- a/components/doodle/doodle_service.h |
+++ b/components/doodle/doodle_service.h |
@@ -12,6 +12,7 @@ |
#include "base/optional.h" |
#include "base/time/clock.h" |
#include "base/time/tick_clock.h" |
+#include "base/time/time.h" |
#include "base/timer/timer.h" |
#include "components/doodle/doodle_fetcher.h" |
#include "components/doodle/doodle_types.h" |
@@ -20,10 +21,6 @@ |
class PrefRegistrySimple; |
class PrefService; |
-namespace base { |
-class TimeDelta; |
-} |
- |
namespace doodle { |
class DoodleService : public KeyedService { |
@@ -35,12 +32,14 @@ class DoodleService : public KeyedService { |
static void RegisterProfilePrefs(PrefRegistrySimple* pref_registry); |
- // All parameters must be non-null. |
+ // All pointer parameters must be non-null. If |min_refresh_interval| doesn't |
+ // have a value, the default value is used. |
DoodleService(PrefService* pref_service, |
std::unique_ptr<DoodleFetcher> fetcher, |
std::unique_ptr<base::OneShotTimer> expiry_timer, |
std::unique_ptr<base::Clock> clock, |
- std::unique_ptr<base::TickClock> tick_clock); |
+ std::unique_ptr<base::TickClock> tick_clock, |
+ base::Optional<base::TimeDelta> override_min_refresh_interval); |
~DoodleService() override; |
// KeyedService implementation. |
@@ -73,8 +72,9 @@ class DoodleService : public KeyedService { |
OUTCOME_EXPIRED = 4, |
OUTCOME_DOWNLOAD_ERROR = 5, |
OUTCOME_PARSING_ERROR = 6, |
+ OUTCOME_REFRESH_INTERVAL_NOT_PASSED = 7, |
// Insert new values here! |
- OUTCOME_COUNT = 7 |
+ OUTCOME_COUNT = 8 |
}; |
static bool DownloadOutcomeIsSuccess(DownloadOutcome outcome); |
@@ -113,9 +113,16 @@ class DoodleService : public KeyedService { |
std::unique_ptr<base::Clock> clock_; |
std::unique_ptr<base::TickClock> tick_clock_; |
+ // The minimum interval between server fetches. After a successful fetch, |
+ // refresh requests are ignored for this period. |
+ const base::TimeDelta min_refresh_interval_; |
+ |
// The result of the last network fetch. |
base::Optional<DoodleConfig> cached_config_; |
+ // The time of the most recent successful fetch. |
+ base::TimeTicks last_successful_fetch_; |
+ |
// The list of observers to be notified when the DoodleConfig changes. |
base::ObserverList<Observer> observers_; |