| 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..5e562ba218bca1ee7c556c8e3b646b156a091010 100644
|
| --- a/storage/browser/quota/quota_manager.cc
|
| +++ b/storage/browser/quota/quota_manager.cc
|
| @@ -813,6 +813,7 @@ QuotaManager::QuotaManager(
|
| special_storage_policy_(special_storage_policy),
|
| get_disk_space_fn_(&CallSystemGetAmountOfFreeDiskSpace),
|
| storage_monitor_(new StorageMonitor(this)),
|
| + is_getting_eviction_origin_(false),
|
| weak_factory_(this) {
|
| }
|
|
|
| @@ -925,6 +926,12 @@ void QuotaManager::SetUsageCacheEnabled(QuotaClient::ID client_id,
|
| GetUsageTracker(type)->SetUsageCacheEnabled(client_id, origin, enabled);
|
| }
|
|
|
| +void QuotaManager::SetQuotaEvictionPolicy(
|
| + StorageType type,
|
| + scoped_ptr<QuotaEvictionPolicy> policy) {
|
| + eviction_policy_map_.set(type, policy.Pass());
|
| +}
|
| +
|
| void QuotaManager::DeleteOriginData(
|
| const GURL& origin, StorageType type, int quota_client_mask,
|
| const StatusCallback& callback) {
|
| @@ -1287,7 +1294,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);
|
| @@ -1442,7 +1449,29 @@ void QuotaManager::DidGetPersistentGlobalUsageForHistogram(
|
|
|
| void QuotaManager::GetEvictionOrigin(StorageType type,
|
| const GetOriginCallback& callback) {
|
| - GetLRUOrigin(type, callback);
|
| + LazyInitialize();
|
| + is_getting_eviction_origin_ = true;
|
| +
|
| + GetOriginCallback did_get_origin_callback =
|
| + base::Bind(&QuotaManager::DidGetEvictionOrigin,
|
| + weak_factory_.GetWeakPtr(), callback);
|
| +
|
| + auto eviction_policy = eviction_policy_map_.find(type);
|
| + if (eviction_policy != eviction_policy_map_.end()) {
|
| + eviction_policy->second->GetEvictionOrigin(
|
| + special_storage_policy_,
|
| + did_get_origin_callback);
|
| + }
|
| +
|
| + // 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 +1515,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();
|
|
|