summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcalamity <calamity@chromium.org>2015-08-26 23:29:14 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-27 06:30:25 +0000
commit508c6fa442424455b9746ba81bc4b9b59a059187 (patch)
tree1debaff089915dd90257b4d9a8464a12d483aa6c
parent35a21829d492dca8c61f7310f5fab36597ba0655 (diff)
downloadchromium_src-508c6fa442424455b9746ba81bc4b9b59a059187.zip
chromium_src-508c6fa442424455b9746ba81bc4b9b59a059187.tar.gz
chromium_src-508c6fa442424455b9746ba81bc4b9b59a059187.tar.bz2
Add a SiteEngagementEvictionPolicy.
This CL adds a TemporaryStorageEvictionPolicy interface to QuotaManager which is implemented by a new SiteEngagementEvictionPolicy which picks the origin to evict based on its site engagement score and usage. This will then be integrated into the actual temporary storage eviction system in a follow-up patch. BUG=464234 TBR=jam@chromium.org Review URL: https://codereview.chromium.org/1221523003 Cr-Commit-Position: refs/heads/master@{#345813}
-rw-r--r--chrome/browser/engagement/site_engagement_eviction_policy.cc117
-rw-r--r--chrome/browser/engagement/site_engagement_eviction_policy.h50
-rw-r--r--chrome/browser/engagement/site_engagement_eviction_policy_unittest.cc128
-rw-r--r--chrome/browser/engagement/site_engagement_service.h23
-rw-r--r--chrome/chrome_browser.gypi2
-rw-r--r--chrome/chrome_tests_unit.gypi1
-rw-r--r--content/browser/quota/quota_temporary_storage_evictor_unittest.cc4
-rw-r--r--storage/browser/quota/quota_callbacks.h1
-rw-r--r--storage/browser/quota/quota_manager.cc69
-rw-r--r--storage/browser/quota/quota_manager.h32
-rw-r--r--storage/browser/quota/quota_temporary_storage_evictor.cc6
-rw-r--r--storage/browser/quota/quota_temporary_storage_evictor.h2
12 files changed, 379 insertions, 56 deletions
diff --git a/chrome/browser/engagement/site_engagement_eviction_policy.cc b/chrome/browser/engagement/site_engagement_eviction_policy.cc
new file mode 100644
index 0000000..ba7a885
--- /dev/null
+++ b/chrome/browser/engagement/site_engagement_eviction_policy.cc
@@ -0,0 +1,117 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/barrier_closure.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/engagement/site_engagement_eviction_policy.h"
+#include "chrome/browser/engagement/site_engagement_service.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_manager.h"
+#include "content/public/browser/browser_thread.h"
+
+namespace {
+
+const int kExpectedEngagementSites = 200;
+
+// Gets the quota that an origin deserves based on its site engagement.
+int64 GetSoftQuotaForOrigin(const GURL& origin,
+ int score,
+ int total_engagement_points,
+ int64 global_quota) {
+ double quota_per_point =
+ global_quota /
+ std::max(kExpectedEngagementSites * SiteEngagementScore::kMaxPoints,
+ static_cast<double>(total_engagement_points));
+
+ return score * quota_per_point;
+}
+
+GURL DoCalculateEvictionOrigin(
+ const scoped_refptr<storage::SpecialStoragePolicy>& special_storage_policy,
+ SiteEngagementScoreProvider* score_provider,
+ const std::map<GURL, int64>& usage_map,
+ int64 global_quota) {
+ // TODO(calamity): Integrate storage access frequency as an input to this
+ // heuristic.
+
+ // This heuristic is intended to optimize for two criteria:
+ // - evict the site that the user cares about least
+ // - evict the least number of sites to get under the quota limit
+ //
+ // The heuristic for deciding the next eviction origin calculates a soft
+ // quota for each origin which is the amount the origin should be allowed to
+ // use based on its engagement and the global quota. The origin that most
+ // exceeds its soft quota is chosen.
+ GURL origin_to_evict;
+ int64 max_overuse = std::numeric_limits<int64>::min();
+ int total_engagement_points = score_provider->GetTotalEngagementPoints();
+
+ for (const auto& usage : usage_map) {
+ GURL origin = usage.first;
+ if (special_storage_policy &&
+ (special_storage_policy->IsStorageUnlimited(origin) ||
+ special_storage_policy->IsStorageDurable(origin))) {
+ continue;
+ }
+
+ // |overuse| can be negative if the soft quota exceeds the usage.
+ int64 overuse = usage.second - GetSoftQuotaForOrigin(
+ origin, score_provider->GetScore(origin),
+ total_engagement_points, global_quota);
+ if (overuse > max_overuse) {
+ max_overuse = overuse;
+ origin_to_evict = origin;
+ }
+ }
+ return origin_to_evict;
+}
+
+GURL GetSiteEngagementEvictionOriginOnUIThread(
+ const scoped_refptr<storage::SpecialStoragePolicy>& special_storage_policy,
+ content::BrowserContext* browser_context,
+ const std::map<GURL, int64>& usage_map,
+ int64 global_quota) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ Profile* profile = Profile::FromBrowserContext(browser_context);
+ SiteEngagementService* service =
+ g_browser_process->profile_manager()->IsValidProfile(profile)
+ ? SiteEngagementService::Get(profile)
+ : nullptr;
+ if (!service)
+ return GURL();
+
+ return DoCalculateEvictionOrigin(special_storage_policy, service, usage_map,
+ global_quota);
+}
+
+} // namespace
+
+SiteEngagementEvictionPolicy::SiteEngagementEvictionPolicy(
+ content::BrowserContext* browser_context)
+ : browser_context_(browser_context) {}
+
+SiteEngagementEvictionPolicy::~SiteEngagementEvictionPolicy() {}
+
+void SiteEngagementEvictionPolicy::GetEvictionOrigin(
+ const scoped_refptr<storage::SpecialStoragePolicy>& special_storage_policy,
+ const std::map<GURL, int64>& usage_map,
+ int64 global_quota,
+ const storage::GetOriginCallback& callback) {
+ content::BrowserThread::PostTaskAndReplyWithResult(
+ content::BrowserThread::UI, FROM_HERE,
+ base::Bind(&GetSiteEngagementEvictionOriginOnUIThread,
+ special_storage_policy, browser_context_, usage_map,
+ global_quota),
+ callback);
+}
+
+// static
+GURL SiteEngagementEvictionPolicy::CalculateEvictionOrigin(
+ const scoped_refptr<storage::SpecialStoragePolicy>& special_storage_policy,
+ SiteEngagementScoreProvider* score_provider,
+ const std::map<GURL, int64>& usage_map,
+ int64 global_quota) {
+ return DoCalculateEvictionOrigin(special_storage_policy, score_provider,
+ usage_map, global_quota);
+}
diff --git a/chrome/browser/engagement/site_engagement_eviction_policy.h b/chrome/browser/engagement/site_engagement_eviction_policy.h
new file mode 100644
index 0000000..470b0ec
--- /dev/null
+++ b/chrome/browser/engagement/site_engagement_eviction_policy.h
@@ -0,0 +1,50 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_EVICTION_POLICY_H_
+#define CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_EVICTION_POLICY_H_
+
+#include <map>
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "storage/browser/quota/quota_manager.h"
+#include "url/gurl.h"
+
+namespace content {
+class BrowserContext;
+}
+
+class SiteEngagementScoreProvider;
+
+class SiteEngagementEvictionPolicy : public storage::QuotaEvictionPolicy {
+ public:
+ explicit SiteEngagementEvictionPolicy(
+ content::BrowserContext* browser_context);
+ virtual ~SiteEngagementEvictionPolicy();
+
+ // Overridden from storage::QuotaEvictionPolicy:
+ void GetEvictionOrigin(const scoped_refptr<storage::SpecialStoragePolicy>&
+ special_storage_policy,
+ const std::map<GURL, int64>& usage_map,
+ int64 global_quota,
+ const storage::GetOriginCallback& callback) override;
+
+ private:
+ friend class SiteEngagementEvictionPolicyTest;
+
+ static GURL CalculateEvictionOrigin(
+ const scoped_refptr<storage::SpecialStoragePolicy>&
+ special_storage_policy,
+ SiteEngagementScoreProvider* score_provider,
+ const std::map<GURL, int64>& usage_map,
+ int64 global_quota);
+
+ content::BrowserContext* browser_context_;
+
+ DISALLOW_COPY_AND_ASSIGN(SiteEngagementEvictionPolicy);
+};
+
+#endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_EVICTION_POLICY_H_
diff --git a/chrome/browser/engagement/site_engagement_eviction_policy_unittest.cc b/chrome/browser/engagement/site_engagement_eviction_policy_unittest.cc
new file mode 100644
index 0000000..49757f2
--- /dev/null
+++ b/chrome/browser/engagement/site_engagement_eviction_policy_unittest.cc
@@ -0,0 +1,128 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/engagement/site_engagement_eviction_policy.h"
+#include "chrome/browser/engagement/site_engagement_service.h"
+#include "content/public/test/mock_special_storage_policy.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+const int64 kGlobalQuota = 25 * 1024;
+
+} // namespace
+
+class TestSiteEngagementScoreProvider : public SiteEngagementScoreProvider {
+ public:
+ TestSiteEngagementScoreProvider() {}
+
+ virtual ~TestSiteEngagementScoreProvider() {}
+
+ int GetScore(const GURL& url) override { return engagement_score_map_[url]; }
+
+ int GetTotalEngagementPoints() override {
+ int total = 0;
+ for (const auto& site : engagement_score_map_)
+ total += site.second;
+ return total;
+ }
+
+ void SetScore(const GURL& origin, int score) {
+ engagement_score_map_[origin] = score;
+ }
+
+ private:
+ std::map<GURL, int> engagement_score_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestSiteEngagementScoreProvider);
+};
+
+class SiteEngagementEvictionPolicyTest : public testing::Test {
+ public:
+ SiteEngagementEvictionPolicyTest()
+ : score_provider_(new TestSiteEngagementScoreProvider()),
+ storage_policy_(new content::MockSpecialStoragePolicy()) {}
+
+ ~SiteEngagementEvictionPolicyTest() override {}
+
+ GURL CalculateEvictionOrigin(const std::map<GURL, int64>& usage) {
+ return SiteEngagementEvictionPolicy::CalculateEvictionOrigin(
+ storage_policy_, score_provider_.get(), usage, kGlobalQuota);
+ }
+
+ TestSiteEngagementScoreProvider* score_provider() {
+ return score_provider_.get();
+ }
+
+ content::MockSpecialStoragePolicy* storage_policy() {
+ return storage_policy_.get();
+ }
+
+ private:
+ scoped_ptr<TestSiteEngagementScoreProvider> score_provider_;
+ scoped_refptr<content::MockSpecialStoragePolicy> storage_policy_;
+
+ DISALLOW_COPY_AND_ASSIGN(SiteEngagementEvictionPolicyTest);
+};
+
+TEST_F(SiteEngagementEvictionPolicyTest, GetEvictionOrigin) {
+ GURL url1("http://www.google.com");
+ GURL url2("http://www.example.com");
+ GURL url3("http://www.spam.me");
+
+ std::map<GURL, int64> usage;
+ usage[url1] = 10 * 1024;
+ usage[url2] = 10 * 1024;
+ usage[url3] = 10 * 1024;
+
+ score_provider()->SetScore(url1, 50);
+ score_provider()->SetScore(url2, 25);
+
+ // When 3 sites have equal usage, evict the site with the least engagement.
+ EXPECT_EQ(url3, CalculateEvictionOrigin(usage));
+
+ usage[url2] = usage[url3] + 10;
+
+ // Now |url2| has the most usage but |url3| has the least engagement score so
+ // one of them should be evicted. In this case the heuristic chooses |url3|.
+ EXPECT_EQ(url3, CalculateEvictionOrigin(usage));
+
+ // But exceeding allocated usage too much will still result in being evicted
+ // even though the engagement with |url2| is higher.
+ usage[url2] = 15 * 1024;
+ EXPECT_EQ(url2, CalculateEvictionOrigin(usage));
+
+ // When all origins have the same engagement, the origin with the highest
+ // usage is evicted.
+ score_provider()->SetScore(url1, 50);
+ score_provider()->SetScore(url2, 50);
+ score_provider()->SetScore(url3, 50);
+
+ usage[url2] = 10 * 1024;
+ usage[url3] = 20 * 1024;
+ EXPECT_EQ(url3, CalculateEvictionOrigin(usage));
+}
+
+// Test that durable and unlimited storage origins are exempt from eviction.
+TEST_F(SiteEngagementEvictionPolicyTest, SpecialStoragePolicy) {
+ GURL url1("http://www.google.com");
+ GURL url2("http://www.example.com");
+
+ std::map<GURL, int64> usage;
+ usage[url1] = 10 * 1024;
+ usage[url2] = 10 * 1024;
+
+ score_provider()->SetScore(url1, 50);
+ score_provider()->SetScore(url2, 25);
+
+ EXPECT_EQ(url2, CalculateEvictionOrigin(usage));
+
+ // Durable storage doesn't get evicted.
+ storage_policy()->AddDurable(url2);
+ EXPECT_EQ(url1, CalculateEvictionOrigin(usage));
+
+ // Unlimited storage doesn't get evicted.
+ storage_policy()->AddUnlimited(url1);
+ EXPECT_EQ(GURL(), CalculateEvictionOrigin(usage));
+}
diff --git a/chrome/browser/engagement/site_engagement_service.h b/chrome/browser/engagement/site_engagement_service.h
index f5494de..60644a4 100644
--- a/chrome/browser/engagement/site_engagement_service.h
+++ b/chrome/browser/engagement/site_engagement_service.h
@@ -7,7 +7,6 @@
#include "base/gtest_prod_util.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/time/default_clock.h"
#include "base/time/time.h"
#include "components/keyed_service/core/keyed_service.h"
@@ -84,6 +83,16 @@ class SiteEngagementScore {
DISALLOW_COPY_AND_ASSIGN(SiteEngagementScore);
};
+class SiteEngagementScoreProvider {
+ public:
+ // Returns a non-negative integer representing the engagement score of the
+ // origin for this URL.
+ virtual int GetScore(const GURL& url) = 0;
+
+ // Returns the sum of engagement points awarded to all sites.
+ virtual int GetTotalEngagementPoints() = 0;
+};
+
// Stores and retrieves the engagement score of an origin.
//
// An engagement score is a positive integer that represents how much a user has
@@ -94,7 +103,8 @@ class SiteEngagementScore {
// the homescreen, will increase the site engagement score. Negative activity,
// such as rejecting permission prompts or not responding to notifications, will
// decrease the site engagement score.
-class SiteEngagementService : public KeyedService {
+class SiteEngagementService : public KeyedService,
+ public SiteEngagementScoreProvider {
public:
static SiteEngagementService* Get(Profile* profile);
@@ -107,12 +117,9 @@ class SiteEngagementService : public KeyedService {
// Update the karma score of the origin matching |url| for user navigation.
void HandleNavigation(const GURL& url);
- // Returns a non-negative integer representing the engagement score of the
- // origin for this URL.
- int GetScore(const GURL& url);
-
- // Returns the sum of engagement points awarded to all sites.
- int GetTotalEngagementPoints();
+ // Overridden from SiteEngagementScoreProvider:
+ int GetScore(const GURL& url) override;
+ int GetTotalEngagementPoints() override;
private:
Profile* profile_;
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index e851701..dc323e1 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1426,6 +1426,8 @@
'browser/content_settings/web_site_settings_uma_util.h',
],
'chrome_browser_engagement_sources': [
+ 'browser/engagement/site_engagement_eviction_policy.cc',
+ 'browser/engagement/site_engagement_eviction_policy.h',
'browser/engagement/site_engagement_helper.cc',
'browser/engagement/site_engagement_helper.h',
'browser/engagement/site_engagement_service.cc',
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index f479da8..cb7086a 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -1472,6 +1472,7 @@
'browser/diagnostics/diagnostics_model_unittest.cc',
'browser/download/download_commands_unittest.cc',
'browser/download/download_shelf_unittest.cc',
+ 'browser/engagement/site_engagement_eviction_policy_unittest.cc',
'browser/engagement/site_engagement_service_unittest.cc',
'browser/first_run/first_run_unittest.cc',
'browser/font_family_cache_unittest.cc',
diff --git a/content/browser/quota/quota_temporary_storage_evictor_unittest.cc b/content/browser/quota/quota_temporary_storage_evictor_unittest.cc
index ba414fc..2d63362 100644
--- a/content/browser/quota/quota_temporary_storage_evictor_unittest.cc
+++ b/content/browser/quota/quota_temporary_storage_evictor_unittest.cc
@@ -59,8 +59,8 @@ class MockQuotaEvictionHandler : public storage::QuotaEvictionHandler {
callback.Run(storage::kQuotaStatusOk, quota_and_usage);
}
- void GetLRUOrigin(StorageType type,
- const GetLRUOriginCallback& callback) override {
+ void GetEvictionOrigin(StorageType type,
+ const storage::GetOriginCallback& callback) override {
if (origin_order_.empty())
callback.Run(GURL());
else
diff --git a/storage/browser/quota/quota_callbacks.h b/storage/browser/quota/quota_callbacks.h
index 298f269..36bca1e 100644
--- a/storage/browser/quota/quota_callbacks.h
+++ b/storage/browser/quota/quota_callbacks.h
@@ -31,6 +31,7 @@ typedef base::Callback<void(QuotaStatusCode)> StatusCallback;
typedef base::Callback<void(const std::set<GURL>& origins,
StorageType type)> GetOriginsCallback;
typedef base::Callback<void(const UsageInfoEntries&)> GetUsageInfoCallback;
+typedef base::Callback<void(const GURL&)> GetOriginCallback;
// Simple template wrapper for a callback queue.
template <typename CallbackType, typename... Args>
diff --git a/storage/browser/quota/quota_manager.cc b/storage/browser/quota/quota_manager.cc
index 13b84c7..52f7280 100644
--- a/storage/browser/quota/quota_manager.cc
+++ b/storage/browser/quota/quota_manager.cc
@@ -1440,9 +1440,42 @@ void QuotaManager::DidGetPersistentGlobalUsageForHistogram(
unlimited_origins);
}
-void QuotaManager::GetLRUOrigin(
- StorageType type,
- const GetLRUOriginCallback& callback) {
+void QuotaManager::GetEvictionOrigin(StorageType type,
+ const GetOriginCallback& callback) {
+ GetLRUOrigin(type, callback);
+}
+
+void QuotaManager::EvictOriginData(const GURL& origin,
+ StorageType type,
+ const EvictOriginDataCallback& callback) {
+ DCHECK(io_thread_->BelongsToCurrentThread());
+ DCHECK_EQ(type, kStorageTypeTemporary);
+
+ eviction_context_.evicted_origin = origin;
+ eviction_context_.evicted_type = type;
+ eviction_context_.evict_origin_data_callback = callback;
+
+ DeleteOriginData(origin, type, QuotaClient::kAllClientsMask,
+ base::Bind(&QuotaManager::DidOriginDataEvicted,
+ weak_factory_.GetWeakPtr()));
+}
+
+void QuotaManager::GetUsageAndQuotaForEviction(
+ const UsageAndQuotaCallback& callback) {
+ DCHECK(io_thread_->BelongsToCurrentThread());
+ LazyInitialize();
+
+ UsageAndQuotaCallbackDispatcher* dispatcher =
+ new UsageAndQuotaCallbackDispatcher(this);
+ GetUsageTracker(kStorageTypeTemporary)
+ ->GetGlobalLimitedUsage(dispatcher->GetGlobalLimitedUsageCallback());
+ GetTemporaryGlobalQuota(dispatcher->GetQuotaCallback());
+ GetAvailableSpace(dispatcher->GetAvailableSpaceCallback());
+ dispatcher->WaitForResults(callback);
+}
+
+void QuotaManager::GetLRUOrigin(StorageType type,
+ const GetOriginCallback& callback) {
LazyInitialize();
// This must not be called while there's an in-flight task.
DCHECK(lru_origin_callback_.is_null());
@@ -1480,36 +1513,6 @@ void QuotaManager::GetLRUOrigin(
base::Owned(url)));
}
-void QuotaManager::EvictOriginData(
- const GURL& origin,
- StorageType type,
- const EvictOriginDataCallback& callback) {
- DCHECK(io_thread_->BelongsToCurrentThread());
- DCHECK_EQ(type, kStorageTypeTemporary);
-
- eviction_context_.evicted_origin = origin;
- eviction_context_.evicted_type = type;
- eviction_context_.evict_origin_data_callback = callback;
-
- DeleteOriginData(origin, type, QuotaClient::kAllClientsMask,
- base::Bind(&QuotaManager::DidOriginDataEvicted,
- weak_factory_.GetWeakPtr()));
-}
-
-void QuotaManager::GetUsageAndQuotaForEviction(
- const UsageAndQuotaCallback& callback) {
- DCHECK(io_thread_->BelongsToCurrentThread());
- LazyInitialize();
-
- UsageAndQuotaCallbackDispatcher* dispatcher =
- new UsageAndQuotaCallbackDispatcher(this);
- GetUsageTracker(kStorageTypeTemporary)->
- GetGlobalLimitedUsage(dispatcher->GetGlobalLimitedUsageCallback());
- GetTemporaryGlobalQuota(dispatcher->GetQuotaCallback());
- GetAvailableSpace(dispatcher->GetAvailableSpaceCallback());
- dispatcher->WaitForResults(callback);
-}
-
void QuotaManager::DidSetTemporaryGlobalOverrideQuota(
const QuotaCallback& callback,
const int64* new_quota,
diff --git a/storage/browser/quota/quota_manager.h b/storage/browser/quota/quota_manager.h
index 07106df..506aa0a 100644
--- a/storage/browser/quota/quota_manager.h
+++ b/storage/browser/quota/quota_manager.h
@@ -69,20 +69,32 @@ struct STORAGE_EXPORT UsageAndQuota {
int64 available_disk_space);
};
+// TODO(calamity): Use this in the temporary storage eviction path.
+// An interface for deciding which origin's temporary storage should be evicted
+// when the quota is exceeded.
+class STORAGE_EXPORT QuotaEvictionPolicy {
+ public:
+ // Returns the next origin to evict. It might return an empty GURL when there
+ // are no evictable origins.
+ virtual void GetEvictionOrigin(
+ const scoped_refptr<SpecialStoragePolicy>& special_storage_policy,
+ const std::map<GURL, int64>& usage_map,
+ int64 global_quota,
+ const GetOriginCallback& callback) = 0;
+};
+
// An interface called by QuotaTemporaryStorageEvictor.
class STORAGE_EXPORT QuotaEvictionHandler {
public:
- typedef base::Callback<void(const GURL&)> GetLRUOriginCallback;
typedef StatusCallback EvictOriginDataCallback;
typedef base::Callback<void(QuotaStatusCode status,
const UsageAndQuota& usage_and_quota)>
UsageAndQuotaCallback;
- // Returns the least recently used origin. It might return empty
- // GURL when there are no evictable origins.
- virtual void GetLRUOrigin(
- StorageType type,
- const GetLRUOriginCallback& callback) = 0;
+ // Returns next origin to evict. It might return an empty GURL when there are
+ // no evictable origins.
+ virtual void GetEvictionOrigin(StorageType type,
+ const GetOriginCallback& callback) = 0;
virtual void EvictOriginData(
const GURL& origin,
@@ -362,14 +374,16 @@ class STORAGE_EXPORT QuotaManager
int64 unlimited_usage);
// QuotaEvictionHandler.
- void GetLRUOrigin(StorageType type,
- const GetLRUOriginCallback& callback) override;
+ void GetEvictionOrigin(StorageType type,
+ const GetOriginCallback& callback) override;
void EvictOriginData(const GURL& origin,
StorageType type,
const EvictOriginDataCallback& callback) override;
void GetUsageAndQuotaForEviction(
const UsageAndQuotaCallback& callback) override;
+ void GetLRUOrigin(StorageType type, const GetOriginCallback& callback);
+
void DidSetTemporaryGlobalOverrideQuota(const QuotaCallback& callback,
const int64* new_quota,
bool success);
@@ -408,7 +422,7 @@ class STORAGE_EXPORT QuotaManager
scoped_refptr<base::SequencedTaskRunner> db_thread_;
mutable scoped_ptr<QuotaDatabase> database_;
- GetLRUOriginCallback lru_origin_callback_;
+ GetOriginCallback lru_origin_callback_;
std::set<GURL> access_notified_origins_;
QuotaClientList clients_;
diff --git a/storage/browser/quota/quota_temporary_storage_evictor.cc b/storage/browser/quota/quota_temporary_storage_evictor.cc
index cb4c504..adcff0d 100644
--- a/storage/browser/quota/quota_temporary_storage_evictor.cc
+++ b/storage/browser/quota/quota_temporary_storage_evictor.cc
@@ -195,9 +195,9 @@ void QuotaTemporaryStorageEvictor::OnGotUsageAndQuotaForEviction(
// Space is getting tight. Get the least recently used origin and continue.
// TODO(michaeln): if the reason for eviction is low physical disk space,
// make 'unlimited' origins subject to eviction too.
- quota_eviction_handler_->GetLRUOrigin(
+ quota_eviction_handler_->GetEvictionOrigin(
kStorageTypeTemporary,
- base::Bind(&QuotaTemporaryStorageEvictor::OnGotLRUOrigin,
+ base::Bind(&QuotaTemporaryStorageEvictor::OnGotEvictionOrigin,
weak_factory_.GetWeakPtr()));
} else {
if (repeated_eviction_) {
@@ -217,7 +217,7 @@ void QuotaTemporaryStorageEvictor::OnGotUsageAndQuotaForEviction(
// TODO(dmikurube): Add error handling for the case status != kQuotaStatusOk.
}
-void QuotaTemporaryStorageEvictor::OnGotLRUOrigin(const GURL& origin) {
+void QuotaTemporaryStorageEvictor::OnGotEvictionOrigin(const GURL& origin) {
DCHECK(CalledOnValidThread());
if (origin.is_empty()) {
diff --git a/storage/browser/quota/quota_temporary_storage_evictor.h b/storage/browser/quota/quota_temporary_storage_evictor.h
index 706355d..a32b6c8 100644
--- a/storage/browser/quota/quota_temporary_storage_evictor.h
+++ b/storage/browser/quota/quota_temporary_storage_evictor.h
@@ -95,7 +95,7 @@ class STORAGE_EXPORT_PRIVATE QuotaTemporaryStorageEvictor
void OnGotUsageAndQuotaForEviction(
QuotaStatusCode status,
const UsageAndQuota& quota_and_usage);
- void OnGotLRUOrigin(const GURL& origin);
+ void OnGotEvictionOrigin(const GURL& origin);
void OnEvictionComplete(QuotaStatusCode status);
void OnEvictionRoundStarted();