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

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

Issue 2395123002: Connecting UserClassifier to NtpSnippetsFetcher (Closed)
Patch Set: A minor fix 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 2d801ac25b858ac06204bfdd88b74fcdd02a8a5e..2bd661e02dde45c0f99dfd3d7071859f7c1479d5 100644
--- a/components/ntp_snippets/remote/ntp_snippets_fetcher.h
+++ b/components/ntp_snippets/remote/ntp_snippets_fetcher.h
@@ -31,6 +31,8 @@ class Value;
namespace ntp_snippets {
+class UserClassifier;
+
// Fetches snippet data for the NTP from the server.
class NTPSnippetsFetcher : public OAuth2TokenService::Consumer,
public OAuth2TokenService::Observer,
@@ -92,7 +94,8 @@ class NTPSnippetsFetcher : public OAuth2TokenService::Consumer,
PrefService* pref_service,
CategoryFactory* category_factory,
const ParseJSONCallback& parse_json_callback,
- const std::string& api_key);
+ const std::string& api_key,
+ const UserClassifier* user_classifier);
~NTPSnippetsFetcher() override;
// Set a callback that is called when a new set of snippets are downloaded,
@@ -165,6 +168,7 @@ class NTPSnippetsFetcher : public OAuth2TokenService::Consumer,
std::set<std::string> excluded_ids;
int count_to_fetch;
bool interactive_request;
+ std::string user_class;
RequestParams();
~RequestParams();
@@ -201,6 +205,8 @@ class NTPSnippetsFetcher : public OAuth2TokenService::Consumer,
FetchResult result,
const std::string& extra_message);
+ bool DemandQuotaForRequest(bool interactive_request);
+
// Authorization for signed-in users.
SigninManagerBase* signin_manager_;
OAuth2TokenService* token_service_;
@@ -253,8 +259,13 @@ class NTPSnippetsFetcher : public OAuth2TokenService::Consumer,
// Allow for an injectable tick clock for testing.
std::unique_ptr<base::TickClock> tick_clock_;
- // Request throttler for limiting requests.
- RequestThrottler request_throttler_;
+ // Classifier that tells us how active the user is. 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_;
// When a token request gets canceled, we want to retry once.
bool oauth_token_retried_;

Powered by Google App Engine
This is Rietveld 408576698