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

Unified Diff: components/ntp_snippets/request_throttler.h

Issue 2162533002: Adding a request counter to the snippets fetcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@traffic-monitor
Patch Set: Bernhard's and Eric's comments Created 4 years, 5 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/request_throttler.h
diff --git a/components/ntp_snippets/request_throttler.h b/components/ntp_snippets/request_throttler.h
index f908825814b62fcb0790aca1a1a2702aeb91013f..a240bfcc9992245cf2e933bb90aa574be5142f00 100644
--- a/components/ntp_snippets/request_throttler.h
+++ b/components/ntp_snippets/request_throttler.h
@@ -18,8 +18,6 @@ class HistogramBase;
namespace ntp_snippets {
-struct RequestTypeInfo;
-
// Counts requests to external services, compares them to a daily quota, reports
// them to UMA. In the application code, create one local instance for each type
// of requests, identified by the RequestType. The request counter is based on:
@@ -45,9 +43,7 @@ class RequestThrottler {
CONTENT_SUGGESTION_FETCHER
};
- RequestThrottler(PrefService* pref_service,
- RequestType type,
- int default_quota);
+ RequestThrottler(PrefService* pref_service, RequestType type);
// Registers profile prefs for all RequestTypes. Called from browser_prefs.cc.
static void RegisterProfilePrefs(PrefRegistrySimple* registry);
@@ -59,6 +55,17 @@ class RequestThrottler {
bool DemandQuotaForRequest(bool force_request);
private:
+ // Used internally for working with a RequestType.
+ struct RequestTypeInfo {
Bernhard Bauer 2016/07/26 09:52:45 Do you need to define the struct here or would a d
jkrcal 2016/07/26 10:05:07 Done.
+ const char* name;
+ const char* count_pref;
+ const char* day_pref;
+ const int default_quota;
+ };
+
+ // The array of info entries - one per each RequestType.
+ static const RequestTypeInfo kRequestTypeInfo[1];
Bernhard Bauer 2016/07/26 09:52:45 Same here for the array size -- could you just lea
jkrcal 2016/07/26 10:05:07 Ah, right!
+
// Also emits the PerDay histogram if the day changed.
void ResetCounterIfDayChanged();
« no previous file with comments | « components/ntp_snippets/ntp_snippets_service_unittest.cc ('k') | components/ntp_snippets/request_throttler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698