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

Unified Diff: storage/browser/quota/quota_settings.cc

Issue 2777183010: [Quota] Lower quota for ephemeral mode (ie. session only) (Closed)
Patch Set: randomize Created 3 years, 9 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: 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;
}
« storage/browser/quota/quota_settings.h ('K') | « storage/browser/quota/quota_settings.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698