When enabling new profile management programmatically, make sure to set the
[chromium-blink-merge.git] / webkit / browser / fileapi / quota / quota_backend_impl.h
blobec4c45ac18b4eb726f06b175a5c17e7925ec438c
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.
5 #ifndef WEBKIT_BROWSER_FILEAPI_QUOTA_QUOTA_BACKEND_IMPL_H_
6 #define WEBKIT_BROWSER_FILEAPI_QUOTA_QUOTA_BACKEND_IMPL_H_
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"
15 namespace base {
16 class SequencedTaskRunner;
19 namespace content {
20 class QuotaBackendImplTest;
23 namespace quota {
24 class QuotaManagerProxy;
27 namespace fileapi {
29 class FileSystemUsageCache;
30 class ObfuscatedFileUtil;
32 // An instance of this class is owned by QuotaReservationManager.
33 class WEBKIT_STORAGE_BROWSER_EXPORT QuotaBackendImpl
34 : public QuotaReservationManager::QuotaBackend {
35 public:
36 typedef QuotaReservationManager::ReserveQuotaCallback
37 ReserveQuotaCallback;
39 QuotaBackendImpl(base::SequencedTaskRunner* file_task_runner,
40 ObfuscatedFileUtil* obfuscated_file_util,
41 FileSystemUsageCache* file_system_usage_cache,
42 quota::QuotaManagerProxy* quota_manager_proxy);
43 virtual ~QuotaBackendImpl();
45 // QuotaReservationManager::QuotaBackend overrides.
46 virtual void ReserveQuota(
47 const GURL& origin,
48 FileSystemType type,
49 int64 delta,
50 const ReserveQuotaCallback& callback) OVERRIDE;
51 virtual void ReleaseReservedQuota(
52 const GURL& origin,
53 FileSystemType type,
54 int64 size) OVERRIDE;
55 virtual void CommitQuotaUsage(
56 const GURL& origin,
57 FileSystemType type,
58 int64 delta) OVERRIDE;
59 virtual void IncrementDirtyCount(
60 const GURL& origin,
61 FileSystemType type) OVERRIDE;
62 virtual void DecrementDirtyCount(
63 const GURL& origin,
64 FileSystemType type) OVERRIDE;
66 private:
67 friend class content::QuotaBackendImplTest;
69 struct QuotaReservationInfo {
70 QuotaReservationInfo(const GURL& origin, FileSystemType type, int64 delta);
71 ~QuotaReservationInfo();
73 GURL origin;
74 FileSystemType type;
75 int64 delta;
78 void DidGetUsageAndQuotaForReserveQuota(
79 const QuotaReservationInfo& info,
80 const ReserveQuotaCallback& callback,
81 quota::QuotaStatusCode status,
82 int64 usage,
83 int64 quota);
85 void ReserveQuotaInternal(
86 const QuotaReservationInfo& info);
87 base::File::Error GetUsageCachePath(
88 const GURL& origin,
89 FileSystemType type,
90 base::FilePath* usage_file_path);
92 scoped_refptr<base::SequencedTaskRunner> file_task_runner_;
94 // Owned by SandboxFileSystemBackendDelegate.
95 ObfuscatedFileUtil* obfuscated_file_util_;
96 FileSystemUsageCache* file_system_usage_cache_;
98 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_;
100 base::WeakPtrFactory<QuotaBackendImpl> weak_ptr_factory_;
102 DISALLOW_COPY_AND_ASSIGN(QuotaBackendImpl);
105 } // namespace fileapi
107 #endif // WEBKIT_BROWSER_FILEAPI_QUOTA_QUOTA_BACKEND_IMPL_H_