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

Side by Side Diff: chrome/browser/ntp_snippets/download_suggestions_provider.cc

Issue 2704203002: Merge "[NTP:Downloads] Request offline pages even if model is not ..." (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ntp_snippets/download_suggestions_provider_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/ntp_snippets/download_suggestions_provider.h" 5 #include "chrome/browser/ntp_snippets/download_suggestions_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 457
458 void DownloadSuggestionsProvider::AsynchronouslyFetchOfflinePagesDownloads( 458 void DownloadSuggestionsProvider::AsynchronouslyFetchOfflinePagesDownloads(
459 bool notify) { 459 bool notify) {
460 if (!offline_page_model_) { 460 if (!offline_page_model_) {
461 // Offline pages are explicitly turned off, so we propagate "no pages" 461 // Offline pages are explicitly turned off, so we propagate "no pages"
462 // further e.g. to clean its prefs. 462 // further e.g. to clean its prefs.
463 UpdateOfflinePagesCache(notify, std::vector<OfflinePageItem>()); 463 UpdateOfflinePagesCache(notify, std::vector<OfflinePageItem>());
464 return; 464 return;
465 } 465 }
466 466
467 if (!offline_page_model_->is_loaded()) { 467 // If Offline Page model is not loaded yet, it will process our query once it
468 // Offline pages model is not ready yet and may return no offline pages. 468 // has finished loading.
469 if (notify) {
470 SubmitContentSuggestions();
471 }
472
473 return;
474 }
475
476 offline_page_model_->GetPagesMatchingQuery( 469 offline_page_model_->GetPagesMatchingQuery(
477 BuildOfflinePageDownloadsQuery(offline_page_model_), 470 BuildOfflinePageDownloadsQuery(offline_page_model_),
478 base::Bind(&DownloadSuggestionsProvider::UpdateOfflinePagesCache, 471 base::Bind(&DownloadSuggestionsProvider::UpdateOfflinePagesCache,
479 weak_ptr_factory_.GetWeakPtr(), notify)); 472 weak_ptr_factory_.GetWeakPtr(), notify));
480 } 473 }
481 474
482 void DownloadSuggestionsProvider::FetchAssetsDownloads() { 475 void DownloadSuggestionsProvider::FetchAssetsDownloads() {
483 if (!download_manager_) { 476 if (!download_manager_) {
484 // The manager has gone down or was explicitly turned off. 477 // The manager has gone down or was explicitly turned off.
485 return; 478 return;
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 void DownloadSuggestionsProvider::UnregisterDownloadItemObservers() { 805 void DownloadSuggestionsProvider::UnregisterDownloadItemObservers() {
813 DCHECK_NE(download_manager_, nullptr); 806 DCHECK_NE(download_manager_, nullptr);
814 807
815 std::vector<DownloadItem*> all_downloads; 808 std::vector<DownloadItem*> all_downloads;
816 download_manager_->GetAllDownloads(&all_downloads); 809 download_manager_->GetAllDownloads(&all_downloads);
817 810
818 for (DownloadItem* item : all_downloads) { 811 for (DownloadItem* item : all_downloads) {
819 item->RemoveObserver(this); 812 item->RemoveObserver(this);
820 } 813 }
821 } 814 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ntp_snippets/download_suggestions_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698