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

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

Issue 1343273003: Integrate SiteEngagementEvictionPolicy with QuotaManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add_eviction_policy
Patch Set: address comments Created 5 years, 2 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
« no previous file with comments | « storage/browser/quota/quota_manager.h ('k') | storage/browser/quota/quota_temporary_storage_evictor.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: storage/browser/quota/quota_manager.cc
diff --git a/storage/browser/quota/quota_manager.cc b/storage/browser/quota/quota_manager.cc
index 52f728086b7169b02f5b62831cf50f7108b6c619..2090f4c6ccd2938a7284baf5ab73617feeac4424 100644
--- a/storage/browser/quota/quota_manager.cc
+++ b/storage/browser/quota/quota_manager.cc
@@ -807,14 +807,14 @@ QuotaManager::QuotaManager(
eviction_disabled_(false),
io_thread_(io_thread),
db_thread_(db_thread),
+ is_getting_eviction_origin_(false),
temporary_quota_initialized_(false),
temporary_quota_override_(-1),
desired_available_space_(-1),
special_storage_policy_(special_storage_policy),
get_disk_space_fn_(&CallSystemGetAmountOfFreeDiskSpace),
storage_monitor_(new StorageMonitor(this)),
- weak_factory_(this) {
-}
+ weak_factory_(this) {}
void QuotaManager::GetUsageInfo(const GetUsageInfoCallback& callback) {
LazyInitialize();
@@ -925,6 +925,11 @@ void QuotaManager::SetUsageCacheEnabled(QuotaClient::ID client_id,
GetUsageTracker(type)->SetUsageCacheEnabled(client_id, origin, enabled);
}
+void QuotaManager::SetTemporaryStorageEvictionPolicy(
+ scoped_ptr<QuotaEvictionPolicy> policy) {
+ temporary_storage_eviction_policy_ = policy.Pass();
+}
+
void QuotaManager::DeleteOriginData(
const GURL& origin, StorageType type, int quota_client_mask,
const StatusCallback& callback) {
@@ -1287,7 +1292,7 @@ void QuotaManager::NotifyStorageAccessedInternal(
const GURL& origin, StorageType type,
base::Time accessed_time) {
LazyInitialize();
- if (type == kStorageTypeTemporary && !lru_origin_callback_.is_null()) {
+ if (type == kStorageTypeTemporary && is_getting_eviction_origin_) {
// Record the accessed origins while GetLRUOrigin task is runing
// to filter out them from eviction.
access_notified_origins_.insert(origin);
@@ -1441,8 +1446,38 @@ void QuotaManager::DidGetPersistentGlobalUsageForHistogram(
}
void QuotaManager::GetEvictionOrigin(StorageType type,
+ int64 global_quota,
const GetOriginCallback& callback) {
- GetLRUOrigin(type, callback);
+ LazyInitialize();
+ // This must not be called while there's an in-flight task.
+ DCHECK(!is_getting_eviction_origin_);
+ is_getting_eviction_origin_ = true;
+
+ GetOriginCallback did_get_origin_callback =
+ base::Bind(&QuotaManager::DidGetEvictionOrigin,
+ weak_factory_.GetWeakPtr(), callback);
+
+ if (type == kStorageTypeTemporary && temporary_storage_eviction_policy_) {
+ std::map<GURL, int64> usage_map;
+ // The cached origins are populated by the prior call to
+ // GetUsageAndQuotaForEviction().
+ GetUsageTracker(kStorageTypeTemporary)->GetCachedOriginsUsage(&usage_map);
+
+ temporary_storage_eviction_policy_->GetEvictionOrigin(
+ special_storage_policy_, usage_map, global_quota,
+ did_get_origin_callback);
+ return;
+ }
+
+ // TODO(calamity): convert LRU origin retrieval into a QuotaEvictionPolicy.
+ GetLRUOrigin(type, did_get_origin_callback);
+}
+
+void QuotaManager::DidGetEvictionOrigin(const GetOriginCallback& callback,
+ const GURL& origin) {
+ callback.Run(origin);
+
+ is_getting_eviction_origin_ = false;
}
void QuotaManager::EvictOriginData(const GURL& origin,
@@ -1486,6 +1521,7 @@ void QuotaManager::GetLRUOrigin(StorageType type,
return;
}
+ // TODO(calamity): make all QuotaEvictionPolicies aware of these exceptions.
std::set<GURL>* exceptions = new std::set<GURL>;
for (std::map<GURL, int>::const_iterator p = origins_in_use_.begin();
p != origins_in_use_.end();
« no previous file with comments | « storage/browser/quota/quota_manager.h ('k') | storage/browser/quota/quota_temporary_storage_evictor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698