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