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

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 #1 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
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 af047ac3af7da517dda41c378aa711cfd3cecd9c..ea575674ca800812191fb4cdb0284cbb242fba71 100644
--- a/components/ntp_snippets/ntp_snippets_service.cc
+++ b/components/ntp_snippets/ntp_snippets_service.cc
@@ -347,6 +347,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,
@@ -422,11 +424,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;
}
@@ -484,6 +481,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(

Powered by Google App Engine
This is Rietveld 408576698