| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 virtual void EvictOriginData( | 68 virtual void EvictOriginData( |
| 69 const GURL& origin, | 69 const GURL& origin, |
| 70 StorageType type, | 70 StorageType type, |
| 71 EvictOriginDataCallback* callback) = 0; | 71 EvictOriginDataCallback* callback) = 0; |
| 72 | 72 |
| 73 virtual void GetUsageAndQuotaForEviction( | 73 virtual void GetUsageAndQuotaForEviction( |
| 74 GetUsageAndQuotaForEvictionCallback* callback) = 0; | 74 GetUsageAndQuotaForEvictionCallback* callback) = 0; |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 struct UsageInfo { |
| 78 UsageInfo(const std::string& host, StorageType type, int64 usage) |
| 79 : host(host), |
| 80 type(type), |
| 81 usage(usage) {} |
| 82 std::string host; |
| 83 StorageType type; |
| 84 int64 usage; |
| 85 }; |
| 86 |
| 77 // The quota manager class. This class is instantiated per profile and | 87 // The quota manager class. This class is instantiated per profile and |
| 78 // held by the profile. With the exception of the constructor and the | 88 // held by the profile. With the exception of the constructor and the |
| 79 // proxy() method, all methods should only be called on the IO thread. | 89 // proxy() method, all methods should only be called on the IO thread. |
| 80 class QuotaManager : public QuotaTaskObserver, | 90 class QuotaManager : public QuotaTaskObserver, |
| 81 public QuotaEvictionHandler, | 91 public QuotaEvictionHandler, |
| 82 public base::RefCountedThreadSafe< | 92 public base::RefCountedThreadSafe< |
| 83 QuotaManager, QuotaManagerDeleter> { | 93 QuotaManager, QuotaManagerDeleter> { |
| 84 public: | 94 public: |
| 85 typedef Callback3<QuotaStatusCode, | 95 typedef Callback3<QuotaStatusCode, |
| 86 int64 /* usage */, | 96 int64 /* usage */, |
| 87 int64 /* quota */>::Type GetUsageAndQuotaCallback; | 97 int64 /* quota */>::Type GetUsageAndQuotaCallback; |
| 88 | 98 |
| 89 QuotaManager(bool is_incognito, | 99 QuotaManager(bool is_incognito, |
| 90 const FilePath& profile_path, | 100 const FilePath& profile_path, |
| 91 base::MessageLoopProxy* io_thread, | 101 base::MessageLoopProxy* io_thread, |
| 92 base::MessageLoopProxy* db_thread, | 102 base::MessageLoopProxy* db_thread, |
| 93 SpecialStoragePolicy* special_storage_policy); | 103 SpecialStoragePolicy* special_storage_policy); |
| 94 | 104 |
| 95 virtual ~QuotaManager(); | 105 virtual ~QuotaManager(); |
| 96 | 106 |
| 97 // Returns a proxy object that can be used on any thread. | 107 // Returns a proxy object that can be used on any thread. |
| 98 QuotaManagerProxy* proxy() { return proxy_.get(); } | 108 QuotaManagerProxy* proxy() { return proxy_.get(); } |
| 99 | 109 |
| 110 // Called by clients or webapps. Returns usage per host. |
| 111 void GetUsageInfo(GetUsageInfoCallback* callback); |
| 112 |
| 100 // Called by clients or webapps. | 113 // Called by clients or webapps. |
| 101 // This method is declared as virtual to allow test code to override it. | 114 // This method is declared as virtual to allow test code to override it. |
| 102 // note: returns host usage and quota | 115 // note: returns host usage and quota |
| 103 virtual void GetUsageAndQuota(const GURL& origin, | 116 virtual void GetUsageAndQuota(const GURL& origin, |
| 104 StorageType type, | 117 StorageType type, |
| 105 GetUsageAndQuotaCallback* callback); | 118 GetUsageAndQuotaCallback* callback); |
| 106 | 119 |
| 107 // Called by clients via proxy. | 120 // Called by clients via proxy. |
| 108 // Client storage should call this method when storage is accessed. | 121 // Client storage should call this method when storage is accessed. |
| 109 // Used to maintain LRU ordering. | 122 // Used to maintain LRU ordering. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 class UpdateTemporaryGlobalQuotaTask; | 194 class UpdateTemporaryGlobalQuotaTask; |
| 182 class GetPersistentHostQuotaTask; | 195 class GetPersistentHostQuotaTask; |
| 183 class UpdatePersistentHostQuotaTask; | 196 class UpdatePersistentHostQuotaTask; |
| 184 class GetLRUOriginTask; | 197 class GetLRUOriginTask; |
| 185 class DeleteOriginInfo; | 198 class DeleteOriginInfo; |
| 186 class InitializeTemporaryOriginsInfoTask; | 199 class InitializeTemporaryOriginsInfoTask; |
| 187 class UpdateAccessTimeTask; | 200 class UpdateAccessTimeTask; |
| 188 class UpdateModifiedTimeTask; | 201 class UpdateModifiedTimeTask; |
| 189 class GetModifiedSinceTask; | 202 class GetModifiedSinceTask; |
| 190 | 203 |
| 204 class GetUsageInfoTask; |
| 191 class UsageAndQuotaDispatcherTask; | 205 class UsageAndQuotaDispatcherTask; |
| 192 class UsageAndQuotaDispatcherTaskForTemporary; | 206 class UsageAndQuotaDispatcherTaskForTemporary; |
| 193 class UsageAndQuotaDispatcherTaskForPersistent; | 207 class UsageAndQuotaDispatcherTaskForPersistent; |
| 194 | 208 |
| 195 class OriginDataDeleter; | 209 class OriginDataDeleter; |
| 196 | 210 |
| 197 class AvailableSpaceQueryTask; | 211 class AvailableSpaceQueryTask; |
| 198 class DumpQuotaTableTask; | 212 class DumpQuotaTableTask; |
| 199 class DumpOriginInfoTableTask; | 213 class DumpOriginInfoTableTask; |
| 200 | 214 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 | 404 |
| 391 QuotaManager* manager_; // only accessed on the io thread | 405 QuotaManager* manager_; // only accessed on the io thread |
| 392 scoped_refptr<base::MessageLoopProxy> io_thread_; | 406 scoped_refptr<base::MessageLoopProxy> io_thread_; |
| 393 | 407 |
| 394 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); | 408 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); |
| 395 }; | 409 }; |
| 396 | 410 |
| 397 } // namespace quota | 411 } // namespace quota |
| 398 | 412 |
| 399 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_ | 413 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_ |
| OLD | NEW |