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

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

Issue 16067003: [Quota] Refine usage handling in ClientUsageTracker. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: buildfix Created 7 years, 6 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
« no previous file with comments | « no previous file | webkit/quota/usage_tracker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // This class holds per-client usage tracking information and caches per-host 83 // This class holds per-client usage tracking information and caches per-host
84 // usage data. An instance of this class is created per client. 84 // usage data. An instance of this class is created per client.
85 class ClientUsageTracker : public SpecialStoragePolicy::Observer, 85 class ClientUsageTracker : public SpecialStoragePolicy::Observer,
86 public base::NonThreadSafe, 86 public base::NonThreadSafe,
87 public base::SupportsWeakPtr<ClientUsageTracker> { 87 public base::SupportsWeakPtr<ClientUsageTracker> {
88 public: 88 public:
89 typedef base::Callback<void(int64 cached_usage, 89 typedef base::Callback<void(int64 cached_usage,
90 int64 non_cached_usage)> HostUsageAccumulator; 90 int64 non_cached_usage)> HostUsageAccumulator;
91 typedef base::Callback<void(const GURL& origin, 91 typedef base::Callback<void(const GURL& origin,
92 int64 usage)> OriginUsageAccumulator; 92 int64 usage)> OriginUsageAccumulator;
93 typedef std::map<std::string, std::set<GURL> > OriginSetByHost;
93 94
94 ClientUsageTracker(UsageTracker* tracker, 95 ClientUsageTracker(UsageTracker* tracker,
95 QuotaClient* client, 96 QuotaClient* client,
96 StorageType type, 97 StorageType type,
97 SpecialStoragePolicy* special_storage_policy); 98 SpecialStoragePolicy* special_storage_policy);
98 virtual ~ClientUsageTracker(); 99 virtual ~ClientUsageTracker();
99 100
100 void GetGlobalUsage(const GlobalUsageCallback& callback); 101 void GetGlobalUsage(const GlobalUsageCallback& callback);
101 void GetHostUsage(const std::string& host, const UsageCallback& callback); 102 void GetHostUsage(const std::string& host, const UsageCallback& callback);
102 void UpdateUsageCache(const GURL& origin, int64 delta); 103 void UpdateUsageCache(const GURL& origin, int64 delta);
103 void GetCachedHostsUsage(std::map<std::string, int64>* host_usage) const; 104 void GetCachedHostsUsage(std::map<std::string, int64>* host_usage) const;
104 void GetCachedOrigins(std::set<GURL>* origins) const; 105 void GetCachedOrigins(std::set<GURL>* origins) const;
105 int64 GetCachedOriginsUsage(const std::set<GURL>& origins, 106 int64 GetCachedOriginsUsage(const std::set<GURL>& origins,
106 std::vector<GURL>* origins_not_in_cache); 107 std::vector<GURL>* origins_not_in_cache);
107 bool IsUsageCacheEnabledForOrigin(const GURL& origin) const; 108 bool IsUsageCacheEnabledForOrigin(const GURL& origin) const;
108 void SetUsageCacheEnabled(const GURL& origin, bool enabled); 109 void SetUsageCacheEnabled(const GURL& origin, bool enabled);
109 110
110 private: 111 private:
111 typedef CallbackQueueMap<HostUsageAccumulator, std::string, 112 typedef CallbackQueueMap<HostUsageAccumulator, std::string,
112 Tuple2<int64, int64> > HostUsageAccumulatorMap; 113 Tuple2<int64, int64> > HostUsageAccumulatorMap;
113 114
114 typedef std::set<std::string> HostSet; 115 typedef std::set<std::string> HostSet;
115 typedef std::map<GURL, int64> UsageMap; 116 typedef std::map<GURL, int64> UsageMap;
116 typedef std::map<std::string, UsageMap> HostUsageMap; 117 typedef std::map<std::string, UsageMap> HostUsageMap;
117 typedef std::map<std::string, std::set<GURL> > OriginSetByHost;
118 118
119 struct AccumulateInfo { 119 struct AccumulateInfo {
120 int pending_jobs; 120 int pending_jobs;
121 int64 cached_usage; 121 int64 cached_usage;
122 int64 non_cached_usage; 122 int64 non_cached_usage;
123 123
124 AccumulateInfo() : pending_jobs(0), cached_usage(0), non_cached_usage(0) {} 124 AccumulateInfo() : pending_jobs(0), cached_usage(0), non_cached_usage(0) {}
125 }; 125 };
126 126
127 void DidGetOriginsForGlobalUsage(const GlobalUsageCallback& callback, 127 void DidGetOriginsForGlobalUsage(const GlobalUsageCallback& callback,
(...skipping 28 matching lines...) Expand all
156 virtual void OnGranted(const GURL& origin, int change_flags) OVERRIDE; 156 virtual void OnGranted(const GURL& origin, int change_flags) OVERRIDE;
157 virtual void OnRevoked(const GURL& origin, int change_flags) OVERRIDE; 157 virtual void OnRevoked(const GURL& origin, int change_flags) OVERRIDE;
158 virtual void OnCleared() OVERRIDE; 158 virtual void OnCleared() OVERRIDE;
159 159
160 bool IsStorageUnlimited(const GURL& origin) const; 160 bool IsStorageUnlimited(const GURL& origin) const;
161 161
162 UsageTracker* tracker_; 162 UsageTracker* tracker_;
163 QuotaClient* client_; 163 QuotaClient* client_;
164 const StorageType type_; 164 const StorageType type_;
165 165
166 int64 global_usage_; 166 int64 global_limited_usage_;
167 int64 global_unlimited_usage_; 167 int64 global_unlimited_usage_;
168 bool global_usage_retrieved_; 168 bool global_usage_retrieved_;
169 HostSet cached_hosts_; 169 HostSet cached_hosts_;
170 HostUsageMap cached_usage_by_host_; 170 HostUsageMap cached_usage_by_host_;
171 171
172 OriginSetByHost non_cached_origins_by_host_; 172 OriginSetByHost non_cached_limited_origins_by_host_;
173 OriginSetByHost non_cached_unlimited_origins_by_host_;
173 174
174 GlobalUsageCallbackQueue global_usage_callback_; 175 GlobalUsageCallbackQueue global_usage_callback_;
175 HostUsageAccumulatorMap host_usage_accumulators_; 176 HostUsageAccumulatorMap host_usage_accumulators_;
176 177
177 scoped_refptr<SpecialStoragePolicy> special_storage_policy_; 178 scoped_refptr<SpecialStoragePolicy> special_storage_policy_;
178 179
179 DISALLOW_COPY_AND_ASSIGN(ClientUsageTracker); 180 DISALLOW_COPY_AND_ASSIGN(ClientUsageTracker);
180 }; 181 };
181 182
182 } // namespace quota 183 } // namespace quota
183 184
184 #endif // WEBKIT_QUOTA_USAGE_TRACKER_H_ 185 #endif // WEBKIT_QUOTA_USAGE_TRACKER_H_
OLDNEW
« no previous file with comments | « no previous file | webkit/quota/usage_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698