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

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

Issue 10948006: Cleanup: quota::HostQuotaCallback do not need to pass host and type as arguments (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed unittests somehow missed in previous patch Created 8 years, 3 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 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 19 matching lines...) Expand all
30 class UsageTracker : public QuotaTaskObserver { 30 class UsageTracker : public QuotaTaskObserver {
31 public: 31 public:
32 UsageTracker(const QuotaClientList& clients, StorageType type, 32 UsageTracker(const QuotaClientList& clients, StorageType type,
33 SpecialStoragePolicy* special_storage_policy); 33 SpecialStoragePolicy* special_storage_policy);
34 virtual ~UsageTracker(); 34 virtual ~UsageTracker();
35 35
36 StorageType type() const { return type_; } 36 StorageType type() const { return type_; }
37 ClientUsageTracker* GetClientTracker(QuotaClient::ID client_id); 37 ClientUsageTracker* GetClientTracker(QuotaClient::ID client_id);
38 38
39 void GetGlobalUsage(const GlobalUsageCallback& callback); 39 void GetGlobalUsage(const GlobalUsageCallback& callback);
40 void GetHostUsage(const std::string& host, const HostUsageCallback& callback); 40 void GetHostUsage(const std::string& host, const UsageCallback& callback);
41 void UpdateUsageCache(QuotaClient::ID client_id, 41 void UpdateUsageCache(QuotaClient::ID client_id,
42 const GURL& origin, 42 const GURL& origin,
43 int64 delta); 43 int64 delta);
44 void GetCachedHostsUsage(std::map<std::string, int64>* host_usage) const; 44 void GetCachedHostsUsage(std::map<std::string, int64>* host_usage) const;
45 void GetCachedOrigins(std::set<GURL>* origins) const; 45 void GetCachedOrigins(std::set<GURL>* origins) const;
46 bool IsWorking() const { 46 bool IsWorking() const {
47 return global_usage_callbacks_.HasCallbacks() || 47 return global_usage_callbacks_.HasCallbacks() ||
48 host_usage_callbacks_.HasAnyCallbacks(); 48 host_usage_callbacks_.HasAnyCallbacks();
49 } 49 }
50 50
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 public base::NonThreadSafe, 83 public base::NonThreadSafe,
84 public base::SupportsWeakPtr<ClientUsageTracker> { 84 public base::SupportsWeakPtr<ClientUsageTracker> {
85 public: 85 public:
86 ClientUsageTracker(UsageTracker* tracker, 86 ClientUsageTracker(UsageTracker* tracker,
87 QuotaClient* client, 87 QuotaClient* client,
88 StorageType type, 88 StorageType type,
89 SpecialStoragePolicy* special_storage_policy); 89 SpecialStoragePolicy* special_storage_policy);
90 virtual ~ClientUsageTracker(); 90 virtual ~ClientUsageTracker();
91 91
92 void GetGlobalUsage(const GlobalUsageCallback& callback); 92 void GetGlobalUsage(const GlobalUsageCallback& callback);
93 void GetHostUsage(const std::string& host, const HostUsageCallback& callback); 93 void GetHostUsage(const std::string& host, const UsageCallback& callback);
94 void UpdateUsageCache(const GURL& origin, int64 delta); 94 void UpdateUsageCache(const GURL& origin, int64 delta);
95 void GetCachedHostsUsage(std::map<std::string, int64>* host_usage) const; 95 void GetCachedHostsUsage(std::map<std::string, int64>* host_usage) const;
96 void GetCachedOrigins(std::set<GURL>* origins) const; 96 void GetCachedOrigins(std::set<GURL>* origins) const;
97 97
98 private: 98 private:
99 typedef std::set<std::string> HostSet; 99 typedef std::set<std::string> HostSet;
100 typedef std::map<GURL, int64> UsageMap; 100 typedef std::map<GURL, int64> UsageMap;
101 typedef std::map<std::string, UsageMap> HostUsageMap; 101 typedef std::map<std::string, UsageMap> HostUsageMap;
102 102
103 class GatherUsageTaskBase; 103 class GatherUsageTaskBase;
104 class GatherGlobalUsageTask; 104 class GatherGlobalUsageTask;
105 class GatherHostUsageTask; 105 class GatherHostUsageTask;
106 106
107 // Methods used by our GatherUsage tasks, as a task makes progress 107 // Methods used by our GatherUsage tasks, as a task makes progress
108 // origins and hosts are added incrementally to the cache. 108 // origins and hosts are added incrementally to the cache.
109 void AddCachedOrigin(const GURL& origin, int64 usage); 109 void AddCachedOrigin(const GURL& origin, int64 usage);
110 void AddCachedHost(const std::string& host); 110 void AddCachedHost(const std::string& host);
111 void GatherGlobalUsageComplete(); 111 void GatherGlobalUsageComplete();
112 void GatherHostUsageComplete(const std::string& host); 112 void GatherHostUsageComplete(const std::string& host);
113 113
114 int64 GetCachedHostUsage(const std::string& host) const; 114 int64 GetCachedHostUsage(const std::string& host) const;
115 int64 GetCachedGlobalUnlimitedUsage(); 115 int64 GetCachedGlobalUnlimitedUsage();
116 virtual void OnSpecialStoragePolicyChanged() OVERRIDE; 116 virtual void OnSpecialStoragePolicyChanged() OVERRIDE;
117 void NoopHostUsageCallback( 117 void NoopHostUsageCallback(int64 usage);
118 const std::string& host, StorageType type, int64 usage);
119 bool IsStorageUnlimited(const GURL& origin) const; 118 bool IsStorageUnlimited(const GURL& origin) const;
120 119
121 UsageTracker* tracker_; 120 UsageTracker* tracker_;
122 QuotaClient* client_; 121 QuotaClient* client_;
123 const StorageType type_; 122 const StorageType type_;
124 123
125 int64 global_usage_; 124 int64 global_usage_;
126 int64 global_unlimited_usage_; 125 int64 global_unlimited_usage_;
127 bool global_usage_retrieved_; 126 bool global_usage_retrieved_;
128 bool global_unlimited_usage_is_valid_; 127 bool global_unlimited_usage_is_valid_;
129 HostSet cached_hosts_; 128 HostSet cached_hosts_;
130 HostUsageMap cached_usage_; 129 HostUsageMap cached_usage_;
131 130
132 GatherGlobalUsageTask* global_usage_task_; 131 GatherGlobalUsageTask* global_usage_task_;
133 GlobalUsageCallbackQueue global_usage_callback_; 132 GlobalUsageCallbackQueue global_usage_callback_;
134 std::map<std::string, GatherHostUsageTask*> host_usage_tasks_; 133 std::map<std::string, GatherHostUsageTask*> host_usage_tasks_;
135 HostUsageCallbackMap host_usage_callbacks_; 134 HostUsageCallbackMap host_usage_callbacks_;
136 135
137 scoped_refptr<SpecialStoragePolicy> special_storage_policy_; 136 scoped_refptr<SpecialStoragePolicy> special_storage_policy_;
138 137
139 DISALLOW_COPY_AND_ASSIGN(ClientUsageTracker); 138 DISALLOW_COPY_AND_ASSIGN(ClientUsageTracker);
140 }; 139 };
141 140
142 } // namespace quota 141 } // namespace quota
143 142
144 #endif // WEBKIT_QUOTA_USAGE_TRACKER_H_ 143 #endif // WEBKIT_QUOTA_USAGE_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698