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

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

Issue 2918893002: evict larger entries first (Closed)
Patch Set: tests added, comments addressed 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
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..0691f40f8fade2f1cbaa50bea9c0ca83cd72ea92 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.
pasko 2017/07/18 15:30:01 nit: s/experiment/|experiment|/
hubbe 2017/07/18 18:27:39 Gone.
+bool CheckForEvictionWithSizeExperiment(
pasko 2017/07/18 15:30:01 The difference between this function and the funct
hubbe 2017/07/18 18:27:39 Done.
+ disk_cache::SimpleExperiment* experiment) {
+ DCHECK_EQ(disk_cache::SimpleExperimentType::NONE, experiment->type);
+ DCHECK_EQ(0u, experiment->param);
+
+ 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(), &params);
+ auto iter = params.find(kSizeEvictionParam);
+ if (iter == params.end())
+ return false;
+
+ uint32_t param;
+ if (!base::StringToUint(iter->second, &param))
+ return false;
+
+ experiment->type = disk_cache::SimpleExperimentType::EVICT_WITH_SIZE;
+ 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);
@@ -57,7 +91,9 @@ SimpleExperiment GetSimpleExperiment(net::CacheType cache_type) {
if (cache_type != net::DISK_CACHE)
return experiment;
- CheckForSimpleSizeExperiment(&experiment);
+ if (CheckForSimpleSizeExperiment(&experiment))
+ return experiment;
+ CheckForEvictionWithSizeExperiment(&experiment);
return experiment;
}

Powered by Google App Engine
This is Rietveld 408576698