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

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

Issue 2421463002: FetchMore functionality backend (Closed)
Patch Set: Introduced callback, removed strategy. 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_fetcher.h
diff --git a/components/ntp_snippets/remote/ntp_snippets_fetcher.h b/components/ntp_snippets/remote/ntp_snippets_fetcher.h
index f5bbf27412cc229053c8a01e15988a324e07afc0..6056f3642106886a2289cf0a06ae075de3db1eb6 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,
@@ -102,10 +102,6 @@ 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);
-
// Fetches snippets from the server. |hosts| restricts the results to a set of
// hosts, e.g. "www.google.com". If |hosts| is empty, no host restrictions are
// applied.
@@ -115,15 +111,20 @@ class NTPSnippetsFetcher : public OAuth2TokenService::Consumer,
//
// If an ongoing fetch exists, it will be cancelled and a new one started,
// without triggering an additional callback (i.e. not noticeable by
- // subscriber of SetCallback()).
+ // the owner of |callback|).
Marc Treib 2016/10/20 16:51:39 This is not accurate anymore: The owner of the pre
fhorschig 2016/11/02 05:05:27 As discussed offline, this behavior will change wi
//
// Fetches snippets only if the daily quota not exceeded, unless
// |interactive_request| is set to true (use only for user-initiated fetches).
+ //
+ // If an |exclusive_category| was defined, the categories passed to the
+ // callback will only contain this category.
void FetchSnippetsFromHosts(const std::set<std::string>& hosts,
const std::string& language_code,
const std::set<std::string>& excluded_ids,
int count,
- bool interactive_request);
+ bool interactive_request,
+ SnippetsAvailableCallback callback,
Marc Treib 2016/10/20 16:51:39 nit: I'd put callback last (all the others are inp
fhorschig 2016/11/02 05:05:27 Done in CL 2466863003.
+ base::Optional<Category> exclusive_category);
// Debug string representing the status/result of the last fetch attempt.
const std::string& last_status() const { return last_status_; }
@@ -216,6 +217,7 @@ class NTPSnippetsFetcher : public OAuth2TokenService::Consumer,
void FetchFinished(OptionalFetchedCategories fetched_categories,
FetchResult result,
const std::string& extra_message);
+ void FilterCategories(OptionalFetchedCategories* fetched);
Marc Treib 2016/10/20 16:51:39 nit: const (or you could convert it to a non-membe
Marc Treib 2016/10/28 14:49:49 Done.
bool DemandQuotaForRequest(bool interactive_request);
@@ -269,6 +271,9 @@ class NTPSnippetsFetcher : public OAuth2TokenService::Consumer,
// Is the request user initiated?
bool interactive_request_;
+ // Is the request supposed to fetch one category excusively? Which one?
Marc Treib 2016/10/20 16:51:40 Typo: excusively (but I'm not a fan of the questio
Marc Treib 2016/10/28 14:49:49 Done.
+ base::Optional<Category> exclusive_category_;
+
// Allow for an injectable tick clock for testing.
std::unique_ptr<base::TickClock> tick_clock_;

Powered by Google App Engine
This is Rietveld 408576698