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

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

Issue 2683383002: [NTP:Downloads] Request offline pages even if model is not loaded. (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
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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 485
486 void DownloadSuggestionsProvider::AsynchronouslyFetchOfflinePagesDownloads( 486 void DownloadSuggestionsProvider::AsynchronouslyFetchOfflinePagesDownloads(
487 bool notify) { 487 bool notify) {
488 if (!offline_page_model_) { 488 if (!offline_page_model_) {
489 // Offline pages are explicitly turned off, so we propagate "no pages" 489 // Offline pages are explicitly turned off, so we propagate "no pages"
490 // further e.g. to clean its prefs. 490 // further e.g. to clean its prefs.
491 UpdateOfflinePagesCache(notify, std::vector<OfflinePageItem>()); 491 UpdateOfflinePagesCache(notify, std::vector<OfflinePageItem>());
492 return; 492 return;
493 } 493 }
494 494
495 if (!offline_page_model_->is_loaded()) { 495 // If Offline Page model is not loaded yet, it will process our query once it
496 // Offline pages model is not ready yet and may return no offline pages. 496 // has finished loading.
497 if (notify) {
498 SubmitContentSuggestions();
Marc Treib 2017/02/10 09:08:11 So the change is essentially to *not* notify here?
vitaliii 2017/02/10 09:39:56 The change is to query even if the model has not b
Marc Treib 2017/02/10 10:05:02 Ah, I thought we'd query as soon as the model has
vitaliii 2017/02/10 12:54:11 But previously we would show incomplete list (with
499 }
500
501 return;
502 }
503
504 offline_page_model_->GetPagesMatchingQuery( 497 offline_page_model_->GetPagesMatchingQuery(
505 BuildOfflinePageDownloadsQuery(offline_page_model_), 498 BuildOfflinePageDownloadsQuery(offline_page_model_),
506 base::Bind(&DownloadSuggestionsProvider::UpdateOfflinePagesCache, 499 base::Bind(&DownloadSuggestionsProvider::UpdateOfflinePagesCache,
507 weak_ptr_factory_.GetWeakPtr(), notify)); 500 weak_ptr_factory_.GetWeakPtr(), notify));
508 } 501 }
509 502
510 void DownloadSuggestionsProvider::FetchAssetsDownloads() { 503 void DownloadSuggestionsProvider::FetchAssetsDownloads() {
511 if (!download_manager_) { 504 if (!download_manager_) {
512 // The manager has gone down or was explicitly turned off. 505 // The manager has gone down or was explicitly turned off.
513 return; 506 return;
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 void DownloadSuggestionsProvider::UnregisterDownloadItemObservers() { 851 void DownloadSuggestionsProvider::UnregisterDownloadItemObservers() {
859 DCHECK_NE(download_manager_, nullptr); 852 DCHECK_NE(download_manager_, nullptr);
860 853
861 std::vector<DownloadItem*> all_downloads; 854 std::vector<DownloadItem*> all_downloads;
862 download_manager_->GetAllDownloads(&all_downloads); 855 download_manager_->GetAllDownloads(&all_downloads);
863 856
864 for (DownloadItem* item : all_downloads) { 857 for (DownloadItem* item : all_downloads) {
865 item->RemoveObserver(this); 858 item->RemoveObserver(this);
866 } 859 }
867 } 860 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698