Chromium Code Reviews| Index: components/ntp_snippets/remote/ntp_snippets_service.cc |
| diff --git a/components/ntp_snippets/remote/ntp_snippets_service.cc b/components/ntp_snippets/remote/ntp_snippets_service.cc |
| index b8c5a194c05fd203dd70396e512ffd842ae96c8c..bb46d9d97687df5fff16bd460df11cb5e17b46a1 100644 |
| --- a/components/ntp_snippets/remote/ntp_snippets_service.cc |
| +++ b/components/ntp_snippets/remote/ntp_snippets_service.cc |
| @@ -569,7 +569,7 @@ void NTPSnippetsService::OnSuggestionsChanged( |
| } |
| void NTPSnippetsService::OnFetchFinished( |
| - NTPSnippetsFetcher::OptionalSnippets snippets) { |
| + NTPSnippetsFetcher::OptionalFetchedCategories fetched_categories) { |
| if (!ready()) |
| return; |
| @@ -583,10 +583,11 @@ void NTPSnippetsService::OnFetchFinished( |
| // If snippets were fetched successfully, update our |categories_| from each |
| // category provided by the server. |
| - if (snippets) { |
| + if (fetched_categories) { |
| // TODO(jkrcal): A bit hard to understand with so many variables called |
| // "*categor*". Isn't here some room for simplification? |
| - for (NTPSnippetsFetcher::FetchedCategory& fetched_category : *snippets) { |
| + for (NTPSnippetsFetcher::FetchedCategory& fetched_category : |
| + *fetched_categories) { |
| Category category = fetched_category.category; |
| // TODO(sfiera): Avoid hard-coding articles category checks in so many |
| @@ -598,11 +599,10 @@ void NTPSnippetsService::OnFetchFinished( |
| } |
| categories_[category].provided_by_server = true; |
| - DCHECK_LE(snippets->size(), static_cast<size_t>(kMaxSnippetCount)); |
| - // TODO(sfiera): histograms for server categories. |
| - // Sparse histogram used because the number of snippets is small (bound by |
| - // kMaxSnippetCount). |
| - if (category == articles_category_) { |
| + // TODO(tschumann): Remove this histogram once we only talk to the content |
| + // suggestions cloud backend. |
| + if (category == articles_category_ && |
| + fetched_category.snippets.size() <= kMaxSnippetCount) { |
|
Marc Treib
2016/10/06 15:36:13
I'd prefer capping at kMaxSnippetCount, rather tha
tschumann
2016/10/06 17:57:42
Done.
|
| UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.Snippets.NumArticlesFetched", |
| fetched_category.snippets.size()); |
| } |
| @@ -631,7 +631,7 @@ void NTPSnippetsService::OnFetchFinished( |
| // fetches, to make sure the fallback interval triggers only if no wifi fetch |
| // succeeded, and also that we don't do a background fetch immediately after |
| // a user-initiated one. |
| - if (snippets) |
| + if (fetched_categories) |
| RescheduleFetching(true); |
| } |