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

Unified Diff: components/ntp_snippets/remote/ntp_snippets_service.h

Issue 2446163005: [NTP Snippets] FetchMore backend (Closed)
Patch Set: Address comments from https://codereview.chromium.org/2421463002/ Created 4 years, 2 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
Index: components/ntp_snippets/remote/ntp_snippets_service.h
diff --git a/components/ntp_snippets/remote/ntp_snippets_service.h b/components/ntp_snippets/remote/ntp_snippets_service.h
index 6af55c661113107e0ec9025f942c84daa168a137..a330622b8af979adec4f0490734ba8cad514933e 100644
--- a/components/ntp_snippets/remote/ntp_snippets_service.h
+++ b/components/ntp_snippets/remote/ntp_snippets_service.h
@@ -117,6 +117,8 @@ class NTPSnippetsService final : public ContentSuggestionsProvider,
void DismissSuggestion(const ContentSuggestion::ID& suggestion_id) override;
void FetchSuggestionImage(const ContentSuggestion::ID& suggestion_id,
const ImageFetchedCallback& callback) override;
+ void FetchMore(const Category& category,
+ FetchedMoreCallback callback) override;
void ClearHistory(
base::Time begin,
base::Time end,
@@ -150,6 +152,7 @@ class NTPSnippetsService final : public ContentSuggestionsProvider,
private:
friend class NTPSnippetsServiceTest;
+
FRIEND_TEST_ALL_PREFIXES(NTPSnippetsServiceTest,
RemoveExpiredDismissedContent);
FRIEND_TEST_ALL_PREFIXES(NTPSnippetsServiceTest, RescheduleOnStateChange);
@@ -209,6 +212,8 @@ class NTPSnippetsService final : public ContentSuggestionsProvider,
// Callback for the NTPSnippetsFetcher.
void OnFetchFinished(
+ bool fetched_more,
+ FetchedMoreCallback fetched_more_callback,
NTPSnippetsFetcher::OptionalFetchedCategories fetched_categories);
// Moves all snippets from |to_archive| into the archive of the |category|.
@@ -216,8 +221,11 @@ class NTPSnippetsService final : public ContentSuggestionsProvider,
// short.
void ArchiveSnippets(Category category, NTPSnippet::PtrVector* to_archive);
- // Replace old snippets in |category| by newly available snippets.
- void ReplaceSnippets(Category category, NTPSnippet::PtrVector new_snippets);
+ // Adds newly available suggestions in |category| to the available ones.
+ // If |replace_snippets| is set, archives existing suggestions.
+ void IncludeSnippets(const Category& category,
+ NTPSnippet::PtrVector new_snippets,
+ bool replace_snippets);
// Removes expired dismissed snippets from the service and the database.
void ClearExpiredDismissedSnippets();
@@ -275,6 +283,10 @@ class NTPSnippetsService final : public ContentSuggestionsProvider,
// and notifies the observer.
void NotifyNewSuggestions(Category category);
+ // Converts the cached snippets in the given |category| to content suggestions
+ // and passes them to the |callback|.
+ void NotifyMoreSuggestions(Category category, FetchedMoreCallback callback);
+
// Updates the internal status for |category| to |category_status_| and
// notifies the content suggestions observer if it changed.
void UpdateCategoryStatus(Category category, CategoryStatus status);
@@ -284,6 +296,22 @@ class NTPSnippetsService final : public ContentSuggestionsProvider,
void RestoreCategoriesFromPrefs();
void StoreCategoriesToPrefs();
+ // Implementation for |FetchSnippets| and |FetchMore| that calls the snippet
+ // fetcher and replaces or adds the fetched snippets depending on the
+ // |fetch_more| parameter.
+ void FetchSnippetsFromHostsImpl(const std::set<std::string>& hosts,
+ bool interactive_request,
+ bool fetch_more,
+ FetchedMoreCallback fetched_more_callback,
+ base::Optional<Category> exclusive_category);
+
+ // Returns a set of snippet IDs that should not be fetcheds. These IDs always
+ // include dismissed snippets. If |fetch_more| is set, they include all known
+ // snippet IDs.
+ std::set<std::string> CollectIdsToExclude(bool fetch_more) const;
+
+ void MarkEmptyCategoriesAsLoading();
+
State state_;
PrefService* pref_service_;

Powered by Google App Engine
This is Rietveld 408576698