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

Side by Side Diff: webkit/quota/usage_tracker.h

Issue 8079004: Retrieve per host storage usage from QuotaManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: The final version to land Created 9 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef WEBKIT_QUOTA_USAGE_TRACKER_H_ 5 #ifndef WEBKIT_QUOTA_USAGE_TRACKER_H_
6 #define WEBKIT_QUOTA_USAGE_TRACKER_H_ 6 #define WEBKIT_QUOTA_USAGE_TRACKER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
(...skipping 25 matching lines...) Expand all
36 virtual ~UsageTracker(); 36 virtual ~UsageTracker();
37 37
38 StorageType type() const { return type_; } 38 StorageType type() const { return type_; }
39 ClientUsageTracker* GetClientTracker(QuotaClient::ID client_id); 39 ClientUsageTracker* GetClientTracker(QuotaClient::ID client_id);
40 40
41 void GetGlobalUsage(GlobalUsageCallback* callback); 41 void GetGlobalUsage(GlobalUsageCallback* callback);
42 void GetHostUsage(const std::string& host, HostUsageCallback* callback); 42 void GetHostUsage(const std::string& host, HostUsageCallback* callback);
43 void UpdateUsageCache(QuotaClient::ID client_id, 43 void UpdateUsageCache(QuotaClient::ID client_id,
44 const GURL& origin, 44 const GURL& origin,
45 int64 delta); 45 int64 delta);
46 void GetCachedHostsUsage(std::map<std::string, int64>* host_usage) const;
46 void GetCachedOrigins(std::set<GURL>* origins) const; 47 void GetCachedOrigins(std::set<GURL>* origins) const;
47 bool IsWorking() const { 48 bool IsWorking() const {
48 return global_usage_callbacks_.HasCallbacks() || 49 return global_usage_callbacks_.HasCallbacks() ||
49 host_usage_callbacks_.HasAnyCallbacks(); 50 host_usage_callbacks_.HasAnyCallbacks();
50 } 51 }
51 52
52 private: 53 private:
53 struct TrackingInfo { 54 struct TrackingInfo {
54 TrackingInfo() : pending_clients(0), usage(0), unlimited_usage(0) {} 55 TrackingInfo() : pending_clients(0), usage(0), unlimited_usage(0) {}
55 int pending_clients; 56 int pending_clients;
(...skipping 29 matching lines...) Expand all
85 public: 86 public:
86 ClientUsageTracker(UsageTracker* tracker, 87 ClientUsageTracker(UsageTracker* tracker,
87 QuotaClient* client, 88 QuotaClient* client,
88 StorageType type, 89 StorageType type,
89 SpecialStoragePolicy* special_storage_policy); 90 SpecialStoragePolicy* special_storage_policy);
90 virtual ~ClientUsageTracker(); 91 virtual ~ClientUsageTracker();
91 92
92 void GetGlobalUsage(GlobalUsageCallback* callback); 93 void GetGlobalUsage(GlobalUsageCallback* callback);
93 void GetHostUsage(const std::string& host, HostUsageCallback* callback); 94 void GetHostUsage(const std::string& host, HostUsageCallback* callback);
94 void UpdateUsageCache(const GURL& origin, int64 delta); 95 void UpdateUsageCache(const GURL& origin, int64 delta);
96 void GetCachedHostsUsage(std::map<std::string, int64>* host_usage) const;
95 void GetCachedOrigins(std::set<GURL>* origins) const; 97 void GetCachedOrigins(std::set<GURL>* origins) const;
96 98
97 private: 99 private:
98 typedef std::set<std::string> HostSet; 100 typedef std::set<std::string> HostSet;
99 typedef std::map<GURL, int64> UsageMap; 101 typedef std::map<GURL, int64> UsageMap;
100 typedef std::map<std::string, UsageMap> HostUsageMap; 102 typedef std::map<std::string, UsageMap> HostUsageMap;
101 103
102 class GatherUsageTaskBase; 104 class GatherUsageTaskBase;
103 class GatherGlobalUsageTask; 105 class GatherGlobalUsageTask;
104 class GatherHostUsageTask; 106 class GatherHostUsageTask;
105 107
106 // Methods used by our GatherUsage tasks, as a task makes progress 108 // Methods used by our GatherUsage tasks, as a task makes progress
107 // origins and hosts are added incrementally to the cache. 109 // origins and hosts are added incrementally to the cache.
108 void AddCachedOrigin(const GURL& origin, int64 usage); 110 void AddCachedOrigin(const GURL& origin, int64 usage);
109 void AddCachedHost(const std::string& host); 111 void AddCachedHost(const std::string& host);
110 void GatherGlobalUsageComplete(); 112 void GatherGlobalUsageComplete();
111 void GatherHostUsageComplete(const std::string& host); 113 void GatherHostUsageComplete(const std::string& host);
112 114
113 int64 GetCachedHostUsage(const std::string& host); 115 int64 GetCachedHostUsage(const std::string& host) const;
114 int64 GetCachedGlobalUnlimitedUsage(); 116 int64 GetCachedGlobalUnlimitedUsage();
115 virtual void OnSpecialStoragePolicyChanged() OVERRIDE; 117 virtual void OnSpecialStoragePolicyChanged() OVERRIDE;
116 void NoopHostUsageCallback( 118 void NoopHostUsageCallback(
117 const std::string& host, StorageType type, int64 usage); 119 const std::string& host, StorageType type, int64 usage);
118 bool IsStorageUnlimited(const GURL& origin) const; 120 bool IsStorageUnlimited(const GURL& origin) const;
119 121
120 UsageTracker* tracker_; 122 UsageTracker* tracker_;
121 QuotaClient* client_; 123 QuotaClient* client_;
122 const StorageType type_; 124 const StorageType type_;
123 125
(...skipping 10 matching lines...) Expand all
134 HostUsageCallbackMap host_usage_callbacks_; 136 HostUsageCallbackMap host_usage_callbacks_;
135 137
136 scoped_refptr<SpecialStoragePolicy> special_storage_policy_; 138 scoped_refptr<SpecialStoragePolicy> special_storage_policy_;
137 139
138 DISALLOW_COPY_AND_ASSIGN(ClientUsageTracker); 140 DISALLOW_COPY_AND_ASSIGN(ClientUsageTracker);
139 }; 141 };
140 142
141 } // namespace quota 143 } // namespace quota
142 144
143 #endif // WEBKIT_QUOTA_USAGE_TRACKER_H_ 145 #endif // WEBKIT_QUOTA_USAGE_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698