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

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

Issue 2714863004: [Remote suggestions] Move the throttler into the Scheduler (Closed)
Patch Set: Created 3 years, 10 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/scheduling_remote_suggestions_provider.h
diff --git a/components/ntp_snippets/remote/scheduling_remote_suggestions_provider.h b/components/ntp_snippets/remote/scheduling_remote_suggestions_provider.h
index 5d6981220317f19ead2e6539a16342631376f525..35946a15229d5400bf0026bc03810e7d33574597 100644
--- a/components/ntp_snippets/remote/scheduling_remote_suggestions_provider.h
+++ b/components/ntp_snippets/remote/scheduling_remote_suggestions_provider.h
@@ -17,6 +17,7 @@
#include "components/ntp_snippets/remote/persistent_scheduler.h"
#include "components/ntp_snippets/remote/remote_suggestions_provider.h"
#include "components/ntp_snippets/remote/remote_suggestions_scheduler.h"
+#include "components/ntp_snippets/remote/request_throttler.h"
class PrefRegistrySimple;
class PrefService;
@@ -146,6 +147,9 @@ class SchedulingRemoteSuggestionsProvider final
// Returns whether background fetching (for the given |trigger|) is disabled.
bool BackgroundFetchesDisabled(TriggerType trigger) const;
+ // Returns true if quota is available for another request.
+ bool DemandQuotaForRequest(bool interactive_request);
tschumann 2017/02/24 10:18:08 nit: would AcquireQuota() be a better name? We hav
jkrcal 2017/02/27 10:26:23 Done.
+
// Callback after Fetch is completed.
void FetchFinished(const FetchDoneCallback& callback,
Status fetch_status,
@@ -191,6 +195,11 @@ class SchedulingRemoteSuggestionsProvider final
// Used to adapt the schedule based on usage activity of the user. Not owned.
const UserClassifier* user_classifier_;
+ // Request throttlers for limiting requests for different classes of users.
+ RequestThrottler request_throttler_rare_ntp_user_;
+ RequestThrottler request_throttler_active_ntp_user_;
+ RequestThrottler request_throttler_active_suggestions_consumer_;
+
PrefService* pref_service_;
std::unique_ptr<base::Clock> clock_;
std::set<SchedulingRemoteSuggestionsProvider::TriggerType> enabled_triggers_;

Powered by Google App Engine
This is Rietveld 408576698