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

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

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

Powered by Google App Engine
This is Rietveld 408576698