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

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

Issue 1343273003: Integrate SiteEngagementEvictionPolicy with QuotaManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add_eviction_policy
Patch Set: rebase Created 5 years, 3 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
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;
raymes 2015/09/22 06:08:49 The storage people would be able to comment on whe
calamity 2015/09/23 01:46:24 I thought it would pollute the QuotaManager API le
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;
raymes 2015/09/22 06:08:49 nit: is the :: necessary, I think the forward decl
calamity 2015/09/23 01:46:24 Didn't seem to be. C++, how does it work.
raymes 2015/09/23 01:56:14 Agreed!
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);

Powered by Google App Engine
This is Rietveld 408576698