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

Unified Diff: components/doodle/doodle_service.h

Issue 2729923003: [Doodle] Automatically expire Doodles after their TTL (Closed)
Patch Set: review 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') | components/doodle/doodle_service.cc » ('J')
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..32ed8d1fadc38a83dd30540e77ca2bd2e9bd72ff 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,8 @@ class DoodleService {
virtual void OnDoodleConfigUpdated(const base::Optional<DoodleConfig>&) = 0;
};
- DoodleService(std::unique_ptr<DoodleFetcher> fetcher);
+ DoodleService(std::unique_ptr<DoodleFetcher> fetcher,
+ std::unique_ptr<base::OneShotTimer> expiry_timer);
mastiz 2017/03/03 11:13:16 Can you document whether either of these two must
Marc Treib 2017/03/03 13:01:48 Neither may be null. Comment added.
~DoodleService();
// Returns the current (cached) config, if any.
@@ -46,16 +48,24 @@ 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_;
// The result of the last network fetch.
base::Optional<DoodleConfig> cached_config_;
+ std::unique_ptr<base::OneShotTimer> expiry_timer_;
mastiz 2017/03/03 11:13:16 Nit: move up before cached_config_, together with
Marc Treib 2017/03/03 13:01:48 Done.
+
// The list of observers to be notified when the DoodleConfig changes.
base::ObserverList<Observer> observers_;
« no previous file with comments | « no previous file | components/doodle/doodle_service.cc » ('j') | components/doodle/doodle_service.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698