OLD | NEW |
---|---|
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_QUOTA_MANAGER_H_ | 5 #ifndef WEBKIT_QUOTA_QUOTA_MANAGER_H_ |
6 #define WEBKIT_QUOTA_QUOTA_MANAGER_H_ | 6 #define WEBKIT_QUOTA_QUOTA_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <deque> | 9 #include <deque> |
10 #include <list> | 10 #include <list> |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 class UsageAndQuotaDispatcherTask; | 149 class UsageAndQuotaDispatcherTask; |
150 class UsageAndQuotaDispatcherTaskForTemporary; | 150 class UsageAndQuotaDispatcherTaskForTemporary; |
151 class UsageAndQuotaDispatcherTaskForPersistent; | 151 class UsageAndQuotaDispatcherTaskForPersistent; |
152 | 152 |
153 typedef std::pair<std::string, StorageType> HostAndType; | 153 typedef std::pair<std::string, StorageType> HostAndType; |
154 typedef std::map<HostAndType, UsageAndQuotaDispatcherTask*> | 154 typedef std::map<HostAndType, UsageAndQuotaDispatcherTask*> |
155 UsageAndQuotaDispatcherTaskMap; | 155 UsageAndQuotaDispatcherTaskMap; |
156 | 156 |
157 friend struct QuotaManagerDeleter; | 157 friend struct QuotaManagerDeleter; |
158 friend class QuotaManagerProxy; | 158 friend class QuotaManagerProxy; |
159 friend class QuotaManagerTest; | |
159 | 160 |
160 // This initialization method is lazily called on the IO thread | 161 // This initialization method is lazily called on the IO thread |
161 // when the first quota manager API is called. | 162 // when the first quota manager API is called. |
162 // Initialize must be called after all quota clients are added to the | 163 // Initialize must be called after all quota clients are added to the |
163 // manager by RegisterStorage. | 164 // manager by RegisterStorage. |
164 void LazyInitialize(); | 165 void LazyInitialize(); |
165 | 166 |
166 // Called by clients via proxy. | 167 // Called by clients via proxy. |
167 // Registers a quota client to the manager. | 168 // Registers a quota client to the manager. |
168 // The client must remain valid until OnQuotaManagerDestored is called. | 169 // The client must remain valid until OnQuotaManagerDestored is called. |
169 void RegisterClient(QuotaClient* client); | 170 void RegisterClient(QuotaClient* client); |
170 | 171 |
171 UsageTracker* GetUsageTracker(StorageType type) const; | 172 UsageTracker* GetUsageTracker(StorageType type) const; |
172 | 173 |
173 void DidGetTemporaryGlobalQuota(int64 quota); | 174 void DidGetTemporaryGlobalQuota(int64 quota); |
174 | 175 |
175 // Methods for eviction logic. | 176 // Methods for eviction logic. |
176 void DeleteOriginFromDatabase(const GURL& origin, StorageType type); | 177 void DeleteOriginFromDatabase(const GURL& origin, StorageType type); |
177 | 178 |
179 void OnOriginDataEvicted(QuotaStatusCode status); | |
180 | |
178 virtual void GetLRUOrigin( | 181 virtual void GetLRUOrigin( |
179 StorageType type, | 182 StorageType type, |
180 GetLRUOriginCallback* callback) OVERRIDE; | 183 GetLRUOriginCallback* callback) OVERRIDE; |
181 virtual void EvictOriginData( | 184 virtual void EvictOriginData( |
182 const GURL& origin, | 185 const GURL& origin, |
183 StorageType type, | 186 StorageType type, |
184 EvictOriginDataCallback* callback) OVERRIDE; | 187 EvictOriginDataCallback* callback) OVERRIDE; |
185 virtual void GetUsageAndQuotaForEviction( | 188 virtual void GetUsageAndQuotaForEviction( |
186 GetUsageAndQuotaForEvictionCallback* callback) OVERRIDE; | 189 GetUsageAndQuotaForEvictionCallback* callback) OVERRIDE; |
187 | 190 |
188 void DeleteOnCorrectThread() const; | 191 void DeleteOnCorrectThread() const; |
189 | 192 |
190 const bool is_incognito_; | 193 const bool is_incognito_; |
191 const FilePath profile_path_; | 194 const FilePath profile_path_; |
192 | 195 |
193 scoped_refptr<QuotaManagerProxy> proxy_; | 196 scoped_refptr<QuotaManagerProxy> proxy_; |
194 bool db_disabled_; | 197 bool db_disabled_; |
195 scoped_refptr<base::MessageLoopProxy> io_thread_; | 198 scoped_refptr<base::MessageLoopProxy> io_thread_; |
196 scoped_refptr<base::MessageLoopProxy> db_thread_; | 199 scoped_refptr<base::MessageLoopProxy> db_thread_; |
197 mutable scoped_ptr<QuotaDatabase> database_; | 200 mutable scoped_ptr<QuotaDatabase> database_; |
198 | 201 |
199 QuotaClientList clients_; | 202 QuotaClientList clients_; |
200 | 203 |
201 scoped_ptr<UsageTracker> temporary_usage_tracker_; | 204 scoped_ptr<UsageTracker> temporary_usage_tracker_; |
202 scoped_ptr<UsageTracker> persistent_usage_tracker_; | 205 scoped_ptr<UsageTracker> persistent_usage_tracker_; |
203 | 206 |
204 UsageAndQuotaDispatcherTaskMap usage_and_quota_dispatchers_; | 207 UsageAndQuotaDispatcherTaskMap usage_and_quota_dispatchers_; |
205 | 208 |
209 EvictOriginDataCallback* evict_origin_data_callback_; | |
210 int num_deletion_requested_clients_; | |
211 int num_deleted_clients_; | |
michaeln
2011/05/17 19:30:01
consider using the term 'evict' in some form in al
Dai Mikurube (NOT FULLTIME)
2011/05/18 04:34:48
Done.
| |
212 | |
206 int64 temporary_global_quota_; | 213 int64 temporary_global_quota_; |
207 QuotaCallbackQueue temporary_global_quota_callbacks_; | 214 QuotaCallbackQueue temporary_global_quota_callbacks_; |
208 | 215 |
209 // Map from origin to count. | 216 // Map from origin to count. |
210 std::map<GURL, int> origins_in_use_; | 217 std::map<GURL, int> origins_in_use_; |
211 | 218 |
219 base::ScopedCallbackFactory<QuotaManager> callback_factory_; | |
220 | |
212 DISALLOW_COPY_AND_ASSIGN(QuotaManager); | 221 DISALLOW_COPY_AND_ASSIGN(QuotaManager); |
213 }; | 222 }; |
214 | 223 |
215 struct QuotaManagerDeleter { | 224 struct QuotaManagerDeleter { |
216 static void Destruct(const QuotaManager* manager) { | 225 static void Destruct(const QuotaManager* manager) { |
217 manager->DeleteOnCorrectThread(); | 226 manager->DeleteOnCorrectThread(); |
218 } | 227 } |
219 }; | 228 }; |
220 | 229 |
221 // The proxy may be called and finally released on any thread. | 230 // The proxy may be called and finally released on any thread. |
(...skipping 25 matching lines...) Expand all Loading... | |
247 QuotaManager* manager_; // only accessed on the io thread | 256 QuotaManager* manager_; // only accessed on the io thread |
248 scoped_refptr<base::MessageLoopProxy> io_thread_; | 257 scoped_refptr<base::MessageLoopProxy> io_thread_; |
249 | 258 |
250 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); | 259 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); |
251 }; | 260 }; |
252 | 261 |
253 | 262 |
254 } // namespace quota | 263 } // namespace quota |
255 | 264 |
256 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_ | 265 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_ |
OLD | NEW |