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

Unified Diff: components/ntp_snippets/request_throttler.cc

Issue 2162533002: Adding a request counter to the snippets fetcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@traffic-monitor
Patch Set: Fix the unittest 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.cc
diff --git a/components/ntp_snippets/request_throttler.cc b/components/ntp_snippets/request_throttler.cc
index 3055375aacbdc379101f1c12b6ec785c9e5a922d..a80345590e6d28e5588b6069f63ad48eec2f07f8 100644
--- a/components/ntp_snippets/request_throttler.cc
+++ b/components/ntp_snippets/request_throttler.cc
@@ -19,13 +19,6 @@
namespace ntp_snippets {
-// Used internally for working with a RequestType.
-struct RequestTypeInfo {
- const char* name;
- const char* count_pref;
- const char* day_pref;
-};
-
namespace {
// Enumeration listing all possible outcomes for fetch attempts. Used for UMA
@@ -38,18 +31,16 @@ enum class RequestStatus {
REQUEST_STATUS_COUNT
};
+} // namespace
+
// When adding a new type here, extend also the "RequestCounterTypes"
// <histogram_suffixes> in histograms.xml with the |name| string.
-const RequestTypeInfo kRequestTypeInfo[] = {
+const RequestThrottler::RequestTypeInfo RequestThrottler::kRequestTypeInfo[] = {
// RequestCounter::RequestType::CONTENT_SUGGESTION_FETCHER,
{"SuggestionFetcher", prefs::kSnippetFetcherQuotaCount,
- prefs::kSnippetFetcherQuotaDay}};
-
-} // namespace
+ prefs::kSnippetFetcherQuotaDay, 50}};
-RequestThrottler::RequestThrottler(PrefService* pref_service,
- RequestType type,
- int default_quota)
+RequestThrottler::RequestThrottler(PrefService* pref_service, RequestType type)
: pref_service_(pref_service),
type_info_(kRequestTypeInfo[static_cast<int>(type)]) {
DCHECK(pref_service);
@@ -61,7 +52,7 @@ RequestThrottler::RequestThrottler(PrefService* pref_service,
LOG_IF(WARNING, !quota.empty())
<< "Invalid variation parameter for quota for "
<< GetRequestTypeAsString();
- quota_ = default_quota;
+ quota_ = type_info_.default_quota;
}
// Since the histogram names are dynamic, we cannot use the standard macros

Powered by Google App Engine
This is Rietveld 408576698