Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Unified Diff: webkit/plugins/ppapi/quota_file_io.cc

Issue 11615036: Reduce copy on QuotaFileIO::Write (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/ppapi/quota_file_io.cc
diff --git a/webkit/plugins/ppapi/quota_file_io.cc b/webkit/plugins/ppapi/quota_file_io.cc
index 84c44e3e833bdea0e8b55073ed7b1288e54d38ca..dc768fae25d217bcdfee22e6d364bfb222e9eee0 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"
@@ -100,10 +101,13 @@ 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(&base::WritePlatformFile,
+ quota_io_->file_, offset_,
+ base::Owned(buffer_.release()),
+ bytes_to_write_),
+ base::Bind(&WriteOperation::DidWrite,
weak_factory_.GetWeakPtr()))) {
DidFail(base::PLATFORM_FILE_ERROR_FAILED);
return;
@@ -123,6 +127,12 @@ class QuotaFileIO::WriteOperation : public PendingOperationBase {
}
private:
+ void DidWrite(int bytes_written) {
+ base::PlatformFileError error = bytes_written >= 0 ?
brettw 2013/01/09 20:17:10 What happens if you write 0 bytes? It looks like b
tzik 2013/01/10 04:02:36 Right, this changes its behavior for 0-byte write.
+ base::PLATFORM_FILE_OK : base::PLATFORM_FILE_ERROR_FAILED;
+ DidFinish(error, bytes_written);
+ }
+
void DidFinish(PlatformFileError status, int bytes_written) {
finished_ = true;
status_ = status;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698