Chromium Code Reviews| 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 17 matching lines...) Expand all Loading... | |
| 28 | 28 |
| 29 namespace quota { | 29 namespace quota { |
| 30 | 30 |
| 31 class QuotaDatabase; | 31 class QuotaDatabase; |
| 32 class UsageTracker; | 32 class UsageTracker; |
| 33 | 33 |
| 34 struct QuotaManagerDeleter; | 34 struct QuotaManagerDeleter; |
| 35 class QuotaManagerProxy; | 35 class QuotaManagerProxy; |
| 36 | 36 |
| 37 // An interface called by QuotaTemporaryStorageEvictor. | 37 // An interface called by QuotaTemporaryStorageEvictor. |
| 38 class QuotaEvictionHandler { | 38 class QuotaEvictionHandler { |
|
kinuko
2011/05/18 10:02:45
could you add virtual ~QuotaEvictionHandler (prote
Dai Mikurube (NOT FULLTIME)
2011/05/18 11:35:25
Done.
| |
| 39 public: | 39 public: |
| 40 typedef Callback1<GURL>::Type GetLRUOriginCallback; | 40 typedef Callback1<GURL>::Type GetLRUOriginCallback; |
| 41 typedef Callback1<QuotaStatusCode>::Type EvictOriginDataCallback; | 41 typedef Callback1<QuotaStatusCode>::Type EvictOriginDataCallback; |
| 42 typedef Callback4<QuotaStatusCode, | 42 typedef Callback4<QuotaStatusCode, |
| 43 int64 /* usage */, | 43 int64 /* usage */, |
| 44 int64 /* quota */, | 44 int64 /* quota */, |
| 45 int64 /* physical_available */ >::Type | 45 int64 /* physical_available */ >::Type |
| 46 GetUsageAndQuotaForEvictionCallback; | 46 GetUsageAndQuotaForEvictionCallback; |
| 47 | 47 |
| 48 virtual void GetLRUOrigin( | 48 virtual void GetLRUOrigin( |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 class PersistentHostQuotaQueryTask; | 147 class PersistentHostQuotaQueryTask; |
| 148 class GetLRUOriginTask; | 148 class GetLRUOriginTask; |
| 149 class OriginDeletionDatabaseTask; | 149 class OriginDeletionDatabaseTask; |
| 150 | 150 |
| 151 class UsageAndQuotaDispatcherTask; | 151 class UsageAndQuotaDispatcherTask; |
| 152 class UsageAndQuotaDispatcherTaskForTemporary; | 152 class UsageAndQuotaDispatcherTaskForTemporary; |
| 153 class UsageAndQuotaDispatcherTaskForPersistent; | 153 class UsageAndQuotaDispatcherTaskForPersistent; |
| 154 | 154 |
| 155 class AvailableSpaceQueryTask; | 155 class AvailableSpaceQueryTask; |
| 156 | 156 |
| 157 struct EvictionContext { | |
| 158 EvictionContext() | |
| 159 : usage(0), | |
| 160 quota(0) {} | |
| 161 | |
| 162 scoped_ptr<GetUsageAndQuotaForEvictionCallback> | |
| 163 get_usage_and_quota_callback; | |
| 164 int64 usage; | |
| 165 int64 quota; | |
| 166 }; | |
| 167 | |
| 157 typedef std::pair<std::string, StorageType> HostAndType; | 168 typedef std::pair<std::string, StorageType> HostAndType; |
| 158 typedef std::map<HostAndType, UsageAndQuotaDispatcherTask*> | 169 typedef std::map<HostAndType, UsageAndQuotaDispatcherTask*> |
| 159 UsageAndQuotaDispatcherTaskMap; | 170 UsageAndQuotaDispatcherTaskMap; |
| 160 | 171 |
| 161 friend struct QuotaManagerDeleter; | 172 friend struct QuotaManagerDeleter; |
| 162 friend class QuotaManagerProxy; | 173 friend class QuotaManagerProxy; |
| 174 friend class QuotaManagerTest; | |
| 163 | 175 |
| 164 // This initialization method is lazily called on the IO thread | 176 // This initialization method is lazily called on the IO thread |
| 165 // when the first quota manager API is called. | 177 // when the first quota manager API is called. |
| 166 // Initialize must be called after all quota clients are added to the | 178 // Initialize must be called after all quota clients are added to the |
| 167 // manager by RegisterStorage. | 179 // manager by RegisterStorage. |
| 168 void LazyInitialize(); | 180 void LazyInitialize(); |
| 169 | 181 |
| 170 // Called by clients via proxy. | 182 // Called by clients via proxy. |
| 171 // Registers a quota client to the manager. | 183 // Registers a quota client to the manager. |
| 172 // The client must remain valid until OnQuotaManagerDestored is called. | 184 // The client must remain valid until OnQuotaManagerDestored is called. |
| 173 void RegisterClient(QuotaClient* client); | 185 void RegisterClient(QuotaClient* client); |
| 174 | 186 |
| 175 UsageTracker* GetUsageTracker(StorageType type) const; | 187 UsageTracker* GetUsageTracker(StorageType type) const; |
| 176 | 188 |
| 177 void DidGetTemporaryGlobalQuota(int64 quota); | 189 void DidGetTemporaryGlobalQuota(int64 quota); |
| 178 | 190 |
| 179 // Methods for eviction logic. | 191 // Methods for eviction logic. |
| 180 void DeleteOriginFromDatabase(const GURL& origin, StorageType type); | 192 void DeleteOriginFromDatabase(const GURL& origin, StorageType type); |
| 181 | 193 |
| 194 void DidGetAvailableSpaceForEviction( | |
| 195 QuotaStatusCode status, | |
| 196 int64 available_space); | |
| 197 void DidGetGlobalQuotaForEviction( | |
| 198 QuotaStatusCode status, | |
| 199 int64 quota); | |
| 200 void DidGetGlobalUsageForEviction(int64 usage); | |
| 201 | |
| 182 virtual void GetLRUOrigin( | 202 virtual void GetLRUOrigin( |
| 183 StorageType type, | 203 StorageType type, |
| 184 GetLRUOriginCallback* callback) OVERRIDE; | 204 GetLRUOriginCallback* callback) OVERRIDE; |
| 185 virtual void EvictOriginData( | 205 virtual void EvictOriginData( |
| 186 const GURL& origin, | 206 const GURL& origin, |
| 187 StorageType type, | 207 StorageType type, |
| 188 EvictOriginDataCallback* callback) OVERRIDE; | 208 EvictOriginDataCallback* callback) OVERRIDE; |
| 189 virtual void GetUsageAndQuotaForEviction( | 209 virtual void GetUsageAndQuotaForEviction( |
| 190 GetUsageAndQuotaForEvictionCallback* callback) OVERRIDE; | 210 GetUsageAndQuotaForEvictionCallback* callback) OVERRIDE; |
| 191 | 211 |
| 192 void DeleteOnCorrectThread() const; | 212 void DeleteOnCorrectThread() const; |
| 193 | 213 |
| 194 const bool is_incognito_; | 214 const bool is_incognito_; |
| 195 const FilePath profile_path_; | 215 const FilePath profile_path_; |
| 196 | 216 |
| 197 scoped_refptr<QuotaManagerProxy> proxy_; | 217 scoped_refptr<QuotaManagerProxy> proxy_; |
| 198 bool db_disabled_; | 218 bool db_disabled_; |
| 199 scoped_refptr<base::MessageLoopProxy> io_thread_; | 219 scoped_refptr<base::MessageLoopProxy> io_thread_; |
| 200 scoped_refptr<base::MessageLoopProxy> db_thread_; | 220 scoped_refptr<base::MessageLoopProxy> db_thread_; |
| 201 mutable scoped_ptr<QuotaDatabase> database_; | 221 mutable scoped_ptr<QuotaDatabase> database_; |
| 202 | 222 |
| 203 QuotaClientList clients_; | 223 QuotaClientList clients_; |
| 204 | 224 |
| 205 scoped_ptr<UsageTracker> temporary_usage_tracker_; | 225 scoped_ptr<UsageTracker> temporary_usage_tracker_; |
| 206 scoped_ptr<UsageTracker> persistent_usage_tracker_; | 226 scoped_ptr<UsageTracker> persistent_usage_tracker_; |
| 207 | 227 |
| 228 EvictionContext eviction_context_; | |
| 229 | |
| 208 UsageAndQuotaDispatcherTaskMap usage_and_quota_dispatchers_; | 230 UsageAndQuotaDispatcherTaskMap usage_and_quota_dispatchers_; |
| 209 | 231 |
| 210 int64 temporary_global_quota_; | 232 int64 temporary_global_quota_; |
| 211 QuotaCallbackQueue temporary_global_quota_callbacks_; | 233 QuotaCallbackQueue temporary_global_quota_callbacks_; |
| 212 | 234 |
| 213 // Map from origin to count. | 235 // Map from origin to count. |
| 214 std::map<GURL, int> origins_in_use_; | 236 std::map<GURL, int> origins_in_use_; |
| 215 | 237 |
| 238 base::ScopedCallbackFactory<QuotaManager> callback_factory_; | |
| 239 | |
| 216 DISALLOW_COPY_AND_ASSIGN(QuotaManager); | 240 DISALLOW_COPY_AND_ASSIGN(QuotaManager); |
| 217 }; | 241 }; |
| 218 | 242 |
| 219 struct QuotaManagerDeleter { | 243 struct QuotaManagerDeleter { |
| 220 static void Destruct(const QuotaManager* manager) { | 244 static void Destruct(const QuotaManager* manager) { |
| 221 manager->DeleteOnCorrectThread(); | 245 manager->DeleteOnCorrectThread(); |
| 222 } | 246 } |
| 223 }; | 247 }; |
| 224 | 248 |
| 225 // The proxy may be called and finally released on any thread. | 249 // 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 | 275 QuotaManager* manager_; // only accessed on the io thread |
| 252 scoped_refptr<base::MessageLoopProxy> io_thread_; | 276 scoped_refptr<base::MessageLoopProxy> io_thread_; |
| 253 | 277 |
| 254 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); | 278 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); |
| 255 }; | 279 }; |
| 256 | 280 |
| 257 | 281 |
| 258 } // namespace quota | 282 } // namespace quota |
| 259 | 283 |
| 260 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_ | 284 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_ |
| OLD | NEW |