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

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

Issue 18565002: [FileSystem] Add another copy-or-move validation hook for post-write. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Manage file_ref in calling code, remove from API. Created 7 years, 5 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 8b706902b5c84396c675b884a01422d75f638b4b..29791b7bbbc4d8ec8c456a09c999755ae3bff5a7 100644
--- a/webkit/browser/fileapi/copy_or_move_operation_delegate.cc
+++ b/webkit/browser/fileapi/copy_or_move_operation_delegate.cc
@@ -111,7 +111,8 @@ void CopyOrMoveOperationDelegate::DidTryRemoveDestRoot(
// http://crbug.com/172187
StartRecursiveOperation(
src_root_, base::Bind(&CopyOrMoveOperationDelegate::DidFinishCopy,
kinuko 2013/07/12 05:00:19 I overlooked this in my previous review, but when
Greg Billock 2013/07/12 18:02:19 OK. I'll add a directory-specific handler for this
vandebo (ex-Chrome) 2013/07/12 18:51:48 Probably want a complementary test that fails veri
Greg Billock 2013/07/12 20:36:46 validation is per-file at present, so you'd expect
vandebo (ex-Chrome) 2013/07/12 21:06:58 We only get one result code, so do you say it work
Greg Billock 2013/07/12 22:06:32 Yeah, the test shows this: it deletes the entire d
- AsWeakPtr(), src_root_, callback_));
+ AsWeakPtr(), URLPair(src_root_, dest_root_),
+ callback_));
}
void CopyOrMoveOperationDelegate::CopyOrMoveFile(const URLPair& url_pair,
@@ -131,7 +132,7 @@ void CopyOrMoveOperationDelegate::CopyOrMoveFile(const URLPair& url_pair,
// copy_callback which removes the source file if operation_type == MOVE.
StatusCallback copy_callback =
base::Bind(&CopyOrMoveOperationDelegate::DidFinishCopy, AsWeakPtr(),
- url_pair.src, callback);
+ url_pair, callback);
operation_runner()->CreateSnapshotFile(
url_pair.src,
base::Bind(&CopyOrMoveOperationDelegate::DidCreateSnapshot, AsWeakPtr(),
@@ -189,11 +190,65 @@ void CopyOrMoveOperationDelegate::DidValidateFile(
}
void CopyOrMoveOperationDelegate::DidFinishCopy(
- const FileSystemURL& src,
+ const URLPair& url_pair,
const StatusCallback& callback,
base::PlatformFileError error) {
- if (error != base::PLATFORM_FILE_OK ||
- operation_type_ == OPERATION_COPY) {
+ if (error != base::PLATFORM_FILE_OK) {
+ callback.Run(error);
+ return;
+ }
+
+ // |validator_| must not exist in the same-filesystem case.
+ if (!validator_.get()) {
+ scoped_refptr<webkit_blob::ShareableFileReference> file_ref;
+ DidPostWriteValidation(url_pair, callback, file_ref,
+ base::PLATFORM_FILE_OK);
+ return;
+ }
+
+ DCHECK(!same_file_system_);
+ operation_runner()->CreateSnapshotFile(
+ url_pair.dest,
+ base::Bind(&CopyOrMoveOperationDelegate::DoPostWriteValidation,
+ AsWeakPtr(), url_pair, callback));
+}
+
+void CopyOrMoveOperationDelegate::DoPostWriteValidation(
+ const URLPair& url_pair,
+ const StatusCallback& callback,
+ base::PlatformFileError error,
+ const base::PlatformFileInfo& file_info,
+ const base::FilePath& platform_path,
+ const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) {
+ if (error != base::PLATFORM_FILE_OK) {
+ operation_runner()->Remove(
+ url_pair.dest, true,
+ base::Bind(&CopyOrMoveOperationDelegate::DidRemoveDestForError,
+ AsWeakPtr(), error, callback));
+ return;
+ }
+
+ DCHECK(validator_.get());
+ validator_->StartPostWriteValidation(
vandebo (ex-Chrome) 2013/07/12 15:08:15 Probably should add a comment about keeping file_r
Greg Billock 2013/07/12 18:02:19 Done.
+ platform_path,
+ base::Bind(&CopyOrMoveOperationDelegate::DidPostWriteValidation,
+ AsWeakPtr(), url_pair, callback, file_ref));
+}
+
+void CopyOrMoveOperationDelegate::DidPostWriteValidation(
+ const URLPair& url_pair,
+ const StatusCallback& callback,
+ const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref,
vandebo (ex-Chrome) 2013/07/12 15:08:15 nit: file_ref isn't used in this context, so /*fil
Greg Billock 2013/07/12 18:02:19 Done.
+ base::PlatformFileError error) {
+ if (error != base::PLATFORM_FILE_OK) {
+ operation_runner()->Remove(
+ url_pair.dest, true,
+ base::Bind(&CopyOrMoveOperationDelegate::DidRemoveDestForError,
+ AsWeakPtr(), error, callback));
+ return;
+ }
+
+ if (operation_type_ == OPERATION_COPY) {
callback.Run(error);
return;
}
@@ -202,7 +257,7 @@ void CopyOrMoveOperationDelegate::DidFinishCopy(
// Remove the source for finalizing move operation.
operation_runner()->Remove(
- src, true /* recursive */,
+ url_pair.src, true /* recursive */,
base::Bind(&CopyOrMoveOperationDelegate::DidRemoveSourceForMove,
AsWeakPtr(), callback));
}
@@ -229,4 +284,11 @@ FileSystemURL CopyOrMoveOperationDelegate::CreateDestURL(
relative);
}
+void CopyOrMoveOperationDelegate::DidRemoveDestForError(
+ base::PlatformFileError prior_error,
+ const StatusCallback& callback,
+ base::PlatformFileError error) {
+ callback.Run(prior_error);
vandebo (ex-Chrome) 2013/07/12 15:08:15 nit: VLOG if error != OK ?
Greg Billock 2013/07/12 18:02:19 Done.
+}
+
} // namespace fileapi

Powered by Google App Engine
This is Rietveld 408576698