diff options
author | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-10 09:03:36 +0000 |
---|---|---|
committer | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-10 09:03:36 +0000 |
commit | 549d087a0d0e0082b3a63c76bf63d557ba006c78 (patch) | |
tree | 6fb6d7a2d8fa6fc4de9db86dea9a34328b6e6f97 /content/renderer/pepper | |
parent | f6bfcf2755f1e3694d56d8cb2235a04d4d242448 (diff) | |
download | chromium_src-549d087a0d0e0082b3a63c76bf63d557ba006c78.zip chromium_src-549d087a0d0e0082b3a63c76bf63d557ba006c78.tar.gz chromium_src-549d087a0d0e0082b3a63c76bf63d557ba006c78.tar.bz2 |
Notify CloseFile from Pepper to FileSystem.
Remote filesystems need to know when a plugin finished
updating a local cache file in order to commit the change.
This CL is to wire the notification of file close between
the two components.
Since writable OpenFile is not yet implemented for remote filesystem,
the CL itself should not cause behavior change.
BUG=132236
TEST=browser_tests --gtest_filter='*FileIO*'
Review URL: https://chromiumcodereview.appspot.com/10541113
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@145856 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer/pepper')
-rw-r--r-- | content/renderer/pepper/pepper_plugin_delegate_impl.cc | 124 | ||||
-rw-r--r-- | content/renderer/pepper/pepper_plugin_delegate_impl.h | 2 |
2 files changed, 71 insertions, 55 deletions
diff --git a/content/renderer/pepper/pepper_plugin_delegate_impl.cc b/content/renderer/pepper/pepper_plugin_delegate_impl.cc index b88a01c..28b5577 100644 --- a/content/renderer/pepper/pepper_plugin_delegate_impl.cc +++ b/content/renderer/pepper/pepper_plugin_delegate_impl.cc @@ -194,6 +194,70 @@ class PluginInstanceLockTarget : public MouseLockDispatcher::LockTarget { webkit::ppapi::PluginInstance* plugin_; }; +class AsyncOpenFileSystemURLCallbackTranslator + : public fileapi::FileSystemCallbackDispatcher { + public: + AsyncOpenFileSystemURLCallbackTranslator( + const webkit::ppapi::PluginDelegate::AsyncOpenFileSystemURLCallback& + callback, + const webkit::ppapi::PluginDelegate::NotifyCloseFileCallback& + close_file_callback) + : callback_(callback), + close_file_callback_(close_file_callback) { + } + + virtual ~AsyncOpenFileSystemURLCallbackTranslator() {} + + virtual void DidSucceed() { + NOTREACHED(); + } + virtual void DidReadMetadata( + const base::PlatformFileInfo& file_info, + const FilePath& platform_path) { + NOTREACHED(); + } + virtual void DidReadDirectory( + const std::vector<base::FileUtilProxy::Entry>& entries, + bool has_more) { + NOTREACHED(); + } + virtual void DidOpenFileSystem(const std::string& name, + const GURL& root) { + NOTREACHED(); + } + + virtual void DidFail(base::PlatformFileError error_code) { + base::PlatformFile invalid_file = base::kInvalidPlatformFileValue; + callback_.Run(error_code, + base::PassPlatformFile(&invalid_file), + webkit::ppapi::PluginDelegate::NotifyCloseFileCallback()); + } + + virtual void DidWrite(int64 bytes, bool complete) { + NOTREACHED(); + } + + virtual void DidOpenFile(base::PlatformFile file) { + callback_.Run(base::PLATFORM_FILE_OK, + base::PassPlatformFile(&file), + close_file_callback_); + // Make sure we won't leak file handle if the requester has died. + if (file != base::kInvalidPlatformFileValue) { + base::FileUtilProxy::Close( + RenderThreadImpl::current()->GetFileThreadMessageLoopProxy(), file, + close_file_callback_); + } + } + + private: + webkit::ppapi::PluginDelegate::AsyncOpenFileSystemURLCallback callback_; + webkit::ppapi::PluginDelegate::NotifyCloseFileCallback close_file_callback_; +}; + +void DoNotifyCloseFile(const GURL& path, base::PlatformFileError /* unused */) { + ChildThread::current()->file_system_dispatcher()->NotifyCloseFile(path); +} + } // namespace PepperPluginDelegateImpl::PepperPluginDelegateImpl(RenderViewImpl* render_view) @@ -859,65 +923,17 @@ void PepperPluginDelegateImpl::DidUpdateFile(const GURL& path, int64_t delta) { ChildThread::current()->Send(new FileSystemHostMsg_DidUpdate(path, delta)); } -class AsyncOpenFileSystemURLCallbackTranslator - : public fileapi::FileSystemCallbackDispatcher { - public: - AsyncOpenFileSystemURLCallbackTranslator( - const webkit::ppapi::PluginDelegate::AsyncOpenFileCallback& callback) - : callback_(callback) { - } - - virtual ~AsyncOpenFileSystemURLCallbackTranslator() {} - - virtual void DidSucceed() { - NOTREACHED(); - } - virtual void DidReadMetadata( - const base::PlatformFileInfo& file_info, - const FilePath& platform_path) { - NOTREACHED(); - } - virtual void DidReadDirectory( - const std::vector<base::FileUtilProxy::Entry>& entries, - bool has_more) { - NOTREACHED(); - } - virtual void DidOpenFileSystem(const std::string& name, - const GURL& root) { - NOTREACHED(); - } - - virtual void DidFail(base::PlatformFileError error_code) { - base::PlatformFile invalid_file = base::kInvalidPlatformFileValue; - callback_.Run(error_code, base::PassPlatformFile(&invalid_file)); - } - - virtual void DidWrite(int64 bytes, bool complete) { - NOTREACHED(); - } - - virtual void DidOpenFile( - base::PlatformFile file) { - callback_.Run(base::PLATFORM_FILE_OK, base::PassPlatformFile(&file)); - // Make sure we won't leak file handle if the requester has died. - if (file != base::kInvalidPlatformFileValue) { - base::FileUtilProxy::Close( - RenderThreadImpl::current()->GetFileThreadMessageLoopProxy(), file, - base::FileUtilProxy::StatusCallback()); - } - } - -private: // TODO(ericu): Delete this? - webkit::ppapi::PluginDelegate::AsyncOpenFileCallback callback_; -}; - bool PepperPluginDelegateImpl::AsyncOpenFileSystemURL( - const GURL& path, int flags, const AsyncOpenFileCallback& callback) { + const GURL& path, + int flags, + const AsyncOpenFileSystemURLCallback& callback) { FileSystemDispatcher* file_system_dispatcher = ChildThread::current()->file_system_dispatcher(); return file_system_dispatcher->OpenFile(path, flags, - new AsyncOpenFileSystemURLCallbackTranslator(callback)); + new AsyncOpenFileSystemURLCallbackTranslator( + callback, + base::Bind(&DoNotifyCloseFile, path))); } base::PlatformFileError PepperPluginDelegateImpl::OpenFile( diff --git a/content/renderer/pepper/pepper_plugin_delegate_impl.h b/content/renderer/pepper/pepper_plugin_delegate_impl.h index ded09ca..7194943 100644 --- a/content/renderer/pepper/pepper_plugin_delegate_impl.h +++ b/content/renderer/pepper/pepper_plugin_delegate_impl.h @@ -219,7 +219,7 @@ class PepperPluginDelegateImpl virtual bool AsyncOpenFileSystemURL( const GURL& path, int flags, - const AsyncOpenFileCallback& callback) OVERRIDE; + const AsyncOpenFileSystemURLCallback& callback) OVERRIDE; virtual bool OpenFileSystem( const GURL& url, fileapi::FileSystemType type, |