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

Unified Diff: components/ntp_snippets/ntp_snippets_service.cc

Issue 1927993002: Allow dumping raw json fetched from the server. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: After code review #2 Created 4 years, 8 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 | « components/ntp_snippets/ntp_snippets_service.h ('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 96abae0e29d6dfe3fd741884712be99f1719456d..5eddd097b2b5b1d356165e4d25e213276f930d92 100644
--- a/components/ntp_snippets/ntp_snippets_service.cc
+++ b/components/ntp_snippets/ntp_snippets_service.cc
@@ -348,6 +348,8 @@ void NTPSnippetsService::OnSnippetsDownloaded(
if (!snippets_json.empty()) {
DCHECK(status.empty());
+ last_fetch_json_ = snippets_json;
+
parse_json_callback_.Run(
snippets_json,
base::Bind(&NTPSnippetsService::OnJsonParsed,
@@ -423,11 +425,6 @@ bool NTPSnippetsService::LoadFromListValue(const base::ListValue& list) {
std::make_move_iterator(new_snippets.begin()),
std::make_move_iterator(new_snippets.end()));
- // If there are more snippets now than we want to show, drop the extra ones
- // from the end of the list.
- if (snippets_.size() > kMaxSnippetCount)
- snippets_.resize(kMaxSnippetCount);
-
return true;
}
@@ -485,6 +482,12 @@ void NTPSnippetsService::LoadingSnippetsFinished() {
return snippet->expiry_date() <= expiry;
}),
snippets_.end());
+
+ // If there are more snippets now than we want to show, drop the extra ones
+ // from the end of the list.
+ if (snippets_.size() > kMaxSnippetCount)
+ snippets_.resize(kMaxSnippetCount);
+
StoreSnippetsToPrefs();
discarded_snippets_.erase(
« no previous file with comments | « components/ntp_snippets/ntp_snippets_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698