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

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

Issue 536453007: Add truncation to StreamCopyOrMoveImpl and test case. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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/copy_or_move_operation_delegate.cc
diff --git a/webkit/browser/fileapi/copy_or_move_operation_delegate.cc b/webkit/browser/fileapi/copy_or_move_operation_delegate.cc
index 97de4f406df6fe1a257951d76af1ec3c2bfc2ccd..27a03d5725015bc6af9599ea814742a362545b0d 100644
--- a/webkit/browser/fileapi/copy_or_move_operation_delegate.cc
+++ b/webkit/browser/fileapi/copy_or_move_operation_delegate.cc
@@ -423,10 +423,12 @@ class StreamCopyOrMoveImpl
// To use FileStreamWriter, we need to ensure the destination file exists.
operation_runner_->CreateFile(
- dest_url_, false /* exclusive */,
+ dest_url_,
+ true /* exclusive */,
base::Bind(&StreamCopyOrMoveImpl::RunAfterCreateFileForDestination,
weak_factory_.GetWeakPtr(),
- callback, file_info.last_modified));
+ callback,
+ file_info.last_modified));
}
void RunAfterCreateFileForDestination(
@@ -436,6 +438,31 @@ class StreamCopyOrMoveImpl
if (cancel_requested_)
error = base::File::FILE_ERROR_ABORT;
+ if (error != base::File::FILE_OK &&
+ error != base::File::FILE_ERROR_EXISTS) {
+ callback.Run(error);
+ return;
+ }
+
+ if (error == base::File::FILE_ERROR_EXISTS) {
+ operation_runner_->Truncate(
+ dest_url_,
+ 0 /* length */,
+ base::Bind(&StreamCopyOrMoveImpl::RunAfterTruncateForDestination,
+ weak_factory_.GetWeakPtr(),
+ callback,
+ last_modified));
+ return;
+ }
tzik 2014/09/03 02:07:43 error == FILE_OK case handling?
iseki 2014/09/03 03:28:21 Done.
+ }
+
+ void RunAfterTruncateForDestination(
+ const CopyOrMoveOperationDelegate::StatusCallback& callback,
+ const base::Time& last_modified,
+ base::File::Error error) {
+ if (cancel_requested_)
+ error = base::File::FILE_ERROR_ABORT;
+
if (error != base::File::FILE_OK) {
callback.Run(error);
return;

Powered by Google App Engine
This is Rietveld 408576698