Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(368)

Unified Diff: components/doodle/doodle_service.h

Issue 2729923003: [Doodle] Automatically expire Doodles after their TTL (Closed)
Patch Set: mastiz nits Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/doodle/doodle_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/doodle/doodle_service.h
diff --git a/components/doodle/doodle_service.h b/components/doodle/doodle_service.h
index f1265e72a3b4753cce78472f3e2d5bbef4a20fec..8913fbf144b8f76005fe457ebcfc947b723f1530 100644
--- a/components/doodle/doodle_service.h
+++ b/components/doodle/doodle_service.h
@@ -10,6 +10,7 @@
#include "base/macros.h"
#include "base/observer_list.h"
#include "base/optional.h"
+#include "base/timer/timer.h"
#include "components/doodle/doodle_fetcher.h"
#include "components/doodle/doodle_types.h"
@@ -26,7 +27,9 @@ class DoodleService {
virtual void OnDoodleConfigUpdated(const base::Optional<DoodleConfig>&) = 0;
};
- DoodleService(std::unique_ptr<DoodleFetcher> fetcher);
+ // Both |fetcher| and |expiry_timer| must be non-null.
+ DoodleService(std::unique_ptr<DoodleFetcher> fetcher,
+ std::unique_ptr<base::OneShotTimer> expiry_timer);
~DoodleService();
// Returns the current (cached) config, if any.
@@ -46,13 +49,21 @@ class DoodleService {
void Refresh();
private:
+ // Callback for the fetcher.
void DoodleFetched(DoodleState state,
base::TimeDelta time_to_live,
const base::Optional<DoodleConfig>& doodle_config);
+ void UpdateTimeToLive(base::TimeDelta time_to_live);
+
+ // Callback for the expiry timer.
+ void DoodleExpired();
+
// The fetcher for getting fresh DoodleConfigs from the network.
std::unique_ptr<DoodleFetcher> fetcher_;
+ std::unique_ptr<base::OneShotTimer> expiry_timer_;
+
// The result of the last network fetch.
base::Optional<DoodleConfig> cached_config_;
« no previous file with comments | « no previous file | components/doodle/doodle_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698