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

Unified Diff: components/ntp_snippets/ntp_snippets_service.cc

Issue 1723493002: [NTP Snippets] Fetch/load snippets on startup, and pass them on NTP creation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gcmtaskservice
Patch Set: Created 4 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
Index: components/ntp_snippets/ntp_snippets_service.cc
diff --git a/components/ntp_snippets/ntp_snippets_service.cc b/components/ntp_snippets/ntp_snippets_service.cc
index 98e823d23ea5ed77a8592cd06e94c30a81bd6129..b68911ba00c03953b23eaf1678019165eedca1fa 100644
--- a/components/ntp_snippets/ntp_snippets_service.cc
+++ b/components/ntp_snippets/ntp_snippets_service.cc
@@ -49,6 +49,11 @@ NTPSnippetsService::NTPSnippetsService(
NTPSnippetsService::~NTPSnippetsService() {}
void NTPSnippetsService::Init(bool enabled) {
+ // If enabled, get snippets immediately. If we've downloaded them before,
+ // this will just read from disk.
+ if (enabled)
+ FetchSnippets(false);
+
// The scheduler only exists on Android so far, it's null on other platforms.
if (!scheduler_)
return;
@@ -84,6 +89,8 @@ void NTPSnippetsService::OnFileReadDone(const std::string& json) {
}
bool NTPSnippetsService::LoadFromJSONString(const std::string& str) {
+ snippets_.clear();
+
JSONStringValueDeserializer deserializer(str);
int error_code;
std::string error_message;

Powered by Google App Engine
This is Rietveld 408576698