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..82f005bda0055258ba3774d7020e883c1ca17b53 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, |
+ const FetchedMoreCallback& callback) override; |
void ClearHistory( |
base::Time begin, |
base::Time end, |
@@ -209,6 +211,8 @@ class NTPSnippetsService final : public ContentSuggestionsProvider, |
// Callback for the NTPSnippetsFetcher. |
void OnFetchFinished( |
+ bool fetched_more, |
+ const FetchedMoreCallback& fetched_more_callback, |
NTPSnippetsFetcher::OptionalFetchedCategories fetched_categories); |
// Moves all snippets from |to_archive| into the archive of the |category|. |
@@ -216,8 +220,15 @@ 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); |
+ // Add newly available snippets in |category| to the provided content. |
vitaliii
2016/11/01 23:29:58
s/Add/Adds
fhorschig
2016/11/02 05:05:28
Done in CL 2446163005.
|
+ // If |replace_snippets| is set, archive existing snippets. |
vitaliii
2016/11/01 23:29:57
nit: remove "is set"
fhorschig
2016/11/02 05:05:28
Done in CL 2446163005.
|
+ void IncludeSnippets(const Category& category, |
+ NTPSnippet::PtrVector new_snippets, |
+ bool replace_snippets); |
+ |
+ void SaveSnippets(const Category& category, |
+ NTPSnippet::PtrVector new_snippets, |
+ bool replace_snippets); |
// Removes expired dismissed snippets from the service and the database. |
void ClearExpiredDismissedSnippets(); |
@@ -272,7 +283,13 @@ class NTPSnippetsService final : public ContentSuggestionsProvider, |
void EnterStateError(); |
// Converts the cached snippets in the given |category| to content suggestions |
- // and notifies the observer. |
+ // and calls a passed callback. If no callbakc is given it notifies the |
vitaliii
2016/11/01 23:29:58
s/callbakc/callbaCK
s/it/,
fhorschig
2016/11/02 05:05:28
Done in CL 2446163005.
|
+ // observer. |
+ void NotifyNewSuggestionsOrInvokeCallback( |
+ Category category, |
+ FetchedMoreCallback fetched_more_callback); |
+ // Triggers notification of observer by calling |
+ // |NotifyNewSuggestionsOrInvokeCallback| with a null callback. |
void NotifyNewSuggestions(Category category); |
// Updates the internal status for |category| to |category_status_| and |
@@ -284,6 +301,27 @@ 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 passed |
+ // |strategy|. |
+ void FetchSnippetsFromHostsImpl( |
+ const std::set<std::string>& hosts, |
+ bool interactive_request, |
+ bool fetch_more, |
+ base::Optional<Category> exclusive_category, |
+ const FetchedMoreCallback& fetched_more_callback); |
+ void MarkEmptyCategoriesAsLoading(NTPSnippetsFetcher::Params* params); |
+ void AssignExpiryDates(NTPSnippet::PtrVector* snippets); |
+ void AddIncompleteSnippets(NTPSnippet::PtrVector* snippets); |
+ void FinishFetch( |
+ NTPSnippetsFetcher::OptionalFetchedCategories fetched_categories, |
+ bool replace_existing_snippets); |
+ // Returns a set of snippet ids that are should not be fetched in subsequent |
vitaliii
2016/11/01 23:29:58
grammar: remove "are"
fhorschig
2016/11/02 05:05:28
Done in CL 2446163005.
|
+ // requests. These IDs akways include dismissed snippets. |
vitaliii
2016/11/01 23:29:57
IDs is inconsistent with the previous line.
s/akwa
fhorschig
2016/11/02 05:05:28
Done in CL 2446163005.
|
+ // For |fetch more| requests, all known snippets are returned. |
+ std::set<std::string> CollectIdsToExclude(bool fetch_more); |
+ void MarkEmptyCategoriesAsLoading(); |
+ |
State state_; |
PrefService* pref_service_; |
@@ -324,7 +362,9 @@ class NTPSnippetsService final : public ContentSuggestionsProvider, |
~CategoryContent(); |
CategoryContent& operator=(CategoryContent&&); |
}; |
- std::map<Category, CategoryContent, Category::CompareByID> categories_; |
+ using CategoryContentMap = |
+ std::map<Category, CategoryContent, Category::CompareByID>; |
+ CategoryContentMap categories_; |
// The ISO 639-1 code of the language used by the application. |
const std::string application_language_code_; |