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