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

Unified Diff: components/ukm/ukm_service.cc

Issue 2727343004: Add Feature params for UKM Service to control thresholds on sources and entries. (Closed)
Patch Set: ukm params2 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
« no previous file with comments | « no previous file | components/ukm/ukm_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ukm/ukm_service.cc
diff --git a/components/ukm/ukm_service.cc b/components/ukm/ukm_service.cc
index 87176c714a5f3e4938b80cd0ec71ede2eeb7ca47..e325ddca93bbf650260750543d8dcb304adb1c44 100644
--- a/components/ukm/ukm_service.cc
+++ b/components/ukm/ukm_service.cc
@@ -63,11 +63,11 @@ constexpr size_t kMaxLogRetransmitSize = 100 * 1024;
// Maximum number of Sources we'll keep in memory before discarding any
// new ones being added.
-const size_t kMaxSources = 500;
+const size_t kDefaultMaxSources = 500;
// Maximum number of Entries we'll keep in memory before discarding any
// new ones being added.
-const size_t kMaxEntries = 5000;
+const size_t kDefaultMaxEntries = 5000;
std::string GetServerUrl() {
std::string server_url =
@@ -77,6 +77,16 @@ std::string GetServerUrl() {
return kDefaultServerUrl;
}
+size_t GetMaxSources() {
Alexei Svitkine (slow) 2017/03/02 23:13:42 Nit: Can you add comments to these?
+ return static_cast<size_t>(base::GetFieldTrialParamByFeatureAsInt(
+ kUkmFeature, "MaxSources", kDefaultMaxSources));
+}
+
+size_t GetMaxEntries() {
+ return static_cast<size_t>(base::GetFieldTrialParamByFeatureAsInt(
+ kUkmFeature, "MaxEntries", kDefaultMaxEntries));
+}
+
bool ShouldRecordInitialUrl() {
return base::GetFieldTrialParamByFeatureAsBool(kUkmFeature,
"RecordInitialUrl", false);
@@ -418,7 +428,7 @@ void UkmService::RecordSource(std::unique_ptr<UkmSource> source) {
RecordDroppedSource(DroppedDataReason::RECORDING_DISABLED);
return;
}
- if (sources_.size() >= kMaxSources) {
+ if (sources_.size() >= GetMaxSources()) {
RecordDroppedSource(DroppedDataReason::MAX_HIT);
return;
}
@@ -459,7 +469,7 @@ void UkmService::UpdateSourceURL(int32_t source_id, const GURL& url) {
return;
}
- if (sources_.size() >= kMaxSources) {
+ if (sources_.size() >= GetMaxSources()) {
RecordDroppedSource(DroppedDataReason::MAX_HIT);
return;
}
@@ -476,7 +486,7 @@ void UkmService::AddEntry(std::unique_ptr<UkmEntry> entry) {
RecordDroppedEntry(DroppedDataReason::RECORDING_DISABLED);
return;
}
- if (entries_.size() >= kMaxEntries) {
+ if (entries_.size() >= GetMaxEntries()) {
RecordDroppedEntry(DroppedDataReason::MAX_HIT);
return;
}
« no previous file with comments | « no previous file | components/ukm/ukm_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698