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 /webkit | |
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 'webkit')
-rw-r--r-- | webkit/chromeos/fileapi/remote_file_system_operation.cc | 9 | ||||
-rw-r--r-- | webkit/chromeos/fileapi/remote_file_system_operation.h | 1 | ||||
-rw-r--r-- | webkit/chromeos/fileapi/remote_file_system_proxy.h | 4 | ||||
-rw-r--r-- | webkit/fileapi/file_system_operation.cc | 6 | ||||
-rw-r--r-- | webkit/fileapi/file_system_operation.h | 1 | ||||
-rw-r--r-- | webkit/fileapi/file_system_operation_interface.h | 8 | ||||
-rw-r--r-- | webkit/plugins/ppapi/mock_plugin_delegate.cc | 4 | ||||
-rw-r--r-- | webkit/plugins/ppapi/mock_plugin_delegate.h | 7 | ||||
-rw-r--r-- | webkit/plugins/ppapi/plugin_delegate.h | 17 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_file_io_impl.cc | 20 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_file_io_impl.h | 7 |
11 files changed, 74 insertions, 10 deletions
diff --git a/webkit/chromeos/fileapi/remote_file_system_operation.cc b/webkit/chromeos/fileapi/remote_file_system_operation.cc index cfe457e..f90aae9 100644 --- a/webkit/chromeos/fileapi/remote_file_system_operation.cc +++ b/webkit/chromeos/fileapi/remote_file_system_operation.cc @@ -176,6 +176,15 @@ void RemoteFileSystemOperation::OpenFile(const FileSystemURL& url, base::Owned(this), callback)); } +void RemoteFileSystemOperation::NotifyCloseFile( + const fileapi::FileSystemURL& url) { + DCHECK(SetPendingOperationType(kOperationCloseFile)); + remote_proxy_->NotifyCloseFile(url); + // Unlike other operations, NotifyCloseFile does not require callback. + // So it must be deleted here right now. + delete this; +} + fileapi::FileSystemOperation* RemoteFileSystemOperation::AsFileSystemOperation() { NOTIMPLEMENTED(); diff --git a/webkit/chromeos/fileapi/remote_file_system_operation.h b/webkit/chromeos/fileapi/remote_file_system_operation.h index 560167d..2cc0c20 100644 --- a/webkit/chromeos/fileapi/remote_file_system_operation.h +++ b/webkit/chromeos/fileapi/remote_file_system_operation.h @@ -65,6 +65,7 @@ class RemoteFileSystemOperation : public fileapi::FileSystemOperationInterface { int file_flags, base::ProcessHandle peer_handle, const OpenFileCallback& callback) OVERRIDE; + virtual void NotifyCloseFile(const fileapi::FileSystemURL& url) OVERRIDE; virtual fileapi::FileSystemOperation* AsFileSystemOperation() OVERRIDE; virtual void CreateSnapshotFile( const fileapi::FileSystemURL& url, diff --git a/webkit/chromeos/fileapi/remote_file_system_proxy.h b/webkit/chromeos/fileapi/remote_file_system_proxy.h index b62c036..3a920f0 100644 --- a/webkit/chromeos/fileapi/remote_file_system_proxy.h +++ b/webkit/chromeos/fileapi/remote_file_system_proxy.h @@ -101,6 +101,10 @@ class RemoteFileSystemProxyInterface : int flags, base::ProcessHandle peer_handle, const FileSystemOperationInterface::OpenFileCallback& callback) = 0; + + // Notifies that a file opened by OpenFile (at |path|) is closed. + virtual void NotifyCloseFile(const FileSystemURL& url) = 0; + // TODO(zelidrag): More methods to follow as we implement other parts of FSO. protected: diff --git a/webkit/fileapi/file_system_operation.cc b/webkit/fileapi/file_system_operation.cc index 46d4cee..4ab97ef 100644 --- a/webkit/fileapi/file_system_operation.cc +++ b/webkit/fileapi/file_system_operation.cc @@ -383,6 +383,12 @@ void FileSystemOperation::OpenFile(const FileSystemURL& url, base::kNullProcessHandle)); } +void FileSystemOperation::NotifyCloseFile(const FileSystemURL& url) { + // No particular task to do. This method is for remote file systems that + // need synchronization with remote server. + delete this; +} + // We can only get here on a write or truncate that's not yet completed. // We don't support cancelling any other operation at this time. void FileSystemOperation::Cancel(const StatusCallback& cancel_callback) { diff --git a/webkit/fileapi/file_system_operation.h b/webkit/fileapi/file_system_operation.h index b5674c8..77f7403 100644 --- a/webkit/fileapi/file_system_operation.h +++ b/webkit/fileapi/file_system_operation.h @@ -87,6 +87,7 @@ class FILEAPI_EXPORT FileSystemOperation int file_flags, base::ProcessHandle peer_handle, const OpenFileCallback& callback) OVERRIDE; + virtual void NotifyCloseFile(const FileSystemURL& url) OVERRIDE; virtual void Cancel(const StatusCallback& cancel_callback) OVERRIDE; virtual FileSystemOperation* AsFileSystemOperation() OVERRIDE; virtual void CreateSnapshotFile( diff --git a/webkit/fileapi/file_system_operation_interface.h b/webkit/fileapi/file_system_operation_interface.h index 5a08970..9196f96 100644 --- a/webkit/fileapi/file_system_operation_interface.h +++ b/webkit/fileapi/file_system_operation_interface.h @@ -226,6 +226,13 @@ class FileSystemOperationInterface { base::ProcessHandle peer_handle, const OpenFileCallback& callback) = 0; + // Notifies a file at |path| opened by OpenFile is closed in plugin process. + // File system will run some cleanup task such as uploading the modified file + // content to a remote storage. + // + // This function is used only by Pepper as of writing. + virtual void NotifyCloseFile(const FileSystemURL& path) = 0; + // For downcasting to FileSystemOperation. // TODO(kinuko): this hack should go away once appropriate upload-stream // handling based on element types is supported. @@ -260,6 +267,7 @@ class FileSystemOperationInterface { kOperationTruncate, kOperationTouchFile, kOperationOpenFile, + kOperationCloseFile, kOperationGetLocalPath, kOperationCancel, }; diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.cc b/webkit/plugins/ppapi/mock_plugin_delegate.cc index e666ab4..08f4f2a 100644 --- a/webkit/plugins/ppapi/mock_plugin_delegate.cc +++ b/webkit/plugins/ppapi/mock_plugin_delegate.cc @@ -143,7 +143,9 @@ bool MockPluginDelegate::AsyncOpenFile(const FilePath& path, } bool MockPluginDelegate::AsyncOpenFileSystemURL( - const GURL& path, int flags, const AsyncOpenFileCallback& callback) { + const GURL& path, + int flags, + const AsyncOpenFileSystemURLCallback& callback) { return false; } diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.h b/webkit/plugins/ppapi/mock_plugin_delegate.h index 46ba02c..2c7d6e2 100644 --- a/webkit/plugins/ppapi/mock_plugin_delegate.h +++ b/webkit/plugins/ppapi/mock_plugin_delegate.h @@ -67,9 +67,10 @@ class MockPluginDelegate : public PluginDelegate { virtual bool AsyncOpenFile(const FilePath& path, int flags, const AsyncOpenFileCallback& callback); - virtual bool AsyncOpenFileSystemURL(const GURL& path, - int flags, - const AsyncOpenFileCallback& callback); + virtual bool AsyncOpenFileSystemURL( + const GURL& path, + int flags, + const AsyncOpenFileSystemURLCallback& callback); virtual bool OpenFileSystem( const GURL& url, fileapi::FileSystemType type, diff --git a/webkit/plugins/ppapi/plugin_delegate.h b/webkit/plugins/ppapi/plugin_delegate.h index 545afa4..7ba136e 100644 --- a/webkit/plugins/ppapi/plugin_delegate.h +++ b/webkit/plugins/ppapi/plugin_delegate.h @@ -422,16 +422,29 @@ class PluginDelegate { const WebKit::WebFileChooserParams& params, WebKit::WebFileChooserCompletion* chooser_completion) = 0; - // Sends an async IPC to open a file. + // Sends an async IPC to open a local file. typedef base::Callback<void (base::PlatformFileError, base::PassPlatformFile)> AsyncOpenFileCallback; virtual bool AsyncOpenFile(const FilePath& path, int flags, const AsyncOpenFileCallback& callback) = 0; + + // Sends an async IPC to open a file through filesystem API. + // When a file is successfully opened, |callback| is invoked with + // PLATFORM_FILE_OK, the opened file handle, and a callback function for + // notifying that the file is closed. When the users of this function + // finished using the file, they must close the file handle and then must call + // the supplied callback function. + typedef base::Callback<void (base::PlatformFileError)> + NotifyCloseFileCallback; + typedef base::Callback< + void (base::PlatformFileError, + base::PassPlatformFile, + const NotifyCloseFileCallback&)> AsyncOpenFileSystemURLCallback; virtual bool AsyncOpenFileSystemURL( const GURL& path, int flags, - const AsyncOpenFileCallback& callback) = 0; + const AsyncOpenFileSystemURLCallback& callback) = 0; virtual bool OpenFileSystem( const GURL& url, diff --git a/webkit/plugins/ppapi/ppb_file_io_impl.cc b/webkit/plugins/ppapi/ppb_file_io_impl.cc index d102270..df4d86b 100644 --- a/webkit/plugins/ppapi/ppb_file_io_impl.cc +++ b/webkit/plugins/ppapi/ppb_file_io_impl.cc @@ -6,6 +6,7 @@ #include "base/bind.h" #include "base/callback.h" +#include "base/callback_helpers.h" #include "base/file_util.h" #include "base/file_util_proxy.h" #include "base/message_loop_proxy.h" @@ -64,8 +65,9 @@ int32_t PPB_FileIO_Impl::OpenValidated( file_system_url_ = file_ref->GetFileSystemURL(); if (!plugin_delegate->AsyncOpenFileSystemURL( file_system_url_, flags, - base::Bind(&PPB_FileIO_Impl::ExecutePlatformOpenFileCallback, - weak_factory_.GetWeakPtr()))) + base::Bind( + &PPB_FileIO_Impl::ExecutePlatformOpenFileSystemURLCallback, + weak_factory_.GetWeakPtr()))) return PP_ERROR_FAILED; } else { if (file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL) @@ -211,8 +213,9 @@ void PPB_FileIO_Impl::Close() { PluginDelegate* plugin_delegate = GetPluginDelegate(); if (file_ != base::kInvalidPlatformFileValue && plugin_delegate) { base::FileUtilProxy::Close( - plugin_delegate->GetFileThreadMessageLoopProxy(), file_, - base::FileUtilProxy::StatusCallback()); + plugin_delegate->GetFileThreadMessageLoopProxy(), + file_, + base::ResetAndReturn(¬ify_close_file_callback_)); file_ = base::kInvalidPlatformFileValue; quota_file_io_.reset(); } @@ -294,6 +297,15 @@ void PPB_FileIO_Impl::ExecutePlatformOpenFileCallback( ExecuteOpenFileCallback(::ppapi::PlatformFileErrorToPepperError(error_code)); } +void PPB_FileIO_Impl::ExecutePlatformOpenFileSystemURLCallback( + base::PlatformFileError error_code, + base::PassPlatformFile file, + const PluginDelegate::NotifyCloseFileCallback& callback) { + if (error_code == base::PLATFORM_FILE_OK) + notify_close_file_callback_ = callback; + ExecutePlatformOpenFileCallback(error_code, file); +} + void PPB_FileIO_Impl::ExecutePlatformQueryCallback( base::PlatformFileError error_code, const base::PlatformFileInfo& file_info) { diff --git a/webkit/plugins/ppapi/ppb_file_io_impl.h b/webkit/plugins/ppapi/ppb_file_io_impl.h index 2298d87..52d1105 100644 --- a/webkit/plugins/ppapi/ppb_file_io_impl.h +++ b/webkit/plugins/ppapi/ppb_file_io_impl.h @@ -74,6 +74,10 @@ class PPB_FileIO_Impl : public ::ppapi::PPB_FileIO_Shared { void ExecutePlatformGeneralCallback(base::PlatformFileError error_code); void ExecutePlatformOpenFileCallback(base::PlatformFileError error_code, base::PassPlatformFile file); + void ExecutePlatformOpenFileSystemURLCallback( + base::PlatformFileError error_code, + base::PassPlatformFile file, + const PluginDelegate::NotifyCloseFileCallback& callback); void ExecutePlatformQueryCallback(base::PlatformFileError error_code, const base::PlatformFileInfo& file_info); void ExecutePlatformReadCallback(base::PlatformFileError error_code, @@ -88,6 +92,9 @@ class PPB_FileIO_Impl : public ::ppapi::PPB_FileIO_Shared { // Valid only for PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY}. GURL file_system_url_; + // Callback function for notifying when the file handle is closed. + PluginDelegate::NotifyCloseFileCallback notify_close_file_callback_; + // Pointer to a QuotaFileIO instance, which is valid only while a file // of type PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY} is opened. scoped_ptr<QuotaFileIO> quota_file_io_; |