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/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 | 13 |
| 14 namespace disk_cache { | 14 namespace disk_cache { |
| 15 | 15 |
| 16 const base::Feature kSimpleSizeExperiment = {"SimpleSizeExperiment", | 16 const base::Feature kSimpleSizeExperiment = {"SimpleSizeExperiment", |
| 17 base::FEATURE_DISABLED_BY_DEFAULT}; | 17 base::FEATURE_DISABLED_BY_DEFAULT}; |
| 18 const base::Feature kSimpleCacheEvictionWithSize = { | |
| 19 "SimpleCacheEvictionWithSize", base::FEATURE_DISABLED_BY_DEFAULT}; | |
| 20 | |
| 18 const char kSizeMultiplierParam[] = "SizeMultiplier"; | 21 const char kSizeMultiplierParam[] = "SizeMultiplier"; |
| 19 | 22 |
| 20 namespace { | 23 namespace { |
| 21 | 24 |
| 25 // Updates experiment if the experiment is active. | |
| 26 void CheckForSimpleCacheEvictionWithSizeExperiment( | |
|
pasko
2017/06/29 15:27:25
nit: "SimpleCache" looks redundant here, I'd sugge
hubbe
2017/06/29 18:55:27
Done.
| |
| 27 disk_cache::SimpleExperiment* experiment) { | |
| 28 if (experiment->type != disk_cache::SimpleExperimentType::NONE) | |
| 29 return; | |
| 30 | |
| 31 if (base::FeatureList::GetFieldTrial(kSimpleCacheEvictionWithSize)) { | |
|
pasko
2017/06/29 15:27:25
nit: the common convention is not to put curly bra
hubbe
2017/06/29 18:55:26
Done.
| |
| 32 experiment->type = SimpleExperimentType::EVICT_WITH_SIZE; | |
|
jkarlin
2017/06/29 16:26:11
You should also parse the parameter and use the pa
hubbe
2017/06/29 18:55:26
My intention was to have the control group disable
jkarlin
2017/06/29 19:17:01
But then you wouldn't clear the control's cache? S
hubbe
2017/06/29 19:26:48
I don't understand, why wouldn't it?
My intention
jkarlin
2017/06/30 11:57:27
Ah, I think I understand now. You want to use the
hubbe
2017/06/30 17:30:34
No, I wasn't planning on using the same field tria
jkarlin
2017/06/30 18:18:48
Correct. And setting the parameter to 100 is a noo
hubbe
2017/06/30 19:00:43
I just change experiment->type.
The control group
| |
| 33 } | |
| 34 } | |
| 35 | |
| 22 // Returns true if the experiment is found and properly defined. | 36 // Returns true if the experiment is found and properly defined. |
| 23 bool CheckForSimpleSizeExperiment(disk_cache::SimpleExperiment* experiment) { | 37 bool CheckForSimpleSizeExperiment(disk_cache::SimpleExperiment* experiment) { |
| 24 DCHECK_EQ(disk_cache::SimpleExperimentType::NONE, experiment->type); | 38 DCHECK_EQ(disk_cache::SimpleExperimentType::NONE, experiment->type); |
| 25 DCHECK_EQ(0u, experiment->param); | 39 DCHECK_EQ(0u, experiment->param); |
| 26 | 40 |
| 27 if (!base::FeatureList::IsEnabled(kSimpleSizeExperiment)) | 41 if (!base::FeatureList::IsEnabled(kSimpleSizeExperiment)) |
| 28 return false; | 42 return false; |
| 29 | 43 |
| 30 base::FieldTrial* trial = | 44 base::FieldTrial* trial = |
| 31 base::FeatureList::GetFieldTrial(kSimpleSizeExperiment); | 45 base::FeatureList::GetFieldTrial(kSimpleSizeExperiment); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 50 | 64 |
| 51 } // namespace | 65 } // namespace |
| 52 | 66 |
| 53 // Returns the experiment for the given |cache_type|. | 67 // Returns the experiment for the given |cache_type|. |
| 54 SimpleExperiment GetSimpleExperiment(net::CacheType cache_type) { | 68 SimpleExperiment GetSimpleExperiment(net::CacheType cache_type) { |
| 55 SimpleExperiment experiment; | 69 SimpleExperiment experiment; |
| 56 | 70 |
| 57 if (cache_type != net::DISK_CACHE) | 71 if (cache_type != net::DISK_CACHE) |
| 58 return experiment; | 72 return experiment; |
| 59 | 73 |
| 60 CheckForSimpleSizeExperiment(&experiment); | 74 CheckForSimpleSizeExperiment(&experiment); |
|
pasko
2017/06/29 15:27:25
jkarlin: why are we ignoring the return value here
jkarlin
2017/06/29 16:26:12
You're right, we should early return if it returns
| |
| 75 CheckForSimpleCacheEvictionWithSizeExperiment(&experiment); | |
|
pasko
2017/06/29 15:27:24
this has the ability to drop the cache in the expe
jkarlin
2017/06/29 16:26:11
Discussed in a comment above.
hubbe
2017/06/29 18:55:26
Acknowledged.
hubbe
2017/06/29 18:55:27
See comment on line 32.
| |
| 61 return experiment; | 76 return experiment; |
| 62 } | 77 } |
| 63 | 78 |
| 64 } // namespace disk_cache | 79 } // namespace disk_cache |
| OLD | NEW |