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

Side by Side Diff: storage/browser/quota/usage_tracker.h

Issue 669603008: Standardize usage of virtual/override/final in storage/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « storage/browser/quota/quota_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 STORAGE_BROWSER_QUOTA_USAGE_TRACKER_H_ 5 #ifndef STORAGE_BROWSER_QUOTA_USAGE_TRACKER_H_
6 #define STORAGE_BROWSER_QUOTA_USAGE_TRACKER_H_ 6 #define STORAGE_BROWSER_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 17 matching lines...) Expand all
28 class StorageMonitor; 28 class StorageMonitor;
29 29
30 // A helper class that gathers and tracks the amount of data stored in 30 // A helper class that gathers and tracks the amount of data stored in
31 // all quota clients. 31 // all quota clients.
32 // An instance of this class is created per storage type. 32 // An instance of this class is created per storage type.
33 class STORAGE_EXPORT UsageTracker : public QuotaTaskObserver { 33 class STORAGE_EXPORT UsageTracker : public QuotaTaskObserver {
34 public: 34 public:
35 UsageTracker(const QuotaClientList& clients, StorageType type, 35 UsageTracker(const QuotaClientList& clients, StorageType type,
36 SpecialStoragePolicy* special_storage_policy, 36 SpecialStoragePolicy* special_storage_policy,
37 StorageMonitor* storage_monitor); 37 StorageMonitor* storage_monitor);
38 virtual ~UsageTracker(); 38 ~UsageTracker() override;
39 39
40 StorageType type() const { return type_; } 40 StorageType type() const { return type_; }
41 ClientUsageTracker* GetClientTracker(QuotaClient::ID client_id); 41 ClientUsageTracker* GetClientTracker(QuotaClient::ID client_id);
42 42
43 void GetGlobalLimitedUsage(const UsageCallback& callback); 43 void GetGlobalLimitedUsage(const UsageCallback& callback);
44 void GetGlobalUsage(const GlobalUsageCallback& callback); 44 void GetGlobalUsage(const GlobalUsageCallback& callback);
45 void GetHostUsage(const std::string& host, const UsageCallback& callback); 45 void GetHostUsage(const std::string& host, const UsageCallback& callback);
46 void UpdateUsageCache(QuotaClient::ID client_id, 46 void UpdateUsageCache(QuotaClient::ID client_id,
47 const GURL& origin, 47 const GURL& origin,
48 int64 delta); 48 int64 delta);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 int64 unlimited_usage)> HostUsageAccumulator; 100 int64 unlimited_usage)> HostUsageAccumulator;
101 typedef base::Callback<void(const GURL& origin, 101 typedef base::Callback<void(const GURL& origin,
102 int64 usage)> OriginUsageAccumulator; 102 int64 usage)> OriginUsageAccumulator;
103 typedef std::map<std::string, std::set<GURL> > OriginSetByHost; 103 typedef std::map<std::string, std::set<GURL> > OriginSetByHost;
104 104
105 ClientUsageTracker(UsageTracker* tracker, 105 ClientUsageTracker(UsageTracker* tracker,
106 QuotaClient* client, 106 QuotaClient* client,
107 StorageType type, 107 StorageType type,
108 SpecialStoragePolicy* special_storage_policy, 108 SpecialStoragePolicy* special_storage_policy,
109 StorageMonitor* storage_monitor); 109 StorageMonitor* storage_monitor);
110 virtual ~ClientUsageTracker(); 110 ~ClientUsageTracker() override;
111 111
112 void GetGlobalLimitedUsage(const UsageCallback& callback); 112 void GetGlobalLimitedUsage(const UsageCallback& callback);
113 void GetGlobalUsage(const GlobalUsageCallback& callback); 113 void GetGlobalUsage(const GlobalUsageCallback& callback);
114 void GetHostUsage(const std::string& host, const UsageCallback& callback); 114 void GetHostUsage(const std::string& host, const UsageCallback& callback);
115 void UpdateUsageCache(const GURL& origin, int64 delta); 115 void UpdateUsageCache(const GURL& origin, int64 delta);
116 void GetCachedHostsUsage(std::map<std::string, int64>* host_usage) const; 116 void GetCachedHostsUsage(std::map<std::string, int64>* host_usage) const;
117 void GetCachedOrigins(std::set<GURL>* origins) const; 117 void GetCachedOrigins(std::set<GURL>* origins) const;
118 int64 GetCachedOriginsUsage(const std::set<GURL>& origins, 118 int64 GetCachedOriginsUsage(const std::set<GURL>& origins,
119 std::vector<GURL>* origins_not_in_cache); 119 std::vector<GURL>* origins_not_in_cache);
120 bool IsUsageCacheEnabledForOrigin(const GURL& origin) const; 120 bool IsUsageCacheEnabledForOrigin(const GURL& origin) const;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 // Methods used by our GatherUsage tasks, as a task makes progress 162 // Methods used by our GatherUsage tasks, as a task makes progress
163 // origins and hosts are added incrementally to the cache. 163 // origins and hosts are added incrementally to the cache.
164 void AddCachedOrigin(const GURL& origin, int64 usage); 164 void AddCachedOrigin(const GURL& origin, int64 usage);
165 void AddCachedHost(const std::string& host); 165 void AddCachedHost(const std::string& host);
166 166
167 int64 GetCachedHostUsage(const std::string& host) const; 167 int64 GetCachedHostUsage(const std::string& host) const;
168 int64 GetCachedGlobalUnlimitedUsage(); 168 int64 GetCachedGlobalUnlimitedUsage();
169 bool GetCachedOriginUsage(const GURL& origin, int64* usage) const; 169 bool GetCachedOriginUsage(const GURL& origin, int64* usage) const;
170 170
171 // SpecialStoragePolicy::Observer overrides 171 // SpecialStoragePolicy::Observer overrides
172 virtual void OnGranted(const GURL& origin, int change_flags) override; 172 void OnGranted(const GURL& origin, int change_flags) override;
173 virtual void OnRevoked(const GURL& origin, int change_flags) override; 173 void OnRevoked(const GURL& origin, int change_flags) override;
174 virtual void OnCleared() override; 174 void OnCleared() override;
175 175
176 bool IsStorageUnlimited(const GURL& origin) const; 176 bool IsStorageUnlimited(const GURL& origin) const;
177 177
178 UsageTracker* tracker_; 178 UsageTracker* tracker_;
179 QuotaClient* client_; 179 QuotaClient* client_;
180 const StorageType type_; 180 const StorageType type_;
181 StorageMonitor* storage_monitor_; 181 StorageMonitor* storage_monitor_;
182 182
183 int64 global_limited_usage_; 183 int64 global_limited_usage_;
184 int64 global_unlimited_usage_; 184 int64 global_unlimited_usage_;
185 bool global_usage_retrieved_; 185 bool global_usage_retrieved_;
186 HostSet cached_hosts_; 186 HostSet cached_hosts_;
187 HostUsageMap cached_usage_by_host_; 187 HostUsageMap cached_usage_by_host_;
188 188
189 OriginSetByHost non_cached_limited_origins_by_host_; 189 OriginSetByHost non_cached_limited_origins_by_host_;
190 OriginSetByHost non_cached_unlimited_origins_by_host_; 190 OriginSetByHost non_cached_unlimited_origins_by_host_;
191 191
192 GlobalUsageCallbackQueue global_usage_callback_; 192 GlobalUsageCallbackQueue global_usage_callback_;
193 HostUsageAccumulatorMap host_usage_accumulators_; 193 HostUsageAccumulatorMap host_usage_accumulators_;
194 194
195 scoped_refptr<SpecialStoragePolicy> special_storage_policy_; 195 scoped_refptr<SpecialStoragePolicy> special_storage_policy_;
196 196
197 DISALLOW_COPY_AND_ASSIGN(ClientUsageTracker); 197 DISALLOW_COPY_AND_ASSIGN(ClientUsageTracker);
198 }; 198 };
199 199
200 } // namespace storage 200 } // namespace storage
201 201
202 #endif // STORAGE_BROWSER_QUOTA_USAGE_TRACKER_H_ 202 #endif // STORAGE_BROWSER_QUOTA_USAGE_TRACKER_H_
OLDNEW
« no previous file with comments | « storage/browser/quota/quota_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698