| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 void GetHostUsage(const std::string& host, StorageType type, | 139 void GetHostUsage(const std::string& host, StorageType type, |
| 140 HostUsageCallback* callback); | 140 HostUsageCallback* callback); |
| 141 | 141 |
| 142 void GetStatistics(std::map<std::string, std::string>* statistics); | 142 void GetStatistics(std::map<std::string, std::string>* statistics); |
| 143 | 143 |
| 144 bool IsStorageUnlimited(const GURL& origin) const { | 144 bool IsStorageUnlimited(const GURL& origin) const { |
| 145 return special_storage_policy_.get() && | 145 return special_storage_policy_.get() && |
| 146 special_storage_policy_->IsStorageUnlimited(origin); | 146 special_storage_policy_->IsStorageUnlimited(origin); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void GetOriginsModifiedSince( |
| 150 StorageType type, |
| 151 base::Time modified_since, |
| 152 GetOriginsCallback* callback); |
| 153 |
| 149 // Used to determine the total size of the temp pool. | 154 // Used to determine the total size of the temp pool. |
| 150 static const int64 kTemporaryStorageQuotaDefaultSize; | 155 static const int64 kTemporaryStorageQuotaDefaultSize; |
| 151 static const int64 kTemporaryStorageQuotaMaxSize; | 156 static const int64 kTemporaryStorageQuotaMaxSize; |
| 152 static const int64 kIncognitoDefaultTemporaryQuota; | 157 static const int64 kIncognitoDefaultTemporaryQuota; |
| 153 | 158 |
| 154 // Determines the portion of the temp pool that can be | 159 // Determines the portion of the temp pool that can be |
| 155 // utilized by a single host (ie. 5 for 20%). | 160 // utilized by a single host (ie. 5 for 20%). |
| 156 static const int kPerHostTemporaryPortion; | 161 static const int kPerHostTemporaryPortion; |
| 157 | 162 |
| 158 static const char kDatabaseName[]; | 163 static const char kDatabaseName[]; |
| 159 | 164 |
| 160 static const int kThresholdOfErrorsToBeBlacklisted; | 165 static const int kThresholdOfErrorsToBeBlacklisted; |
| 161 | 166 |
| 162 static const int kEvictionIntervalInMilliSeconds; | 167 static const int kEvictionIntervalInMilliSeconds; |
| 163 | 168 |
| 164 private: | 169 private: |
| 165 class DatabaseTaskBase; | 170 class DatabaseTaskBase; |
| 166 class InitializeTask; | 171 class InitializeTask; |
| 167 class TemporaryGlobalQuotaUpdateTask; | 172 class UpdateTemporaryGlobalQuotaTask; |
| 168 class PersistentHostQuotaQueryTask; | 173 class GetPersistentHostQuotaTask; |
| 169 class PersistentHostQuotaUpdateTask; | 174 class UpdatePersistentHostQuotaTask; |
| 170 class GetLRUOriginTask; | 175 class GetLRUOriginTask; |
| 171 class OriginDeletionDatabaseTask; | 176 class DeleteOriginInfo; |
| 172 class TemporaryOriginsRegistrationTask; | 177 class InitializeTemporaryOriginsInfoTask; |
| 173 class OriginAccessRecordDatabaseTask; | 178 class UpdateAccesTimeTask; |
| 179 class UpdateModifiedTimeTask; |
| 180 class GetModifiedSinceTask; |
| 174 | 181 |
| 175 class UsageAndQuotaDispatcherTask; | 182 class UsageAndQuotaDispatcherTask; |
| 176 class UsageAndQuotaDispatcherTaskForTemporary; | 183 class UsageAndQuotaDispatcherTaskForTemporary; |
| 177 class UsageAndQuotaDispatcherTaskForPersistent; | 184 class UsageAndQuotaDispatcherTaskForPersistent; |
| 178 | 185 |
| 179 class OriginDataDeleter; | 186 class OriginDataDeleter; |
| 180 | 187 |
| 181 class AvailableSpaceQueryTask; | 188 class AvailableSpaceQueryTask; |
| 182 class DumpQuotaTableTask; | 189 class DumpQuotaTableTask; |
| 183 class DumpLastAccessTimeTableTask; | 190 class DumpOriginInfoTableTask; |
| 184 | 191 |
| 185 typedef QuotaDatabase::QuotaTableEntry QuotaTableEntry; | 192 typedef QuotaDatabase::QuotaTableEntry QuotaTableEntry; |
| 186 typedef QuotaDatabase::LastAccessTimeTableEntry LastAccessTimeTableEntry; | 193 typedef QuotaDatabase::OriginInfoTableEntry OriginInfoTableEntry; |
| 187 typedef std::vector<QuotaTableEntry> QuotaTableEntries; | 194 typedef std::vector<QuotaTableEntry> QuotaTableEntries; |
| 188 typedef std::vector<LastAccessTimeTableEntry> LastAccessTimeTableEntries; | 195 typedef std::vector<OriginInfoTableEntry> OriginInfoTableEntries; |
| 189 | 196 |
| 190 typedef Callback1<const QuotaTableEntries&>::Type DumpQuotaTableCallback; | 197 typedef Callback1<const QuotaTableEntries&>::Type DumpQuotaTableCallback; |
| 191 typedef Callback1<const LastAccessTimeTableEntries&>::Type | 198 typedef Callback1<const OriginInfoTableEntries&>::Type |
| 192 DumpLastAccessTimeTableCallback; | 199 DumpOriginInfoTableCallback; |
| 193 | 200 |
| 194 struct EvictionContext { | 201 struct EvictionContext { |
| 195 EvictionContext() | 202 EvictionContext() |
| 196 : evicted_type(kStorageTypeUnknown), | 203 : evicted_type(kStorageTypeUnknown), |
| 197 usage(0), | 204 usage(0), |
| 198 unlimited_usage(0), | 205 unlimited_usage(0), |
| 199 quota(0) {} | 206 quota(0) {} |
| 200 virtual ~EvictionContext() {} | 207 virtual ~EvictionContext() {} |
| 201 | 208 |
| 202 GURL evicted_origin; | 209 GURL evicted_origin; |
| 203 StorageType evicted_type; | 210 StorageType evicted_type; |
| 204 | 211 |
| 205 scoped_ptr<EvictOriginDataCallback> evict_origin_data_callback; | 212 scoped_ptr<EvictOriginDataCallback> evict_origin_data_callback; |
| 206 | 213 |
| 207 scoped_ptr<GetUsageAndQuotaForEvictionCallback> | 214 scoped_ptr<GetUsageAndQuotaForEvictionCallback> |
| 208 get_usage_and_quota_callback; | 215 get_usage_and_quota_callback; |
| 209 int64 usage; | 216 int64 usage; |
| 210 int64 unlimited_usage; | 217 int64 unlimited_usage; |
| 211 int64 quota; | 218 int64 quota; |
| 212 }; | 219 }; |
| 213 | 220 |
| 214 typedef std::pair<std::string, StorageType> HostAndType; | 221 typedef std::pair<std::string, StorageType> HostAndType; |
| 215 typedef std::map<HostAndType, UsageAndQuotaDispatcherTask*> | 222 typedef std::map<HostAndType, UsageAndQuotaDispatcherTask*> |
| 216 UsageAndQuotaDispatcherTaskMap; | 223 UsageAndQuotaDispatcherTaskMap; |
| 217 | 224 |
| 218 friend struct QuotaManagerDeleter; | 225 friend struct QuotaManagerDeleter; |
| 226 friend class MockStorageClient; |
| 219 friend class QuotaManagerProxy; | 227 friend class QuotaManagerProxy; |
| 220 friend class QuotaManagerTest; | 228 friend class QuotaManagerTest; |
| 221 friend class QuotaTemporaryStorageEvictor; | 229 friend class QuotaTemporaryStorageEvictor; |
| 222 | 230 |
| 223 // This initialization method is lazily called on the IO thread | 231 // This initialization method is lazily called on the IO thread |
| 224 // when the first quota manager API is called. | 232 // when the first quota manager API is called. |
| 225 // Initialize must be called after all quota clients are added to the | 233 // Initialize must be called after all quota clients are added to the |
| 226 // manager by RegisterStorage. | 234 // manager by RegisterStorage. |
| 227 void LazyInitialize(); | 235 void LazyInitialize(); |
| 228 | 236 |
| 229 // Called by clients via proxy. | 237 // Called by clients via proxy. |
| 230 // Registers a quota client to the manager. | 238 // Registers a quota client to the manager. |
| 231 // The client must remain valid until OnQuotaManagerDestored is called. | 239 // The client must remain valid until OnQuotaManagerDestored is called. |
| 232 void RegisterClient(QuotaClient* client); | 240 void RegisterClient(QuotaClient* client); |
| 233 | 241 |
| 234 UsageTracker* GetUsageTracker(StorageType type) const; | 242 UsageTracker* GetUsageTracker(StorageType type) const; |
| 235 | 243 |
| 236 // Extract cached origins list from the usage tracker. | 244 // Extract cached origins list from the usage tracker. |
| 237 // (Might return empty list if no origin is tracked by the tracker.) | 245 // (Might return empty list if no origin is tracked by the tracker.) |
| 238 void GetCachedOrigins(StorageType type, std::set<GURL>* origins); | 246 void GetCachedOrigins(StorageType type, std::set<GURL>* origins); |
| 239 | 247 |
| 240 // This internal method is separately defined mainly for testing. | 248 // These internal methods are separately defined mainly for testing. |
| 241 void NotifyStorageAccessedInternal( | 249 void NotifyStorageAccessedInternal( |
| 242 QuotaClient::ID client_id, | 250 QuotaClient::ID client_id, |
| 243 const GURL& origin, | 251 const GURL& origin, |
| 244 StorageType type, | 252 StorageType type, |
| 245 base::Time accessed_time); | 253 base::Time accessed_time); |
| 254 void NotifyStorageModifiedInternal( |
| 255 QuotaClient::ID client_id, |
| 256 const GURL& origin, |
| 257 StorageType type, |
| 258 int64 delta, |
| 259 base::Time modified_time); |
| 246 | 260 |
| 247 void DumpQuotaTable(DumpQuotaTableCallback* callback); | 261 void DumpQuotaTable(DumpQuotaTableCallback* callback); |
| 248 void DumpLastAccessTimeTable(DumpLastAccessTimeTableCallback* callback); | 262 void DumpOriginInfoTable(DumpOriginInfoTableCallback* callback); |
| 249 | 263 |
| 250 // Methods for eviction logic. | 264 // Methods for eviction logic. |
| 251 void StartEviction(); | 265 void StartEviction(); |
| 252 void DeleteOriginFromDatabase(const GURL& origin, StorageType type); | 266 void DeleteOriginFromDatabase(const GURL& origin, StorageType type); |
| 253 | 267 |
| 254 void DidOriginDataEvicted(QuotaStatusCode status); | 268 void DidOriginDataEvicted(QuotaStatusCode status); |
| 255 void DidGetAvailableSpaceForEviction( | 269 void DidGetAvailableSpaceForEviction( |
| 256 QuotaStatusCode status, | 270 QuotaStatusCode status, |
| 257 int64 available_space); | 271 int64 available_space); |
| 258 void DidGetGlobalQuotaForEviction( | 272 void DidGetGlobalQuotaForEviction( |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 | 369 |
| 356 QuotaManager* manager_; // only accessed on the io thread | 370 QuotaManager* manager_; // only accessed on the io thread |
| 357 scoped_refptr<base::MessageLoopProxy> io_thread_; | 371 scoped_refptr<base::MessageLoopProxy> io_thread_; |
| 358 | 372 |
| 359 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); | 373 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); |
| 360 }; | 374 }; |
| 361 | 375 |
| 362 } // namespace quota | 376 } // namespace quota |
| 363 | 377 |
| 364 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_ | 378 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_ |
| OLD | NEW |