diff options
author | yzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-15 19:18:51 +0000 |
---|---|---|
committer | yzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-15 19:18:51 +0000 |
commit | ee405c220b9c2551c6138c79375bf0f553cdb8c4 (patch) | |
tree | 73111b1d92e9113725b5e020d79bbe32519ad840 /webkit | |
parent | 8fd7b2d6cd00d43f63ccee9bd3372e79814b137b (diff) | |
download | chromium_src-ee405c220b9c2551c6138c79375bf0f553cdb8c4.zip chromium_src-ee405c220b9c2551c6138c79375bf0f553cdb8c4.tar.gz chromium_src-ee405c220b9c2551c6138c79375bf0f553cdb8c4.tar.bz2 |
Avoid leaking file handles.
AsyncOpenFileCallback: fix the issue that file handle is leaked if the file handle arrives after the requester has died.
This change also fixes test_file_system.
BUG=79820
TEST=FileIO/FileRef/FileSystem tests in ppapi_tests: Reload the test page, the test still passes. The output files can be deleted when any of these tests finishes running, no matter the test page is still open or not.
Review URL: http://codereview.chromium.org/7327025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92727 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/fileapi/file_system_callback_dispatcher.cc | 3 | ||||
-rw-r--r-- | webkit/fileapi/file_system_callback_dispatcher.h | 1 | ||||
-rw-r--r-- | webkit/plugins/ppapi/plugin_delegate.h | 2 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_file_io_impl.cc | 4 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_file_io_impl.h | 2 |
5 files changed, 8 insertions, 4 deletions
diff --git a/webkit/fileapi/file_system_callback_dispatcher.cc b/webkit/fileapi/file_system_callback_dispatcher.cc index 1298979..08fdf55 100644 --- a/webkit/fileapi/file_system_callback_dispatcher.cc +++ b/webkit/fileapi/file_system_callback_dispatcher.cc @@ -15,6 +15,9 @@ void FileSystemCallbackDispatcher::DidOpenFile( base::PlatformFile file, base::ProcessHandle peer_handle) { NOTREACHED(); + + if (file != base::kInvalidPlatformFileValue) + base::ClosePlatformFile(file); } } // namespace fileapi diff --git a/webkit/fileapi/file_system_callback_dispatcher.h b/webkit/fileapi/file_system_callback_dispatcher.h index e2d3caa..cf19d00 100644 --- a/webkit/fileapi/file_system_callback_dispatcher.h +++ b/webkit/fileapi/file_system_callback_dispatcher.h @@ -55,6 +55,7 @@ class FileSystemCallbackDispatcher { // Callback for OpenFile. This isn't in WebFileSystemCallbacks, as it's just // for Pepper. + // The method will be responsible for closing |file|. virtual void DidOpenFile( base::PlatformFile file, base::ProcessHandle peer_handle); diff --git a/webkit/plugins/ppapi/plugin_delegate.h b/webkit/plugins/ppapi/plugin_delegate.h index 2b6e098..ebfda18 100644 --- a/webkit/plugins/ppapi/plugin_delegate.h +++ b/webkit/plugins/ppapi/plugin_delegate.h @@ -294,7 +294,7 @@ class PluginDelegate { WebKit::WebFileChooserCompletion* chooser_completion) = 0; // Sends an async IPC to open a file. - typedef Callback2<base::PlatformFileError, base::PlatformFile + typedef Callback2<base::PlatformFileError, base::PassPlatformFile >::Type AsyncOpenFileCallback; virtual bool AsyncOpenFile(const FilePath& path, int flags, diff --git a/webkit/plugins/ppapi/ppb_file_io_impl.cc b/webkit/plugins/ppapi/ppb_file_io_impl.cc index 8a3b3d1..309067c 100644 --- a/webkit/plugins/ppapi/ppb_file_io_impl.cc +++ b/webkit/plugins/ppapi/ppb_file_io_impl.cc @@ -304,14 +304,14 @@ void PPB_FileIO_Impl::StatusCallback(base::PlatformFileError error_code) { void PPB_FileIO_Impl::AsyncOpenFileCallback( base::PlatformFileError error_code, - base::PlatformFile file) { + base::PassPlatformFile file) { if (pending_op_ != OPERATION_EXCLUSIVE || callbacks_.empty()) { NOTREACHED(); return; } DCHECK(file_ == base::kInvalidPlatformFileValue); - file_ = file; + file_ = file.ReleaseValue(); RunAndRemoveFirstPendingCallback(PlatformFileErrorToPepperError(error_code)); } diff --git a/webkit/plugins/ppapi/ppb_file_io_impl.h b/webkit/plugins/ppapi/ppb_file_io_impl.h index 0fc3507..327f713 100644 --- a/webkit/plugins/ppapi/ppb_file_io_impl.h +++ b/webkit/plugins/ppapi/ppb_file_io_impl.h @@ -115,7 +115,7 @@ class PPB_FileIO_Impl : public Resource, void StatusCallback(base::PlatformFileError error_code); void AsyncOpenFileCallback(base::PlatformFileError error_code, - base::PlatformFile file); + base::PassPlatformFile file); void QueryInfoCallback(base::PlatformFileError error_code, const base::PlatformFileInfo& file_info); void ReadCallback(base::PlatformFileError error_code, |