Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/disk_cache/simple/simple_experiment.h" | 5 #include "net/disk_cache/simple/simple_experiment.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| 11 #include "base/metrics/field_trial_param_associator.h" | 11 #include "base/metrics/field_trial_param_associator.h" |
| 12 #include "base/metrics/field_trial_params.h" | |
| 12 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 13 | 14 |
| 14 namespace disk_cache { | 15 namespace disk_cache { |
| 15 | 16 |
| 16 const base::Feature kSimpleSizeExperiment = {"SimpleSizeExperiment", | 17 const base::Feature kSimpleSizeExperiment = {"SimpleSizeExperiment", |
| 17 base::FEATURE_DISABLED_BY_DEFAULT}; | 18 base::FEATURE_DISABLED_BY_DEFAULT}; |
| 18 const char kSizeMultiplierParam[] = "SizeMultiplier"; | 19 const char kSizeMultiplierParam[] = "SizeMultiplier"; |
| 19 | 20 |
| 21 const base::Feature kSimpleCachePrefetchExperiment = { | |
| 22 "GetSimpleCachePrefetchExperiment", base::FEATURE_DISABLED_BY_DEFAULT}; | |
| 23 const char kSimplePrefetchBytesParam[] = "Bytes"; | |
| 24 | |
| 20 namespace { | 25 namespace { |
| 21 | 26 |
| 22 // Returns true if the experiment is found and properly defined. | 27 // Returns true if the experiment is found and properly defined. |
| 23 bool CheckForSimpleSizeExperiment(disk_cache::SimpleExperiment* experiment) { | 28 bool CheckForSimpleSizeExperiment(disk_cache::SimpleExperiment* experiment) { |
| 24 DCHECK_EQ(disk_cache::SimpleExperimentType::NONE, experiment->type); | 29 DCHECK_EQ(disk_cache::SimpleExperimentType::NONE, experiment->type); |
| 25 DCHECK_EQ(0u, experiment->param); | 30 DCHECK_EQ(0u, experiment->param); |
| 26 | 31 |
| 27 if (!base::FeatureList::IsEnabled(kSimpleSizeExperiment)) | 32 if (!base::FeatureList::IsEnabled(kSimpleSizeExperiment)) |
| 28 return false; | 33 return false; |
| 29 | 34 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 54 SimpleExperiment GetSimpleExperiment(net::CacheType cache_type) { | 59 SimpleExperiment GetSimpleExperiment(net::CacheType cache_type) { |
| 55 SimpleExperiment experiment; | 60 SimpleExperiment experiment; |
| 56 | 61 |
| 57 if (cache_type != net::DISK_CACHE) | 62 if (cache_type != net::DISK_CACHE) |
| 58 return experiment; | 63 return experiment; |
| 59 | 64 |
| 60 CheckForSimpleSizeExperiment(&experiment); | 65 CheckForSimpleSizeExperiment(&experiment); |
| 61 return experiment; | 66 return experiment; |
| 62 } | 67 } |
| 63 | 68 |
| 69 int GetSimpleCachePrefetchSize() { | |
| 70 return base::GetFieldTrialParamByFeatureAsInt(kSimpleCachePrefetchExperiment, | |
|
pasko
2017/07/18 14:02:57
please also add a test that sets the experiment pa
Maks Orlovich
2017/07/25 16:06:29
Done.
| |
| 71 kSimplePrefetchBytesParam, 0); | |
| 72 } | |
| 73 | |
| 64 } // namespace disk_cache | 74 } // namespace disk_cache |
| OLD | NEW |