| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef WEBKIT_BROWSER_FILEAPI_QUOTA_QUOTA_BACKEND_IMPL_H_ |
| 6 #define WEBKIT_BROWSER_FILEAPI_QUOTA_QUOTA_BACKEND_IMPL_H_ |
| 7 |
| 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/weak_ptr.h" |
| 10 #include "webkit/browser/fileapi/quota/quota_reservation_manager.h" |
| 11 #include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h" |
| 12 #include "webkit/browser/webkit_storage_browser_export.h" |
| 13 #include "webkit/common/quota/quota_status_code.h" |
| 14 |
| 15 namespace base { |
| 16 class SequencedTaskRunner; |
| 17 } |
| 18 |
| 19 namespace quota { |
| 20 class QuotaManagerProxy; |
| 21 } |
| 22 |
| 23 namespace fileapi { |
| 24 |
| 25 class FileSystemUsageCache; |
| 26 class ObfuscatedFileUtil; |
| 27 |
| 28 // An instance of this class is owned by QuotaReservationManager. |
| 29 class WEBKIT_STORAGE_BROWSER_EXPORT QuotaBackendImpl |
| 30 : public QuotaReservationManager::QuotaBackend { |
| 31 public: |
| 32 typedef QuotaReservationManager::ReserveQuotaCallback |
| 33 ReserveQuotaCallback; |
| 34 |
| 35 QuotaBackendImpl(base::SequencedTaskRunner* file_task_runner, |
| 36 ObfuscatedFileUtil* obfuscated_file_util, |
| 37 FileSystemUsageCache* file_system_usage_cache, |
| 38 quota::QuotaManagerProxy* quota_manager_proxy); |
| 39 virtual ~QuotaBackendImpl(); |
| 40 |
| 41 // QuotaReservationManager::QuotaBackend overrides. |
| 42 virtual void ReserveQuota( |
| 43 const GURL& origin, |
| 44 FileSystemType type, |
| 45 int64 delta, |
| 46 const ReserveQuotaCallback& callback) OVERRIDE; |
| 47 virtual void ReleaseReservedQuota( |
| 48 const GURL& origin, |
| 49 FileSystemType type, |
| 50 int64 size) OVERRIDE; |
| 51 virtual void CommitQuotaUsage( |
| 52 const GURL& origin, |
| 53 FileSystemType type, |
| 54 int64 delta) OVERRIDE; |
| 55 virtual void IncrementDirtyCount( |
| 56 const GURL& origin, |
| 57 FileSystemType type) OVERRIDE; |
| 58 virtual void DecrementDirtyCount( |
| 59 const GURL& origin, |
| 60 FileSystemType type) OVERRIDE; |
| 61 |
| 62 private: |
| 63 friend class QuotaBackendImplTest; |
| 64 |
| 65 struct QuotaReservationInfo { |
| 66 QuotaReservationInfo(const GURL& origin, FileSystemType type, int64 delta); |
| 67 ~QuotaReservationInfo(); |
| 68 |
| 69 GURL origin; |
| 70 FileSystemType type; |
| 71 int64 delta; |
| 72 }; |
| 73 |
| 74 void DidGetUsageAndQuotaForReserveQuota( |
| 75 const QuotaReservationInfo& info, |
| 76 const ReserveQuotaCallback& callback, |
| 77 quota::QuotaStatusCode status, |
| 78 int64 usage, |
| 79 int64 quota); |
| 80 |
| 81 void ReserveQuotaInternal( |
| 82 const QuotaReservationInfo& info); |
| 83 base::PlatformFileError GetUsageCachePath( |
| 84 const GURL& origin, |
| 85 FileSystemType type, |
| 86 base::FilePath* usage_file_path); |
| 87 |
| 88 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; |
| 89 |
| 90 // Owned by SandboxFileSystemBackendDelegate. |
| 91 ObfuscatedFileUtil* obfuscated_file_util_; |
| 92 FileSystemUsageCache* file_system_usage_cache_; |
| 93 |
| 94 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; |
| 95 |
| 96 base::WeakPtrFactory<QuotaBackendImpl> weak_ptr_factory_; |
| 97 |
| 98 DISALLOW_COPY_AND_ASSIGN(QuotaBackendImpl); |
| 99 }; |
| 100 |
| 101 } // namespace fileapi |
| 102 |
| 103 #endif // WEBKIT_BROWSER_FILEAPI_QUOTA_QUOTA_BACKEND_IMPL_H_ |
| OLD | NEW |