summaryrefslogtreecommitdiffstats
path: root/webkit/quota
diff options
context:
space:
mode:
authormnaganov@chromium.org <mnaganov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-06 17:33:40 +0000
committermnaganov@chromium.org <mnaganov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-06 17:33:40 +0000
commit4a026a81d2ed193acabacf6d66ba410adc5ac869 (patch)
treeca426cc6cb80f5f6a587c7c33168b623056c036c /webkit/quota
parent81d1da62a2739ffa5488b68a951e707c7417644c (diff)
downloadchromium_src-4a026a81d2ed193acabacf6d66ba410adc5ac869.zip
chromium_src-4a026a81d2ed193acabacf6d66ba410adc5ac869.tar.gz
chromium_src-4a026a81d2ed193acabacf6d66ba410adc5ac869.tar.bz2
By default, disable temporary storage eviction based on free disk space.
R=kinuko@chromium.org BUG=none TEST=QuotaTemporaryStorageEvictorTest::DiskSpaceNonEvictionTest, ::DiskSpaceEvictionTest Review URL: http://codereview.chromium.org/8137008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104317 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/quota')
-rw-r--r--webkit/quota/quota_temporary_storage_evictor.cc6
-rw-r--r--webkit/quota/quota_temporary_storage_evictor.h15
-rw-r--r--webkit/quota/quota_temporary_storage_evictor_unittest.cc35
3 files changed, 49 insertions, 7 deletions
diff --git a/webkit/quota/quota_temporary_storage_evictor.cc b/webkit/quota/quota_temporary_storage_evictor.cc
index 49229c3..f4b6750 100644
--- a/webkit/quota/quota_temporary_storage_evictor.cc
+++ b/webkit/quota/quota_temporary_storage_evictor.cc
@@ -26,8 +26,8 @@ const int64 kMBytes = 1024 * 1024;
namespace quota {
const double QuotaTemporaryStorageEvictor::kUsageRatioToStartEviction = 0.7;
-const int64 QuotaTemporaryStorageEvictor::
- kDefaultMinAvailableDiskSpaceToStartEviction = 1000 * 1000 * 500;
+const int QuotaTemporaryStorageEvictor::
+ kMinAvailableDiskSpaceToStartEvictionNotSpecified = -1;
const int QuotaTemporaryStorageEvictor::kThresholdOfErrorsToStopEviction = 5;
const base::TimeDelta QuotaTemporaryStorageEvictor::kHistogramReportInterval =
@@ -37,7 +37,7 @@ QuotaTemporaryStorageEvictor::QuotaTemporaryStorageEvictor(
QuotaEvictionHandler* quota_eviction_handler,
int64 interval_ms)
: min_available_disk_space_to_start_eviction_(
- kDefaultMinAvailableDiskSpaceToStartEviction),
+ kMinAvailableDiskSpaceToStartEvictionNotSpecified),
quota_eviction_handler_(quota_eviction_handler),
interval_ms_(interval_ms),
repeated_eviction_(true),
diff --git a/webkit/quota/quota_temporary_storage_evictor.h b/webkit/quota/quota_temporary_storage_evictor.h
index 6492227..e65dd80 100644
--- a/webkit/quota/quota_temporary_storage_evictor.h
+++ b/webkit/quota/quota_temporary_storage_evictor.h
@@ -82,6 +82,17 @@ class QuotaTemporaryStorageEvictor : public base::NonThreadSafe {
void ReportPerHourHistogram();
void Start();
+ int64 min_available_disk_space_to_start_eviction() {
+ return min_available_disk_space_to_start_eviction_;
+ }
+ void reset_min_available_disk_space_to_start_eviction() {
+ min_available_disk_space_to_start_eviction_ =
+ kMinAvailableDiskSpaceToStartEvictionNotSpecified;
+ }
+ void set_min_available_disk_space_to_start_eviction(int64 value) {
+ min_available_disk_space_to_start_eviction_ = value;
+ }
+
private:
friend class QuotaTemporaryStorageEvictorTest;
@@ -105,11 +116,11 @@ class QuotaTemporaryStorageEvictor : public base::NonThreadSafe {
}
static const double kUsageRatioToStartEviction;
- static const int64 kDefaultMinAvailableDiskSpaceToStartEviction;
+ static const int kMinAvailableDiskSpaceToStartEvictionNotSpecified;
static const int kThresholdOfErrorsToStopEviction;
static const base::TimeDelta kHistogramReportInterval;
- const int64 min_available_disk_space_to_start_eviction_;
+ int64 min_available_disk_space_to_start_eviction_;
// Not owned; quota_eviction_handler owns us.
QuotaEvictionHandler* quota_eviction_handler_;
diff --git a/webkit/quota/quota_temporary_storage_evictor_unittest.cc b/webkit/quota/quota_temporary_storage_evictor_unittest.cc
index 63420b2..6e857c7 100644
--- a/webkit/quota/quota_temporary_storage_evictor_unittest.cc
+++ b/webkit/quota/quota_temporary_storage_evictor_unittest.cc
@@ -211,8 +211,17 @@ class QuotaTemporaryStorageEvictorTest : public testing::Test {
}
int64 default_min_available_disk_space_to_start_eviction() const {
- return QuotaTemporaryStorageEvictor::
- kDefaultMinAvailableDiskSpaceToStartEviction;
+ return 1000 * 1000 * 500;
+ }
+
+ void set_min_available_disk_space_to_start_eviction(int64 value) const {
+ temporary_storage_evictor_->set_min_available_disk_space_to_start_eviction(
+ value);
+ }
+
+ void reset_min_available_disk_space_to_start_eviction() const {
+ temporary_storage_evictor_->
+ reset_min_available_disk_space_to_start_eviction();
}
scoped_ptr<QuotaEvictionHandler> quota_eviction_handler_;
@@ -370,6 +379,26 @@ TEST_F(QuotaTemporaryStorageEvictorTest, RepeatedEvictionWithAccessOriginTest) {
EXPECT_EQ(0, statistics().num_skipped_eviction_rounds);
}
+TEST_F(QuotaTemporaryStorageEvictorTest, DiskSpaceNonEvictionTest) {
+ quota_eviction_handler()->AddOrigin(GURL("http://www.z.com"), 414);
+ quota_eviction_handler()->AddOrigin(GURL("http://www.x.com"), 450);
+ quota_eviction_handler()->set_quota(10000);
+ quota_eviction_handler()->set_available_space(
+ default_min_available_disk_space_to_start_eviction() - 350);
+ EXPECT_EQ(414 + 450, quota_eviction_handler()->GetUsage());
+ reset_min_available_disk_space_to_start_eviction();
+ set_repeated_eviction(false);
+ temporary_storage_evictor()->Start();
+ MessageLoop::current()->RunAllPending();
+ EXPECT_EQ(414 + 450, quota_eviction_handler()->GetUsage());
+
+ EXPECT_EQ(0, statistics().num_errors_on_evicting_origin);
+ EXPECT_EQ(0, statistics().num_errors_on_getting_usage_and_quota);
+ EXPECT_EQ(0, statistics().num_evicted_origins);
+ EXPECT_EQ(1, statistics().num_eviction_rounds);
+ EXPECT_EQ(1, statistics().num_skipped_eviction_rounds);
+}
+
TEST_F(QuotaTemporaryStorageEvictorTest, DiskSpaceEvictionTest) {
quota_eviction_handler()->AddOrigin(GURL("http://www.z.com"), 294);
quota_eviction_handler()->AddOrigin(GURL("http://www.y.com"), 120);
@@ -379,6 +408,8 @@ TEST_F(QuotaTemporaryStorageEvictorTest, DiskSpaceEvictionTest) {
quota_eviction_handler()->set_available_space(
default_min_available_disk_space_to_start_eviction() - 350);
EXPECT_EQ(294 + 120 + 150 + 300, quota_eviction_handler()->GetUsage());
+ set_min_available_disk_space_to_start_eviction(
+ default_min_available_disk_space_to_start_eviction());
set_repeated_eviction(false);
temporary_storage_evictor()->Start();
MessageLoop::current()->RunAllPending();