diff options
author | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-16 04:42:01 +0000 |
---|---|---|
committer | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-16 04:42:01 +0000 |
commit | 7e84b912f7ef7e5eb5b6b89342e14031d8c4845c (patch) | |
tree | cdd18c87d167886215d9ae9e840621b83f0a12e1 /webkit/fileapi | |
parent | 8203a05e750a3d2df91690e34eeffddd04b57b54 (diff) | |
download | chromium_src-7e84b912f7ef7e5eb5b6b89342e14031d8c4845c.zip chromium_src-7e84b912f7ef7e5eb5b6b89342e14031d8c4845c.tar.gz chromium_src-7e84b912f7ef7e5eb5b6b89342e14031d8c4845c.tar.bz2 |
Add CreateFileWriter method to MountPointProvider.
In this patch, just adding an interface. Concrete implementations that return
appropriate FileWriter subclass instances are on the way.
BUG=123993
TEST=check it compiles.
Review URL: https://chromiumcodereview.appspot.com/10332164
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137363 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi')
-rw-r--r-- | webkit/fileapi/file_system_mount_point_provider.h | 11 | ||||
-rw-r--r-- | webkit/fileapi/isolated_mount_point_provider.cc | 36 | ||||
-rw-r--r-- | webkit/fileapi/isolated_mount_point_provider.h | 5 | ||||
-rw-r--r-- | webkit/fileapi/sandbox_mount_point_provider.cc | 9 | ||||
-rw-r--r-- | webkit/fileapi/sandbox_mount_point_provider.h | 4 | ||||
-rw-r--r-- | webkit/fileapi/test_mount_point_provider.cc | 9 | ||||
-rw-r--r-- | webkit/fileapi/test_mount_point_provider.h | 4 |
7 files changed, 66 insertions, 12 deletions
diff --git a/webkit/fileapi/file_system_mount_point_provider.h b/webkit/fileapi/file_system_mount_point_provider.h index 55ecbdf..6373f8a 100644 --- a/webkit/fileapi/file_system_mount_point_provider.h +++ b/webkit/fileapi/file_system_mount_point_provider.h @@ -26,6 +26,7 @@ class FileSystemContext; class FileSystemFileUtil; class FileSystemOperationInterface; class FileSystemQuotaUtil; +class FileWriter; class RemoteFileSystemProxyInterface; // An interface to provide mount-point-specific path-related utilities @@ -101,6 +102,16 @@ class FileSystemMountPointProvider { int64 offset, FileSystemContext* context) const = 0; + // Creates a new file writer for a given filesystem URL |url| with a offset + // |offset|. + // The returned object must be owned and managed by the caller. + // This method itself does *not* check if the given path exists and is a + // regular file. + virtual FileWriter* CreateFileWriter( + const GURL& url, + int64 offset, + FileSystemContext* context) const = 0; + // Returns the specialized FileSystemQuotaUtil for this mount point. // This could return NULL if this mount point does not support quota. virtual FileSystemQuotaUtil* GetQuotaUtil() = 0; diff --git a/webkit/fileapi/isolated_mount_point_provider.cc b/webkit/fileapi/isolated_mount_point_provider.cc index 1e6b8b5..f32f28a 100644 --- a/webkit/fileapi/isolated_mount_point_provider.cc +++ b/webkit/fileapi/isolated_mount_point_provider.cc @@ -21,6 +21,7 @@ #include "webkit/fileapi/file_system_util.h" #include "webkit/fileapi/isolated_context.h" #include "webkit/fileapi/isolated_file_util.h" +#include "webkit/fileapi/local_file_writer.h" #include "webkit/fileapi/native_file_util.h" namespace fileapi { @@ -105,21 +106,19 @@ webkit_blob::FileReader* IsolatedMountPointProvider::CreateFileReader( const GURL& url, int64 offset, FileSystemContext* context) const { - GURL origin_url; - FileSystemType file_system_type = kFileSystemTypeUnknown; - FilePath virtual_path; - if (!CrackFileSystemURL(url, &origin_url, &file_system_type, &virtual_path)) - return NULL; - std::string fsid; - FilePath path; - if (!isolated_context()->CrackIsolatedPath(virtual_path, &fsid, NULL, &path)) - return NULL; - if (path.empty()) - return NULL; - return new webkit_blob::LocalFileReader( + FilePath path = GetPathFromURL(url); + return path.empty() ? NULL : new webkit_blob::LocalFileReader( context->file_task_runner(), path, offset, base::Time()); } +FileWriter* IsolatedMountPointProvider::CreateFileWriter( + const GURL& url, + int64 offset, + FileSystemContext* context) const { + FilePath path = GetPathFromURL(url); + return path.empty() ? NULL : new LocalFileWriter(path, offset); +} + FileSystemQuotaUtil* IsolatedMountPointProvider::GetQuotaUtil() { // No quota support. return NULL; @@ -129,4 +128,17 @@ IsolatedContext* IsolatedMountPointProvider::isolated_context() const { return IsolatedContext::GetInstance(); } +FilePath IsolatedMountPointProvider::GetPathFromURL(const GURL& url) const { + GURL origin_url; + FileSystemType file_system_type = kFileSystemTypeUnknown; + FilePath virtual_path; + if (!CrackFileSystemURL(url, &origin_url, &file_system_type, &virtual_path)) + return FilePath(); + std::string fsid; + FilePath path; + if (!isolated_context()->CrackIsolatedPath(virtual_path, &fsid, NULL, &path)) + return FilePath(); + return path; +} + } // namespace fileapi diff --git a/webkit/fileapi/isolated_mount_point_provider.h b/webkit/fileapi/isolated_mount_point_provider.h index f3e3f41..85559d0 100644 --- a/webkit/fileapi/isolated_mount_point_provider.h +++ b/webkit/fileapi/isolated_mount_point_provider.h @@ -50,10 +50,15 @@ class IsolatedMountPointProvider : public FileSystemMountPointProvider { const GURL& url, int64 offset, FileSystemContext* context) const OVERRIDE; + virtual FileWriter* CreateFileWriter( + const GURL& url, + int64 offset, + FileSystemContext* context) const OVERRIDE; virtual FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; private: IsolatedContext* isolated_context() const; + FilePath GetPathFromURL(const GURL& url) const; scoped_ptr<FileSystemFileUtil> isolated_file_util_; }; diff --git a/webkit/fileapi/sandbox_mount_point_provider.cc b/webkit/fileapi/sandbox_mount_point_provider.cc index c4d03c5..74dc0ca 100644 --- a/webkit/fileapi/sandbox_mount_point_provider.cc +++ b/webkit/fileapi/sandbox_mount_point_provider.cc @@ -457,6 +457,15 @@ webkit_blob::FileReader* SandboxMountPointProvider::CreateFileReader( return new FileSystemFileReader(context, url, offset); } +fileapi::FileWriter* SandboxMountPointProvider::CreateFileWriter( + const GURL& url, + int64 offset, + FileSystemContext* context) const { + // TODO(kinaba,kinuko): return SandboxFileWriter when it is implemented. + NOTIMPLEMENTED(); + return NULL; +} + FileSystemQuotaUtil* SandboxMountPointProvider::GetQuotaUtil() { return this; } diff --git a/webkit/fileapi/sandbox_mount_point_provider.h b/webkit/fileapi/sandbox_mount_point_provider.h index 63c386f..b38c48d 100644 --- a/webkit/fileapi/sandbox_mount_point_provider.h +++ b/webkit/fileapi/sandbox_mount_point_provider.h @@ -99,6 +99,10 @@ class SandboxMountPointProvider const GURL& url, int64 offset, FileSystemContext* context) const OVERRIDE; + virtual FileWriter* CreateFileWriter( + const GURL& url, + int64 offset, + FileSystemContext* context) const OVERRIDE; virtual FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; FilePath old_base_path() const; diff --git a/webkit/fileapi/test_mount_point_provider.cc b/webkit/fileapi/test_mount_point_provider.cc index d91c8298..da2b5df 100644 --- a/webkit/fileapi/test_mount_point_provider.cc +++ b/webkit/fileapi/test_mount_point_provider.cc @@ -151,6 +151,15 @@ webkit_blob::FileReader* TestMountPointProvider::CreateFileReader( return new FileSystemFileReader(context, url, offset); } +fileapi::FileWriter* TestMountPointProvider::CreateFileWriter( + const GURL& url, + int64 offset, + FileSystemContext* context) const { + // TODO(kinaba,kinuko): return SandboxFileWriter when it is implemented. + NOTIMPLEMENTED(); + return NULL; +} + FileSystemQuotaUtil* TestMountPointProvider::GetQuotaUtil() { return quota_util_.get(); } diff --git a/webkit/fileapi/test_mount_point_provider.h b/webkit/fileapi/test_mount_point_provider.h index 570f70e..aa739be 100644 --- a/webkit/fileapi/test_mount_point_provider.h +++ b/webkit/fileapi/test_mount_point_provider.h @@ -60,6 +60,10 @@ class TestMountPointProvider : public FileSystemMountPointProvider { const GURL& url, int64 offset, FileSystemContext* context) const OVERRIDE; + virtual FileWriter* CreateFileWriter( + const GURL& url, + int64 offset, + FileSystemContext* context) const OVERRIDE; virtual FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; private: |