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

Side by Side Diff: components/ntp_snippets/remote/ntp_snippets_service.cc

Issue 2454063002: [NTP Snippets] Clean up NTPSnippetsFetcher (Closed)
Patch Set: review 2 Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « components/ntp_snippets/remote/ntp_snippets_fetcher_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/ntp_snippets/remote/ntp_snippets_service.h" 5 #include "components/ntp_snippets/remote/ntp_snippets_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 return; 247 return;
248 248
249 // Empty categories are marked as loading; others are unchanged. 249 // Empty categories are marked as loading; others are unchanged.
250 for (const auto& item : categories_) { 250 for (const auto& item : categories_) {
251 Category category = item.first; 251 Category category = item.first;
252 const CategoryContent& content = item.second; 252 const CategoryContent& content = item.second;
253 if (content.snippets.empty()) 253 if (content.snippets.empty())
254 UpdateCategoryStatus(category, CategoryStatus::AVAILABLE_LOADING); 254 UpdateCategoryStatus(category, CategoryStatus::AVAILABLE_LOADING);
255 } 255 }
256 256
257 std::set<std::string> excluded_ids; 257 NTPSnippetsFetcher::Params params;
258 params.language_code = application_language_code_;
259 params.count_to_fetch = kMaxSnippetCount;
260 params.hosts = hosts;
261 params.interactive_request = interactive_request;
258 for (const auto& item : categories_) { 262 for (const auto& item : categories_) {
259 const CategoryContent& content = item.second; 263 const CategoryContent& content = item.second;
260 for (const auto& snippet : content.dismissed) 264 for (const auto& snippet : content.dismissed)
261 excluded_ids.insert(snippet->id()); 265 params.excluded_ids.insert(snippet->id());
262 } 266 }
263 snippets_fetcher_->FetchSnippetsFromHosts(hosts, application_language_code_, 267 snippets_fetcher_->FetchSnippets(params);
264 excluded_ids, kMaxSnippetCount,
265 interactive_request);
266 } 268 }
267 269
268 void NTPSnippetsService::RescheduleFetching(bool force) { 270 void NTPSnippetsService::RescheduleFetching(bool force) {
269 // The scheduler only exists on Android so far, it's null on other platforms. 271 // The scheduler only exists on Android so far, it's null on other platforms.
270 if (!scheduler_) 272 if (!scheduler_)
271 return; 273 return;
272 274
273 if (ready()) { 275 if (ready()) {
274 base::TimeDelta old_interval_wifi = 276 base::TimeDelta old_interval_wifi =
275 base::TimeDelta::FromInternalValue(pref_service_->GetInt64( 277 base::TimeDelta::FromInternalValue(pref_service_->GetInt64(
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 } 1112 }
1111 1113
1112 NTPSnippetsService::CategoryContent::CategoryContent() = default; 1114 NTPSnippetsService::CategoryContent::CategoryContent() = default;
1113 NTPSnippetsService::CategoryContent::CategoryContent(CategoryContent&&) = 1115 NTPSnippetsService::CategoryContent::CategoryContent(CategoryContent&&) =
1114 default; 1116 default;
1115 NTPSnippetsService::CategoryContent::~CategoryContent() = default; 1117 NTPSnippetsService::CategoryContent::~CategoryContent() = default;
1116 NTPSnippetsService::CategoryContent& NTPSnippetsService::CategoryContent:: 1118 NTPSnippetsService::CategoryContent& NTPSnippetsService::CategoryContent::
1117 operator=(CategoryContent&&) = default; 1119 operator=(CategoryContent&&) = default;
1118 1120
1119 } // namespace ntp_snippets 1121 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/remote/ntp_snippets_fetcher_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698