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

Unified Diff: components/ntp_snippets/ntp_snippets_service.h

Issue 2051823003: [NTP Snippets] More reliable service initialization (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/ntp_snippets/ntp_snippets_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_snippets/ntp_snippets_service.h
diff --git a/components/ntp_snippets/ntp_snippets_service.h b/components/ntp_snippets/ntp_snippets_service.h
index a1a7090fbd684ce428703a46913127951d069bd5..fad27ab7e665d649fbdd8dccb2234d728026a086 100644
--- a/components/ntp_snippets/ntp_snippets_service.h
+++ b/components/ntp_snippets/ntp_snippets_service.h
@@ -177,7 +177,6 @@ class NTPSnippetsService : public KeyedService,
// The service registered observers, timers, etc. and is ready to answer to
// queries, fetch snippets... Can change to states:
- // - READY: noop
// - DISABLED: when the global Chrome state changes, for example after
// |OnStateChanged| is called and sync is disabled.
// - SHUT_DOWN: when |Shutdown| is called, during the browser shutdown.
@@ -185,7 +184,6 @@ class NTPSnippetsService : public KeyedService,
// The service is disabled and unregistered the related resources.
// Can change to states:
- // - DISABLED: noop
// - READY: when the global Chrome state changes, for example after
// |OnStateChanged| is called and sync is enabled.
// - SHUT_DOWN: when |Shutdown| is called, during the browser shutdown.
@@ -214,6 +212,14 @@ class NTPSnippetsService : public KeyedService,
std::set<std::string> GetSnippetHostsFromPrefs() const;
void StoreSnippetHostsToPrefs(const std::set<std::string>& hosts);
+ // Removes the expired snippets (including discarded) from the service and the
+ // database, and schedules another pass for the next expiration.
+ void ClearExpiredSnippets();
+
+ // Completes the initialization phase of the service, registering the last
+ // observers. This is done after construction, once the database is loaded.
+ void FinishInitialization();
+
void LoadingSnippetsFinished();
// Returns whether the service should be enabled or disable depending on its
@@ -221,6 +227,7 @@ class NTPSnippetsService : public KeyedService,
State GetStateForDependenciesStatus();
// Verifies state transitions (see |State|'s documentation) and applies them.
+ // Does nothing if called with the current state.
void EnterState(State state);
// Enables the service and triggers a fetch if required. Do not call directly,
« no previous file with comments | « no previous file | components/ntp_snippets/ntp_snippets_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698