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

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: crash fix on deletion Created 7 years, 11 months 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..961c79ab4ba3ddfa1b6ac921fe7b48db1e742e4c 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_;
« 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