summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorvandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-19 04:01:33 +0000
committervandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-19 04:01:33 +0000
commit6eb2d4eed7c17d48ea46902653533db143c8b141 (patch)
tree715b2ba3e70b2e11c25762cf05cc3fd46b439d95 /webkit
parentba59a929b164234e574ba6a04c81f0a6b362353a (diff)
downloadchromium_src-6eb2d4eed7c17d48ea46902653533db143c8b141.zip
chromium_src-6eb2d4eed7c17d48ea46902653533db143c8b141.tar.gz
chromium_src-6eb2d4eed7c17d48ea46902653533db143c8b141.tar.bz2
fileapi: Pass virtual path to copy validator.
Copy validator factory needs to know the virtual path because the platform path may have a different file extension; this is true for obfuscated file util. BUG=144509 Review URL: https://chromiumcodereview.appspot.com/14225022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195089 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/fileapi/copy_or_move_file_validator.h5
-rw-r--r--webkit/fileapi/copy_or_move_file_validator_unittest.cc1
-rw-r--r--webkit/fileapi/cross_operation_delegate.cc37
-rw-r--r--webkit/fileapi/cross_operation_delegate.h14
4 files changed, 36 insertions, 21 deletions
diff --git a/webkit/fileapi/copy_or_move_file_validator.h b/webkit/fileapi/copy_or_move_file_validator.h
index 507a276..a3e4a42 100644
--- a/webkit/fileapi/copy_or_move_file_validator.h
+++ b/webkit/fileapi/copy_or_move_file_validator.h
@@ -26,8 +26,11 @@ class CopyOrMoveFileValidatorFactory {
public:
virtual ~CopyOrMoveFileValidatorFactory() {}
- // This method must always return a non-NULL validator.
+ // This method must always return a non-NULL validator. |src_url| is needed
+ // in addition to |platform_path| because in the obfuscated file system
+ // case, |platform_path| will be an obfuscated filename and extension.
virtual CopyOrMoveFileValidator* CreateCopyOrMoveFileValidator(
+ const FileSystemURL& src_url,
const base::FilePath& platform_path) = 0;
};
diff --git a/webkit/fileapi/copy_or_move_file_validator_unittest.cc b/webkit/fileapi/copy_or_move_file_validator_unittest.cc
index 5852d6c..e5d4438 100644
--- a/webkit/fileapi/copy_or_move_file_validator_unittest.cc
+++ b/webkit/fileapi/copy_or_move_file_validator_unittest.cc
@@ -171,6 +171,7 @@ class TestCopyOrMoveFileValidatorFactory
virtual ~TestCopyOrMoveFileValidatorFactory() {}
virtual CopyOrMoveFileValidator* CreateCopyOrMoveFileValidator(
+ const FileSystemURL& /*src_url*/,
const base::FilePath& /*platform_path*/) {
return new TestCopyOrMoveFileValidator(all_valid_);
}
diff --git a/webkit/fileapi/cross_operation_delegate.cc b/webkit/fileapi/cross_operation_delegate.cc
index 3ec57ec..8de48d5 100644
--- a/webkit/fileapi/cross_operation_delegate.cc
+++ b/webkit/fileapi/cross_operation_delegate.cc
@@ -55,14 +55,14 @@ void CrossOperationDelegate::RunRecursively() {
}
// First try to copy/move it as a file.
- CopyOrMoveFile(src_root_, dest_root_,
+ CopyOrMoveFile(URLPair(src_root_, dest_root_),
base::Bind(&CrossOperationDelegate::DidTryCopyOrMoveFile,
AsWeakPtr()));
}
void CrossOperationDelegate::ProcessFile(const FileSystemURL& src_url,
const StatusCallback& callback) {
- CopyOrMoveFile(src_url, CreateDestURL(src_url), callback);
+ CopyOrMoveFile(URLPair(src_url, CreateDestURL(src_url)), callback);
}
void CrossOperationDelegate::ProcessDirectory(const FileSystemURL& src_url,
@@ -114,16 +114,17 @@ void CrossOperationDelegate::DidTryRemoveDestRoot(
AsWeakPtr(), src_root_, callback_));
}
-void CrossOperationDelegate::CopyOrMoveFile(
- const FileSystemURL& src,
- const FileSystemURL& dest,
- const StatusCallback& callback) {
+void CrossOperationDelegate::CopyOrMoveFile(const URLPair& url_pair,
+ const StatusCallback& callback) {
// Same filesystem case.
if (same_file_system_) {
- if (operation_type_ == OPERATION_MOVE)
- NewSourceOperation()->MoveFileLocal(src, dest, callback);
- else
- NewSourceOperation()->CopyFileLocal(src, dest, callback);
+ if (operation_type_ == OPERATION_MOVE) {
+ NewSourceOperation()->MoveFileLocal(url_pair.src, url_pair.dest,
+ callback);
+ } else {
+ NewSourceOperation()->CopyFileLocal(url_pair.src, url_pair.dest,
+ callback);
+ }
return;
}
@@ -132,14 +133,15 @@ void CrossOperationDelegate::CopyOrMoveFile(
// copy_callback which removes the source file if operation_type == MOVE.
StatusCallback copy_callback =
base::Bind(&CrossOperationDelegate::DidFinishCopy, AsWeakPtr(),
- src, callback);
+ url_pair.src, callback);
NewSourceOperation()->CreateSnapshotFile(
- src, base::Bind(&CrossOperationDelegate::DidCreateSnapshot, AsWeakPtr(),
- dest, copy_callback));
+ url_pair.src,
+ base::Bind(&CrossOperationDelegate::DidCreateSnapshot, AsWeakPtr(),
+ url_pair, copy_callback));
}
void CrossOperationDelegate::DidCreateSnapshot(
- const FileSystemURL& dest,
+ const URLPair& url_pair,
const StatusCallback& callback,
base::PlatformFileError error,
const base::PlatformFileInfo& file_info,
@@ -163,14 +165,15 @@ void CrossOperationDelegate::DidCreateSnapshot(
return;
}
if (!factory) {
- DidValidateFile(dest, callback, file_info, platform_path, error);
+ DidValidateFile(url_pair.dest, callback, file_info, platform_path, error);
return;
}
- validator_.reset(factory->CreateCopyOrMoveFileValidator(platform_path));
+ validator_.reset(
+ factory->CreateCopyOrMoveFileValidator(url_pair.src, platform_path));
validator_->StartValidation(
base::Bind(&CrossOperationDelegate::DidValidateFile, AsWeakPtr(),
- dest, callback, file_info, platform_path));
+ url_pair.dest, callback, file_info, platform_path));
}
void CrossOperationDelegate::DidValidateFile(
diff --git a/webkit/fileapi/cross_operation_delegate.h b/webkit/fileapi/cross_operation_delegate.h
index 77c15f5..37f088c 100644
--- a/webkit/fileapi/cross_operation_delegate.h
+++ b/webkit/fileapi/cross_operation_delegate.h
@@ -50,14 +50,22 @@ class CrossOperationDelegate
using base::SupportsWeakPtr<CrossOperationDelegate>::AsWeakPtr;
private:
+ struct URLPair {
+ URLPair(const FileSystemURL& src, const FileSystemURL& dest)
+ : src(src),
+ dest(dest) {
+ }
+ FileSystemURL src;
+ FileSystemURL dest;
+ };
+
void DidTryCopyOrMoveFile(base::PlatformFileError error);
void DidTryRemoveDestRoot(base::PlatformFileError error);
void CopyOrMoveFile(
- const FileSystemURL& src,
- const FileSystemURL& dest,
+ const URLPair& url_pair,
const StatusCallback& callback);
void DidCreateSnapshot(
- const FileSystemURL& dest,
+ const URLPair& url_pair,
const StatusCallback& callback,
base::PlatformFileError error,
const base::PlatformFileInfo& file_info,