| 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 private: | 159 private: |
| 160 class DatabaseTaskBase; | 160 class DatabaseTaskBase; |
| 161 class InitializeTask; | 161 class InitializeTask; |
| 162 class TemporaryGlobalQuotaUpdateTask; | 162 class TemporaryGlobalQuotaUpdateTask; |
| 163 class PersistentHostQuotaQueryTask; | 163 class PersistentHostQuotaQueryTask; |
| 164 class PersistentHostQuotaUpdateTask; | 164 class PersistentHostQuotaUpdateTask; |
| 165 class GetLRUOriginTask; | 165 class GetLRUOriginTask; |
| 166 class OriginDeletionDatabaseTask; | 166 class OriginDeletionDatabaseTask; |
| 167 class TemporaryOriginsRegistrationTask; | 167 class TemporaryOriginsRegistrationTask; |
| 168 class OriginAccessRecordDatabaseTask; | 168 class OriginAccessRecordDatabaseTask; |
| 169 class OriginModifyRecordDatabaseTask; |
| 170 class OriginsModifiedSinceRetrieveTask; |
| 169 | 171 |
| 170 class UsageAndQuotaDispatcherTask; | 172 class UsageAndQuotaDispatcherTask; |
| 171 class UsageAndQuotaDispatcherTaskForTemporary; | 173 class UsageAndQuotaDispatcherTaskForTemporary; |
| 172 class UsageAndQuotaDispatcherTaskForPersistent; | 174 class UsageAndQuotaDispatcherTaskForPersistent; |
| 173 | 175 |
| 174 class AvailableSpaceQueryTask; | 176 class AvailableSpaceQueryTask; |
| 175 class DumpQuotaTableTask; | 177 class DumpQuotaTableTask; |
| 176 class DumpLastAccessTimeTableTask; | 178 class DumpOriginInfoTableTask; |
| 177 | 179 |
| 178 typedef QuotaDatabase::QuotaTableEntry QuotaTableEntry; | 180 typedef QuotaDatabase::QuotaTableEntry QuotaTableEntry; |
| 179 typedef QuotaDatabase::LastAccessTimeTableEntry LastAccessTimeTableEntry; | 181 typedef QuotaDatabase::OriginInfoTableEntry OriginInfoTableEntry; |
| 180 typedef std::vector<QuotaTableEntry> QuotaTableEntries; | 182 typedef std::vector<QuotaTableEntry> QuotaTableEntries; |
| 181 typedef std::vector<LastAccessTimeTableEntry> LastAccessTimeTableEntries; | 183 typedef std::vector<OriginInfoTableEntry> OriginInfoTableEntries; |
| 182 | 184 |
| 183 typedef Callback1<const QuotaTableEntries&>::Type DumpQuotaTableCallback; | 185 typedef Callback1<const QuotaTableEntries&>::Type DumpQuotaTableCallback; |
| 184 typedef Callback1<const LastAccessTimeTableEntries&>::Type | 186 typedef Callback1<const OriginInfoTableEntries&>::Type |
| 185 DumpLastAccessTimeTableCallback; | 187 DumpOriginInfoTableCallback; |
| 186 | 188 |
| 187 struct EvictionContext { | 189 struct EvictionContext { |
| 188 EvictionContext() | 190 EvictionContext() |
| 189 : evicted_type(kStorageTypeUnknown), | 191 : evicted_type(kStorageTypeUnknown), |
| 190 num_eviction_requested_clients(0), | 192 num_eviction_requested_clients(0), |
| 191 num_evicted_clients(0), | 193 num_evicted_clients(0), |
| 192 num_eviction_error(0), | 194 num_eviction_error(0), |
| 193 usage(0), | 195 usage(0), |
| 194 unlimited_usage(0), | 196 unlimited_usage(0), |
| 195 quota(0) {} | 197 quota(0) {} |
| (...skipping 12 matching lines...) Expand all Loading... |
| 208 int64 usage; | 210 int64 usage; |
| 209 int64 unlimited_usage; | 211 int64 unlimited_usage; |
| 210 int64 quota; | 212 int64 quota; |
| 211 }; | 213 }; |
| 212 | 214 |
| 213 typedef std::pair<std::string, StorageType> HostAndType; | 215 typedef std::pair<std::string, StorageType> HostAndType; |
| 214 typedef std::map<HostAndType, UsageAndQuotaDispatcherTask*> | 216 typedef std::map<HostAndType, UsageAndQuotaDispatcherTask*> |
| 215 UsageAndQuotaDispatcherTaskMap; | 217 UsageAndQuotaDispatcherTaskMap; |
| 216 | 218 |
| 217 friend struct QuotaManagerDeleter; | 219 friend struct QuotaManagerDeleter; |
| 220 friend class MockStorageClient; |
| 218 friend class QuotaManagerProxy; | 221 friend class QuotaManagerProxy; |
| 219 friend class QuotaManagerTest; | 222 friend class QuotaManagerTest; |
| 220 friend class QuotaTemporaryStorageEvictor; | 223 friend class QuotaTemporaryStorageEvictor; |
| 221 | 224 |
| 222 // This initialization method is lazily called on the IO thread | 225 // This initialization method is lazily called on the IO thread |
| 223 // when the first quota manager API is called. | 226 // when the first quota manager API is called. |
| 224 // Initialize must be called after all quota clients are added to the | 227 // Initialize must be called after all quota clients are added to the |
| 225 // manager by RegisterStorage. | 228 // manager by RegisterStorage. |
| 226 void LazyInitialize(); | 229 void LazyInitialize(); |
| 227 | 230 |
| 228 // Called by clients via proxy. | 231 // Called by clients via proxy. |
| 229 // Registers a quota client to the manager. | 232 // Registers a quota client to the manager. |
| 230 // The client must remain valid until OnQuotaManagerDestored is called. | 233 // The client must remain valid until OnQuotaManagerDestored is called. |
| 231 void RegisterClient(QuotaClient* client); | 234 void RegisterClient(QuotaClient* client); |
| 232 | 235 |
| 233 UsageTracker* GetUsageTracker(StorageType type) const; | 236 UsageTracker* GetUsageTracker(StorageType type) const; |
| 234 | 237 |
| 235 // Extract cached origins list from the usage tracker. | 238 // Extract cached origins list from the usage tracker. |
| 236 // (Might return empty list if no origin is tracked by the tracker.) | 239 // (Might return empty list if no origin is tracked by the tracker.) |
| 237 void GetCachedOrigins(StorageType type, std::set<GURL>* origins); | 240 void GetCachedOrigins(StorageType type, std::set<GURL>* origins); |
| 238 | 241 |
| 239 // This internal method is separately defined mainly for testing. | 242 // These internal methods are separately defined mainly for testing. |
| 240 void NotifyStorageAccessedInternal( | 243 void NotifyStorageAccessedInternal( |
| 241 QuotaClient::ID client_id, | 244 QuotaClient::ID client_id, |
| 242 const GURL& origin, | 245 const GURL& origin, |
| 243 StorageType type, | 246 StorageType type, |
| 244 base::Time accessed_time); | 247 base::Time accessed_time); |
| 248 void NotifyStorageModifiedInternal( |
| 249 QuotaClient::ID client_id, |
| 250 const GURL& origin, |
| 251 StorageType type, |
| 252 int64 delta, |
| 253 base::Time modified_time); |
| 254 |
| 255 void GetOriginsModifiedSince( |
| 256 StorageType type, |
| 257 base::Time modified_since, |
| 258 GetOriginsCallback* callback); |
| 245 | 259 |
| 246 void DumpQuotaTable(DumpQuotaTableCallback* callback); | 260 void DumpQuotaTable(DumpQuotaTableCallback* callback); |
| 247 void DumpLastAccessTimeTable(DumpLastAccessTimeTableCallback* callback); | 261 void DumpOriginInfoTable(DumpOriginInfoTableCallback* callback); |
| 248 | 262 |
| 249 // Methods for eviction logic. | 263 // Methods for eviction logic. |
| 250 void StartEviction(); | 264 void StartEviction(); |
| 251 void DeleteOriginFromDatabase(const GURL& origin, StorageType type); | 265 void DeleteOriginFromDatabase(const GURL& origin, StorageType type); |
| 252 | 266 |
| 253 void DidOriginDataEvicted(QuotaStatusCode status); | 267 void DidOriginDataEvicted(QuotaStatusCode status); |
| 254 void DidGetAvailableSpaceForEviction( | 268 void DidGetAvailableSpaceForEviction( |
| 255 QuotaStatusCode status, | 269 QuotaStatusCode status, |
| 256 int64 available_space); | 270 int64 available_space); |
| 257 void DidGetGlobalQuotaForEviction( | 271 void DidGetGlobalQuotaForEviction( |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 | 368 |
| 355 QuotaManager* manager_; // only accessed on the io thread | 369 QuotaManager* manager_; // only accessed on the io thread |
| 356 scoped_refptr<base::MessageLoopProxy> io_thread_; | 370 scoped_refptr<base::MessageLoopProxy> io_thread_; |
| 357 | 371 |
| 358 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); | 372 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); |
| 359 }; | 373 }; |
| 360 | 374 |
| 361 } // namespace quota | 375 } // namespace quota |
| 362 | 376 |
| 363 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_ | 377 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_ |
| OLD | NEW |