Chromium Code Reviews| Index: storage/browser/quota/quota_settings.cc |
| diff --git a/storage/browser/quota/quota_settings.cc b/storage/browser/quota/quota_settings.cc |
| index 97daf843933b9d6bb861b010738b96352669b26d..85b5654d5a7684a71c876698a82e4789f2e7965e 100644 |
| --- a/storage/browser/quota/quota_settings.cc |
| +++ b/storage/browser/quota/quota_settings.cc |
| @@ -7,6 +7,7 @@ |
| #include <algorithm> |
| #include "base/metrics/histogram_macros.h" |
| +#include "base/rand_util.h" |
| #include "base/sys_info.h" |
| #define UMA_HISTOGRAM_MBYTES(name, sample) \ |
| @@ -15,16 +16,28 @@ |
| namespace storage { |
| +namespace { |
| + |
| +// Skews |value| by +/- |percent|. |
| +int64_t RandomizeByPercent(int64_t value, int percent) { |
| + double random_percent = (base::RandDouble() - 0.5) * percent; |
| + return value + (value * (random_percent / 50.0)); |
| +} |
| + |
| +} // anon namespace |
| + |
| base::Optional<storage::QuotaSettings> CalculateNominalDynamicSettings( |
| const base::FilePath& partition_path, |
| bool is_incognito) { |
| const int64_t kMBytes = 1024 * 1024; |
| + const int k10Percent = 10; |
|
jsbell
2017/04/04 16:23:57
This should probably be named with respect to what
michaeln
2017/04/05 01:20:56
Done.
|
| if (is_incognito) { |
| storage::QuotaSettings settings; |
| - settings.pool_size = |
| - std::min(300 * kMBytes, base::SysInfo::AmountOfPhysicalMemory() / 10); |
| + settings.pool_size = std::min(RandomizeByPercent(300 * kMBytes, k10Percent), |
|
jsbell
2017/04/04 16:23:57
Can we make the 300*kMBytes a constant, e.g. kMaxM
michaeln
2017/04/05 01:20:56
Done.
|
| + base::SysInfo::AmountOfPhysicalMemory() / 10); |
|
jsbell
2017/04/04 16:23:57
Can we make the 10 here a constant, e.g. kMemoryQu
michaeln
2017/04/05 01:20:56
Done.
|
| settings.per_host_quota = settings.pool_size / 3; |
| + settings.session_only_per_host_quota = settings.per_host_quota; |
| settings.refresh_interval = base::TimeDelta::Max(); |
| return settings; |
| } |
| @@ -81,6 +94,9 @@ base::Optional<storage::QuotaSettings> CalculateNominalDynamicSettings( |
| settings.should_remain_available = total * kShouldRemainAvailableRatio; |
| settings.must_remain_available = total * kMustRemainAvailableRatio; |
| settings.per_host_quota = pool_size / kPerHostTemporaryPortion; |
| + settings.session_only_per_host_quota = |
| + std::min(RandomizeByPercent(300 * kMBytes, k10Percent), |
|
cmumford
2017/04/04 16:38:29
This doesn't actually do what the title of issue 6
michaeln
2017/04/05 01:20:56
I've decoupled them from one another rather than l
|
| + settings.per_host_quota / 10); |
| settings.refresh_interval = base::TimeDelta::FromSeconds(60); |
| return settings; |
| } |