Chromium Code Reviews| 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..0e7ccc0d15b75d4a11f3aef21aaa2bfca271b3a3 100644 |
| --- a/storage/browser/quota/quota_manager.cc |
| +++ b/storage/browser/quota/quota_manager.cc |
| @@ -813,8 +813,8 @@ QuotaManager::QuotaManager( |
| special_storage_policy_(special_storage_policy), |
| get_disk_space_fn_(&CallSystemGetAmountOfFreeDiskSpace), |
| storage_monitor_(new StorageMonitor(this)), |
| - weak_factory_(this) { |
| -} |
| + is_getting_eviction_origin_(false), |
| + weak_factory_(this) {} |
| void QuotaManager::GetUsageInfo(const GetUsageInfoCallback& callback) { |
| LazyInitialize(); |
| @@ -925,6 +925,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 +1293,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 +1448,28 @@ void QuotaManager::DidGetPersistentGlobalUsageForHistogram( |
| void QuotaManager::GetEvictionOrigin(StorageType type, |
| const GetOriginCallback& callback) { |
| - GetLRUOrigin(type, callback); |
| + LazyInitialize(); |
| + is_getting_eviction_origin_ = true; |
|
raymes
2015/09/22 06:08:49
Should we dcheck this is false (as with lru_origin
calamity
2015/09/23 01:46:24
Done.
|
| + |
| + 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); |
|
raymes
2015/09/22 06:08:49
Should this return here?
calamity
2015/09/23 01:46:24
Done. Good catch >_>
|
| + } |
| + |
| + // 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 +1513,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(); |