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

Side by Side Diff: components/ntp_snippets/content_suggestions_service.h

Issue 2260783002: Make GetDismissedSuggestionsForDebugging asynchronous (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 #ifndef COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_ 5 #ifndef COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_
6 #define COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_ 6 #define COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 15 matching lines...) Expand all
26 26
27 class NTPSnippetsService; 27 class NTPSnippetsService;
28 28
29 // Retrieves suggestions from a number of ContentSuggestionsProviders and serves 29 // Retrieves suggestions from a number of ContentSuggestionsProviders and serves
30 // them grouped into categories. There can be at most one provider per category. 30 // them grouped into categories. There can be at most one provider per category.
31 class ContentSuggestionsService : public KeyedService, 31 class ContentSuggestionsService : public KeyedService,
32 public ContentSuggestionsProvider::Observer { 32 public ContentSuggestionsProvider::Observer {
33 public: 33 public:
34 using ImageFetchedCallback = 34 using ImageFetchedCallback =
35 base::Callback<void(const std::string& suggestion_id, const gfx::Image&)>; 35 base::Callback<void(const std::string& suggestion_id, const gfx::Image&)>;
36 using DismissedSuggestionsCallback = base::Callback<void(
37 Category category,
38 std::vector<ContentSuggestion> dismissed_suggestions)>;
36 39
37 class Observer { 40 class Observer {
38 public: 41 public:
39 // Fired every time the service receives a new set of data for the given 42 // Fired every time the service receives a new set of data for the given
40 // |category|, replacing any previously available data (though in most cases 43 // |category|, replacing any previously available data (though in most cases
41 // there will be an overlap and only a few changes within the data). The new 44 // there will be an overlap and only a few changes within the data). The new
42 // data is then available through |GetSuggestionsForCategory(category)|. 45 // data is then available through |GetSuggestionsForCategory(category)|.
43 virtual void OnNewSuggestions(Category category) = 0; 46 virtual void OnNewSuggestions(Category category) = 0;
44 47
45 // Fired when the status of a suggestions category changed. When the status 48 // Fired when the status of a suggestions category changed. When the status
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // stores in the service and the corresponding provider. It does, however, not 131 // stores in the service and the corresponding provider. It does, however, not
129 // remove any suggestions from the provider's sources, so if its configuration 132 // remove any suggestions from the provider's sources, so if its configuration
130 // hasn't changed, it might return the same results when it fetches the next 133 // hasn't changed, it might return the same results when it fetches the next
131 // time. In particular, calling this method will not mark any suggestions as 134 // time. In particular, calling this method will not mark any suggestions as
132 // dismissed. 135 // dismissed.
133 void ClearCachedSuggestionsForDebugging(Category category); 136 void ClearCachedSuggestionsForDebugging(Category category);
134 137
135 // Only for debugging use through the internals page. 138 // Only for debugging use through the internals page.
136 // Retrieves suggestions of the given |category| that have previously been 139 // Retrieves suggestions of the given |category| that have previously been
137 // dismissed and are still stored in the respective provider. If the 140 // dismissed and are still stored in the respective provider. If the
138 // provider doesn't store dismissed suggestions, this returns an empty vector. 141 // provider doesn't store dismissed suggestions, the callback receives an
139 std::vector<ContentSuggestion> GetDismissedSuggestionsForDebugging( 142 // empty vector. The callback may be called synchronously.
140 Category category); 143 void GetDismissedSuggestionsForDebugging(
144 Category category,
145 const DismissedSuggestionsCallback& callback);
141 146
142 // Only for debugging use through the internals page. Some providers 147 // Only for debugging use through the internals page. Some providers
143 // internally store a list of dismissed suggestions to prevent them from 148 // internally store a list of dismissed suggestions to prevent them from
144 // reappearing. This function clears all suggestions of the given |category| 149 // reappearing. This function clears all suggestions of the given |category|
145 // from such lists, making dismissed suggestions reappear (if the provider 150 // from such lists, making dismissed suggestions reappear (if the provider
146 // supports it). 151 // supports it).
147 void ClearDismissedSuggestionsForDebugging(Category category); 152 void ClearDismissedSuggestionsForDebugging(Category category);
148 153
149 CategoryFactory* category_factory() { return &category_factory_; } 154 CategoryFactory* category_factory() { return &category_factory_; }
150 155
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 // background fetching and debugging calls to it. If the NTPSnippetsService is 230 // background fetching and debugging calls to it. If the NTPSnippetsService is
226 // loaded, it is also present in |providers_|, otherwise this is a nullptr. 231 // loaded, it is also present in |providers_|, otherwise this is a nullptr.
227 NTPSnippetsService* ntp_snippets_service_; 232 NTPSnippetsService* ntp_snippets_service_;
228 233
229 DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsService); 234 DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsService);
230 }; 235 };
231 236
232 } // namespace ntp_snippets 237 } // namespace ntp_snippets
233 238
234 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_ 239 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698