| Index: storage/browser/quota/quota_manager.h
|
| diff --git a/storage/browser/quota/quota_manager.h b/storage/browser/quota/quota_manager.h
|
| index 506aa0ad05f806d9bd3ec58f1734ca2829a97229..da280277cf98a90bb0b7cc15f9d555dafdf8959f 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,16 +73,16 @@ 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:
|
| + virtual ~QuotaEvictionPolicy() {}
|
| +
|
| // 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;
|
| };
|
|
|
| @@ -194,6 +197,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,
|
| + 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 +252,7 @@ class STORAGE_EXPORT QuotaManager
|
| base::Time modified_since,
|
| const GetOriginsCallback& callback);
|
|
|
| + UsageTracker* GetUsageTracker(StorageType type) const;
|
| bool ResetUsageTracker(StorageType type);
|
|
|
| // Used to register/deregister observers that wish to monitor storage events.
|
| @@ -286,6 +294,7 @@ class STORAGE_EXPORT QuotaManager
|
| friend class QuotaManagerProxy;
|
| friend class QuotaTemporaryStorageEvictor;
|
| friend struct QuotaManagerDeleter;
|
| + friend class ::SiteEngagementEvictionPolicyWithQuotaManagerTest;
|
|
|
| class GetUsageInfoTask;
|
|
|
| @@ -339,8 +348,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 +380,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 +471,11 @@ class STORAGE_EXPORT QuotaManager
|
|
|
| scoped_ptr<StorageMonitor> storage_monitor_;
|
|
|
| + base::ScopedPtrMap<StorageType, scoped_ptr<QuotaEvictionPolicy>>
|
| + eviction_policy_map_;
|
| +
|
| + bool is_getting_eviction_origin_;
|
| +
|
| base::WeakPtrFactory<QuotaManager> weak_factory_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(QuotaManager);
|
|
|