diff options
author | nhiroki@chromium.org <nhiroki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-25 08:30:08 +0000 |
---|---|---|
committer | nhiroki@chromium.org <nhiroki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-25 08:30:08 +0000 |
commit | 2aa1e26455e858bf1e855e0c919dd7f9b2a68bad (patch) | |
tree | 8f71b2b7c56cc63aaf58a85754fe63f0221b6df8 /webkit/plugins | |
parent | efc2238f9cbdcf4ddc363ebf5b4cba68b8c41a15 (diff) | |
download | chromium_src-2aa1e26455e858bf1e855e0c919dd7f9b2a68bad.zip chromium_src-2aa1e26455e858bf1e855e0c919dd7f9b2a68bad.tar.gz chromium_src-2aa1e26455e858bf1e855e0c919dd7f9b2a68bad.tar.bz2 |
Current implementation of ppapi::FileIO.SetLength fails on Mac due to sandbox restrictions.
This patch fixes the failure only for temporary/persistent filesystem since fixing for external filesystem needs more extensive modifications.
BUG=156077
TEST=browser_tests --gtest_filter=\*SetLength\*
Review URL: https://chromiumcodereview.appspot.com/11238029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@164030 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins')
-rw-r--r-- | webkit/plugins/ppapi/mock_plugin_delegate.cc | 7 | ||||
-rw-r--r-- | webkit/plugins/ppapi/mock_plugin_delegate.h | 3 | ||||
-rw-r--r-- | webkit/plugins/ppapi/plugin_delegate.h | 3 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_file_io_impl.cc | 65 |
4 files changed, 73 insertions, 5 deletions
diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.cc b/webkit/plugins/ppapi/mock_plugin_delegate.cc index a7f4551..95d5940 100644 --- a/webkit/plugins/ppapi/mock_plugin_delegate.cc +++ b/webkit/plugins/ppapi/mock_plugin_delegate.cc @@ -176,6 +176,13 @@ bool MockPluginDelegate::Touch( return false; } +bool MockPluginDelegate::SetLength( + const GURL& path, + int64_t length, + fileapi::FileSystemCallbackDispatcher* dispatcher) { + return false; +} + bool MockPluginDelegate::Delete( const GURL& path, fileapi::FileSystemCallbackDispatcher* dispatcher) { diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.h b/webkit/plugins/ppapi/mock_plugin_delegate.h index ed5b857..b7f17f0 100644 --- a/webkit/plugins/ppapi/mock_plugin_delegate.h +++ b/webkit/plugins/ppapi/mock_plugin_delegate.h @@ -84,6 +84,9 @@ class MockPluginDelegate : public PluginDelegate { const base::Time& last_access_time, const base::Time& last_modified_time, fileapi::FileSystemCallbackDispatcher* dispatcher); + virtual bool SetLength(const GURL& path, + int64_t length, + fileapi::FileSystemCallbackDispatcher* dispatcher); virtual bool Delete(const GURL& path, fileapi::FileSystemCallbackDispatcher* dispatcher); virtual bool Rename(const GURL& file_path, diff --git a/webkit/plugins/ppapi/plugin_delegate.h b/webkit/plugins/ppapi/plugin_delegate.h index e65beca..e623edc 100644 --- a/webkit/plugins/ppapi/plugin_delegate.h +++ b/webkit/plugins/ppapi/plugin_delegate.h @@ -457,6 +457,9 @@ class PluginDelegate { const base::Time& last_access_time, const base::Time& last_modified_time, fileapi::FileSystemCallbackDispatcher* dispatcher) = 0; + virtual bool SetLength(const GURL& path, + int64_t length, + fileapi::FileSystemCallbackDispatcher* dispatcher) = 0; virtual bool Delete(const GURL& path, fileapi::FileSystemCallbackDispatcher* dispatcher) = 0; virtual bool Rename(const GURL& file_path, diff --git a/webkit/plugins/ppapi/ppb_file_io_impl.cc b/webkit/plugins/ppapi/ppb_file_io_impl.cc index fd4d38d..2c33b2f 100644 --- a/webkit/plugins/ppapi/ppb_file_io_impl.cc +++ b/webkit/plugins/ppapi/ppb_file_io_impl.cc @@ -39,6 +39,58 @@ using ppapi::thunk::PPB_FileRef_API; namespace webkit { namespace ppapi { +namespace { + +typedef base::Callback<void (base::PlatformFileError)> PlatformGeneralCallback; + +class PlatformGeneralCallbackTranslator + : public fileapi::FileSystemCallbackDispatcher { + public: + PlatformGeneralCallbackTranslator( + const PlatformGeneralCallback& callback) + : callback_(callback) {} + + virtual ~PlatformGeneralCallbackTranslator() {} + + virtual void DidSucceed() OVERRIDE { + callback_.Run(base::PLATFORM_FILE_OK); + } + + virtual void DidReadMetadata( + const base::PlatformFileInfo& file_info, + const FilePath& platform_path) OVERRIDE { + NOTREACHED(); + } + + virtual void DidReadDirectory( + const std::vector<base::FileUtilProxy::Entry>& entries, + bool has_more) OVERRIDE { + NOTREACHED(); + } + + virtual void DidOpenFileSystem(const std::string& name, + const GURL& root) OVERRIDE { + NOTREACHED(); + } + + virtual void DidFail(base::PlatformFileError error_code) OVERRIDE { + callback_.Run(error_code); + } + + virtual void DidWrite(int64 bytes, bool complete) OVERRIDE { + NOTREACHED(); + } + + virtual void DidOpenFile(base::PlatformFile file) OVERRIDE { + NOTREACHED(); + } + + private: + PlatformGeneralCallback callback_; +}; + +} // namespace + PPB_FileIO_Impl::PPB_FileIO_Impl(PP_Instance instance) : ::ppapi::PPB_FileIO_Shared(instance), file_(base::kInvalidPlatformFileValue), @@ -190,13 +242,16 @@ int32_t PPB_FileIO_Impl::SetLengthValidated( if (!plugin_delegate) return PP_ERROR_FAILED; - if (quota_file_io_.get()) { - if (!quota_file_io_->SetLength( - length, - base::Bind(&PPB_FileIO_Impl::ExecutePlatformGeneralCallback, - weak_factory_.GetWeakPtr()))) + if (file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL) { + if (!plugin_delegate->SetLength( + file_system_url_, length, + new PlatformGeneralCallbackTranslator( + base::Bind(&PPB_FileIO_Impl::ExecutePlatformGeneralCallback, + weak_factory_.GetWeakPtr())))) return PP_ERROR_FAILED; } else { + // TODO(nhiroki): fix a failure of FileIO.SetLength for an external + // filesystem on Mac due to sandbox restrictions (http://crbug.com/156077). if (!base::FileUtilProxy::Truncate( plugin_delegate->GetFileThreadMessageLoopProxy(), file_, length, base::Bind(&PPB_FileIO_Impl::ExecutePlatformGeneralCallback, |