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

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

Issue 2513393002: [NTP] Cleanup: offline pages related tests. (Closed)
Patch Set: rebase + treib@ comment. 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 | « 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 // Ignored. The internal caches are not stored on disk and they are just 231 // Ignored. The internal caches are not stored on disk and they are just
232 // partial copies of the data stored at OfflinePage model and DownloadManager. 232 // partial copies of the data stored at OfflinePage model and DownloadManager.
233 // If it is cleared there, it will be cleared in these caches as well. 233 // If it is cleared there, it will be cleared in these caches as well.
234 } 234 }
235 235
236 void DownloadSuggestionsProvider::GetDismissedSuggestionsForDebugging( 236 void DownloadSuggestionsProvider::GetDismissedSuggestionsForDebugging(
237 Category category, 237 Category category,
238 const ntp_snippets::DismissedSuggestionsCallback& callback) { 238 const ntp_snippets::DismissedSuggestionsCallback& callback) {
239 DCHECK_EQ(provided_category_, category); 239 DCHECK_EQ(provided_category_, category);
240 240
241 // TODO(vitaliii): Query all pages instead by using an empty query.
242 if (offline_page_model_) { 241 if (offline_page_model_) {
242 // Offline pages which are not related to downloads are also queried here,
243 // so that they can be returned if they happen to be dismissed (e.g. due to
244 // a bug).
245 OfflinePageModelQueryBuilder query_builder;
243 offline_page_model_->GetPagesMatchingQuery( 246 offline_page_model_->GetPagesMatchingQuery(
244 BuildOfflinePageDownloadsQuery(offline_page_model_), 247 query_builder.Build(offline_page_model_->GetPolicyController()),
245 base::Bind(&DownloadSuggestionsProvider:: 248 base::Bind(&DownloadSuggestionsProvider::
246 GetPagesMatchingQueryCallbackForGetDismissedSuggestions, 249 GetPagesMatchingQueryCallbackForGetDismissedSuggestions,
247 weak_ptr_factory_.GetWeakPtr(), callback)); 250 weak_ptr_factory_.GetWeakPtr(), callback));
248 } else { 251 } else {
249 GetPagesMatchingQueryCallbackForGetDismissedSuggestions( 252 GetPagesMatchingQueryCallbackForGetDismissedSuggestions(
250 callback, std::vector<OfflinePageItem>()); 253 callback, std::vector<OfflinePageItem>());
251 } 254 }
252 } 255 }
253 256
254 void DownloadSuggestionsProvider::ClearDismissedSuggestionsForDebugging( 257 void DownloadSuggestionsProvider::ClearDismissedSuggestionsForDebugging(
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 void DownloadSuggestionsProvider::UnregisterDownloadItemObservers() { 745 void DownloadSuggestionsProvider::UnregisterDownloadItemObservers() {
743 DCHECK_NE(download_manager_, nullptr); 746 DCHECK_NE(download_manager_, nullptr);
744 747
745 std::vector<DownloadItem*> all_downloads; 748 std::vector<DownloadItem*> all_downloads;
746 download_manager_->GetAllDownloads(&all_downloads); 749 download_manager_->GetAllDownloads(&all_downloads);
747 750
748 for (DownloadItem* item : all_downloads) { 751 for (DownloadItem* item : all_downloads) {
749 item->RemoveObserver(this); 752 item->RemoveObserver(this);
750 } 753 }
751 } 754 }
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