diff options
author | tzik@chromium.org <tzik@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-16 10:36:55 +0000 |
---|---|---|
committer | tzik@chromium.org <tzik@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-16 10:36:55 +0000 |
commit | 6f03a74abb49057f63d57e5e6b56e7d49a04af78 (patch) | |
tree | dce180620215bea7be3a9f04d3a2989924aa950e /webkit | |
parent | a78740033381be029a72cfdd1938a14645154ec1 (diff) | |
download | chromium_src-6f03a74abb49057f63d57e5e6b56e7d49a04af78.zip chromium_src-6f03a74abb49057f63d57e5e6b56e7d49a04af78.tar.gz chromium_src-6f03a74abb49057f63d57e5e6b56e7d49a04af78.tar.bz2 |
Reduce copy on QuotaFileIO::Write.
FileUtilProxy::Write makes a copy of the data before posting the write job, and it is one of the bottlenecks of the write operation on pepper.
Though, we can safely omit the copy in QuotaFileIO::Write.
BUG=168744
Review URL: https://chromiumcodereview.appspot.com/11615036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177125 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/plugins/ppapi/quota_file_io.cc | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/webkit/plugins/ppapi/quota_file_io.cc b/webkit/plugins/ppapi/quota_file_io.cc index 84c44e3..961c79a 100644 --- a/webkit/plugins/ppapi/quota_file_io.cc +++ b/webkit/plugins/ppapi/quota_file_io.cc @@ -11,6 +11,7 @@ #include "base/memory/weak_ptr.h" #include "base/message_loop_proxy.h" #include "base/stl_util.h" +#include "base/task_runner_util.h" #include "webkit/plugins/ppapi/host_globals.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" #include "webkit/plugins/ppapi/resource_helper.h" @@ -35,6 +36,12 @@ StorageType PPFileSystemTypeToQuotaStorageType(PP_FileSystemType type) { NOTREACHED(); return quota::kStorageTypeUnknown; } + +int WriteAdapter(PlatformFile file, int64 offset, + scoped_ptr<char[]> data, int size) { + return base::WritePlatformFile(file, offset, data.get(), size); +} + } // namespace class QuotaFileIO::PendingOperationBase { @@ -100,10 +107,12 @@ class QuotaFileIO::WriteOperation : public PendingOperationBase { return; } - if (!base::FileUtilProxy::Write( - plugin_delegate->GetFileThreadMessageLoopProxy(), - quota_io_->file_, offset_, buffer_.get(), bytes_to_write_, - base::Bind(&WriteOperation::DidFinish, + if (!base::PostTaskAndReplyWithResult( + plugin_delegate->GetFileThreadMessageLoopProxy(), FROM_HERE, + base::Bind(&WriteAdapter, + quota_io_->file_, offset_, + base::Passed(&buffer_), bytes_to_write_), + base::Bind(&WriteOperation::DidWrite, weak_factory_.GetWeakPtr()))) { DidFail(base::PLATFORM_FILE_ERROR_FAILED); return; @@ -123,6 +132,12 @@ class QuotaFileIO::WriteOperation : public PendingOperationBase { } private: + void DidWrite(int bytes_written) { + base::PlatformFileError error = bytes_written > 0 ? + base::PLATFORM_FILE_OK : base::PLATFORM_FILE_ERROR_FAILED; + DidFinish(error, bytes_written); + } + void DidFinish(PlatformFileError status, int bytes_written) { finished_ = true; status_ = status; @@ -140,7 +155,7 @@ class QuotaFileIO::WriteOperation : public PendingOperationBase { } const int64_t offset_; - scoped_array<char> buffer_; + scoped_ptr<char[]> buffer_; const int32_t bytes_to_write_; WriteCallback callback_; bool finished_; |