diff options
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/chromeos/fileapi/cros_mount_point_provider.cc | 9 | ||||
-rw-r--r-- | webkit/chromeos/fileapi/cros_mount_point_provider.h | 23 | ||||
-rw-r--r-- | webkit/fileapi/file_system_context.cc | 47 | ||||
-rw-r--r-- | webkit/fileapi/file_system_context.h | 14 | ||||
-rw-r--r-- | webkit/fileapi/file_system_mount_point_provider.h | 9 | ||||
-rw-r--r-- | webkit/fileapi/file_system_quota_client.cc | 10 | ||||
-rw-r--r-- | webkit/fileapi/isolated_mount_point_provider.cc | 9 | ||||
-rw-r--r-- | webkit/fileapi/isolated_mount_point_provider.h | 21 | ||||
-rw-r--r-- | webkit/fileapi/sandbox_mount_point_provider.cc | 36 | ||||
-rw-r--r-- | webkit/fileapi/sandbox_mount_point_provider.h | 11 | ||||
-rw-r--r-- | webkit/fileapi/test_mount_point_provider.cc | 11 | ||||
-rw-r--r-- | webkit/fileapi/test_mount_point_provider.h | 21 |
12 files changed, 157 insertions, 64 deletions
diff --git a/webkit/chromeos/fileapi/cros_mount_point_provider.cc b/webkit/chromeos/fileapi/cros_mount_point_provider.cc index 4b834a9..f30b5ce 100644 --- a/webkit/chromeos/fileapi/cros_mount_point_provider.cc +++ b/webkit/chromeos/fileapi/cros_mount_point_provider.cc @@ -138,6 +138,15 @@ fileapi::FileSystemQuotaUtil* CrosMountPointProvider::GetQuotaUtil() { return NULL; } +void CrosMountPointProvider::DeleteFileSystem( + const GURL& origin_url, + fileapi::FileSystemType type, + fileapi::FileSystemContext* context, + const DeleteFileSystemCallback& callback) { + NOTREACHED(); + callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); +} + bool CrosMountPointProvider::HasMountPoint(const FilePath& mount_point) { base::AutoLock locker(mount_point_map_lock_); MountPointMap::const_iterator iter = mount_point_map_.find( diff --git a/webkit/chromeos/fileapi/cros_mount_point_provider.h b/webkit/chromeos/fileapi/cros_mount_point_provider.h index a904e85..a7c410b 100644 --- a/webkit/chromeos/fileapi/cros_mount_point_provider.h +++ b/webkit/chromeos/fileapi/cros_mount_point_provider.h @@ -28,6 +28,9 @@ class FileAccessPermissions; class CrosMountPointProvider : public fileapi::ExternalFileSystemMountPointProvider { public: + using fileapi::FileSystemMountPointProvider::ValidateFileSystemCallback; + using fileapi::FileSystemMountPointProvider::DeleteFileSystemCallback; + // Mount point file system location enum. enum FileSystemLocation { // File system that is locally mounted by the underlying OS. @@ -36,9 +39,6 @@ class CrosMountPointProvider REMOTE, }; - typedef fileapi::FileSystemMountPointProvider::ValidateFileSystemCallback - ValidateFileSystemCallback; - CrosMountPointProvider( scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy); virtual ~CrosMountPointProvider(); @@ -67,14 +67,19 @@ class CrosMountPointProvider const fileapi::FileSystemURL& url, fileapi::FileSystemContext* context) const OVERRIDE; virtual webkit_blob::FileStreamReader* CreateFileStreamReader( - const fileapi::FileSystemURL& path, - int64 offset, - fileapi::FileSystemContext* context) const OVERRIDE; + const fileapi::FileSystemURL& path, + int64 offset, + fileapi::FileSystemContext* context) const OVERRIDE; virtual fileapi::FileStreamWriter* CreateFileStreamWriter( - const fileapi::FileSystemURL& url, - int64 offset, - fileapi::FileSystemContext* context) const OVERRIDE; + const fileapi::FileSystemURL& url, + int64 offset, + fileapi::FileSystemContext* context) const OVERRIDE; virtual fileapi::FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; + virtual void DeleteFileSystem( + const GURL& origin_url, + fileapi::FileSystemType type, + fileapi::FileSystemContext* context, + const DeleteFileSystemCallback& callback) OVERRIDE; // fileapi::ExternalFileSystemMountPointProvider overrides. virtual std::vector<FilePath> GetRootDirectories() const OVERRIDE; diff --git a/webkit/fileapi/file_system_context.cc b/webkit/fileapi/file_system_context.cc index 53afbb1..3e3679e 100644 --- a/webkit/fileapi/file_system_context.cc +++ b/webkit/fileapi/file_system_context.cc @@ -36,10 +36,11 @@ QuotaClient* CreateQuotaClient( return new FileSystemQuotaClient(context, is_incognito); } -void DidOpenFileSystem(FileSystemContext::OpenFileSystemCallback callback, - const GURL& filesystem_root, - const std::string& filesystem_name, - base::PlatformFileError error) { +void DidOpenFileSystem( + const FileSystemContext::OpenFileSystemCallback& callback, + const GURL& filesystem_root, + const std::string& filesystem_name, + base::PlatformFileError error) { callback.Run(error, filesystem_name, filesystem_root); } @@ -78,22 +79,12 @@ bool FileSystemContext::DeleteDataForOriginOnFileThread( // Delete temporary and persistent data. return - sandbox_provider()->DeleteOriginDataOnFileThread( - this, quota_manager_proxy(), origin_url, kFileSystemTypeTemporary) && - sandbox_provider()->DeleteOriginDataOnFileThread( - this, quota_manager_proxy(), origin_url, kFileSystemTypePersistent); -} - -bool FileSystemContext::DeleteDataForOriginAndTypeOnFileThread( - const GURL& origin_url, FileSystemType type) { - DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); - if (type == fileapi::kFileSystemTypeTemporary || - type == fileapi::kFileSystemTypePersistent) { - DCHECK(sandbox_provider()); - return sandbox_provider()->DeleteOriginDataOnFileThread( - this, quota_manager_proxy(), origin_url, type); - } - return false; + (sandbox_provider()->DeleteOriginDataOnFileThread( + this, quota_manager_proxy(), origin_url, kFileSystemTypeTemporary) == + base::PLATFORM_FILE_OK) && + (sandbox_provider()->DeleteOriginDataOnFileThread( + this, quota_manager_proxy(), origin_url, kFileSystemTypePersistent) == + base::PLATFORM_FILE_OK); } FileSystemQuotaUtil* @@ -151,7 +142,7 @@ void FileSystemContext::OpenFileSystem( const GURL& origin_url, FileSystemType type, bool create, - OpenFileSystemCallback callback) { + const OpenFileSystemCallback& callback) { DCHECK(!callback.is_null()); FileSystemMountPointProvider* mount_point_provider = @@ -169,6 +160,20 @@ void FileSystemContext::OpenFileSystem( base::Bind(&DidOpenFileSystem, callback, root_url, name)); } +void FileSystemContext::DeleteFileSystem( + const GURL& origin_url, + FileSystemType type, + const DeleteFileSystemCallback& callback) { + FileSystemMountPointProvider* mount_point_provider = + GetMountPointProvider(type); + if (!mount_point_provider) { + callback.Run(base::PLATFORM_FILE_ERROR_SECURITY); + return; + } + + mount_point_provider->DeleteFileSystem(origin_url, type, this, callback); +} + FileSystemOperationInterface* FileSystemContext::CreateFileSystemOperation( const FileSystemURL& url) { if (!url.is_valid()) diff --git a/webkit/fileapi/file_system_context.h b/webkit/fileapi/file_system_context.h index 12906a9..232cb00 100644 --- a/webkit/fileapi/file_system_context.h +++ b/webkit/fileapi/file_system_context.h @@ -66,8 +66,6 @@ class FILEAPI_EXPORT FileSystemContext const FileSystemOptions& options); bool DeleteDataForOriginOnFileThread(const GURL& origin_url); - bool DeleteDataForOriginAndTypeOnFileThread(const GURL& origin_url, - FileSystemType type); quota::QuotaManagerProxy* quota_manager_proxy() const { return quota_manager_proxy_.get(); @@ -108,6 +106,10 @@ class FILEAPI_EXPORT FileSystemContext const std::string& name, const GURL& root)> OpenFileSystemCallback; + // Used for DeleteFileSystem. + typedef base::Callback<void(base::PlatformFileError result)> + DeleteFileSystemCallback; + // Opens the filesystem for the given |origin_url| and |type|, and dispatches // the DidOpenFileSystem callback of the given |dispatcher|. // If |create| is true this may actually set up a filesystem instance @@ -117,7 +119,13 @@ class FILEAPI_EXPORT FileSystemContext const GURL& origin_url, FileSystemType type, bool create, - OpenFileSystemCallback callback); + const OpenFileSystemCallback& callback); + + // Deletes the filesystem for the given |origin_url| and |type|. + void DeleteFileSystem( + const GURL& origin_url, + FileSystemType type, + const DeleteFileSystemCallback& callback); // Creates a new FileSystemOperation instance by cracking // the given filesystem URL |url| to get an appropriate MountPointProvider diff --git a/webkit/fileapi/file_system_mount_point_provider.h b/webkit/fileapi/file_system_mount_point_provider.h index b3309bc..fbc7b58 100644 --- a/webkit/fileapi/file_system_mount_point_provider.h +++ b/webkit/fileapi/file_system_mount_point_provider.h @@ -35,6 +35,8 @@ class FILEAPI_EXPORT FileSystemMountPointProvider { // Callback for ValidateFileSystemRoot. typedef base::Callback<void(base::PlatformFileError error)> ValidateFileSystemCallback; + typedef base::Callback<void(base::PlatformFileError error)> + DeleteFileSystemCallback; virtual ~FileSystemMountPointProvider() {} // Validates the filesystem for the given |origin_url| and |type|. @@ -107,6 +109,13 @@ class FILEAPI_EXPORT FileSystemMountPointProvider { // Returns the specialized FileSystemQuotaUtil for this mount point. // This could return NULL if this mount point does not support quota. virtual FileSystemQuotaUtil* GetQuotaUtil() = 0; + + // Deletes the filesystem for the given |origin_url| and |type|. + virtual void DeleteFileSystem( + const GURL& origin_url, + FileSystemType type, + FileSystemContext* context, + const DeleteFileSystemCallback& callback) = 0; }; // An interface to control external file system access permissions. diff --git a/webkit/fileapi/file_system_quota_client.cc b/webkit/fileapi/file_system_quota_client.cc index 9619ecc..9812ae0 100644 --- a/webkit/fileapi/file_system_quota_client.cc +++ b/webkit/fileapi/file_system_quota_client.cc @@ -18,6 +18,7 @@ #include "webkit/fileapi/file_system_quota_util.h" #include "webkit/fileapi/file_system_usage_cache.h" #include "webkit/fileapi/file_system_util.h" +#include "webkit/fileapi/sandbox_mount_point_provider.h" using base::SequencedTaskRunner; using quota::QuotaThreadTask; @@ -152,8 +153,13 @@ class FileSystemQuotaClient::DeleteOriginTask // QuotaThreadTask: virtual void RunOnTargetThread() OVERRIDE { - if (file_system_context_->DeleteDataForOriginAndTypeOnFileThread( - origin_, type_)) + base::PlatformFileError result = + file_system_context_->sandbox_provider()->DeleteOriginDataOnFileThread( + file_system_context_, + file_system_context_->quota_manager_proxy(), + origin_, + type_); + if (result == base::PLATFORM_FILE_OK) status_ = quota::kQuotaStatusOk; else status_ = quota::kQuotaErrorInvalidModification; diff --git a/webkit/fileapi/isolated_mount_point_provider.cc b/webkit/fileapi/isolated_mount_point_provider.cc index 7e66106..bca05fa 100644 --- a/webkit/fileapi/isolated_mount_point_provider.cc +++ b/webkit/fileapi/isolated_mount_point_provider.cc @@ -139,4 +139,13 @@ FileSystemQuotaUtil* IsolatedMountPointProvider::GetQuotaUtil() { return NULL; } +void IsolatedMountPointProvider::DeleteFileSystem( + const GURL& origin_url, + FileSystemType type, + FileSystemContext* context, + const DeleteFileSystemCallback& callback) { + NOTREACHED(); + callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); +} + } // namespace fileapi diff --git a/webkit/fileapi/isolated_mount_point_provider.h b/webkit/fileapi/isolated_mount_point_provider.h index 0bd5182..f6340dc 100644 --- a/webkit/fileapi/isolated_mount_point_provider.h +++ b/webkit/fileapi/isolated_mount_point_provider.h @@ -20,8 +20,8 @@ class NativeMediaFileUtil; class IsolatedMountPointProvider : public FileSystemMountPointProvider { public: - typedef FileSystemMountPointProvider::ValidateFileSystemCallback - ValidateFileSystemCallback; + using FileSystemMountPointProvider::ValidateFileSystemCallback; + using FileSystemMountPointProvider::DeleteFileSystemCallback; IsolatedMountPointProvider(); virtual ~IsolatedMountPointProvider(); @@ -48,14 +48,19 @@ class IsolatedMountPointProvider : public FileSystemMountPointProvider { const FileSystemURL& url, FileSystemContext* context) const OVERRIDE; virtual webkit_blob::FileStreamReader* CreateFileStreamReader( - const FileSystemURL& url, - int64 offset, - FileSystemContext* context) const OVERRIDE; + const FileSystemURL& url, + int64 offset, + FileSystemContext* context) const OVERRIDE; virtual FileStreamWriter* CreateFileStreamWriter( - const FileSystemURL& url, - int64 offset, - FileSystemContext* context) const OVERRIDE; + const FileSystemURL& url, + int64 offset, + FileSystemContext* context) const OVERRIDE; virtual FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; + virtual void DeleteFileSystem( + const GURL& origin_url, + FileSystemType type, + FileSystemContext* context, + const DeleteFileSystemCallback& callback) OVERRIDE; private: scoped_ptr<MediaPathFilter> media_path_filter_; diff --git a/webkit/fileapi/sandbox_mount_point_provider.cc b/webkit/fileapi/sandbox_mount_point_provider.cc index 30f6a97..b08927a 100644 --- a/webkit/fileapi/sandbox_mount_point_provider.cc +++ b/webkit/fileapi/sandbox_mount_point_provider.cc @@ -13,6 +13,7 @@ #include "base/sequenced_task_runner.h" #include "base/string_util.h" #include "base/stringprintf.h" +#include "base/task_runner_util.h" #include "googleurl/src/gurl.h" #include "net/base/net_util.h" #include "webkit/fileapi/file_system_file_stream_reader.h" @@ -268,16 +269,9 @@ void MigrateIfNeeded( MigrateAllOldFileSystems(file_util, old_base_path); } -void PassPointerErrorByValue( - const base::Callback<void(PlatformFileError)>& callback, - PlatformFileError* error_ptr) { - DCHECK(error_ptr); - callback.Run(*error_ptr); -} - void DidValidateFileSystemRoot( base::WeakPtr<SandboxMountPointProvider> mount_point_provider, - const base::Callback<void(PlatformFileError)>& callback, + const FileSystemMountPointProvider::ValidateFileSystemCallback& callback, base::PlatformFileError* error) { if (mount_point_provider.get()) mount_point_provider.get()->CollectOpenFileSystemMetrics(*error); @@ -459,6 +453,24 @@ FileSystemQuotaUtil* SandboxMountPointProvider::GetQuotaUtil() { return this; } +void SandboxMountPointProvider::DeleteFileSystem( + const GURL& origin_url, + FileSystemType type, + FileSystemContext* context, + const DeleteFileSystemCallback& callback) { + base::PostTaskAndReplyWithResult( + context->file_task_runner(), + FROM_HERE, + // It is safe to pass Unretained(this) since context owns it. + base::Bind(&SandboxMountPointProvider::DeleteOriginDataOnFileThread, + base::Unretained(this), + make_scoped_refptr(context), + base::Unretained(context->quota_manager_proxy()), + origin_url, + type), + callback); +} + FilePath SandboxMountPointProvider::old_base_path() const { return profile_path_.Append(kOldFileSystemDirectory); } @@ -490,7 +502,8 @@ FilePath SandboxMountPointProvider::GetBaseDirectoryForOriginAndType( return path; } -bool SandboxMountPointProvider::DeleteOriginDataOnFileThread( +base::PlatformFileError +SandboxMountPointProvider::DeleteOriginDataOnFileThread( FileSystemContext* file_system_context, QuotaManagerProxy* proxy, const GURL& origin_url, @@ -509,7 +522,10 @@ bool SandboxMountPointProvider::DeleteOriginDataOnFileThread( FileSystemTypeToQuotaStorageType(type), -usage); } - return result; + + if (result) + return base::PLATFORM_FILE_OK; + return base::PLATFORM_FILE_ERROR_FAILED; } void SandboxMountPointProvider::GetOriginsForTypeOnFileThread( diff --git a/webkit/fileapi/sandbox_mount_point_provider.h b/webkit/fileapi/sandbox_mount_point_provider.h index 5921bb5..2d97a7e 100644 --- a/webkit/fileapi/sandbox_mount_point_provider.h +++ b/webkit/fileapi/sandbox_mount_point_provider.h @@ -41,8 +41,8 @@ class FILEAPI_EXPORT SandboxMountPointProvider : public FileSystemMountPointProvider, public FileSystemQuotaUtil { public: - typedef FileSystemMountPointProvider::ValidateFileSystemCallback - ValidateFileSystemCallback; + using FileSystemMountPointProvider::ValidateFileSystemCallback; + using FileSystemMountPointProvider::DeleteFileSystemCallback; // Origin enumerator interface. // An instance of this interface is assumed to be called on the file thread. @@ -104,6 +104,11 @@ class FILEAPI_EXPORT SandboxMountPointProvider int64 offset, FileSystemContext* context) const OVERRIDE; virtual FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; + virtual void DeleteFileSystem( + const GURL& origin_url, + FileSystemType type, + FileSystemContext* context, + const DeleteFileSystemCallback& callback) OVERRIDE; FilePath old_base_path() const; FilePath new_base_path() const; @@ -126,7 +131,7 @@ class FILEAPI_EXPORT SandboxMountPointProvider // Deletes the data on the origin and reports the amount of deleted data // to the quota manager via |proxy|. - bool DeleteOriginDataOnFileThread( + base::PlatformFileError DeleteOriginDataOnFileThread( FileSystemContext* context, quota::QuotaManagerProxy* proxy, const GURL& origin_url, diff --git a/webkit/fileapi/test_mount_point_provider.cc b/webkit/fileapi/test_mount_point_provider.cc index c1e76d3..fd0023e 100644 --- a/webkit/fileapi/test_mount_point_provider.cc +++ b/webkit/fileapi/test_mount_point_provider.cc @@ -160,4 +160,15 @@ FileSystemQuotaUtil* TestMountPointProvider::GetQuotaUtil() { return quota_util_.get(); } +void TestMountPointProvider::DeleteFileSystem( + const GURL& origin_url, + FileSystemType type, + FileSystemContext* context, + const DeleteFileSystemCallback& callback) { + // This won't be called unless we add test code that opens a test + // filesystem by OpenFileSystem. + NOTREACHED(); + callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); +} + } // namespace fileapi diff --git a/webkit/fileapi/test_mount_point_provider.h b/webkit/fileapi/test_mount_point_provider.h index 8181333..5716368 100644 --- a/webkit/fileapi/test_mount_point_provider.h +++ b/webkit/fileapi/test_mount_point_provider.h @@ -26,8 +26,8 @@ class FileSystemQuotaUtil; class FILEAPI_EXPORT_PRIVATE TestMountPointProvider : public FileSystemMountPointProvider { public: - typedef FileSystemMountPointProvider::ValidateFileSystemCallback - ValidateFileSystemCallback; + using FileSystemMountPointProvider::ValidateFileSystemCallback; + using FileSystemMountPointProvider::DeleteFileSystemCallback; TestMountPointProvider( base::SequencedTaskRunner* task_runner, @@ -56,14 +56,19 @@ class FILEAPI_EXPORT_PRIVATE TestMountPointProvider const FileSystemURL& url, FileSystemContext* context) const OVERRIDE; virtual webkit_blob::FileStreamReader* CreateFileStreamReader( - const FileSystemURL& url, - int64 offset, - FileSystemContext* context) const OVERRIDE; + const FileSystemURL& url, + int64 offset, + FileSystemContext* context) const OVERRIDE; virtual FileStreamWriter* CreateFileStreamWriter( - const FileSystemURL& url, - int64 offset, - FileSystemContext* context) const OVERRIDE; + const FileSystemURL& url, + int64 offset, + FileSystemContext* context) const OVERRIDE; virtual FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE; + virtual void DeleteFileSystem( + const GURL& origin_url, + FileSystemType type, + FileSystemContext* context, + const DeleteFileSystemCallback& callback) OVERRIDE; private: FilePath base_path_; |