diff options
author | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-29 21:14:05 +0000 |
---|---|---|
committer | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-29 21:14:05 +0000 |
commit | 62bf213f70f3fa3ebbe2eaa9353ca9ac9f8264fb (patch) | |
tree | 9040e07832c545e0abb5754da126f0b314afb17f /webkit/quota/usage_tracker.h | |
parent | fcfa89d8845754ceb5680805b5726de002a030be (diff) | |
download | chromium_src-62bf213f70f3fa3ebbe2eaa9353ca9ac9f8264fb.zip chromium_src-62bf213f70f3fa3ebbe2eaa9353ca9ac9f8264fb.tar.gz chromium_src-62bf213f70f3fa3ebbe2eaa9353ca9ac9f8264fb.tar.bz2 |
Retain support for 'UnlimitedStorage' in the QuotaManager.
Track unlimited_usage in parallel with total global_usage. The latter value is the sum of all usage by any origin (same as before). The new value is the amount of the total that is attributable to origins with the unlimited storage permission.
Widened the GlobalUsageCallback to take two int64 params, one for the total global_usage and the other for the unlimited_usage.
Modified the eviction logic to exempt origins with the unlimited storage right from eviction.
Modified the behavior of QuotaManager::GetUsageAndQuota(origin) method to return kint64max for unlimited origins. Also modified the return value in the limited case to be 10% of the total limit for temp storage, unless the system is over the total limit in which case they're capped at their current usage level.
// Allow an individual host to utilize no more than 10% of the total
// pool available for temp storage.
int64 host_quota = quota() / 10;
// If total temp usage is over-budget, stop letting new data in until we reclaim space.
limited_global_usage = global_usage() - unlimted_global_usage();
if (limited_global_usage > quota())
host_quota = std::min(host_quota, host_usage());
return host_quota;
At this time, the total limit for temp storage is 1G, that gives each site 100M to work with (no prompts involved).
BUG=61676
TEST=unittests
Review URL: http://codereview.chromium.org/6962005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87207 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/quota/usage_tracker.h')
-rw-r--r-- | webkit/quota/usage_tracker.h | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/webkit/quota/usage_tracker.h b/webkit/quota/usage_tracker.h index 084842c..cced53d 100644 --- a/webkit/quota/usage_tracker.h +++ b/webkit/quota/usage_tracker.h @@ -23,19 +23,21 @@ namespace quota { class ClientUsageTracker; +class SpecialStoragePolicy; // A helper class that gathers and tracks the amount of data stored in // all quota clients. // An instance of this class is created per storage type. class UsageTracker : public QuotaTaskObserver { public: - UsageTracker(const QuotaClientList& clients, StorageType type); + UsageTracker(const QuotaClientList& clients, StorageType type, + SpecialStoragePolicy* special_storage_policy); virtual ~UsageTracker(); StorageType type() const { return type_; } ClientUsageTracker* GetClientTracker(QuotaClient::ID client_id); - void GetGlobalUsage(UsageCallback* callback); + void GetGlobalUsage(GlobalUsageCallback* callback); void GetHostUsage(const std::string& host, HostUsageCallback* callback); void UpdateUsageCache(QuotaClient::ID client_id, const GURL& origin, @@ -45,15 +47,17 @@ class UsageTracker : public QuotaTaskObserver { private: struct TrackingInfo { - TrackingInfo() : pending_clients(0), usage(0) {} + TrackingInfo() : pending_clients(0), usage(0), unlimited_usage(0) {} int pending_clients; int64 usage; + int64 unlimited_usage; }; typedef std::map<QuotaClient::ID, ClientUsageTracker*> ClientTrackerMap; friend class ClientUsageTracker; - void DidGetClientGlobalUsage(StorageType type, int64 usage); + void DidGetClientGlobalUsage(StorageType type, int64 usage, + int64 unlimited_usage); void DidGetClientHostUsage(const std::string& host, StorageType type, int64 usage); @@ -63,7 +67,7 @@ class UsageTracker : public QuotaTaskObserver { TrackingInfo global_usage_; std::map<std::string, TrackingInfo> outstanding_host_usage_; - UsageCallbackQueue global_usage_callbacks_; + GlobalUsageCallbackQueue global_usage_callbacks_; HostUsageCallbackMap host_usage_callbacks_; base::ScopedCallbackFactory<UsageTracker> callback_factory_; @@ -74,12 +78,13 @@ class UsageTracker : public QuotaTaskObserver { // usage data. An instance of this class is created per client. class ClientUsageTracker { public: - ClientUsageTracker(UsageTracker* tracking_info, + ClientUsageTracker(UsageTracker* tracker, QuotaClient* client, - StorageType type); + StorageType type, + SpecialStoragePolicy* special_storage_policy); ~ClientUsageTracker(); - void GetGlobalUsage(UsageCallback* callback); + void GetGlobalUsage(GlobalUsageCallback* callback); void GetHostUsage(const std::string& host, HostUsageCallback* callback); void DetermineOriginsToGetUsage(const std::set<GURL>& origins, std::set<GURL>* origins_to_process); @@ -95,6 +100,7 @@ class ClientUsageTracker { void DidGetGlobalUsage(const std::map<GURL, int64>& origin_usage_map); void DidGetHostUsage(const std::string& host, const std::map<GURL, int64>& origin_usage_map); + bool IsStorageUnlimited(const GURL& origin) const; UsageTracker* tracker_; QuotaClient* client_; @@ -102,14 +108,17 @@ class ClientUsageTracker { std::set<GURL> cached_origins_; int64 global_usage_; + int64 global_unlimited_usage_; bool global_usage_retrieved_; GatherGlobalUsageTask* global_usage_task_; - UsageCallbackQueue global_usage_callback_; + GlobalUsageCallbackQueue global_usage_callback_; std::map<std::string, int64> host_usage_map_; std::map<std::string, GatherHostUsageTask*> host_usage_tasks_; HostUsageCallbackMap host_usage_callbacks_; + scoped_refptr<SpecialStoragePolicy> special_storage_policy_; + DISALLOW_COPY_AND_ASSIGN(ClientUsageTracker); }; |