Index: webkit/quota/usage_tracker.h |
diff --git a/webkit/quota/usage_tracker.h b/webkit/quota/usage_tracker.h |
index 185527248eafa669951fcb167e85d8f4f52a719c..383dd1c1a589ff53ef006c6c14a6d9504cc0bb21 100644 |
--- a/webkit/quota/usage_tracker.h |
+++ b/webkit/quota/usage_tracker.h |
@@ -53,8 +53,8 @@ class WEBKIT_STORAGE_EXPORT UsageTracker : public QuotaTaskObserver { |
bool enabled); |
private: |
- struct TrackingInfo { |
- TrackingInfo() : pending_clients(0), usage(0), unlimited_usage(0) {} |
+ struct AccumulateInfo { |
+ AccumulateInfo() : pending_clients(0), usage(0), unlimited_usage(0) {} |
int pending_clients; |
int64 usage; |
int64 unlimited_usage; |
@@ -63,12 +63,12 @@ class WEBKIT_STORAGE_EXPORT UsageTracker : public QuotaTaskObserver { |
typedef std::map<QuotaClient::ID, ClientUsageTracker*> ClientTrackerMap; |
friend class ClientUsageTracker; |
- void DidGetClientGlobalUsage(TrackingInfo* info, |
- int64 usage, |
- int64 unlimited_usage); |
- void DidGetClientHostUsage(TrackingInfo* info, |
- const std::string& host, |
- int64 usage); |
+ void AccumulateClientGlobalUsage(AccumulateInfo* info, |
+ int64 usage, |
+ int64 unlimited_usage); |
+ void AccumulateClientHostUsage(AccumulateInfo* info, |
+ const std::string& host, |
+ int64 usage); |
const StorageType type_; |
ClientTrackerMap client_tracker_map_; |
@@ -86,6 +86,11 @@ class ClientUsageTracker : public SpecialStoragePolicy::Observer, |
public base::NonThreadSafe, |
public base::SupportsWeakPtr<ClientUsageTracker> { |
public: |
+ typedef base::Callback<void(int64 cached_usage, |
+ int64 non_cached_usage)> HostUsageAccumulator; |
+ typedef base::Callback<void(const GURL& origin, |
+ int64 usage)> OriginUsageAccumulator; |
+ |
ClientUsageTracker(UsageTracker* tracker, |
QuotaClient* client, |
StorageType type, |
@@ -103,24 +108,45 @@ class ClientUsageTracker : public SpecialStoragePolicy::Observer, |
void SetUsageCacheEnabled(const GURL& origin, bool enabled); |
private: |
+ typedef CallbackQueueMap<HostUsageAccumulator, std::string, |
+ Tuple2<int64, int64> > HostUsageAccumulatorMap; |
+ |
typedef std::set<std::string> HostSet; |
typedef std::map<GURL, int64> UsageMap; |
typedef std::map<std::string, UsageMap> HostUsageMap; |
typedef std::map<std::string, std::set<GURL> > OriginSetByHost; |
- class GatherUsageTaskBase; |
- class GatherGlobalUsageTask; |
- class GatherHostUsageTask; |
+ struct AccumulateInfo { |
+ int pending_jobs; |
+ int64 cached_usage; |
+ int64 non_cached_usage; |
+ |
+ AccumulateInfo() : pending_jobs(0), cached_usage(0), non_cached_usage(0) {} |
+ }; |
+ |
+ void DidGetOriginsForGlobalUsage(const GlobalUsageCallback& callback, |
+ const std::set<GURL>& origins, |
+ StorageType type); |
+ void AccumulateHostUsage(AccumulateInfo* info, |
+ const GlobalUsageCallback& callback, |
+ int64 cached_usage, |
+ int64 non_cached_usage); |
+ |
+ void DidGetOriginsForHostUsage(const std::string& host, |
+ const std::set<GURL>& origins, |
+ StorageType type); |
+ |
+ void GetUsageForOrigins(const std::string& host, |
+ const std::set<GURL>& origins); |
+ void AccumulateOriginUsage(AccumulateInfo* info, |
+ const std::string& host, |
+ const GURL& origin, |
+ int64 usage); |
// Methods used by our GatherUsage tasks, as a task makes progress |
// origins and hosts are added incrementally to the cache. |
void AddCachedOrigin(const GURL& origin, int64 usage); |
void AddCachedHost(const std::string& host); |
- void GatherGlobalUsageComplete( |
- int64 global_usage, |
- int64 non_cached_global_usage, |
- const std::map<std::string, int64>& non_cached_usage_by_host); |
- void GatherHostUsageComplete(const std::string& host, int64 host_usage); |
int64 GetCachedHostUsage(const std::string& host) const; |
int64 GetCachedGlobalUnlimitedUsage(); |
@@ -131,7 +157,6 @@ class ClientUsageTracker : public SpecialStoragePolicy::Observer, |
virtual void OnRevoked(const GURL& origin, int change_flags) OVERRIDE; |
virtual void OnCleared() OVERRIDE; |
- void NoopHostUsageCallback(int64 usage); |
bool IsStorageUnlimited(const GURL& origin) const; |
UsageTracker* tracker_; |
@@ -146,10 +171,8 @@ class ClientUsageTracker : public SpecialStoragePolicy::Observer, |
OriginSetByHost non_cached_origins_by_host_; |
- GatherGlobalUsageTask* global_usage_task_; |
GlobalUsageCallbackQueue global_usage_callback_; |
- std::map<std::string, GatherHostUsageTask*> host_usage_tasks_; |
- HostUsageCallbackMap host_usage_callbacks_; |
+ HostUsageAccumulatorMap host_usage_accumulators_; |
scoped_refptr<SpecialStoragePolicy> special_storage_policy_; |