Chromium Code Reviews| Index: storage/browser/quota/quota_manager.h |
| diff --git a/storage/browser/quota/quota_manager.h b/storage/browser/quota/quota_manager.h |
| index 3e053887b1ff41fb41810af6b5bfa9f134f6aa3d..714ba2ae32cc3f32cb1240c49a0dfa9586820ac3 100644 |
| --- a/storage/browser/quota/quota_manager.h |
| +++ b/storage/browser/quota/quota_manager.h |
| @@ -15,6 +15,7 @@ |
| #include "base/basictypes.h" |
| #include "base/callback.h" |
| +#include "base/containers/scoped_ptr_map.h" |
| #include "base/files/file_path.h" |
| #include "base/memory/ref_counted.h" |
| #include "base/memory/scoped_ptr.h" |
| @@ -28,6 +29,8 @@ |
| #include "storage/browser/quota/storage_observer.h" |
| #include "storage/browser/storage_browser_export.h" |
| +class SiteEngagementEvictionPolicyWithQuotaManagerTest; |
| + |
| namespace base { |
| class FilePath; |
| class SequencedTaskRunner; |
| @@ -70,17 +73,29 @@ struct STORAGE_EXPORT UsageAndQuota { |
| }; |
| // 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. |
| +// An interface for deciding which origin's storage should be evicted when the |
| +// quota is exceeded. |
| class STORAGE_EXPORT QuotaEvictionPolicy { |
| public: |
| + struct STORAGE_EXPORT Info { |
| + std::map<GURL, int64> origin_usage_map; |
| + int64 global_quota = 0; |
| + |
| + Info(); |
| + ~Info(); |
| + }; |
| + |
| + virtual ~QuotaEvictionPolicy() {} |
| + |
| // Returns the next origin to evict. It might return an empty GURL when there |
| // are no evictable origins. |
| virtual void GetEvictionOrigin( |
| + scoped_ptr<Info> info, |
| const scoped_refptr<SpecialStoragePolicy>& special_storage_policy, |
| - const std::map<GURL, int64>& usage_map, |
| - int64 global_quota, |
| const GetOriginCallback& callback) = 0; |
| + |
| + virtual bool NeedsOriginUsageMap(); |
| + virtual bool NeedsGlobalQuota(); |
|
michaeln
2015/10/06 00:35:09
It'd be simpler to always include this info and I
calamity
2015/10/07 02:42:46
Done.
|
| }; |
| // An interface called by QuotaTemporaryStorageEvictor. |
| @@ -194,6 +209,10 @@ class STORAGE_EXPORT QuotaManager |
| StorageType type, |
| bool enabled); |
| + // Set the eviction policy to use when choosing an origin to evict. |
| + void SetQuotaEvictionPolicy(StorageType type, |
|
michaeln
2015/10/06 00:35:09
We can probably constrain this to just "temp" stor
calamity
2015/10/07 02:42:46
Done.
|
| + scoped_ptr<QuotaEvictionPolicy> policy); |
| + |
| // DeleteOriginData and DeleteHostData (surprisingly enough) delete data of a |
| // particular StorageType associated with either a specific origin or set of |
| // origins. Each method additionally requires a |quota_client_mask| which |
| @@ -245,6 +264,7 @@ class STORAGE_EXPORT QuotaManager |
| base::Time modified_since, |
| const GetOriginsCallback& callback); |
| + UsageTracker* GetUsageTracker(StorageType type) const; |
|
michaeln
2015/10/06 00:35:09
pleas keep this method private
calamity
2015/10/07 02:42:46
Done.
|
| bool ResetUsageTracker(StorageType type); |
| // Used to register/deregister observers that wish to monitor storage events. |
| @@ -286,8 +306,10 @@ class STORAGE_EXPORT QuotaManager |
| friend class QuotaManagerProxy; |
| friend class QuotaTemporaryStorageEvictor; |
| friend struct QuotaManagerDeleter; |
| + friend class ::SiteEngagementEvictionPolicyWithQuotaManagerTest; |
| class GetUsageInfoTask; |
| + class GetEvictionOriginTask; |
| class OriginDataDeleter; |
| class HostDataDeleter; |
| @@ -339,8 +361,6 @@ class STORAGE_EXPORT QuotaManager |
| // The client must remain valid until OnQuotaManagerDestored is called. |
| void RegisterClient(QuotaClient* client); |
| - UsageTracker* GetUsageTracker(StorageType type) const; |
| - |
| // Extract cached origins list from the usage tracker. |
| // (Might return empty list if no origin is tracked by the tracker.) |
| void GetCachedOrigins(StorageType type, std::set<GURL>* origins); |
| @@ -373,6 +393,9 @@ class STORAGE_EXPORT QuotaManager |
| void DidGetPersistentGlobalUsageForHistogram(int64 usage, |
| int64 unlimited_usage); |
| + void DidGetEvictionOrigin(const GetOriginCallback& callback, |
| + const GURL& origin); |
| + |
| // QuotaEvictionHandler. |
| void GetEvictionOrigin(StorageType type, |
| const GetOriginCallback& callback) override; |
| @@ -461,6 +484,11 @@ class STORAGE_EXPORT QuotaManager |
| scoped_ptr<StorageMonitor> storage_monitor_; |
| + base::ScopedPtrMap<StorageType, scoped_ptr<QuotaEvictionPolicy>> |
| + eviction_policy_map_; |
|
michaeln
2015/10/06 00:35:09
lets put these new data members next to the other
calamity
2015/10/07 02:42:46
Done.
|
| + |
| + bool is_getting_eviction_origin_; |
| + |
| base::WeakPtrFactory<QuotaManager> weak_factory_; |
| DISALLOW_COPY_AND_ASSIGN(QuotaManager); |