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

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

Issue 2570673004: Remove host restrictions from snippets (Closed)
Patch Set: rebase Created 4 years 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/remote_suggestions_provider.h ('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/remote_suggestions_provider.h" 5 #include "components/ntp_snippets/remote/remote_suggestions_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 void RemoteSuggestionsProvider::FetchSnippetsInTheBackground() { 301 void RemoteSuggestionsProvider::FetchSnippetsInTheBackground() {
302 FetchSnippets(/*interactive_request=*/false); 302 FetchSnippets(/*interactive_request=*/false);
303 } 303 }
304 304
305 void RemoteSuggestionsProvider::FetchSnippetsForAllCategories() { 305 void RemoteSuggestionsProvider::FetchSnippetsForAllCategories() {
306 // TODO(markusheintz): Investigate whether we can call the Fetch method 306 // TODO(markusheintz): Investigate whether we can call the Fetch method
307 // instead of the FetchSnippets. 307 // instead of the FetchSnippets.
308 FetchSnippets(/*interactive_request=*/true); 308 FetchSnippets(/*interactive_request=*/true);
309 } 309 }
310 310
311 void RemoteSuggestionsProvider::FetchSnippets(bool interactive_request) { 311 void RemoteSuggestionsProvider::FetchSnippets(
312 // TODO(markusheintz): Merge the FetchSnippets into the 312 bool interactive_request) {
313 // FetchSnippetsInTheBackground method. 313 if (!ready()) {
314 if (ready()) {
315 FetchSnippetsFromHosts(std::set<std::string>(), interactive_request);
316 } else {
317 fetch_when_ready_ = true; 314 fetch_when_ready_ = true;
318 }
319 }
320
321 void RemoteSuggestionsProvider::FetchSnippetsFromHosts(
322 const std::set<std::string>& hosts,
323 bool interactive_request) {
324 // TODO(tschumann): FetchSnippets() and FetchSnippetsFromHost() implement the
325 // fetch logic when called by the background fetcher or interactive "reload"
326 // requests. Fetch() is right now only called for the fetch-more use case.
327 // The names are confusing and we need to clean them up.
328 if (!ready()) {
329 return; 315 return;
330 } 316 }
317
331 MarkEmptyCategoriesAsLoading(); 318 MarkEmptyCategoriesAsLoading();
332 319
333 NTPSnippetsFetcher::Params params = BuildFetchParams(); 320 NTPSnippetsFetcher::Params params = BuildFetchParams();
334 params.hosts = hosts;
335 params.interactive_request = interactive_request; 321 params.interactive_request = interactive_request;
336 snippets_fetcher_->FetchSnippets( 322 snippets_fetcher_->FetchSnippets(
337 params, base::BindOnce(&RemoteSuggestionsProvider::OnFetchFinished, 323 params, base::BindOnce(&RemoteSuggestionsProvider::OnFetchFinished,
338 base::Unretained(this), interactive_request)); 324 base::Unretained(this), interactive_request));
339 } 325 }
340 326
341 void RemoteSuggestionsProvider::Fetch( 327 void RemoteSuggestionsProvider::Fetch(
342 const Category& category, 328 const Category& category,
343 const std::set<std::string>& known_suggestion_ids, 329 const std::set<std::string>& known_suggestion_ids,
344 const FetchDoneCallback& callback) { 330 const FetchDoneCallback& callback) {
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 RemoteSuggestionsProvider::CategoryContent::CategoryContent(CategoryContent&&) = 1332 RemoteSuggestionsProvider::CategoryContent::CategoryContent(CategoryContent&&) =
1347 default; 1333 default;
1348 1334
1349 RemoteSuggestionsProvider::CategoryContent::~CategoryContent() = default; 1335 RemoteSuggestionsProvider::CategoryContent::~CategoryContent() = default;
1350 1336
1351 RemoteSuggestionsProvider::CategoryContent& 1337 RemoteSuggestionsProvider::CategoryContent&
1352 RemoteSuggestionsProvider::CategoryContent::operator=(CategoryContent&&) = 1338 RemoteSuggestionsProvider::CategoryContent::operator=(CategoryContent&&) =
1353 default; 1339 default;
1354 1340
1355 } // namespace ntp_snippets 1341 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/remote/remote_suggestions_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698