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

Side by Side Diff: components/ntp_snippets/content_suggestions_provider.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_PROVIDER_H_ 5 #ifndef COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_PROVIDER_H_
6 #define COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_PROVIDER_H_ 6 #define COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_PROVIDER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 12 matching lines...) Expand all
23 // Provides content suggestions from one particular source. 23 // Provides content suggestions from one particular source.
24 // A provider can provide suggestions for multiple ContentSuggestionCategories, 24 // A provider can provide suggestions for multiple ContentSuggestionCategories,
25 // but for every category that it provides, it will be the only provider in the 25 // but for every category that it provides, it will be the only provider in the
26 // system which provides suggestions for that category. 26 // system which provides suggestions for that category.
27 // Providers are created by the ContentSuggestionsServiceFactory and owned and 27 // Providers are created by the ContentSuggestionsServiceFactory and owned and
28 // shut down by the ContentSuggestionsService. 28 // shut down by the ContentSuggestionsService.
29 class ContentSuggestionsProvider { 29 class ContentSuggestionsProvider {
30 public: 30 public:
31 using ImageFetchedCallback = 31 using ImageFetchedCallback =
32 base::Callback<void(const std::string& suggestion_id, const gfx::Image&)>; 32 base::Callback<void(const std::string& suggestion_id, const gfx::Image&)>;
33 using DismissedSuggestionsCallback = base::Callback<void(
34 std::vector<ContentSuggestion> dismissed_suggestions)>;
33 35
34 // The observer of a provider is notified when new data is available. 36 // The observer of a provider is notified when new data is available.
35 class Observer { 37 class Observer {
36 public: 38 public:
37 // Called when the available content changed. 39 // Called when the available content changed.
38 // If a provider provides suggestions for multiple categories, this callback 40 // If a provider provides suggestions for multiple categories, this callback
39 // is called once per category. The |suggestions| parameter always contains 41 // is called once per category. The |suggestions| parameter always contains
40 // the full list of currently available suggestions for that category, i.e., 42 // the full list of currently available suggestions for that category, i.e.,
41 // an empty list will remove all suggestions from the given category. Note 43 // an empty list will remove all suggestions from the given category. Note
42 // that to clear them from the UI immediately, the provider needs to change 44 // that to clear them from the UI immediately, the provider needs to change
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 virtual void FetchSuggestionImage(const std::string& suggestion_id, 110 virtual void FetchSuggestionImage(const std::string& suggestion_id,
109 const ImageFetchedCallback& callback) = 0; 111 const ImageFetchedCallback& callback) = 0;
110 112
111 // Used only for debugging purposes. Clears all caches for the given category, 113 // Used only for debugging purposes. Clears all caches for the given category,
112 // so that the next fetch starts from scratch. 114 // so that the next fetch starts from scratch.
113 virtual void ClearCachedSuggestionsForDebugging(Category category) = 0; 115 virtual void ClearCachedSuggestionsForDebugging(Category category) = 0;
114 116
115 // Used only for debugging purposes. Retrieves suggestions for the given 117 // Used only for debugging purposes. Retrieves suggestions for the given
116 // |category| that have previously been dismissed and are still stored in the 118 // |category| that have previously been dismissed and are still stored in the
117 // provider. If the provider doesn't store dismissed suggestions for the given 119 // provider. If the provider doesn't store dismissed suggestions for the given
118 // |category|, it always returns an empty vector. 120 // |category|, it always calls the callback with an empty vector. The callback
119 virtual std::vector<ContentSuggestion> GetDismissedSuggestionsForDebugging( 121 // may be called synchronously.
120 Category category) = 0; 122 virtual void GetDismissedSuggestionsForDebugging(
123 Category category,
124 const DismissedSuggestionsCallback& callback) = 0;
121 125
122 // Used only for debugging purposes. Clears the cache of dismissed 126 // Used only for debugging purposes. Clears the cache of dismissed
123 // suggestions for the given |category|, if present, so that no suggestions 127 // suggestions for the given |category|, if present, so that no suggestions
124 // are suppressed. This does not necessarily make previously dismissed 128 // are suppressed. This does not necessarily make previously dismissed
125 // suggestions reappear, as they may have been permanently deleted, depending 129 // suggestions reappear, as they may have been permanently deleted, depending
126 // on the provider implementation. 130 // on the provider implementation.
127 virtual void ClearDismissedSuggestionsForDebugging(Category category) = 0; 131 virtual void ClearDismissedSuggestionsForDebugging(Category category) = 0;
128 132
129 protected: 133 protected:
130 ContentSuggestionsProvider(Observer* observer, 134 ContentSuggestionsProvider(Observer* observer,
(...skipping 16 matching lines...) Expand all
147 CategoryFactory* category_factory() const { return category_factory_; } 151 CategoryFactory* category_factory() const { return category_factory_; }
148 152
149 private: 153 private:
150 Observer* observer_; 154 Observer* observer_;
151 CategoryFactory* category_factory_; 155 CategoryFactory* category_factory_;
152 }; 156 };
153 157
154 } // namespace ntp_snippets 158 } // namespace ntp_snippets
155 159
156 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_PROVIDER_H_ 160 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698