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