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

Unified Diff: webkit/browser/fileapi/local_file_system_operation.cc

Issue 16311010: Make FileSystemOperation::Write take closure-friendly parameters (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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
Index: webkit/browser/fileapi/local_file_system_operation.cc
diff --git a/webkit/browser/fileapi/local_file_system_operation.cc b/webkit/browser/fileapi/local_file_system_operation.cc
index a79b4799dba4e463050a8931c09db8c9b7fc3c95..23653b49e1ed40dce7aecd007d2ad03603b48f22 100644
--- a/webkit/browser/fileapi/local_file_system_operation.cc
+++ b/webkit/browser/fileapi/local_file_system_operation.cc
@@ -9,7 +9,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/time.h"
#include "net/base/escape.h"
-#include "net/url_request/url_request_context.h"
+#include "net/url_request/url_request.h"
#include "webkit/browser/fileapi/async_file_util.h"
#include "webkit/browser/fileapi/copy_or_move_operation_delegate.h"
#include "webkit/browser/fileapi/file_observers.h"
@@ -156,12 +156,16 @@ void LocalFileSystemOperation::Remove(const FileSystemURL& url,
}
void LocalFileSystemOperation::Write(
- const net::URLRequestContext* url_request_context,
const FileSystemURL& url,
- const GURL& blob_url,
- int64 offset,
+ scoped_ptr<FileWriterDelegate> writer_delegate,
+ scoped_ptr<net::URLRequest> blob_request,
const WriteCallback& callback) {
- GetWriteClosure(url_request_context, url, blob_url, offset, callback).Run();
+ DCHECK(SetPendingOperationType(kOperationWrite));
+ file_writer_delegate_ = writer_delegate.Pass();
+ file_writer_delegate_->Start(
+ blob_request.Pass(),
+ base::Bind(&LocalFileSystemOperation::DidWrite, AsWeakPtr(),
+ url, callback));
}
void LocalFileSystemOperation::Truncate(const FileSystemURL& url, int64 length,
@@ -351,43 +355,6 @@ void LocalFileSystemOperation::DidGetUsageAndQuotaAndRunTask(
task.Run();
}
-base::Closure LocalFileSystemOperation::GetWriteClosure(
- const net::URLRequestContext* url_request_context,
- const FileSystemURL& url,
- const GURL& blob_url,
- int64 offset,
- const WriteCallback& callback) {
- DCHECK(SetPendingOperationType(kOperationWrite));
- scoped_ptr<FileStreamWriter> writer(
- file_system_context()->CreateFileStreamWriter(url, offset));
-
- if (!writer) {
- // Write is not supported.
- return base::Bind(&LocalFileSystemOperation::DidFailWrite,
- AsWeakPtr(), callback,
- base::PLATFORM_FILE_ERROR_SECURITY);
- }
-
- DCHECK(blob_url.is_valid());
- file_writer_delegate_.reset(new FileWriterDelegate(
- base::Bind(&LocalFileSystemOperation::DidWrite, AsWeakPtr(),
- url, callback),
- writer.Pass()));
-
- scoped_ptr<net::URLRequest> blob_request(url_request_context->CreateRequest(
- blob_url, file_writer_delegate_.get()));
-
- return base::Bind(&FileWriterDelegate::Start,
- base::Unretained(file_writer_delegate_.get()),
- base::Passed(&blob_request));
-}
-
-void LocalFileSystemOperation::DidFailWrite(
- const WriteCallback& callback,
- base::PlatformFileError result) {
- callback.Run(result, 0, false);
-}
-
void LocalFileSystemOperation::DoCreateFile(
const FileSystemURL& url,
const StatusCallback& callback,

Powered by Google App Engine
This is Rietveld 408576698