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

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

Issue 2714863004: [Remote suggestions] Move the throttler into the Scheduler (Closed)
Patch Set: Comments #1 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 8012a1460b0ff78f27fd73b8879128257eeed210..32f1964134162f5453d195bbcda7f90b8d1fffba 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;
@@ -144,6 +145,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 AcquireQuota(bool interactive_request);
+
// Callback after Fetch is completed.
void FetchFinished(const FetchDoneCallback& callback,
Status fetch_status,
@@ -189,6 +193,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