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

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: rebase 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
« no previous file with comments | « chrome/browser/android/ntp_snippets_bridge.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 fd031e322aeef767def74ed473a30c619ca46b09..c696405d82fc58ec56c79ca21a2d7ced803a2938 100644
--- a/components/ntp_snippets/ntp_snippets_service.cc
+++ b/components/ntp_snippets/ntp_snippets_service.cc
@@ -48,6 +48,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;
@@ -87,6 +92,8 @@ void NTPSnippetsService::OnFileReadDone(const std::string* json, bool success) {
}
bool NTPSnippetsService::LoadFromJSONString(const std::string& str) {
+ snippets_.clear();
+
JSONStringValueDeserializer deserializer(str);
int error_code;
std::string error_message;
« no previous file with comments | « chrome/browser/android/ntp_snippets_bridge.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698