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

Side by Side Diff: components/ntp_snippets/bookmarks/bookmark_suggestions_provider.cc

Issue 2260783002: Make GetDismissedSuggestionsForDebugging asynchronous (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replace function pointer, use multiple if-continue Created 4 years, 4 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 "components/ntp_snippets/bookmarks/bookmark_suggestions_provider.h" 5 #include "components/ntp_snippets/bookmarks/bookmark_suggestions_provider.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 base::ThreadTaskRunnerHandle::Get()->PostTask( 120 base::ThreadTaskRunnerHandle::Get()->PostTask(
121 FROM_HERE, base::Bind(callback, suggestion_id, gfx::Image())); 121 FROM_HERE, base::Bind(callback, suggestion_id, gfx::Image()));
122 } 122 }
123 123
124 void BookmarkSuggestionsProvider::ClearCachedSuggestionsForDebugging( 124 void BookmarkSuggestionsProvider::ClearCachedSuggestionsForDebugging(
125 Category category) { 125 Category category) {
126 DCHECK_EQ(category, provided_category_); 126 DCHECK_EQ(category, provided_category_);
127 // Ignored. 127 // Ignored.
128 } 128 }
129 129
130 std::vector<ContentSuggestion> 130 void BookmarkSuggestionsProvider::GetDismissedSuggestionsForDebugging(
131 BookmarkSuggestionsProvider::GetDismissedSuggestionsForDebugging( 131 Category category,
132 Category category) { 132 const DismissedSuggestionsCallback& callback) {
133 DCHECK_EQ(category, provided_category_); 133 DCHECK_EQ(category, provided_category_);
134 std::vector<const BookmarkNode*> bookmarks = 134 std::vector<const BookmarkNode*> bookmarks =
135 GetDismissedBookmarksForDebugging(bookmark_model_); 135 GetDismissedBookmarksForDebugging(bookmark_model_);
136 136
137 std::vector<ContentSuggestion> suggestions; 137 std::vector<ContentSuggestion> suggestions;
138 for (const BookmarkNode* bookmark : bookmarks) 138 for (const BookmarkNode* bookmark : bookmarks)
139 suggestions.emplace_back(ConvertBookmark(bookmark)); 139 suggestions.emplace_back(ConvertBookmark(bookmark));
140 return suggestions; 140 callback.Run(std::move(suggestions));
141 } 141 }
142 142
143 void BookmarkSuggestionsProvider::ClearDismissedSuggestionsForDebugging( 143 void BookmarkSuggestionsProvider::ClearDismissedSuggestionsForDebugging(
144 Category category) { 144 Category category) {
145 DCHECK_EQ(category, provided_category_); 145 DCHECK_EQ(category, provided_category_);
146 if (!bookmark_model_->loaded()) 146 if (!bookmark_model_->loaded())
147 return; 147 return;
148 MarkAllBookmarksUndismissed(bookmark_model_); 148 MarkAllBookmarksUndismissed(bookmark_model_);
149 } 149 }
150 150
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 238
239 void BookmarkSuggestionsProvider::NotifyStatusChanged( 239 void BookmarkSuggestionsProvider::NotifyStatusChanged(
240 CategoryStatus new_status) { 240 CategoryStatus new_status) {
241 if (category_status_ == new_status) 241 if (category_status_ == new_status)
242 return; 242 return;
243 category_status_ = new_status; 243 category_status_ = new_status;
244 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); 244 observer()->OnCategoryStatusChanged(this, provided_category_, new_status);
245 } 245 }
246 246
247 } // namespace ntp_snippets 247 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698