diff options
Diffstat (limited to 'chromium/webkit/browser/fileapi/file_system_context.h')
-rw-r--r-- | chromium/webkit/browser/fileapi/file_system_context.h | 74 |
1 files changed, 57 insertions, 17 deletions
diff --git a/chromium/webkit/browser/fileapi/file_system_context.h b/chromium/webkit/browser/fileapi/file_system_context.h index 2ceb96fb1aa..428ef601149 100644 --- a/chromium/webkit/browser/fileapi/file_system_context.h +++ b/chromium/webkit/browser/fileapi/file_system_context.h @@ -10,10 +10,10 @@ #include <vector> #include "base/callback.h" +#include "base/files/file.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" -#include "base/platform_file.h" #include "base/sequenced_task_runner_helpers.h" #include "webkit/browser/fileapi/file_system_url.h" #include "webkit/browser/fileapi/open_file_system_mode.h" @@ -38,6 +38,10 @@ class QuotaManagerProxy; class SpecialStoragePolicy; } +namespace net { +class URLRequest; +} + namespace webkit_blob { class BlobURLRequestJobTest; class FileStreamReader; @@ -65,6 +69,18 @@ class SandboxFileSystemBackend; struct DefaultContextDeleter; struct FileSystemInfo; +// An auto mount handler will attempt to mount the file system requested in +// |url_request|. If the URL is for this auto mount handler, it returns true +// and calls |callback| when the attempt is complete. If the auto mounter +// does not recognize the URL, it returns false and does not call |callback|. +// Called on the IO thread. +typedef base::Callback<bool( + const net::URLRequest* url_request, + const FileSystemURL& filesystem_url, + const std::string& storage_domain, + const base::Callback<void(base::File::Error result)>& callback)> + URLRequestAutoMountHandler; + // This class keeps and provides a file system context for FileSystem API. // An instance of this class is created and owned by profile. class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext @@ -95,6 +111,10 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext // to serve filesystem requests for non-regular types. // If none is given, this context only handles HTML5 Sandbox FileSystem // and Drag-and-drop Isolated FileSystem requests. + // + // |auto_mount_handlers| are used to resolve calls to + // AttemptAutoMountForURLRequest. Only external filesystems are auto mounted + // when a filesystem: URL request is made. FileSystemContext( base::SingleThreadTaskRunner* io_task_runner, base::SequencedTaskRunner* file_task_runner, @@ -102,12 +122,11 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext quota::SpecialStoragePolicy* special_storage_policy, quota::QuotaManagerProxy* quota_manager_proxy, ScopedVector<FileSystemBackend> additional_backends, + const std::vector<URLRequestAutoMountHandler>& auto_mount_handlers, const base::FilePath& partition_path, const FileSystemOptions& options); - // TODO(nhiroki): Rename *OnFileThread methods since these are no longer on - // FILE thread. - bool DeleteDataForOriginOnFileThread(const GURL& origin_url); + bool DeleteDataForOriginOnFileTaskRunner(const GURL& origin_url); // Creates a new QuotaReservation for the given |origin_url| and |type|. // Returns NULL if |type| does not support quota or reservation fails. @@ -133,10 +152,10 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext AsyncFileUtil* GetAsyncFileUtil(FileSystemType type) const; // Returns the appropriate CopyOrMoveFileValidatorFactory for the given - // |type|. If |error_code| is PLATFORM_FILE_OK and the result is NULL, + // |type|. If |error_code| is File::FILE_OK and the result is NULL, // then no validator is required. CopyOrMoveFileValidatorFactory* GetCopyOrMoveFileValidatorFactory( - FileSystemType type, base::PlatformFileError* error_code) const; + FileSystemType type, base::File::Error* error_code) const; // Returns the file system backend instance for the given |type|. // This may return NULL if it is given an invalid or unsupported filesystem @@ -165,17 +184,22 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext // Used for OpenFileSystem. typedef base::Callback<void(const GURL& root, const std::string& name, - base::PlatformFileError result)> + base::File::Error result)> OpenFileSystemCallback; // Used for ResolveURL. - typedef base::Callback<void(base::PlatformFileError result, + enum ResolvedEntryType { + RESOLVED_ENTRY_FILE, + RESOLVED_ENTRY_DIRECTORY, + RESOLVED_ENTRY_NOT_FOUND, + }; + typedef base::Callback<void(base::File::Error result, const FileSystemInfo& info, const base::FilePath& file_path, - bool is_directory)> ResolveURLCallback; + ResolvedEntryType type)> ResolveURLCallback; // Used for DeleteFileSystem and OpenPluginPrivateFileSystem. - typedef base::Callback<void(base::PlatformFileError result)> StatusCallback; + typedef base::Callback<void(base::File::Error result)> StatusCallback; // Opens the filesystem for the given |origin_url| and |type|, and dispatches // |callback| on completion. @@ -188,13 +212,23 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext OpenFileSystemMode mode, const OpenFileSystemCallback& callback); - // Opens the filesystem for the given |url| as read-only, and then checks the - // existence of the file entry referred by the URL. This should be called on - // the IO thread. + // Opens the filesystem for the given |url| as read-only, if the filesystem + // backend referred by the URL allows opening by resolveURL. Otherwise it + // fails with FILE_ERROR_SECURITY. The entry pointed by the URL can be + // absent; in that case RESOLVED_ENTRY_NOT_FOUND type is returned to the + // callback for indicating the absence. Can be called from any thread with + // a message loop. |callback| is invoked on the caller thread. void ResolveURL( const FileSystemURL& url, const ResolveURLCallback& callback); + // Attempts to mount the filesystem needed to satisfy |url_request| made + // from |storage_domain|. If an appropriate file system is not found, + // callback will return an error. + void AttemptAutoMountForURLRequest(const net::URLRequest* url_request, + const std::string& storage_domain, + const StatusCallback& callback); + // Deletes the filesystem for the given |origin_url| and |type|. This should // be called on the IO thread. void DeleteFileSystem( @@ -257,6 +291,10 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext // (E.g. this returns false if the context is created for incognito mode) bool CanServeURLRequest(const FileSystemURL& url) const; + // Returns true if a file in the file system should be flushed for each write + // completion. + bool ShouldFlushOnWriteCompletion(FileSystemType type) const; + // This must be used to open 'plugin private' filesystem. // See "plugin_private_file_system_backend.h" for more details. void OpenPluginPrivateFileSystem( @@ -275,10 +313,10 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext friend class FileSystemOperationRunner; // For sandbox_backend(). - friend class SandboxFileSystemTestHelper; + friend class content::SandboxFileSystemTestHelper; // For plugin_private_backend(). - friend class PluginPrivateFileSystemBackendTest; + friend class content::PluginPrivateFileSystemBackendTest; // Deleters. friend struct DefaultContextDeleter; @@ -298,7 +336,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext // Called by FileSystemOperationRunner. FileSystemOperation* CreateFileSystemOperation( const FileSystemURL& url, - base::PlatformFileError* error_code); + base::File::Error* error_code); // For non-cracked isolated and external mount points, returns a FileSystemURL // created by cracking |url|. The url is cracked using MountPoints registered @@ -318,7 +356,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext const ResolveURLCallback& callback, const GURL& filesystem_root, const std::string& filesystem_name, - base::PlatformFileError error); + base::File::Error error); // Returns a FileSystemBackend, used only by test code. SandboxFileSystemBackend* sandbox_backend() const { @@ -345,6 +383,8 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext scoped_ptr<PluginPrivateFileSystemBackend> plugin_private_backend_; ScopedVector<FileSystemBackend> additional_backends_; + std::vector<URLRequestAutoMountHandler> auto_mount_handlers_; + // Registered file system backends. // The map must be constructed in the constructor since it can be accessed // on multiple threads. |