[email protected] | e7e4673 | 2012-01-05 11:45:55 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 073a04f | 2011-03-24 00:49:40 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | f19bbf6 | 2013-07-09 01:22:32 | [diff] [blame] | 5 | #ifndef WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_H_ |
| 6 | #define WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_H_ |
[email protected] | 073a04f | 2011-03-24 00:49:40 | [diff] [blame] | 7 | |
[email protected] | 5caeb20 | 2011-05-17 07:42:07 | [diff] [blame] | 8 | #include <set> |
[email protected] | 073a04f | 2011-03-24 00:49:40 | [diff] [blame] | 9 | #include <string> |
[email protected] | 073a04f | 2011-03-24 00:49:40 | [diff] [blame] | 10 | |
[email protected] | b7d38af7 | 2012-05-23 02:51:09 | [diff] [blame] | 11 | #include "base/compiler_specific.h" |
[email protected] | 5799981 | 2013-02-24 05:40:52 | [diff] [blame] | 12 | #include "base/files/file_path.h" |
[email protected] | b7d38af7 | 2012-05-23 02:51:09 | [diff] [blame] | 13 | #include "base/memory/ref_counted.h" |
[email protected] | 3cfc10f | 2012-05-24 01:20:41 | [diff] [blame] | 14 | #include "base/memory/scoped_ptr.h" |
[email protected] | f19bbf6 | 2013-07-09 01:22:32 | [diff] [blame] | 15 | #include "webkit/browser/fileapi/file_system_backend.h" |
[email protected] | 20c2df6 | 2013-05-21 08:26:36 | [diff] [blame] | 16 | #include "webkit/browser/fileapi/file_system_quota_util.h" |
[email protected] | 639772f | 2013-08-15 05:55:37 | [diff] [blame] | 17 | #include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h" |
[email protected] | f25e113 | 2013-05-24 13:58:04 | [diff] [blame] | 18 | #include "webkit/browser/fileapi/task_runner_bound_observer_list.h" |
[email protected] | 7660ec9 | 2013-05-30 05:12:39 | [diff] [blame] | 19 | #include "webkit/browser/quota/special_storage_policy.h" |
[email protected] | e5bf2fd | 2013-06-13 02:59:18 | [diff] [blame] | 20 | #include "webkit/browser/webkit_storage_browser_export.h" |
[email protected] | 073a04f | 2011-03-24 00:49:40 | [diff] [blame] | 21 | |
[email protected] | 073a04f | 2011-03-24 00:49:40 | [diff] [blame] | 22 | namespace fileapi { |
| 23 | |
[email protected] | 4f9b143 | 2011-12-20 11:10:16 | [diff] [blame] | 24 | // An interface to construct or crack sandboxed filesystem paths for |
| 25 | // TEMPORARY or PERSISTENT filesystems, which are placed under the user's |
| 26 | // profile directory in a sandboxed way. |
| 27 | // This interface also lets one enumerate and remove storage for the origins |
| 28 | // that use the filesystem. |
[email protected] | f19bbf6 | 2013-07-09 01:22:32 | [diff] [blame] | 29 | class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackend |
[email protected] | 18141c32 | 2013-08-22 10:33:04 | [diff] [blame] | 30 | : public FileSystemBackend { |
[email protected] | 073a04f | 2011-03-24 00:49:40 | [diff] [blame] | 31 | public: |
[email protected] | 639772f | 2013-08-15 05:55:37 | [diff] [blame] | 32 | explicit SandboxFileSystemBackend(SandboxFileSystemBackendDelegate* delegate); |
[email protected] | f19bbf6 | 2013-07-09 01:22:32 | [diff] [blame] | 33 | virtual ~SandboxFileSystemBackend(); |
[email protected] | 3c48b53 | 2011-12-20 12:42:44 | [diff] [blame] | 34 | |
[email protected] | f19bbf6 | 2013-07-09 01:22:32 | [diff] [blame] | 35 | // FileSystemBackend overrides. |
[email protected] | 420fb56 | 2013-04-18 01:46:34 | [diff] [blame] | 36 | virtual bool CanHandleType(FileSystemType type) const OVERRIDE; |
[email protected] | 3fc17aed | 2013-07-24 10:01:50 | [diff] [blame] | 37 | virtual void Initialize(FileSystemContext* context) OVERRIDE; |
| 38 | virtual void OpenFileSystem( |
[email protected] | 60f60f8 | 2012-01-11 10:26:10 | [diff] [blame] | 39 | const GURL& origin_url, |
| 40 | FileSystemType type, |
[email protected] | 22dea52c | 2013-05-29 07:44:40 | [diff] [blame] | 41 | OpenFileSystemMode mode, |
[email protected] | 3fc17aed | 2013-07-24 10:01:50 | [diff] [blame] | 42 | const OpenFileSystemCallback& callback) OVERRIDE; |
[email protected] | 25b69799 | 2013-01-29 07:10:05 | [diff] [blame] | 43 | virtual AsyncFileUtil* GetAsyncFileUtil(FileSystemType type) OVERRIDE; |
[email protected] | 98407ee | 2013-04-04 08:52:17 | [diff] [blame] | 44 | virtual CopyOrMoveFileValidatorFactory* GetCopyOrMoveFileValidatorFactory( |
| 45 | FileSystemType type, |
[email protected] | 141bcc5 | 2014-01-27 21:36:00 | [diff] [blame^] | 46 | base::File::Error* error_code) OVERRIDE; |
[email protected] | 8e3bc3e | 2012-08-24 13:12:53 | [diff] [blame] | 47 | virtual FileSystemOperation* CreateFileSystemOperation( |
[email protected] | 949f25a | 2012-06-27 01:53:09 | [diff] [blame] | 48 | const FileSystemURL& url, |
[email protected] | d23a00cc | 2012-09-11 17:38:13 | [diff] [blame] | 49 | FileSystemContext* context, |
[email protected] | 141bcc5 | 2014-01-27 21:36:00 | [diff] [blame^] | 50 | base::File::Error* error_code) const OVERRIDE; |
[email protected] | 3ee9eb0 | 2013-04-10 09:17:05 | [diff] [blame] | 51 | virtual scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader( |
[email protected] | 949f25a | 2012-06-27 01:53:09 | [diff] [blame] | 52 | const FileSystemURL& url, |
| 53 | int64 offset, |
[email protected] | a105783 | 2012-10-15 13:28:06 | [diff] [blame] | 54 | const base::Time& expected_modification_time, |
[email protected] | 949f25a | 2012-06-27 01:53:09 | [diff] [blame] | 55 | FileSystemContext* context) const OVERRIDE; |
[email protected] | 3ee9eb0 | 2013-04-10 09:17:05 | [diff] [blame] | 56 | virtual scoped_ptr<FileStreamWriter> CreateFileStreamWriter( |
[email protected] | 949f25a | 2012-06-27 01:53:09 | [diff] [blame] | 57 | const FileSystemURL& url, |
| 58 | int64 offset, |
| 59 | FileSystemContext* context) const OVERRIDE; |
[email protected] | 6faad82 | 2012-05-11 12:58:29 | [diff] [blame] | 60 | virtual FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; |
[email protected] | 3c48b53 | 2011-12-20 12:42:44 | [diff] [blame] | 61 | |
[email protected] | f19bbf6 | 2013-07-09 01:22:32 | [diff] [blame] | 62 | // Returns an origin enumerator of this backend. |
[email protected] | 054702d | 2011-05-28 01:12:18 | [diff] [blame] | 63 | // This method can only be called on the file thread. |
[email protected] | 639772f | 2013-08-15 05:55:37 | [diff] [blame] | 64 | SandboxFileSystemBackendDelegate::OriginEnumerator* CreateOriginEnumerator(); |
[email protected] | 073a04f | 2011-03-24 00:49:40 | [diff] [blame] | 65 | |
[email protected] | 9cf2d7c7 | 2013-04-24 13:54:13 | [diff] [blame] | 66 | void set_enable_temporary_file_system_in_incognito(bool enable) { |
| 67 | enable_temporary_file_system_in_incognito_ = enable; |
| 68 | } |
[email protected] | 190dbb5c | 2013-09-06 10:19:24 | [diff] [blame] | 69 | bool enable_temporary_file_system_in_incognito() const { |
| 70 | return enable_temporary_file_system_in_incognito_; |
| 71 | } |
| 72 | |
[email protected] | 9cf2d7c7 | 2013-04-24 13:54:13 | [diff] [blame] | 73 | |
[email protected] | 073a04f | 2011-03-24 00:49:40 | [diff] [blame] | 74 | private: |
[email protected] | 639772f | 2013-08-15 05:55:37 | [diff] [blame] | 75 | SandboxFileSystemBackendDelegate* delegate_; // Not owned. |
[email protected] | 073a04f | 2011-03-24 00:49:40 | [diff] [blame] | 76 | |
[email protected] | 9cf2d7c7 | 2013-04-24 13:54:13 | [diff] [blame] | 77 | bool enable_temporary_file_system_in_incognito_; |
[email protected] | e7e4673 | 2012-01-05 11:45:55 | [diff] [blame] | 78 | |
[email protected] | f19bbf6 | 2013-07-09 01:22:32 | [diff] [blame] | 79 | DISALLOW_COPY_AND_ASSIGN(SandboxFileSystemBackend); |
[email protected] | 073a04f | 2011-03-24 00:49:40 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | } // namespace fileapi |
| 83 | |
[email protected] | f19bbf6 | 2013-07-09 01:22:32 | [diff] [blame] | 84 | #endif // WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_H_ |