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

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

Issue 2446163005: [NTP Snippets] FetchMore backend (Closed)
Patch Set: Address comments from https://codereview.chromium.org/2421463002/ Created 4 years, 1 month 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 13 matching lines...) Expand all
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 = base::Callback<void(const gfx::Image&)>; 31 using ImageFetchedCallback = base::Callback<void(const gfx::Image&)>;
32 using DismissedSuggestionsCallback = base::Callback<void( 32 using DismissedSuggestionsCallback = base::Callback<void(
33 std::vector<ContentSuggestion> dismissed_suggestions)>; 33 std::vector<ContentSuggestion> dismissed_suggestions)>;
34 using FetchedMoreCallback =
35 base::Callback<void(std::vector<ContentSuggestion> suggestions)>;
34 36
35 // 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.
36 class Observer { 38 class Observer {
37 public: 39 public:
38 // Called when the available content changed. 40 // Called when the available content changed.
39 // If a provider provides suggestions for multiple categories, this callback 41 // If a provider provides suggestions for multiple categories, this callback
40 // is called once per category. The |suggestions| parameter always contains 42 // is called once per category. The |suggestions| parameter always contains
41 // 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.,
42 // 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
43 // 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 const ContentSuggestion::ID& suggestion_id) = 0; 95 const ContentSuggestion::ID& suggestion_id) = 0;
94 96
95 // Fetches the image for the suggestion with the given ID and returns it 97 // Fetches the image for the suggestion with the given ID and returns it
96 // through the callback. This fetch may occur locally or from the internet. 98 // through the callback. This fetch may occur locally or from the internet.
97 // If that suggestion doesn't exist, doesn't have an image or if the fetch 99 // If that suggestion doesn't exist, doesn't have an image or if the fetch
98 // fails, the callback gets a null image. The callback will not be called 100 // fails, the callback gets a null image. The callback will not be called
99 // synchronously. 101 // synchronously.
100 virtual void FetchSuggestionImage(const ContentSuggestion::ID& suggestion_id, 102 virtual void FetchSuggestionImage(const ContentSuggestion::ID& suggestion_id,
101 const ImageFetchedCallback& callback) = 0; 103 const ImageFetchedCallback& callback) = 0;
102 104
105 // A user-triggered request to fetch more content for the given category.
106 // Provides only suggestions that have not been provided. The given |callback|
107 // is called with these suggestion, along with all existing suggestions.
108 virtual void FetchMore(const Category& category,
Bernhard Bauer 2016/10/28 16:25:59 If the plan is to migrate from the Observer to thi
fhorschig 2016/11/02 05:06:12 Done.
109 FetchedMoreCallback callback) = 0;
110
103 // Removes history from the specified time range where the URL matches the 111 // Removes history from the specified time range where the URL matches the
104 // |filter|. The data removed depends on the provider. Note that the 112 // |filter|. The data removed depends on the provider. Note that the
105 // data outside the time range may be deleted, for example suggestions, which 113 // data outside the time range may be deleted, for example suggestions, which
106 // are based on history from that time range. Providers should immediately 114 // are based on history from that time range. Providers should immediately
107 // clear any data related to history from the specified time range where the 115 // clear any data related to history from the specified time range where the
108 // URL matches the |filter|. 116 // URL matches the |filter|.
109 virtual void ClearHistory( 117 virtual void ClearHistory(
110 base::Time begin, 118 base::Time begin,
111 base::Time end, 119 base::Time end,
112 const base::Callback<bool(const GURL& url)>& filter) = 0; 120 const base::Callback<bool(const GURL& url)>& filter) = 0;
(...skipping 26 matching lines...) Expand all
139 CategoryFactory* category_factory() const { return category_factory_; } 147 CategoryFactory* category_factory() const { return category_factory_; }
140 148
141 private: 149 private:
142 Observer* observer_; 150 Observer* observer_;
143 CategoryFactory* category_factory_; 151 CategoryFactory* category_factory_;
144 }; 152 };
145 153
146 } // namespace ntp_snippets 154 } // namespace ntp_snippets
147 155
148 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_PROVIDER_H_ 156 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698