Chromium Code Reviews| Index: net/disk_cache/simple/simple_experiment.cc |
| diff --git a/net/disk_cache/simple/simple_experiment.cc b/net/disk_cache/simple/simple_experiment.cc |
| index 38ea589322f97df405f9b48bcaa349510847ce52..dc7b6cd0ae7a0c92e543cc8ceccf7b0179c33a83 100644 |
| --- a/net/disk_cache/simple/simple_experiment.cc |
| +++ b/net/disk_cache/simple/simple_experiment.cc |
| @@ -15,10 +15,44 @@ namespace disk_cache { |
| const base::Feature kSimpleSizeExperiment = {"SimpleSizeExperiment", |
| base::FEATURE_DISABLED_BY_DEFAULT}; |
| +const base::Feature kSimpleCacheEvictionWithSizeExperiment = { |
| + "SimpleCacheEvictionWithSizeExperiment", base::FEATURE_DISABLED_BY_DEFAULT}; |
| + |
| const char kSizeMultiplierParam[] = "SizeMultiplier"; |
| +const char kSizeEvictionParam[] = "SizeEviction"; |
| namespace { |
| +// Updates experiment if the experiment is active. |
| +bool CheckForEvictionWithSizeExperiment( |
| + disk_cache::SimpleExperiment* experiment) { |
| + if (disk_cache::SimpleExperimentType::NONE != experiment->type) |
|
jkarlin
2017/07/12 15:51:40
After returning early in GetSimpleExperiment you c
hubbe
2017/07/12 18:22:50
Done.
|
| + return false; |
| + |
| + if (!base::FeatureList::IsEnabled(kSimpleCacheEvictionWithSizeExperiment)) |
| + return false; |
| + |
| + base::FieldTrial* trial = |
| + base::FeatureList::GetFieldTrial(kSimpleCacheEvictionWithSizeExperiment); |
| + if (!trial) |
| + return false; |
| + |
| + std::map<std::string, std::string> params; |
| + base::FieldTrialParamAssociator::GetInstance()->GetFieldTrialParams( |
| + trial->trial_name(), ¶ms); |
| + auto iter = params.find(kSizeEvictionParam); |
| + if (iter == params.end()) |
| + return false; |
| + |
| + uint32_t param; |
| + if (!base::StringToUint(iter->second, ¶m)) |
| + return false; |
| + |
| + experiment->type = disk_cache::SimpleExperimentType::SIZE; |
|
jkarlin
2017/07/12 15:51:41
I believe you want EVICT_WITH_SIZE here ;) That wo
hubbe
2017/07/12 18:22:50
Done.
|
| + experiment->param = param; |
| + return true; |
| +} |
| + |
| // Returns true if the experiment is found and properly defined. |
| bool CheckForSimpleSizeExperiment(disk_cache::SimpleExperiment* experiment) { |
| DCHECK_EQ(disk_cache::SimpleExperimentType::NONE, experiment->type); |
| @@ -58,6 +92,7 @@ SimpleExperiment GetSimpleExperiment(net::CacheType cache_type) { |
| return experiment; |
| CheckForSimpleSizeExperiment(&experiment); |
|
jkarlin
2017/07/12 15:51:41
Can you have each check return early if they retur
hubbe
2017/07/12 18:22:50
Done.
|
| + CheckForEvictionWithSizeExperiment(&experiment); |
| return experiment; |
| } |