Commit 747e4e29 authored by tzik@chromium.org's avatar tzik@chromium.org

Use RelayFileTask instead of CopyOrMoveHelper


BUG=114732
TEST='existing tests'


Review URL: http://codereview.chromium.org/9570061

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124639 0039d316-1c4b-4281-b951-d872f2087c98
parent a704b438
...@@ -23,28 +23,6 @@ namespace { ...@@ -23,28 +23,6 @@ namespace {
typedef fileapi::FileSystemFileUtilProxy Proxy; typedef fileapi::FileSystemFileUtilProxy Proxy;
class CopyOrMoveHelper {
public:
CopyOrMoveHelper(CrossFileUtilHelper* helper)
: helper_(helper),
error_(base::PLATFORM_FILE_OK) {}
~CopyOrMoveHelper() {}
void RunWork() {
error_ = helper_->DoWork();
}
void Reply(const Proxy::StatusCallback& callback) {
if (!callback.is_null())
callback.Run(error_);
}
private:
scoped_ptr<CrossFileUtilHelper> helper_;
base::PlatformFileError error_;
DISALLOW_COPY_AND_ASSIGN(CopyOrMoveHelper);
};
class EnsureFileExistsHelper { class EnsureFileExistsHelper {
public: public:
EnsureFileExistsHelper() : error_(base::PLATFORM_FILE_OK), created_(false) {} EnsureFileExistsHelper() : error_(base::PLATFORM_FILE_OK), created_(false) {}
...@@ -153,14 +131,15 @@ bool FileSystemFileUtilProxy::Copy( ...@@ -153,14 +131,15 @@ bool FileSystemFileUtilProxy::Copy(
const FileSystemPath& src_path, const FileSystemPath& src_path,
const FileSystemPath& dest_path, const FileSystemPath& dest_path,
const StatusCallback& callback) { const StatusCallback& callback) {
CopyOrMoveHelper* helper = new CopyOrMoveHelper( CrossFileUtilHelper* helper =
new CrossFileUtilHelper( new CrossFileUtilHelper(
context, src_util, dest_util, src_path, dest_path, context, src_util, dest_util, src_path, dest_path,
CrossFileUtilHelper::OPERATION_COPY)); CrossFileUtilHelper::OPERATION_COPY);
return message_loop_proxy->PostTaskAndReply(
FROM_HERE, return base::FileUtilProxy::RelayFileTask(
Bind(&CopyOrMoveHelper::RunWork, Unretained(helper)), message_loop_proxy, FROM_HERE,
Bind(&CopyOrMoveHelper::Reply, Owned(helper), callback)); Bind(&CrossFileUtilHelper::DoWork, Owned(helper)),
callback);
} }
// static // static
...@@ -172,14 +151,14 @@ bool FileSystemFileUtilProxy::Move( ...@@ -172,14 +151,14 @@ bool FileSystemFileUtilProxy::Move(
const FileSystemPath& src_path, const FileSystemPath& src_path,
const FileSystemPath& dest_path, const FileSystemPath& dest_path,
const StatusCallback& callback) { const StatusCallback& callback) {
CopyOrMoveHelper* helper = new CopyOrMoveHelper( CrossFileUtilHelper* helper =
new CrossFileUtilHelper( new CrossFileUtilHelper(
context, src_util, dest_util, src_path, dest_path, context, src_util, dest_util, src_path, dest_path,
CrossFileUtilHelper::OPERATION_MOVE)); CrossFileUtilHelper::OPERATION_MOVE);
return message_loop_proxy->PostTaskAndReply( return base::FileUtilProxy::RelayFileTask(
FROM_HERE, message_loop_proxy, FROM_HERE,
Bind(&CopyOrMoveHelper::RunWork, Unretained(helper)), Bind(&CrossFileUtilHelper::DoWork, Owned(helper)),
Bind(&CopyOrMoveHelper::Reply, Owned(helper), callback)); callback);
} }
// static // static
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment