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

Unified Diff: net/disk_cache/simple/simple_experiment.cc

Issue 2918893002: evict larger entries first (Closed)
Patch Set: -SortHelper Created 3 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
« no previous file with comments | « net/disk_cache/simple/simple_experiment.h ('k') | net/disk_cache/simple/simple_experiment_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..81d8a4960dc86640f8f0f37d35a6fff351888954 100644
--- a/net/disk_cache/simple/simple_experiment.cc
+++ b/net/disk_cache/simple/simple_experiment.cc
@@ -15,49 +15,61 @@ 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 {
-// Returns true if the experiment is found and properly defined.
-bool CheckForSimpleSizeExperiment(disk_cache::SimpleExperiment* experiment) {
- DCHECK_EQ(disk_cache::SimpleExperimentType::NONE, experiment->type);
- DCHECK_EQ(0u, experiment->param);
-
- if (!base::FeatureList::IsEnabled(kSimpleSizeExperiment))
- return false;
-
- base::FieldTrial* trial =
- base::FeatureList::GetFieldTrial(kSimpleSizeExperiment);
- if (!trial)
- return false;
-
- std::map<std::string, std::string> params;
- base::FieldTrialParamAssociator::GetInstance()->GetFieldTrialParams(
- trial->trial_name(), &params);
- auto iter = params.find(kSizeMultiplierParam);
- if (iter == params.end())
- return false;
-
- uint32_t param;
- if (!base::StringToUint(iter->second, &param))
- return false;
-
- experiment->type = disk_cache::SimpleExperimentType::SIZE;
- experiment->param = param;
- return true;
-}
+struct ExperimentDescription {
+ disk_cache::SimpleExperimentType experiment_type;
+ const base::Feature* feature;
+ const char* param_name;
+};
+
+// List of experimens to be checked for.
+const ExperimentDescription experiments[] = {
+ {disk_cache::SimpleExperimentType::SIZE, &kSimpleSizeExperiment,
+ kSizeMultiplierParam},
+ {disk_cache::SimpleExperimentType::EVICT_WITH_SIZE,
+ &kSimpleCacheEvictionWithSizeExperiment, kSizeEvictionParam},
+};
} // namespace
// Returns the experiment for the given |cache_type|.
SimpleExperiment GetSimpleExperiment(net::CacheType cache_type) {
SimpleExperiment experiment;
-
if (cache_type != net::DISK_CACHE)
return experiment;
- CheckForSimpleSizeExperiment(&experiment);
+ for (size_t i = 0; i < arraysize(experiments); i++) {
+ if (!base::FeatureList::IsEnabled(*experiments[i].feature))
+ continue;
+
+ base::FieldTrial* trial =
+ base::FeatureList::GetFieldTrial(*experiments[i].feature);
+ if (!trial)
+ continue;
+
+ std::map<std::string, std::string> params;
+ base::FieldTrialParamAssociator::GetInstance()->GetFieldTrialParams(
+ trial->trial_name(), &params);
+ auto iter = params.find(experiments[i].param_name);
+ if (iter == params.end())
+ continue;
+
+ uint32_t param;
+ if (!base::StringToUint(iter->second, &param))
+ continue;
+
+ experiment.type = experiments[i].experiment_type;
+ experiment.param = param;
+ return experiment;
+ }
+
return experiment;
}
« no previous file with comments | « net/disk_cache/simple/simple_experiment.h ('k') | net/disk_cache/simple/simple_experiment_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698