OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SANDBOX_FILE_SYSTEM_BACKEND_H_ | 5 #ifndef WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_H_ |
6 #define WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_H_ | 6 #define WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "webkit/browser/fileapi/file_system_backend.h" | 15 #include "webkit/browser/fileapi/file_system_backend.h" |
16 #include "webkit/browser/fileapi/file_system_quota_util.h" | 16 #include "webkit/browser/fileapi/file_system_quota_util.h" |
17 #include "webkit/browser/fileapi/sandbox_context.h" | 17 #include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h" |
18 #include "webkit/browser/fileapi/task_runner_bound_observer_list.h" | 18 #include "webkit/browser/fileapi/task_runner_bound_observer_list.h" |
19 #include "webkit/browser/quota/special_storage_policy.h" | 19 #include "webkit/browser/quota/special_storage_policy.h" |
20 #include "webkit/browser/webkit_storage_browser_export.h" | 20 #include "webkit/browser/webkit_storage_browser_export.h" |
21 | 21 |
22 namespace fileapi { | 22 namespace fileapi { |
23 | 23 |
24 // An interface to construct or crack sandboxed filesystem paths for | 24 // An interface to construct or crack sandboxed filesystem paths for |
25 // TEMPORARY or PERSISTENT filesystems, which are placed under the user's | 25 // TEMPORARY or PERSISTENT filesystems, which are placed under the user's |
26 // profile directory in a sandboxed way. | 26 // profile directory in a sandboxed way. |
27 // This interface also lets one enumerate and remove storage for the origins | 27 // This interface also lets one enumerate and remove storage for the origins |
28 // that use the filesystem. | 28 // that use the filesystem. |
29 class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackend | 29 class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackend |
30 : public FileSystemBackend, | 30 : public FileSystemBackend, |
31 public FileSystemQuotaUtil { | 31 public FileSystemQuotaUtil { |
32 public: | 32 public: |
33 explicit SandboxFileSystemBackend(SandboxContext* sandbox_context); | 33 explicit SandboxFileSystemBackend(SandboxFileSystemBackendDelegate* delegate); |
34 virtual ~SandboxFileSystemBackend(); | 34 virtual ~SandboxFileSystemBackend(); |
35 | 35 |
36 // FileSystemBackend overrides. | 36 // FileSystemBackend overrides. |
37 virtual bool CanHandleType(FileSystemType type) const OVERRIDE; | 37 virtual bool CanHandleType(FileSystemType type) const OVERRIDE; |
38 virtual void Initialize(FileSystemContext* context) OVERRIDE; | 38 virtual void Initialize(FileSystemContext* context) OVERRIDE; |
39 virtual void OpenFileSystem( | 39 virtual void OpenFileSystem( |
40 const GURL& origin_url, | 40 const GURL& origin_url, |
41 FileSystemType type, | 41 FileSystemType type, |
42 OpenFileSystemMode mode, | 42 OpenFileSystemMode mode, |
43 const OpenFileSystemCallback& callback) OVERRIDE; | 43 const OpenFileSystemCallback& callback) OVERRIDE; |
(...skipping 12 matching lines...) Expand all Loading... |
56 const base::Time& expected_modification_time, | 56 const base::Time& expected_modification_time, |
57 FileSystemContext* context) const OVERRIDE; | 57 FileSystemContext* context) const OVERRIDE; |
58 virtual scoped_ptr<FileStreamWriter> CreateFileStreamWriter( | 58 virtual scoped_ptr<FileStreamWriter> CreateFileStreamWriter( |
59 const FileSystemURL& url, | 59 const FileSystemURL& url, |
60 int64 offset, | 60 int64 offset, |
61 FileSystemContext* context) const OVERRIDE; | 61 FileSystemContext* context) const OVERRIDE; |
62 virtual FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; | 62 virtual FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; |
63 | 63 |
64 // Returns an origin enumerator of this backend. | 64 // Returns an origin enumerator of this backend. |
65 // This method can only be called on the file thread. | 65 // This method can only be called on the file thread. |
66 SandboxContext::OriginEnumerator* CreateOriginEnumerator(); | 66 SandboxFileSystemBackendDelegate::OriginEnumerator* CreateOriginEnumerator(); |
67 | 67 |
68 // FileSystemQuotaUtil overrides. | 68 // FileSystemQuotaUtil overrides. |
69 virtual base::PlatformFileError DeleteOriginDataOnFileThread( | 69 virtual base::PlatformFileError DeleteOriginDataOnFileThread( |
70 FileSystemContext* context, | 70 FileSystemContext* context, |
71 quota::QuotaManagerProxy* proxy, | 71 quota::QuotaManagerProxy* proxy, |
72 const GURL& origin_url, | 72 const GURL& origin_url, |
73 FileSystemType type) OVERRIDE; | 73 FileSystemType type) OVERRIDE; |
74 virtual void GetOriginsForTypeOnFileThread( | 74 virtual void GetOriginsForTypeOnFileThread( |
75 FileSystemType type, | 75 FileSystemType type, |
76 std::set<GURL>* origins) OVERRIDE; | 76 std::set<GURL>* origins) OVERRIDE; |
(...skipping 22 matching lines...) Expand all Loading... |
99 virtual const ChangeObserverList* GetChangeObservers( | 99 virtual const ChangeObserverList* GetChangeObservers( |
100 FileSystemType type) const OVERRIDE; | 100 FileSystemType type) const OVERRIDE; |
101 virtual const AccessObserverList* GetAccessObservers( | 101 virtual const AccessObserverList* GetAccessObservers( |
102 FileSystemType type) const OVERRIDE; | 102 FileSystemType type) const OVERRIDE; |
103 | 103 |
104 void set_enable_temporary_file_system_in_incognito(bool enable) { | 104 void set_enable_temporary_file_system_in_incognito(bool enable) { |
105 enable_temporary_file_system_in_incognito_ = enable; | 105 enable_temporary_file_system_in_incognito_ = enable; |
106 } | 106 } |
107 | 107 |
108 private: | 108 private: |
109 SandboxContext* sandbox_context_; // Not owned. | 109 SandboxFileSystemBackendDelegate* delegate_; // Not owned. |
110 | 110 |
111 bool enable_temporary_file_system_in_incognito_; | 111 bool enable_temporary_file_system_in_incognito_; |
112 | 112 |
113 // Observers. | 113 // Observers. |
114 UpdateObserverList update_observers_; | 114 UpdateObserverList update_observers_; |
115 ChangeObserverList change_observers_; | 115 ChangeObserverList change_observers_; |
116 AccessObserverList access_observers_; | 116 AccessObserverList access_observers_; |
117 | 117 |
118 DISALLOW_COPY_AND_ASSIGN(SandboxFileSystemBackend); | 118 DISALLOW_COPY_AND_ASSIGN(SandboxFileSystemBackend); |
119 }; | 119 }; |
120 | 120 |
121 } // namespace fileapi | 121 } // namespace fileapi |
122 | 122 |
123 #endif // WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_H_ | 123 #endif // WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_H_ |
OLD | NEW |