diff options
author | dmikurube@chromium.org <dmikurube@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-30 11:40:23 +0000 |
---|---|---|
committer | dmikurube@chromium.org <dmikurube@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-30 11:40:23 +0000 |
commit | ec3941bbe38e397d72d255fff2b0cf5100065ae4 (patch) | |
tree | 96a2155be963a9b0f6d454a1e7aa4e87ec2ac0e6 /webkit/quota | |
parent | a6e146b4a369b31afa4c4323cc813dcbe0ef0c2b (diff) | |
download | chromium_src-ec3941bbe38e397d72d255fff2b0cf5100065ae4.zip chromium_src-ec3941bbe38e397d72d255fff2b0cf5100065ae4.tar.gz chromium_src-ec3941bbe38e397d72d255fff2b0cf5100065ae4.tar.bz2 |
Integrate QuotaTemporaryStorageEvictor and QuotaManager functions.
It enables the Evictor for the temporary storage if the --enable-quota-evictor option is given.
BUG=61676
TEST=QuotaTemporaryStorageEvictorTest.*,QuotaManagerTest.*
Review URL: http://codereview.chromium.org/7039008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87228 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/quota')
-rw-r--r-- | webkit/quota/mock_storage_client.cc | 19 | ||||
-rw-r--r-- | webkit/quota/mock_storage_client.h | 4 | ||||
-rw-r--r-- | webkit/quota/quota_manager.cc | 49 | ||||
-rw-r--r-- | webkit/quota/quota_manager.h | 15 | ||||
-rw-r--r-- | webkit/quota/quota_manager_unittest.cc | 104 | ||||
-rw-r--r-- | webkit/quota/quota_temporary_storage_evictor.cc | 21 | ||||
-rw-r--r-- | webkit/quota/quota_temporary_storage_evictor.h | 17 | ||||
-rw-r--r-- | webkit/quota/quota_temporary_storage_evictor_unittest.cc | 13 |
8 files changed, 204 insertions, 38 deletions
diff --git a/webkit/quota/mock_storage_client.cc b/webkit/quota/mock_storage_client.cc index 89499ce..5880411 100644 --- a/webkit/quota/mock_storage_client.cc +++ b/webkit/quota/mock_storage_client.cc @@ -81,6 +81,11 @@ void MockStorageClient::ModifyOriginAndNotify( quota_manager_proxy_->NotifyStorageModified(id(), origin_url, type, delta); } +void MockStorageClient::AddOriginToErrorSet( + const GURL& origin_url, StorageType type) { + error_origins_.insert(make_pair(origin_url, type)); +} + QuotaClient::ID MockStorageClient::id() const { return id_; } @@ -172,8 +177,17 @@ void MockStorageClient::RunDeleteOriginData( const GURL& origin_url, StorageType type, DeletionCallback* callback_ptr) { - OriginDataMap::iterator itr - = origin_data_.find(make_pair(origin_url, type)); + scoped_ptr<DeletionCallback> callback(callback_ptr); + ErrorOriginSet::iterator itr_error = + error_origins_.find(make_pair(origin_url, type)); + if (itr_error != error_origins_.end()) { + deletion_callbacks_.erase(callback_ptr); + callback->Run(kQuotaErrorInvalidModification); + return; + } + + OriginDataMap::iterator itr = + origin_data_.find(make_pair(origin_url, type)); if (itr != origin_data_.end()) { int64 delta = itr->second; quota_manager_proxy_-> @@ -181,7 +195,6 @@ void MockStorageClient::RunDeleteOriginData( origin_data_.erase(itr); } - scoped_ptr<DeletionCallback> callback(callback_ptr); deletion_callbacks_.erase(callback_ptr); callback->Run(kQuotaStatusOk); } diff --git a/webkit/quota/mock_storage_client.h b/webkit/quota/mock_storage_client.h index 51c6985..7a25c44 100644 --- a/webkit/quota/mock_storage_client.h +++ b/webkit/quota/mock_storage_client.h @@ -37,6 +37,8 @@ class MockStorageClient : public QuotaClient { void ModifyOriginAndNotify( const GURL& origin_url, StorageType type, int64 delta); + void AddOriginToErrorSet(const GURL& origin_url, StorageType type); + // QuotaClient methods. virtual QuotaClient::ID id() const OVERRIDE; virtual void OnQuotaManagerDestroyed() OVERRIDE; @@ -69,6 +71,8 @@ class MockStorageClient : public QuotaClient { typedef std::map<std::pair<GURL, StorageType>, int64> OriginDataMap; OriginDataMap origin_data_; + typedef std::set<std::pair<GURL, StorageType> > ErrorOriginSet; + ErrorOriginSet error_origins_; std::set<GetUsageCallback*> usage_callbacks_; std::set<GetOriginsCallback*> origins_callbacks_; diff --git a/webkit/quota/quota_manager.cc b/webkit/quota/quota_manager.cc index 741a9b2..53a97a6 100644 --- a/webkit/quota/quota_manager.cc +++ b/webkit/quota/quota_manager.cc @@ -18,6 +18,7 @@ #include "base/sys_info.h" #include "net/base/net_util.h" #include "webkit/quota/quota_database.h" +#include "webkit/quota/quota_temporary_storage_evictor.h" #include "webkit/quota/quota_types.h" #include "webkit/quota/usage_tracker.h" @@ -57,19 +58,26 @@ int64 GetInitialTemporaryStorageQuotaSize(const FilePath& path, return QuotaManager::kTemporaryStorageQuotaMaxSize; } -const int64 MBytes = 1024 * 1024; +const int64 kMBytes = 1024 * 1024; +const int kMinutesInMilliSeconds = 60 * 1000; + } // anonymous namespace // TODO(kinuko): We will need to have different sizes for different platforms // (e.g. larger for desktop etc) and may want to have them in preferences. -const int64 QuotaManager::kTemporaryStorageQuotaDefaultSize = 50 * MBytes; -const int64 QuotaManager::kTemporaryStorageQuotaMaxSize = 1 * 1024 * MBytes; -const int64 QuotaManager::kIncognitoDefaultTemporaryQuota = 50 * MBytes; +const int64 QuotaManager::kTemporaryStorageQuotaDefaultSize = 50 * kMBytes; +const int64 QuotaManager::kTemporaryStorageQuotaMaxSize = 1 * 1024 * kMBytes; +const int64 QuotaManager::kIncognitoDefaultTemporaryQuota = 50 * kMBytes; const int QuotaManager::kPerHostTemporaryPortion = 5; // 20% const char QuotaManager::kDatabaseName[] = "QuotaManager"; +const int QuotaManager::kThresholdOfErrorsToBeBlacklisted = 3; + +const int QuotaManager::kEvictionIntervalInMilliSeconds = + 30 * kMinutesInMilliSeconds; + // This class is for posting GetUsage/GetQuota tasks, gathering // results and dispatching GetAndQuota callbacks. // This class is self-destructed. @@ -531,6 +539,7 @@ class QuotaManager::GetLRUOriginTask scoped_refptr<base::MessageLoopProxy> db_message_loop, StorageType type, const std::map<GURL, int>& origins_in_use, + const std::map<GURL, int>& origins_in_error, GetLRUOriginCallback *callback) : DatabaseTaskBase(manager, database, db_message_loop), type_(type), @@ -542,6 +551,12 @@ class QuotaManager::GetLRUOriginTask if (p->second > 0) exceptions_.insert(p->first); } + for (std::map<GURL, int>::const_iterator p = origins_in_error.begin(); + p != origins_in_error.end(); + ++p) { + if (p->second > QuotaManager::kThresholdOfErrorsToBeBlacklisted) + exceptions_.insert(p->first); + } } protected: @@ -1066,7 +1081,7 @@ void QuotaManager::GetLRUOrigin( } scoped_refptr<GetLRUOriginTask> task(new GetLRUOriginTask( this, database_.get(), db_thread_, type, origins_in_use_, - callback_factory_.NewCallback( + origins_in_error_, callback_factory_.NewCallback( &QuotaManager::DidGetDatabaseLRUOrigin))); task->Start(); } @@ -1075,11 +1090,8 @@ void QuotaManager::DidOriginDataEvicted( QuotaStatusCode status) { DCHECK(io_thread_->BelongsToCurrentThread()); - if (status != kQuotaStatusOk) { + if (status != kQuotaStatusOk) ++eviction_context_.num_eviction_error; - // TODO(dmikurube): The origin with some error should have lower priority in - // the next eviction? - } ++eviction_context_.num_evicted_clients; DCHECK(eviction_context_.num_evicted_clients <= @@ -1089,8 +1101,15 @@ void QuotaManager::DidOriginDataEvicted( eviction_context_.num_eviction_requested_clients = 0; eviction_context_.num_evicted_clients = 0; - // TODO(dmikurube): Call DeleteOriginFromDatabase here. - eviction_context_.evict_origin_data_callback->Run(kQuotaStatusOk); + if (eviction_context_.num_eviction_error == 0) { + DeleteOriginFromDatabase(eviction_context_.evicted_origin, + eviction_context_.evicted_type); + eviction_context_.evict_origin_data_callback->Run(kQuotaStatusOk); + } else { + origins_in_error_[eviction_context_.evicted_origin]++; + eviction_context_.evict_origin_data_callback->Run( + kQuotaErrorInvalidModification); + } eviction_context_.evict_origin_data_callback.reset(); } } @@ -1114,7 +1133,10 @@ void QuotaManager::EvictOriginData( eviction_context_.num_eviction_requested_clients = num_clients; eviction_context_.num_evicted_clients = 0; + eviction_context_.num_eviction_error = 0; + eviction_context_.evicted_origin = origin; + eviction_context_.evicted_type = type; eviction_context_.evict_origin_data_callback.reset(callback); for (QuotaClientList::iterator p = clients_.begin(); p != clients_.end(); @@ -1173,7 +1195,10 @@ void QuotaManager::GetUsageAndQuotaForEviction( } void QuotaManager::StartEviction() { - // TODO(kinuko,dmikurube): kick the first eviction here. + DCHECK(!temporary_storage_evictor_.get()); + temporary_storage_evictor_.reset(new QuotaTemporaryStorageEvictor(this, + kEvictionIntervalInMilliSeconds)); + temporary_storage_evictor_->Start(); } void QuotaManager::DidInitializeTemporaryGlobalQuota(int64 quota) { diff --git a/webkit/quota/quota_manager.h b/webkit/quota/quota_manager.h index ee279ae..aa747c8 100644 --- a/webkit/quota/quota_manager.h +++ b/webkit/quota/quota_manager.h @@ -33,6 +33,7 @@ class FilePath; namespace quota { class QuotaDatabase; +class QuotaTemporaryStorageEvictor; class UsageTracker; struct QuotaManagerDeleter; @@ -157,6 +158,10 @@ class QuotaManager : public QuotaTaskObserver, static const char kDatabaseName[]; + static const int kThresholdOfErrorsToBeBlacklisted; + + static const int kEvictionIntervalInMilliSeconds; + private: class DatabaseTaskBase; class InitializeTask; @@ -187,7 +192,8 @@ class QuotaManager : public QuotaTaskObserver, struct EvictionContext { EvictionContext() - : num_eviction_requested_clients(0), + : evicted_type(kStorageTypeUnknown), + num_eviction_requested_clients(0), num_evicted_clients(0), num_eviction_error(0), usage(0), @@ -195,6 +201,9 @@ class QuotaManager : public QuotaTaskObserver, quota(0) {} virtual ~EvictionContext() {} + GURL evicted_origin; + StorageType evicted_type; + scoped_ptr<EvictOriginDataCallback> evict_origin_data_callback; int num_eviction_requested_clients; int num_evicted_clients; @@ -214,6 +223,7 @@ class QuotaManager : public QuotaTaskObserver, friend struct QuotaManagerDeleter; friend class QuotaManagerProxy; friend class QuotaManagerTest; + friend class QuotaTemporaryStorageEvictor; // This initialization method is lazily called on the IO thread // when the first quota manager API is called. @@ -288,6 +298,7 @@ class QuotaManager : public QuotaTaskObserver, // TODO(michaeln): Need a way to clear the cache, drop and // reinstantiate the trackers when they're not handling requests. + scoped_ptr<QuotaTemporaryStorageEvictor> temporary_storage_evictor_; EvictionContext eviction_context_; UsageAndQuotaDispatcherTaskMap usage_and_quota_dispatchers_; @@ -297,6 +308,8 @@ class QuotaManager : public QuotaTaskObserver, // Map from origin to count. std::map<GURL, int> origins_in_use_; + // Map from origin to error count. + std::map<GURL, int> origins_in_error_; scoped_refptr<SpecialStoragePolicy> special_storage_policy_; diff --git a/webkit/quota/quota_manager_unittest.cc b/webkit/quota/quota_manager_unittest.cc index e3611c5..0ededdb 100644 --- a/webkit/quota/quota_manager_unittest.cc +++ b/webkit/quota/quota_manager_unittest.cc @@ -1013,9 +1013,28 @@ TEST_F(QuotaManagerTest, EvictOriginData) { MessageLoop::current()->RunAllPending(); int64 predelete_host_pers = usage(); + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kData1); ++i) + quota_manager()->NotifyStorageAccessed(QuotaClient::kMockStart, + GURL(kData1[i].origin), kData1[i].type); + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kData2); ++i) + quota_manager()->NotifyStorageAccessed(QuotaClient::kMockStart, + GURL(kData2[i].origin), kData2[i].type); + MessageLoop::current()->RunAllPending(); + EvictOriginData(GURL("http://foo.com/"), kStorageTypeTemporary); MessageLoop::current()->RunAllPending(); + DumpLastAccessTimeTable(); + MessageLoop::current()->RunAllPending(); + + typedef LastAccessTimeTableEntries::const_iterator iterator; + for (iterator itr(last_access_time_table().begin()), + end(last_access_time_table().end()); + itr != end; ++itr) { + if (itr->type == kStorageTypeTemporary) + EXPECT_NE(std::string("http://foo.com/"), itr->origin.spec()); + } + GetGlobalUsage(kStorageTypeTemporary); MessageLoop::current()->RunAllPending(); EXPECT_EQ(predelete_global_tmp - (1 + 50000), usage()); @@ -1029,6 +1048,91 @@ TEST_F(QuotaManagerTest, EvictOriginData) { EXPECT_EQ(predelete_host_pers, usage()); } +TEST_F(QuotaManagerTest, EvictOriginDataWithDeletionError) { + static const MockOriginData kData[] = { + { "http://foo.com/", kStorageTypeTemporary, 1 }, + { "http://foo.com:1/", kStorageTypeTemporary, 20 }, + { "http://foo.com/", kStorageTypePersistent, 300 }, + { "http://bar.com/", kStorageTypeTemporary, 4000 }, + }; + static const int kNumberOfTemporaryOrigins = 3; + MockStorageClient* client = CreateClient(kData, ARRAYSIZE_UNSAFE(kData)); + RegisterClient(client); + + GetGlobalUsage(kStorageTypeTemporary); + MessageLoop::current()->RunAllPending(); + int64 predelete_global_tmp = usage(); + + GetHostUsage("foo.com", kStorageTypeTemporary); + MessageLoop::current()->RunAllPending(); + int64 predelete_host_tmp = usage(); + + GetHostUsage("foo.com", kStorageTypePersistent); + MessageLoop::current()->RunAllPending(); + int64 predelete_host_pers = usage(); + + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kData); ++i) + quota_manager()->NotifyStorageAccessed(QuotaClient::kMockStart, + GURL(kData[i].origin), kData[i].type); + MessageLoop::current()->RunAllPending(); + + client->AddOriginToErrorSet(GURL("http://foo.com/"), kStorageTypeTemporary); + + for (int i = 0; + i < QuotaManager::kThresholdOfErrorsToBeBlacklisted + 1; + ++i) { + EvictOriginData(GURL("http://foo.com/"), kStorageTypeTemporary); + MessageLoop::current()->RunAllPending(); + EXPECT_EQ(kQuotaErrorInvalidModification, status()); + } + + DumpLastAccessTimeTable(); + MessageLoop::current()->RunAllPending(); + + bool found_origin_in_database = false; + typedef LastAccessTimeTableEntries::const_iterator iterator; + for (iterator itr(last_access_time_table().begin()), + end(last_access_time_table().end()); + itr != end; ++itr) { + if (itr->type == kStorageTypeTemporary && + GURL("http://foo.com/") == itr->origin) { + found_origin_in_database = true; + break; + } + } + // The origin "http://foo.com/" should be in the database. + EXPECT_TRUE(found_origin_in_database); + + for (size_t i = 0; i < kNumberOfTemporaryOrigins - 1; ++i) { + GetLRUOrigin(kStorageTypeTemporary); + MessageLoop::current()->RunAllPending(); + EXPECT_FALSE(lru_origin().is_empty()); + // The origin "http://foo.com/" should not be in the LRU list. + EXPECT_NE(std::string("http://foo.com/"), lru_origin().spec()); + DeleteOriginFromDatabase(lru_origin(), kStorageTypeTemporary); + MessageLoop::current()->RunAllPending(); + } + + // Now the LRU list must be empty. + GetLRUOrigin(kStorageTypeTemporary); + MessageLoop::current()->RunAllPending(); + EXPECT_TRUE(lru_origin().is_empty()); + + // Deleting origins from the database should not affect the results of the + // following checks. + GetGlobalUsage(kStorageTypeTemporary); + MessageLoop::current()->RunAllPending(); + EXPECT_EQ(predelete_global_tmp, usage()); + + GetHostUsage("foo.com", kStorageTypeTemporary); + MessageLoop::current()->RunAllPending(); + EXPECT_EQ(predelete_host_tmp, usage()); + + GetHostUsage("foo.com", kStorageTypePersistent); + MessageLoop::current()->RunAllPending(); + EXPECT_EQ(predelete_host_pers, usage()); +} + TEST_F(QuotaManagerTest, GetUsageAndQuotaForEviction) { static const MockOriginData kData[] = { { "http://foo.com/", kStorageTypeTemporary, 1 }, diff --git a/webkit/quota/quota_temporary_storage_evictor.cc b/webkit/quota/quota_temporary_storage_evictor.cc index 1df3436..16e88bc 100644 --- a/webkit/quota/quota_temporary_storage_evictor.cc +++ b/webkit/quota/quota_temporary_storage_evictor.cc @@ -4,7 +4,6 @@ #include "webkit/quota/quota_temporary_storage_evictor.h" -#include "base/message_loop_proxy.h" #include "googleurl/src/gurl.h" #include "webkit/quota/quota_manager.h" @@ -16,14 +15,12 @@ const int64 QuotaTemporaryStorageEvictor:: QuotaTemporaryStorageEvictor::QuotaTemporaryStorageEvictor( QuotaEvictionHandler* quota_eviction_handler, - int64 interval_ms, - scoped_refptr<base::MessageLoopProxy> io_thread) + int64 interval_ms) : min_available_disk_space_to_start_eviction_( kDefaultMinAvailableDiskSpaceToStartEviction), quota_eviction_handler_(quota_eviction_handler), interval_ms_(interval_ms), - repeated_eviction_(false), - io_thread_(io_thread), + repeated_eviction_(true), callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { DCHECK(quota_eviction_handler); } @@ -32,7 +29,7 @@ QuotaTemporaryStorageEvictor::~QuotaTemporaryStorageEvictor() { } void QuotaTemporaryStorageEvictor::Start() { - DCHECK(io_thread_->BelongsToCurrentThread()); + DCHECK(CalledOnValidThread()); StartEvictionTimerWithDelay(0); } @@ -56,7 +53,7 @@ void QuotaTemporaryStorageEvictor::OnGotUsageAndQuotaForEviction( int64 unlimited_usage, int64 quota, int64 available_disk_space) { - DCHECK(io_thread_->BelongsToCurrentThread()); + DCHECK(CalledOnValidThread()); DCHECK_GE(usage, unlimited_usage); // unlimited_usage is a subset of usage usage -= unlimited_usage; @@ -72,6 +69,7 @@ void QuotaTemporaryStorageEvictor::OnGotUsageAndQuotaForEviction( &QuotaTemporaryStorageEvictor::OnGotLRUOrigin)); } else if (repeated_eviction_) { // No action required, sleep for a while and check again later. + // TODO(dmikurube): Stop repeating if error happens frequently. StartEvictionTimerWithDelay(interval_ms_); } @@ -80,7 +78,7 @@ void QuotaTemporaryStorageEvictor::OnGotUsageAndQuotaForEviction( } void QuotaTemporaryStorageEvictor::OnGotLRUOrigin(const GURL& origin) { - DCHECK(io_thread_->BelongsToCurrentThread()); + DCHECK(CalledOnValidThread()); if (origin.is_empty()) { if (repeated_eviction_) @@ -95,7 +93,12 @@ void QuotaTemporaryStorageEvictor::OnGotLRUOrigin(const GURL& origin) { void QuotaTemporaryStorageEvictor::OnEvictionComplete( QuotaStatusCode status) { - DCHECK(io_thread_->BelongsToCurrentThread()); + DCHECK(CalledOnValidThread()); + + // Just calling ConsiderEviction() here is ok. No need to deal with the + // case that all of the Delete operations fail for a certain origin. It + // doesn't result in trying to evict the same origin permanently. The + // evictor skips origins which had deletion errors a few times. // We many need to get rid of more space so reconsider immediately. ConsiderEviction(); diff --git a/webkit/quota/quota_temporary_storage_evictor.h b/webkit/quota/quota_temporary_storage_evictor.h index 6a7c97e1..7bb1899 100644 --- a/webkit/quota/quota_temporary_storage_evictor.h +++ b/webkit/quota/quota_temporary_storage_evictor.h @@ -7,6 +7,7 @@ #pragma once #include "base/memory/scoped_callback_factory.h" +#include "base/threading/non_thread_safe.h" #include "base/timer.h" #include "webkit/quota/quota_types.h" @@ -20,21 +21,15 @@ namespace quota { class QuotaEvictionHandler; -class QuotaTemporaryStorageEvictor { +class QuotaTemporaryStorageEvictor : public base::NonThreadSafe { public: QuotaTemporaryStorageEvictor( QuotaEvictionHandler* quota_eviction_handler, - int64 interval_ms, - scoped_refptr<base::MessageLoopProxy> io_thread); + int64 interval_ms); virtual ~QuotaTemporaryStorageEvictor(); void Start(); - bool repeated_eviction() const { return repeated_eviction_; } - void set_repeated_eviction(bool repeated_eviction) { - repeated_eviction_ = repeated_eviction; - } - private: friend class QuotaTemporaryStorageEvictorTest; @@ -49,6 +44,11 @@ class QuotaTemporaryStorageEvictor { void OnGotLRUOrigin(const GURL& origin); void OnEvictionComplete(QuotaStatusCode status); + // This is only used for tests. + void set_repeated_eviction(bool repeated_eviction) { + repeated_eviction_ = repeated_eviction; + } + static const double kUsageRatioToStartEviction; static const int64 kDefaultMinAvailableDiskSpaceToStartEviction; @@ -59,7 +59,6 @@ class QuotaTemporaryStorageEvictor { int64 interval_ms_; bool repeated_eviction_; - scoped_refptr<base::MessageLoopProxy> io_thread_; base::OneShotTimer<QuotaTemporaryStorageEvictor> timer_; diff --git a/webkit/quota/quota_temporary_storage_evictor_unittest.cc b/webkit/quota/quota_temporary_storage_evictor_unittest.cc index ed17752..59933e0 100644 --- a/webkit/quota/quota_temporary_storage_evictor_unittest.cc +++ b/webkit/quota/quota_temporary_storage_evictor_unittest.cc @@ -134,8 +134,7 @@ class QuotaTemporaryStorageEvictorTest : public testing::Test { // Run multiple evictions in a single RunAllPending() when interval_ms == 0 temporary_storage_evictor_.reset(new QuotaTemporaryStorageEvictor( - quota_eviction_handler_.get(), - 0, base::MessageLoopProxy::CreateForCurrentThread())); + quota_eviction_handler_.get(), 0)); } void TearDown() { @@ -177,6 +176,10 @@ class QuotaTemporaryStorageEvictorTest : public testing::Test { return temporary_storage_evictor_.get(); } + void set_repeated_eviction(bool repeated_eviction) const { + return temporary_storage_evictor_->set_repeated_eviction(repeated_eviction); + } + int num_get_usage_and_quota_for_eviction() const { return num_get_usage_and_quota_for_eviction_; } @@ -204,6 +207,7 @@ TEST_F(QuotaTemporaryStorageEvictorTest, SimpleEvictionTest) { quota_eviction_handler()->set_quota(4000); quota_eviction_handler()->set_available_space(1000000000); EXPECT_EQ(3000 + 200 + 500, quota_eviction_handler()->GetUsage()); + set_repeated_eviction(false); temporary_storage_evictor()->Start(); MessageLoop::current()->RunAllPending(); EXPECT_EQ(200 + 500, quota_eviction_handler()->GetUsage()); @@ -217,6 +221,7 @@ TEST_F(QuotaTemporaryStorageEvictorTest, MultipleEvictionTest) { quota_eviction_handler()->set_quota(4000); quota_eviction_handler()->set_available_space(1000000000); EXPECT_EQ(20 + 2900 + 450 + 400, quota_eviction_handler()->GetUsage()); + set_repeated_eviction(false); temporary_storage_evictor()->Start(); MessageLoop::current()->RunAllPending(); EXPECT_EQ(450 + 400, quota_eviction_handler()->GetUsage()); @@ -244,7 +249,6 @@ TEST_F(QuotaTemporaryStorageEvictorTest, RepeatedEvictionTest) { initial_total_size - d_size, initial_total_size - d_size + e_size - c_size)); EXPECT_EQ(initial_total_size, quota_eviction_handler()->GetUsage()); - temporary_storage_evictor()->set_repeated_eviction(true); temporary_storage_evictor()->Start(); MessageLoop::current()->RunAllPending(); EXPECT_EQ(initial_total_size - d_size + e_size - c_size - b_size, @@ -274,7 +278,6 @@ TEST_F(QuotaTemporaryStorageEvictorTest, RepeatedEvictionWithAccessOriginTest) { initial_total_size - d_size, initial_total_size - d_size + e_size - b_size)); EXPECT_EQ(initial_total_size, quota_eviction_handler()->GetUsage()); - temporary_storage_evictor()->set_repeated_eviction(true); temporary_storage_evictor()->Start(); MessageLoop::current()->RunAllPending(); EXPECT_EQ(initial_total_size - d_size + e_size - b_size - a_size, @@ -291,6 +294,7 @@ 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_repeated_eviction(false); temporary_storage_evictor()->Start(); MessageLoop::current()->RunAllPending(); EXPECT_EQ(150 + 300, quota_eviction_handler()->GetUsage()); @@ -304,6 +308,7 @@ TEST_F(QuotaTemporaryStorageEvictorTest, UnlimitedExclusionEvictionTest) { quota_eviction_handler()->set_quota(5000); quota_eviction_handler()->set_available_space(1000000000); EXPECT_EQ(3000 + 200 + 500000, quota_eviction_handler()->GetUsage()); + set_repeated_eviction(false); temporary_storage_evictor()->Start(); MessageLoop::current()->RunAllPending(); // Nothing should have been evicted. |