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

Unified Diff: components/ntp_snippets/content_suggestions_provider.h

Issue 2205233002: Combine all suggestions factories into ContentSuggestionsServiceFactory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bernhard's comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/chrome_browser.gypi ('k') | components/ntp_snippets/content_suggestions_provider.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_snippets/content_suggestions_provider.h
diff --git a/components/ntp_snippets/content_suggestions_provider.h b/components/ntp_snippets/content_suggestions_provider.h
index c8bffd72673443c4c202759e82653141c95bdeca..066ea1e1f23d9ae4c9756a598c91f750e38abb49 100644
--- a/components/ntp_snippets/content_suggestions_provider.h
+++ b/components/ntp_snippets/content_suggestions_provider.h
@@ -23,8 +23,8 @@ namespace ntp_snippets {
// A provider can provide suggestions for multiple ContentSuggestionCategories,
// but for every category that it provides, it will be the only provider in the
// system which provides suggestions for that category.
-// A provider can be a keyed service, in which case it should notify the
-// ContentSuggestionsService through the observer before it shuts down.
+// Providers are created by the ContentSuggestionsServiceFactory and owned and
+// shut down by the ContentSuggestionsService.
class ContentSuggestionsProvider {
public:
using ImageFetchedCallback =
@@ -63,16 +63,9 @@ class ContentSuggestionsProvider {
virtual void OnCategoryStatusChanged(ContentSuggestionsProvider* provider,
Category category,
CategoryStatus new_status) = 0;
-
- // Called when the provider needs to shut down and will not deliver any
- // suggestions anymore.
- virtual void OnProviderShutdown(ContentSuggestionsProvider* provider) = 0;
};
- // Sets an observer which is notified about changes to the available
- // suggestions, or removes it by passing a nullptr. The provider does not take
- // ownership of the observer and the observer must outlive this provider.
- virtual void SetObserver(Observer* observer) = 0;
+ virtual ~ContentSuggestionsProvider();
// Returns the categories provided by this provider.
// When the set of provided categories changes, the Observer is notified
@@ -108,8 +101,8 @@ class ContentSuggestionsProvider {
virtual void ClearDismissedSuggestionsForDebugging() = 0;
protected:
- ContentSuggestionsProvider(CategoryFactory* category_factory);
- virtual ~ContentSuggestionsProvider();
+ ContentSuggestionsProvider(Observer* observer,
+ CategoryFactory* category_factory);
// Creates a unique ID. The given |within_category_id| must be unique among
// all suggestion IDs from this provider for the given |category|. This method
@@ -118,13 +111,16 @@ class ContentSuggestionsProvider {
// suggestions for that category.
std::string MakeUniqueID(Category category,
const std::string& within_category_id);
+
// Reverse functions for MakeUniqueID()
Category GetCategoryFromUniqueID(const std::string& unique_id);
std::string GetWithinCategoryIDFromUniqueID(const std::string& unique_id);
+ Observer* observer() const { return observer_; }
CategoryFactory* category_factory() const { return category_factory_; }
private:
+ Observer* observer_;
CategoryFactory* category_factory_;
};
« no previous file with comments | « chrome/chrome_browser.gypi ('k') | components/ntp_snippets/content_suggestions_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698