| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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> |
| 11 #include <map> | 11 #include <map> |
| 12 #include <set> | 12 #include <set> |
| 13 #include <string> | 13 #include <string> |
| 14 #include <utility> | 14 #include <utility> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
| 18 #include "base/callback.h" | 18 #include "base/callback.h" |
| 19 #include "base/file_path.h" | 19 #include "base/file_path.h" |
| 20 #include "base/memory/ref_counted.h" | 20 #include "base/memory/ref_counted.h" |
| 21 #include "base/memory/weak_ptr.h" | 21 #include "base/memory/weak_ptr.h" |
| 22 #include "base/memory/scoped_ptr.h" | 22 #include "base/memory/scoped_ptr.h" |
| 23 #include "base/memory/weak_ptr.h" | 23 #include "base/memory/weak_ptr.h" |
| 24 #include "base/sequenced_task_runner_helpers.h" |
| 24 #include "webkit/quota/quota_database.h" | 25 #include "webkit/quota/quota_database.h" |
| 25 #include "webkit/quota/quota_client.h" | 26 #include "webkit/quota/quota_client.h" |
| 26 #include "webkit/quota/quota_task.h" | 27 #include "webkit/quota/quota_task.h" |
| 27 #include "webkit/quota/quota_types.h" | 28 #include "webkit/quota/quota_types.h" |
| 28 #include "webkit/quota/special_storage_policy.h" | 29 #include "webkit/quota/special_storage_policy.h" |
| 29 | 30 |
| 30 class FilePath; | 31 class FilePath; |
| 31 | 32 |
| 32 namespace base { | 33 namespace base { |
| 33 class MessageLoopProxy; | 34 class MessageLoopProxy; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 int64 /* usage */, | 103 int64 /* usage */, |
| 103 int64 /* quota */)> | 104 int64 /* quota */)> |
| 104 GetUsageAndQuotaCallback; | 105 GetUsageAndQuotaCallback; |
| 105 | 106 |
| 106 QuotaManager(bool is_incognito, | 107 QuotaManager(bool is_incognito, |
| 107 const FilePath& profile_path, | 108 const FilePath& profile_path, |
| 108 base::MessageLoopProxy* io_thread, | 109 base::MessageLoopProxy* io_thread, |
| 109 base::MessageLoopProxy* db_thread, | 110 base::MessageLoopProxy* db_thread, |
| 110 SpecialStoragePolicy* special_storage_policy); | 111 SpecialStoragePolicy* special_storage_policy); |
| 111 | 112 |
| 112 virtual ~QuotaManager(); | |
| 113 | |
| 114 // Returns a proxy object that can be used on any thread. | 113 // Returns a proxy object that can be used on any thread. |
| 115 QuotaManagerProxy* proxy() { return proxy_.get(); } | 114 QuotaManagerProxy* proxy() { return proxy_.get(); } |
| 116 | 115 |
| 117 // Called by clients or webapps. Returns usage per host. | 116 // Called by clients or webapps. Returns usage per host. |
| 118 void GetUsageInfo(const GetUsageInfoCallback& callback); | 117 void GetUsageInfo(const GetUsageInfoCallback& callback); |
| 119 | 118 |
| 120 // Called by clients or webapps. | 119 // Called by clients or webapps. |
| 121 // This method is declared as virtual to allow test code to override it. | 120 // This method is declared as virtual to allow test code to override it. |
| 122 // note: returns host usage and quota | 121 // note: returns host usage and quota |
| 123 virtual void GetUsageAndQuota(const GURL& origin, | 122 virtual void GetUsageAndQuota(const GURL& origin, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 // Determines the portion of the temp pool that can be | 196 // Determines the portion of the temp pool that can be |
| 198 // utilized by a single host (ie. 5 for 20%). | 197 // utilized by a single host (ie. 5 for 20%). |
| 199 static const int kPerHostTemporaryPortion; | 198 static const int kPerHostTemporaryPortion; |
| 200 | 199 |
| 201 static const char kDatabaseName[]; | 200 static const char kDatabaseName[]; |
| 202 | 201 |
| 203 static const int kThresholdOfErrorsToBeBlacklisted; | 202 static const int kThresholdOfErrorsToBeBlacklisted; |
| 204 | 203 |
| 205 static const int kEvictionIntervalInMilliSeconds; | 204 static const int kEvictionIntervalInMilliSeconds; |
| 206 | 205 |
| 206 protected: |
| 207 virtual ~QuotaManager(); |
| 208 |
| 207 private: | 209 private: |
| 210 friend class base::DeleteHelper<QuotaManager>; |
| 211 friend class MockQuotaManager; |
| 212 friend class MockStorageClient; |
| 213 friend class quota_internals::QuotaInternalsProxy; |
| 214 friend class QuotaManagerProxy; |
| 215 friend class QuotaManagerTest; |
| 216 friend class QuotaTemporaryStorageEvictor; |
| 217 friend struct QuotaManagerDeleter; |
| 218 |
| 208 class DatabaseTaskBase; | 219 class DatabaseTaskBase; |
| 209 class InitializeTask; | 220 class InitializeTask; |
| 210 class UpdateTemporaryQuotaOverrideTask; | 221 class UpdateTemporaryQuotaOverrideTask; |
| 211 class GetPersistentHostQuotaTask; | 222 class GetPersistentHostQuotaTask; |
| 212 class UpdatePersistentHostQuotaTask; | 223 class UpdatePersistentHostQuotaTask; |
| 213 class GetLRUOriginTask; | 224 class GetLRUOriginTask; |
| 214 class DeleteOriginInfo; | 225 class DeleteOriginInfo; |
| 215 class InitializeTemporaryOriginsInfoTask; | 226 class InitializeTemporaryOriginsInfoTask; |
| 216 class UpdateAccessTimeTask; | 227 class UpdateAccessTimeTask; |
| 217 class UpdateModifiedTimeTask; | 228 class UpdateModifiedTimeTask; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 EvictOriginDataCallback evict_origin_data_callback; | 260 EvictOriginDataCallback evict_origin_data_callback; |
| 250 }; | 261 }; |
| 251 | 262 |
| 252 typedef std::pair<std::string, StorageType> HostAndType; | 263 typedef std::pair<std::string, StorageType> HostAndType; |
| 253 typedef std::map<HostAndType, UsageAndQuotaDispatcherTask*> | 264 typedef std::map<HostAndType, UsageAndQuotaDispatcherTask*> |
| 254 UsageAndQuotaDispatcherTaskMap; | 265 UsageAndQuotaDispatcherTaskMap; |
| 255 | 266 |
| 256 typedef QuotaEvictionHandler::GetUsageAndQuotaForEvictionCallback | 267 typedef QuotaEvictionHandler::GetUsageAndQuotaForEvictionCallback |
| 257 UsageAndQuotaDispatcherCallback; | 268 UsageAndQuotaDispatcherCallback; |
| 258 | 269 |
| 259 friend class quota_internals::QuotaInternalsProxy; | |
| 260 friend struct QuotaManagerDeleter; | |
| 261 friend class MockStorageClient; | |
| 262 friend class QuotaManagerProxy; | |
| 263 friend class QuotaManagerTest; | |
| 264 friend class QuotaTemporaryStorageEvictor; | |
| 265 friend class MockQuotaManager; | |
| 266 | |
| 267 // This initialization method is lazily called on the IO thread | 270 // This initialization method is lazily called on the IO thread |
| 268 // when the first quota manager API is called. | 271 // when the first quota manager API is called. |
| 269 // Initialize must be called after all quota clients are added to the | 272 // Initialize must be called after all quota clients are added to the |
| 270 // manager by RegisterStorage. | 273 // manager by RegisterStorage. |
| 271 void LazyInitialize(); | 274 void LazyInitialize(); |
| 272 | 275 |
| 273 // Called by clients via proxy. | 276 // Called by clients via proxy. |
| 274 // Registers a quota client to the manager. | 277 // Registers a quota client to the manager. |
| 275 // The client must remain valid until OnQuotaManagerDestored is called. | 278 // The client must remain valid until OnQuotaManagerDestored is called. |
| 276 void RegisterClient(QuotaClient* client); | 279 void RegisterClient(QuotaClient* client); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 | 423 |
| 421 QuotaManager* manager_; // only accessed on the io thread | 424 QuotaManager* manager_; // only accessed on the io thread |
| 422 scoped_refptr<base::MessageLoopProxy> io_thread_; | 425 scoped_refptr<base::MessageLoopProxy> io_thread_; |
| 423 | 426 |
| 424 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); | 427 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); |
| 425 }; | 428 }; |
| 426 | 429 |
| 427 } // namespace quota | 430 } // namespace quota |
| 428 | 431 |
| 429 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_ | 432 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_ |
| OLD | NEW |