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 3 // found in the LICENSE file. 4 5 #ifndef WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_H_ 6 #define WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_H_ 7 8 #include <set> 9 #include <string> 10 11 #include "base/compiler_specific.h" 12 #include "base/files/file_path.h" 13 #include "base/memory/ref_counted.h" 14 #include "base/memory/scoped_ptr.h" 15 #include "webkit/browser/fileapi/file_system_backend.h" 16 #include "webkit/browser/fileapi/file_system_quota_util.h" 17 #include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h" 18 #include "webkit/browser/fileapi/task_runner_bound_observer_list.h" 19 #include "webkit/browser/quota/special_storage_policy.h" 20 #include "webkit/browser/webkit_storage_browser_export.h" 21 22 namespace fileapi { 23 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. 29 class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackend 30 : public FileSystemBackend { 31 public: 32 explicit SandboxFileSystemBackend(SandboxFileSystemBackendDelegate* delegate); 33 virtual ~SandboxFileSystemBackend(); 34 35 // FileSystemBackend overrides. 36 virtual bool CanHandleType(FileSystemType type) const OVERRIDE; 37 virtual void Initialize(FileSystemContext* context) OVERRIDE; 38 virtual void OpenFileSystem( 39 const GURL& origin_url, 40 FileSystemType type, 41 OpenFileSystemMode mode, 42 const OpenFileSystemCallback& callback) OVERRIDE; 43 virtual AsyncFileUtil* GetAsyncFileUtil(FileSystemType type) OVERRIDE; 44 virtual CopyOrMoveFileValidatorFactory* GetCopyOrMoveFileValidatorFactory( 45 FileSystemType type, 46 base::PlatformFileError* error_code) OVERRIDE; 47 virtual FileSystemOperation* CreateFileSystemOperation( 48 const FileSystemURL& url, 49 FileSystemContext* context, 50 base::PlatformFileError* error_code) const OVERRIDE; 51 virtual scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader( 52 const FileSystemURL& url, 53 int64 offset, 54 const base::Time& expected_modification_time, 55 FileSystemContext* context) const OVERRIDE; 56 virtual scoped_ptr<FileStreamWriter> CreateFileStreamWriter( 57 const FileSystemURL& url, 58 int64 offset, 59 FileSystemContext* context) const OVERRIDE; 60 virtual FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; 61 62 // Returns an origin enumerator of this backend. 63 // This method can only be called on the file thread. 64 SandboxFileSystemBackendDelegate::OriginEnumerator* CreateOriginEnumerator(); 65 set_enable_temporary_file_system_in_incognito(bool enable)66 void set_enable_temporary_file_system_in_incognito(bool enable) { 67 enable_temporary_file_system_in_incognito_ = enable; 68 } enable_temporary_file_system_in_incognito()69 bool enable_temporary_file_system_in_incognito() const { 70 return enable_temporary_file_system_in_incognito_; 71 } 72 73 74 private: 75 SandboxFileSystemBackendDelegate* delegate_; // Not owned. 76 77 bool enable_temporary_file_system_in_incognito_; 78 79 DISALLOW_COPY_AND_ASSIGN(SandboxFileSystemBackend); 80 }; 81 82 } // namespace fileapi 83 84 #endif // WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_H_ 85