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

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: 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 Category category,
Marc Treib 2016/08/19 10:07:51 The category param isn't really required in the ca
Philipp Keck 2016/08/19 12:11:53 That's right. Why does ImageFetchedCallback have t
Marc Treib 2016/08/19 12:36:14 I don't know if there's a good reason for it in th
Philipp Keck 2016/08/19 14:20:40 Done.
35 std::vector<ContentSuggestion> dismissed_suggestions)>;
33 36
34 // The observer of a provider is notified when new data is available. 37 // The observer of a provider is notified when new data is available.
35 class Observer { 38 class Observer {
36 public: 39 public:
37 // Called when the available content changed. 40 // Called when the available content changed.
38 // If a provider provides suggestions for multiple categories, this callback 41 // If a provider provides suggestions for multiple categories, this callback
39 // is called once per category. The |suggestions| parameter always contains 42 // is called once per category. The |suggestions| parameter always contains
40 // the full list of currently available suggestions for that category, i.e., 43 // 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 44 // 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 45 // 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, 111 virtual void FetchSuggestionImage(const std::string& suggestion_id,
109 const ImageFetchedCallback& callback) = 0; 112 const ImageFetchedCallback& callback) = 0;
110 113
111 // Used only for debugging purposes. Clears all caches for the given category, 114 // Used only for debugging purposes. Clears all caches for the given category,
112 // so that the next fetch starts from scratch. 115 // so that the next fetch starts from scratch.
113 virtual void ClearCachedSuggestionsForDebugging(Category category) = 0; 116 virtual void ClearCachedSuggestionsForDebugging(Category category) = 0;
114 117
115 // Used only for debugging purposes. Retrieves suggestions for the given 118 // Used only for debugging purposes. Retrieves suggestions for the given
116 // |category| that have previously been dismissed and are still stored in the 119 // |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 120 // provider. If the provider doesn't store dismissed suggestions for the given
118 // |category|, it always returns an empty vector. 121 // |category|, it always calls the callback with an empty vector. The callback
119 virtual std::vector<ContentSuggestion> GetDismissedSuggestionsForDebugging( 122 // may be called synchronously.
120 Category category) = 0; 123 virtual void GetDismissedSuggestionsForDebugging(
124 Category category,
125 const DismissedSuggestionsCallback& callback) = 0;
121 126
122 // Used only for debugging purposes. Clears the cache of dismissed 127 // Used only for debugging purposes. Clears the cache of dismissed
123 // suggestions for the given |category|, if present, so that no suggestions 128 // suggestions for the given |category|, if present, so that no suggestions
124 // are suppressed. This does not necessarily make previously dismissed 129 // are suppressed. This does not necessarily make previously dismissed
125 // suggestions reappear, as they may have been permanently deleted, depending 130 // suggestions reappear, as they may have been permanently deleted, depending
126 // on the provider implementation. 131 // on the provider implementation.
127 virtual void ClearDismissedSuggestionsForDebugging(Category category) = 0; 132 virtual void ClearDismissedSuggestionsForDebugging(Category category) = 0;
128 133
129 protected: 134 protected:
130 ContentSuggestionsProvider(Observer* observer, 135 ContentSuggestionsProvider(Observer* observer,
(...skipping 16 matching lines...) Expand all
147 CategoryFactory* category_factory() const { return category_factory_; } 152 CategoryFactory* category_factory() const { return category_factory_; }
148 153
149 private: 154 private:
150 Observer* observer_; 155 Observer* observer_;
151 CategoryFactory* category_factory_; 156 CategoryFactory* category_factory_;
152 }; 157 };
153 158
154 } // namespace ntp_snippets 159 } // namespace ntp_snippets
155 160
156 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_PROVIDER_H_ 161 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698