Chromium Code Reviews| Index: components/ntp_snippets/remote/ntp_snippets_fetcher.h |
| diff --git a/components/ntp_snippets/remote/ntp_snippets_fetcher.h b/components/ntp_snippets/remote/ntp_snippets_fetcher.h |
| index ce40c5539207362b11a8693ce4f235ef76aad2c8..382021f575dd5400895e922280ec47ec5a3d513c 100644 |
| --- a/components/ntp_snippets/remote/ntp_snippets_fetcher.h |
| +++ b/components/ntp_snippets/remote/ntp_snippets_fetcher.h |
| @@ -65,7 +65,7 @@ class NTPSnippetsFetcher : public OAuth2TokenService::Consumer, |
| // occur, |snippets| contains no value (no actual vector in base::Optional). |
| // Error details can be retrieved using last_status(). |
| using SnippetsAvailableCallback = |
| - base::Callback<void(OptionalFetchedCategories fetched_categories)>; |
| + base::OnceCallback<void(OptionalFetchedCategories fetched_categories)>; |
| // Enumeration listing all possible outcomes for fetch attempts. Used for UMA |
| // histograms, so do not change existing values. Insert new values at the end, |
| @@ -112,6 +112,9 @@ class NTPSnippetsFetcher : public OAuth2TokenService::Consumer, |
| // user action. Typically, non-interactive requests are subject to a daily |
| // quota. |
| bool interactive_request = false; |
| + |
| + // If set, only return results for this category. |
| + base::Optional<Category> exclusive_category; |
| }; |
| NTPSnippetsFetcher( |
| @@ -126,17 +129,13 @@ class NTPSnippetsFetcher : public OAuth2TokenService::Consumer, |
| const UserClassifier* user_classifier); |
| ~NTPSnippetsFetcher() override; |
| - // Set a callback that is called when a new set of snippets are downloaded, |
| - // overriding any previously set callback. |
| - void SetCallback(const SnippetsAvailableCallback& callback); |
| - |
| // Initiates a fetch from the server. When done (successfully or not), calls |
| // the subscriber of SetCallback(). |
| // |
| // If an ongoing fetch exists, it will be silently abandoned and a new one |
| // started, without triggering an additional callback (i.e. the callback will |
| // only be called once). |
| - void FetchSnippets(const Params& params); |
| + void FetchSnippets(const Params& params, SnippetsAvailableCallback callback); |
| // Debug string representing the status/result of the last fetch attempt. |
| const std::string& last_status() const { return last_status_; } |
| @@ -227,6 +226,7 @@ class NTPSnippetsFetcher : public OAuth2TokenService::Consumer, |
| void FetchFinished(OptionalFetchedCategories fetched_categories, |
| FetchResult result, |
| const std::string& extra_message); |
| + void FilterCategories(FetchedCategoriesVector* categories); |
|
markusheintz_
2016/11/03 11:43:54
A comment would be nice that describes the filteri
tschumann
2016/11/03 11:55:46
Done.
|
| bool DemandQuotaForRequest(bool interactive_request); |