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

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: 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 #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 std::vector<ContentSuggestion> dismissed_suggestions)>;
36 38
37 class Observer { 39 class Observer {
38 public: 40 public:
39 // Fired every time the service receives a new set of data for the given 41 // 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 42 // |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 43 // there will be an overlap and only a few changes within the data). The new
42 // data is then available through |GetSuggestionsForCategory(category)|. 44 // data is then available through |GetSuggestionsForCategory(category)|.
43 virtual void OnNewSuggestions(Category category) = 0; 45 virtual void OnNewSuggestions(Category category) = 0;
44 46
45 // Fired when the status of a suggestions category changed. When the status 47 // 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 130 // 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 131 // 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 132 // 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 133 // time. In particular, calling this method will not mark any suggestions as
132 // dismissed. 134 // dismissed.
133 void ClearCachedSuggestionsForDebugging(Category category); 135 void ClearCachedSuggestionsForDebugging(Category category);
134 136
135 // Only for debugging use through the internals page. 137 // Only for debugging use through the internals page.
136 // Retrieves suggestions of the given |category| that have previously been 138 // Retrieves suggestions of the given |category| that have previously been
137 // dismissed and are still stored in the respective provider. If the 139 // dismissed and are still stored in the respective provider. If the
138 // provider doesn't store dismissed suggestions, this returns an empty vector. 140 // provider doesn't store dismissed suggestions, the callback receives an
139 std::vector<ContentSuggestion> GetDismissedSuggestionsForDebugging( 141 // empty vector. The callback may be called synchronously.
140 Category category); 142 void GetDismissedSuggestionsForDebugging(
143 Category category,
144 const DismissedSuggestionsCallback& callback);
141 145
142 // Only for debugging use through the internals page. Some providers 146 // Only for debugging use through the internals page. Some providers
143 // internally store a list of dismissed suggestions to prevent them from 147 // internally store a list of dismissed suggestions to prevent them from
144 // reappearing. This function clears all suggestions of the given |category| 148 // reappearing. This function clears all suggestions of the given |category|
145 // from such lists, making dismissed suggestions reappear (if the provider 149 // from such lists, making dismissed suggestions reappear (if the provider
146 // supports it). 150 // supports it).
147 void ClearDismissedSuggestionsForDebugging(Category category); 151 void ClearDismissedSuggestionsForDebugging(Category category);
148 152
149 CategoryFactory* category_factory() { return &category_factory_; } 153 CategoryFactory* category_factory() { return &category_factory_; }
150 154
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 // background fetching and debugging calls to it. If the NTPSnippetsService is 229 // background fetching and debugging calls to it. If the NTPSnippetsService is
226 // loaded, it is also present in |providers_|, otherwise this is a nullptr. 230 // loaded, it is also present in |providers_|, otherwise this is a nullptr.
227 NTPSnippetsService* ntp_snippets_service_; 231 NTPSnippetsService* ntp_snippets_service_;
228 232
229 DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsService); 233 DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsService);
230 }; 234 };
231 235
232 } // namespace ntp_snippets 236 } // namespace ntp_snippets
233 237
234 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_ 238 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_
OLDNEW
« no previous file with comments | « components/ntp_snippets/content_suggestions_provider.h ('k') | components/ntp_snippets/content_suggestions_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698