| 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_FILEAPI_FILE_SYSTEM_CONTEXT_H_ | 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_CONTEXT_H_ |
| 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_CONTEXT_H_ | 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_CONTEXT_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | |
| 9 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
| 12 #include "webkit/fileapi/file_system_types.h" | 11 #include "webkit/fileapi/file_system_types.h" |
| 13 #include "webkit/quota/special_storage_policy.h" | 12 #include "webkit/quota/special_storage_policy.h" |
| 14 | 13 |
| 15 class FilePath; | 14 class FilePath; |
| 16 class GURL; | 15 class GURL; |
| 17 | 16 |
| 18 namespace base { | 17 namespace base { |
| 19 class MessageLoopProxy; | 18 class MessageLoopProxy; |
| 20 } | 19 } |
| 21 | 20 |
| 22 namespace quota { | 21 namespace quota { |
| 23 class QuotaManagerProxy; | 22 class QuotaManagerProxy; |
| 24 } | 23 } |
| 25 | 24 |
| 26 namespace fileapi { | 25 namespace fileapi { |
| 27 | 26 |
| 28 class ExternalFileSystemMountPointProvider; | 27 class ExternalFileSystemMountPointProvider; |
| 28 class FileSystemCallbackDispatcher; |
| 29 class FileSystemContext; |
| 29 class FileSystemFileUtil; | 30 class FileSystemFileUtil; |
| 30 class FileSystemMountPointProvider; | 31 class FileSystemMountPointProvider; |
| 31 class FileSystemOperationInterface; | 32 class FileSystemOperationInterface; |
| 32 class FileSystemOptions; | 33 class FileSystemOptions; |
| 33 class FileSystemPathManager; | 34 class FileSystemPathManager; |
| 34 class FileSystemQuotaUtil; | 35 class FileSystemQuotaUtil; |
| 35 class SandboxMountPointProvider; | 36 class SandboxMountPointProvider; |
| 36 | 37 |
| 37 struct DefaultContextDeleter; | 38 struct DefaultContextDeleter; |
| 38 | 39 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // Returns a FileSystemMountPointProvider instance for sandboxed filesystem | 80 // Returns a FileSystemMountPointProvider instance for sandboxed filesystem |
| 80 // types (e.g. TEMPORARY or PERSISTENT). This is equivalent to calling | 81 // types (e.g. TEMPORARY or PERSISTENT). This is equivalent to calling |
| 81 // GetMountPointProvider(kFileSystemType{Temporary, Persistent}). | 82 // GetMountPointProvider(kFileSystemType{Temporary, Persistent}). |
| 82 SandboxMountPointProvider* sandbox_provider() const; | 83 SandboxMountPointProvider* sandbox_provider() const; |
| 83 | 84 |
| 84 // Returns a FileSystemMountPointProvider instance for external filesystem | 85 // Returns a FileSystemMountPointProvider instance for external filesystem |
| 85 // type, which is used only by chromeos for now. This is equivalent to | 86 // type, which is used only by chromeos for now. This is equivalent to |
| 86 // calling GetMountPointProvider(kFileSystemTypeExternal). | 87 // calling GetMountPointProvider(kFileSystemTypeExternal). |
| 87 ExternalFileSystemMountPointProvider* external_provider() const; | 88 ExternalFileSystemMountPointProvider* external_provider() const; |
| 88 | 89 |
| 89 // Used for OpenFileSystem. | |
| 90 typedef base::Callback<void(base::PlatformFileError result, | |
| 91 const std::string& name, | |
| 92 const GURL& root)> OpenFileSystemCallback; | |
| 93 | |
| 94 // Opens the filesystem for the given |origin_url| and |type|, and dispatches | 90 // Opens the filesystem for the given |origin_url| and |type|, and dispatches |
| 95 // the DidOpenFileSystem callback of the given |dispatcher|. | 91 // the DidOpenFileSystem callback of the given |dispatcher|. |
| 96 // If |create| is true this may actually set up a filesystem instance | 92 // If |create| is true this may actually set up a filesystem instance |
| 97 // (e.g. by creating the root directory or initializing the database | 93 // (e.g. by creating the root directory or initializing the database |
| 98 // entry etc). | 94 // entry etc). |
| 95 // TODO(kinuko): replace the dispatcher with a regular callback. |
| 99 void OpenFileSystem( | 96 void OpenFileSystem( |
| 100 const GURL& origin_url, | 97 const GURL& origin_url, |
| 101 FileSystemType type, | 98 FileSystemType type, |
| 102 bool create, | 99 bool create, |
| 103 OpenFileSystemCallback callback); | 100 scoped_ptr<FileSystemCallbackDispatcher> dispatcher); |
| 104 | 101 |
| 105 // Creates a new FileSystemOperation instance by cracking | 102 // Creates a new FileSystemOperation instance by cracking |
| 106 // the given filesystem URL |url| to get an appropriate MountPointProvider | 103 // the given filesystem URL |url| to get an appropriate MountPointProvider |
| 107 // and calling the provider's corresponding CreateFileSystemOperation method. | 104 // and calling the provider's corresponding CreateFileSystemOperation method. |
| 108 // The resolved MountPointProvider could perform further specialization | 105 // The resolved MountPointProvider could perform further specialization |
| 109 // depending on the filesystem type pointed by the |url|. | 106 // depending on the filesystem type pointed by the |url|. |
| 110 FileSystemOperationInterface* CreateFileSystemOperation( | 107 FileSystemOperationInterface* CreateFileSystemOperation( |
| 111 const GURL& url, | 108 const GURL& url, |
| 109 scoped_ptr<FileSystemCallbackDispatcher> dispatcher, |
| 112 base::MessageLoopProxy* file_proxy); | 110 base::MessageLoopProxy* file_proxy); |
| 113 | 111 |
| 114 private: | 112 private: |
| 115 friend struct DefaultContextDeleter; | 113 friend struct DefaultContextDeleter; |
| 116 void DeleteOnCorrectThread() const; | 114 void DeleteOnCorrectThread() const; |
| 117 | 115 |
| 118 scoped_refptr<base::MessageLoopProxy> file_message_loop_; | 116 scoped_refptr<base::MessageLoopProxy> file_message_loop_; |
| 119 scoped_refptr<base::MessageLoopProxy> io_message_loop_; | 117 scoped_refptr<base::MessageLoopProxy> io_message_loop_; |
| 120 | 118 |
| 121 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; | 119 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; |
| 122 | 120 |
| 123 // Mount point providers. | 121 // Mount point providers. |
| 124 scoped_ptr<SandboxMountPointProvider> sandbox_provider_; | 122 scoped_ptr<SandboxMountPointProvider> sandbox_provider_; |
| 125 scoped_ptr<ExternalFileSystemMountPointProvider> external_provider_; | 123 scoped_ptr<ExternalFileSystemMountPointProvider> external_provider_; |
| 126 | 124 |
| 127 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemContext); | 125 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemContext); |
| 128 }; | 126 }; |
| 129 | 127 |
| 130 struct DefaultContextDeleter { | 128 struct DefaultContextDeleter { |
| 131 static void Destruct(const FileSystemContext* context) { | 129 static void Destruct(const FileSystemContext* context) { |
| 132 context->DeleteOnCorrectThread(); | 130 context->DeleteOnCorrectThread(); |
| 133 } | 131 } |
| 134 }; | 132 }; |
| 135 | 133 |
| 136 } // namespace fileapi | 134 } // namespace fileapi |
| 137 | 135 |
| 138 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_CONTEXT_H_ | 136 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_CONTEXT_H_ |
| OLD | NEW |