Chromium Code Reviews| 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; |
| } |