| Index: storage/browser/fileapi/copy_or_move_operation_delegate.cc
|
| diff --git a/webkit/browser/fileapi/copy_or_move_operation_delegate.cc b/storage/browser/fileapi/copy_or_move_operation_delegate.cc
|
| similarity index 79%
|
| rename from webkit/browser/fileapi/copy_or_move_operation_delegate.cc
|
| rename to storage/browser/fileapi/copy_or_move_operation_delegate.cc
|
| index 699e3e3c171f691a0d857b855322730f50b2c6cb..95864ed5ec8c22847ec2c7479ac5faa6fab8a5f8 100644
|
| --- a/webkit/browser/fileapi/copy_or_move_operation_delegate.cc
|
| +++ b/storage/browser/fileapi/copy_or_move_operation_delegate.cc
|
| @@ -2,23 +2,23 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "webkit/browser/fileapi/copy_or_move_operation_delegate.h"
|
| +#include "storage/browser/fileapi/copy_or_move_operation_delegate.h"
|
|
|
| #include "base/bind.h"
|
| #include "base/files/file_path.h"
|
| #include "net/base/io_buffer.h"
|
| #include "net/base/net_errors.h"
|
| -#include "webkit/browser/blob/file_stream_reader.h"
|
| -#include "webkit/browser/fileapi/copy_or_move_file_validator.h"
|
| -#include "webkit/browser/fileapi/file_stream_writer.h"
|
| -#include "webkit/browser/fileapi/file_system_context.h"
|
| -#include "webkit/browser/fileapi/file_system_operation_runner.h"
|
| -#include "webkit/browser/fileapi/file_system_url.h"
|
| -#include "webkit/browser/fileapi/recursive_operation_delegate.h"
|
| -#include "webkit/common/blob/shareable_file_reference.h"
|
| -#include "webkit/common/fileapi/file_system_util.h"
|
| -
|
| -namespace fileapi {
|
| +#include "storage/browser/blob/file_stream_reader.h"
|
| +#include "storage/browser/fileapi/copy_or_move_file_validator.h"
|
| +#include "storage/browser/fileapi/file_stream_writer.h"
|
| +#include "storage/browser/fileapi/file_system_context.h"
|
| +#include "storage/browser/fileapi/file_system_operation_runner.h"
|
| +#include "storage/browser/fileapi/file_system_url.h"
|
| +#include "storage/browser/fileapi/recursive_operation_delegate.h"
|
| +#include "storage/common/blob/shareable_file_reference.h"
|
| +#include "storage/common/fileapi/file_system_util.h"
|
| +
|
| +namespace storage {
|
|
|
| const int64 kFlushIntervalInBytes = 10 << 20; // 10MB.
|
|
|
| @@ -56,8 +56,7 @@ class CopyOrMoveOnSameFileSystemImpl
|
| src_url_(src_url),
|
| dest_url_(dest_url),
|
| option_(option),
|
| - file_progress_callback_(file_progress_callback) {
|
| - }
|
| + file_progress_callback_(file_progress_callback) {}
|
|
|
| virtual void Run(
|
| const CopyOrMoveOperationDelegate::StatusCallback& callback) OVERRIDE {
|
| @@ -109,8 +108,7 @@ class SnapshotCopyOrMoveImpl
|
| validator_factory_(validator_factory),
|
| file_progress_callback_(file_progress_callback),
|
| cancel_requested_(false),
|
| - weak_factory_(this) {
|
| - }
|
| + weak_factory_(this) {}
|
|
|
| virtual void Run(
|
| const CopyOrMoveOperationDelegate::StatusCallback& callback) OVERRIDE {
|
| @@ -118,12 +116,11 @@ class SnapshotCopyOrMoveImpl
|
| operation_runner_->CreateSnapshotFile(
|
| src_url_,
|
| base::Bind(&SnapshotCopyOrMoveImpl::RunAfterCreateSnapshot,
|
| - weak_factory_.GetWeakPtr(), callback));
|
| + weak_factory_.GetWeakPtr(),
|
| + callback));
|
| }
|
|
|
| - virtual void Cancel() OVERRIDE {
|
| - cancel_requested_ = true;
|
| - }
|
| + virtual void Cancel() OVERRIDE { cancel_requested_ = true; }
|
|
|
| private:
|
| void RunAfterCreateSnapshot(
|
| @@ -131,7 +128,7 @@ class SnapshotCopyOrMoveImpl
|
| base::File::Error error,
|
| const base::File::Info& file_info,
|
| const base::FilePath& platform_path,
|
| - const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) {
|
| + const scoped_refptr<storage::ShareableFileReference>& file_ref) {
|
| if (cancel_requested_)
|
| error = base::File::FILE_ERROR_ABORT;
|
|
|
| @@ -146,8 +143,8 @@ class SnapshotCopyOrMoveImpl
|
|
|
| if (!validator_factory_) {
|
| // No validation is needed.
|
| - RunAfterPreWriteValidation(platform_path, file_info, file_ref, callback,
|
| - base::File::FILE_OK);
|
| + RunAfterPreWriteValidation(
|
| + platform_path, file_info, file_ref, callback, base::File::FILE_OK);
|
| return;
|
| }
|
|
|
| @@ -156,13 +153,16 @@ class SnapshotCopyOrMoveImpl
|
| platform_path,
|
| base::Bind(&SnapshotCopyOrMoveImpl::RunAfterPreWriteValidation,
|
| weak_factory_.GetWeakPtr(),
|
| - platform_path, file_info, file_ref, callback));
|
| + platform_path,
|
| + file_info,
|
| + file_ref,
|
| + callback));
|
| }
|
|
|
| void RunAfterPreWriteValidation(
|
| const base::FilePath& platform_path,
|
| const base::File::Info& file_info,
|
| - const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref,
|
| + const scoped_refptr<storage::ShareableFileReference>& file_ref,
|
| const CopyOrMoveOperationDelegate::StatusCallback& callback,
|
| base::File::Error error) {
|
| if (cancel_requested_)
|
| @@ -176,14 +176,18 @@ class SnapshotCopyOrMoveImpl
|
| // |file_ref| is unused but necessary to keep the file alive until
|
| // CopyInForeignFile() is completed.
|
| operation_runner_->CopyInForeignFile(
|
| - platform_path, dest_url_,
|
| + platform_path,
|
| + dest_url_,
|
| base::Bind(&SnapshotCopyOrMoveImpl::RunAfterCopyInForeignFile,
|
| - weak_factory_.GetWeakPtr(), file_info, file_ref, callback));
|
| + weak_factory_.GetWeakPtr(),
|
| + file_info,
|
| + file_ref,
|
| + callback));
|
| }
|
|
|
| void RunAfterCopyInForeignFile(
|
| const base::File::Info& file_info,
|
| - const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref,
|
| + const scoped_refptr<storage::ShareableFileReference>& file_ref,
|
| const CopyOrMoveOperationDelegate::StatusCallback& callback,
|
| base::File::Error error) {
|
| if (cancel_requested_)
|
| @@ -202,10 +206,12 @@ class SnapshotCopyOrMoveImpl
|
| }
|
|
|
| operation_runner_->TouchFile(
|
| - dest_url_, base::Time::Now() /* last_access */,
|
| + dest_url_,
|
| + base::Time::Now() /* last_access */,
|
| file_info.last_modified,
|
| base::Bind(&SnapshotCopyOrMoveImpl::RunAfterTouchFile,
|
| - weak_factory_.GetWeakPtr(), callback));
|
| + weak_factory_.GetWeakPtr(),
|
| + callback));
|
| }
|
|
|
| void RunAfterTouchFile(
|
| @@ -228,7 +234,8 @@ class SnapshotCopyOrMoveImpl
|
|
|
| PostWriteValidation(
|
| base::Bind(&SnapshotCopyOrMoveImpl::RunAfterPostWriteValidation,
|
| - weak_factory_.GetWeakPtr(), callback));
|
| + weak_factory_.GetWeakPtr(),
|
| + callback));
|
| }
|
|
|
| void RunAfterPostWriteValidation(
|
| @@ -242,9 +249,12 @@ class SnapshotCopyOrMoveImpl
|
| if (error != base::File::FILE_OK) {
|
| // Failed to validate. Remove the destination file.
|
| operation_runner_->Remove(
|
| - dest_url_, true /* recursive */,
|
| + dest_url_,
|
| + true /* recursive */,
|
| base::Bind(&SnapshotCopyOrMoveImpl::DidRemoveDestForError,
|
| - weak_factory_.GetWeakPtr(), error, callback));
|
| + weak_factory_.GetWeakPtr(),
|
| + error,
|
| + callback));
|
| return;
|
| }
|
|
|
| @@ -257,9 +267,11 @@ class SnapshotCopyOrMoveImpl
|
|
|
| // Remove the source for finalizing move operation.
|
| operation_runner_->Remove(
|
| - src_url_, true /* recursive */,
|
| + src_url_,
|
| + true /* recursive */,
|
| base::Bind(&SnapshotCopyOrMoveImpl::RunAfterRemoveSourceForMove,
|
| - weak_factory_.GetWeakPtr(), callback));
|
| + weak_factory_.GetWeakPtr(),
|
| + callback));
|
| }
|
|
|
| void RunAfterRemoveSourceForMove(
|
| @@ -289,9 +301,8 @@ class SnapshotCopyOrMoveImpl
|
| const base::FilePath& platform_path,
|
| const CopyOrMoveOperationDelegate::StatusCallback& callback) {
|
| DCHECK(validator_factory_);
|
| - validator_.reset(
|
| - validator_factory_->CreateCopyOrMoveFileValidator(
|
| - src_url_, platform_path));
|
| + validator_.reset(validator_factory_->CreateCopyOrMoveFileValidator(
|
| + src_url_, platform_path));
|
| validator_->StartPreWriteValidation(callback);
|
| }
|
|
|
| @@ -302,7 +313,8 @@ class SnapshotCopyOrMoveImpl
|
| dest_url_,
|
| base::Bind(
|
| &SnapshotCopyOrMoveImpl::PostWriteValidationAfterCreateSnapshotFile,
|
| - weak_factory_.GetWeakPtr(), callback));
|
| + weak_factory_.GetWeakPtr(),
|
| + callback));
|
| }
|
|
|
| void PostWriteValidationAfterCreateSnapshotFile(
|
| @@ -310,7 +322,7 @@ class SnapshotCopyOrMoveImpl
|
| base::File::Error error,
|
| const base::File::Info& file_info,
|
| const base::FilePath& platform_path,
|
| - const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) {
|
| + const scoped_refptr<storage::ShareableFileReference>& file_ref) {
|
| if (cancel_requested_)
|
| error = base::File::FILE_ERROR_ABORT;
|
|
|
| @@ -325,13 +337,15 @@ class SnapshotCopyOrMoveImpl
|
| validator_->StartPostWriteValidation(
|
| platform_path,
|
| base::Bind(&SnapshotCopyOrMoveImpl::DidPostWriteValidation,
|
| - weak_factory_.GetWeakPtr(), file_ref, callback));
|
| + weak_factory_.GetWeakPtr(),
|
| + file_ref,
|
| + callback));
|
| }
|
|
|
| // |file_ref| is unused; it is passed here to make sure the reference is
|
| // alive until after post-write validation is complete.
|
| void DidPostWriteValidation(
|
| - const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref,
|
| + const scoped_refptr<storage::ShareableFileReference>& file_ref,
|
| const CopyOrMoveOperationDelegate::StatusCallback& callback,
|
| base::File::Error error) {
|
| callback.Run(error);
|
| @@ -370,7 +384,7 @@ class StreamCopyOrMoveImpl
|
| const FileSystemURL& src_url,
|
| const FileSystemURL& dest_url,
|
| CopyOrMoveOperationDelegate::CopyOrMoveOption option,
|
| - scoped_ptr<webkit_blob::FileStreamReader> reader,
|
| + scoped_ptr<storage::FileStreamReader> reader,
|
| scoped_ptr<FileStreamWriter> writer,
|
| const FileSystemOperation::CopyFileProgressCallback&
|
| file_progress_callback)
|
| @@ -383,8 +397,7 @@ class StreamCopyOrMoveImpl
|
| writer_(writer.Pass()),
|
| file_progress_callback_(file_progress_callback),
|
| cancel_requested_(false),
|
| - weak_factory_(this) {
|
| - }
|
| + weak_factory_(this) {}
|
|
|
| virtual void Run(
|
| const CopyOrMoveOperationDelegate::StatusCallback& callback) OVERRIDE {
|
| @@ -394,7 +407,8 @@ class StreamCopyOrMoveImpl
|
| operation_runner_->GetMetadata(
|
| src_url_,
|
| base::Bind(&StreamCopyOrMoveImpl::RunAfterGetMetadataForSource,
|
| - weak_factory_.GetWeakPtr(), callback));
|
| + weak_factory_.GetWeakPtr(),
|
| + callback));
|
| }
|
|
|
| virtual void Cancel() OVERRIDE {
|
| @@ -424,10 +438,12 @@ class StreamCopyOrMoveImpl
|
|
|
| // To use FileStreamWriter, we need to ensure the destination file exists.
|
| operation_runner_->CreateFile(
|
| - dest_url_, false /* exclusive */,
|
| + dest_url_,
|
| + false /* exclusive */,
|
| base::Bind(&StreamCopyOrMoveImpl::RunAfterCreateFileForDestination,
|
| weak_factory_.GetWeakPtr(),
|
| - callback, file_info.last_modified));
|
| + callback,
|
| + file_info.last_modified));
|
| }
|
|
|
| void RunAfterCreateFileForDestination(
|
| @@ -443,20 +459,21 @@ class StreamCopyOrMoveImpl
|
| }
|
|
|
| const bool need_flush = dest_url_.mount_option().copy_sync_option() ==
|
| - fileapi::COPY_SYNC_OPTION_SYNC;
|
| + storage::COPY_SYNC_OPTION_SYNC;
|
|
|
| DCHECK(!copy_helper_);
|
| - copy_helper_.reset(
|
| - new CopyOrMoveOperationDelegate::StreamCopyHelper(
|
| - reader_.Pass(), writer_.Pass(),
|
| - need_flush,
|
| - kReadBufferSize,
|
| - file_progress_callback_,
|
| - base::TimeDelta::FromMilliseconds(
|
| - kMinProgressCallbackInvocationSpanInMilliseconds)));
|
| - copy_helper_->Run(
|
| - base::Bind(&StreamCopyOrMoveImpl::RunAfterStreamCopy,
|
| - weak_factory_.GetWeakPtr(), callback, last_modified));
|
| + copy_helper_.reset(new CopyOrMoveOperationDelegate::StreamCopyHelper(
|
| + reader_.Pass(),
|
| + writer_.Pass(),
|
| + need_flush,
|
| + kReadBufferSize,
|
| + file_progress_callback_,
|
| + base::TimeDelta::FromMilliseconds(
|
| + kMinProgressCallbackInvocationSpanInMilliseconds)));
|
| + copy_helper_->Run(base::Bind(&StreamCopyOrMoveImpl::RunAfterStreamCopy,
|
| + weak_factory_.GetWeakPtr(),
|
| + callback,
|
| + last_modified));
|
| }
|
|
|
| void RunAfterStreamCopy(
|
| @@ -477,9 +494,12 @@ class StreamCopyOrMoveImpl
|
| }
|
|
|
| operation_runner_->TouchFile(
|
| - dest_url_, base::Time::Now() /* last_access */, last_modified,
|
| + dest_url_,
|
| + base::Time::Now() /* last_access */,
|
| + last_modified,
|
| base::Bind(&StreamCopyOrMoveImpl::RunAfterTouchFile,
|
| - weak_factory_.GetWeakPtr(), callback));
|
| + weak_factory_.GetWeakPtr(),
|
| + callback));
|
| }
|
|
|
| void RunAfterTouchFile(
|
| @@ -500,9 +520,11 @@ class StreamCopyOrMoveImpl
|
|
|
| // Remove the source for finalizing move operation.
|
| operation_runner_->Remove(
|
| - src_url_, false /* recursive */,
|
| + src_url_,
|
| + false /* recursive */,
|
| base::Bind(&StreamCopyOrMoveImpl::RunAfterRemoveForMove,
|
| - weak_factory_.GetWeakPtr(), callback));
|
| + weak_factory_.GetWeakPtr(),
|
| + callback));
|
| }
|
|
|
| void RunAfterRemoveForMove(
|
| @@ -520,7 +542,7 @@ class StreamCopyOrMoveImpl
|
| FileSystemURL src_url_;
|
| FileSystemURL dest_url_;
|
| CopyOrMoveOperationDelegate::CopyOrMoveOption option_;
|
| - scoped_ptr<webkit_blob::FileStreamReader> reader_;
|
| + scoped_ptr<storage::FileStreamReader> reader_;
|
| scoped_ptr<FileStreamWriter> writer_;
|
| FileSystemOperation::CopyFileProgressCallback file_progress_callback_;
|
| scoped_ptr<CopyOrMoveOperationDelegate::StreamCopyHelper> copy_helper_;
|
| @@ -532,12 +554,11 @@ class StreamCopyOrMoveImpl
|
| } // namespace
|
|
|
| CopyOrMoveOperationDelegate::StreamCopyHelper::StreamCopyHelper(
|
| - scoped_ptr<webkit_blob::FileStreamReader> reader,
|
| + scoped_ptr<storage::FileStreamReader> reader,
|
| scoped_ptr<FileStreamWriter> writer,
|
| bool need_flush,
|
| int buffer_size,
|
| - const FileSystemOperation::CopyFileProgressCallback&
|
| - file_progress_callback,
|
| + const FileSystemOperation::CopyFileProgressCallback& file_progress_callback,
|
| const base::TimeDelta& min_progress_callback_invocation_span)
|
| : reader_(reader.Pass()),
|
| writer_(writer.Pass()),
|
| @@ -569,15 +590,17 @@ void CopyOrMoveOperationDelegate::StreamCopyHelper::Cancel() {
|
| void CopyOrMoveOperationDelegate::StreamCopyHelper::Read(
|
| const StatusCallback& callback) {
|
| int result = reader_->Read(
|
| - io_buffer_.get(), io_buffer_->size(),
|
| - base::Bind(&StreamCopyHelper::DidRead,
|
| - weak_factory_.GetWeakPtr(), callback));
|
| + io_buffer_.get(),
|
| + io_buffer_->size(),
|
| + base::Bind(
|
| + &StreamCopyHelper::DidRead, weak_factory_.GetWeakPtr(), callback));
|
| if (result != net::ERR_IO_PENDING)
|
| DidRead(callback, result);
|
| }
|
|
|
| void CopyOrMoveOperationDelegate::StreamCopyHelper::DidRead(
|
| - const StatusCallback& callback, int result) {
|
| + const StatusCallback& callback,
|
| + int result) {
|
| if (cancel_requested_) {
|
| callback.Run(base::File::FILE_ERROR_ABORT);
|
| return;
|
| @@ -605,10 +628,12 @@ void CopyOrMoveOperationDelegate::StreamCopyHelper::Write(
|
| scoped_refptr<net::DrainableIOBuffer> buffer) {
|
| DCHECK_GT(buffer->BytesRemaining(), 0);
|
|
|
| - int result = writer_->Write(
|
| - buffer.get(), buffer->BytesRemaining(),
|
| - base::Bind(&StreamCopyHelper::DidWrite,
|
| - weak_factory_.GetWeakPtr(), callback, buffer));
|
| + int result = writer_->Write(buffer.get(),
|
| + buffer->BytesRemaining(),
|
| + base::Bind(&StreamCopyHelper::DidWrite,
|
| + weak_factory_.GetWeakPtr(),
|
| + callback,
|
| + buffer));
|
| if (result != net::ERR_IO_PENDING)
|
| DidWrite(callback, buffer, result);
|
| }
|
| @@ -652,16 +677,20 @@ void CopyOrMoveOperationDelegate::StreamCopyHelper::DidWrite(
|
| }
|
|
|
| void CopyOrMoveOperationDelegate::StreamCopyHelper::Flush(
|
| - const StatusCallback& callback, bool is_eof) {
|
| - int result = writer_->Flush(
|
| - base::Bind(&StreamCopyHelper::DidFlush,
|
| - weak_factory_.GetWeakPtr(), callback, is_eof));
|
| + const StatusCallback& callback,
|
| + bool is_eof) {
|
| + int result = writer_->Flush(base::Bind(&StreamCopyHelper::DidFlush,
|
| + weak_factory_.GetWeakPtr(),
|
| + callback,
|
| + is_eof));
|
| if (result != net::ERR_IO_PENDING)
|
| DidFlush(callback, is_eof, result);
|
| }
|
|
|
| void CopyOrMoveOperationDelegate::StreamCopyHelper::DidFlush(
|
| - const StatusCallback& callback, bool is_eof, int result) {
|
| + const StatusCallback& callback,
|
| + bool is_eof,
|
| + int result) {
|
| if (cancel_requested_) {
|
| callback.Run(base::File::FILE_ERROR_ABORT);
|
| return;
|
| @@ -726,9 +755,8 @@ void CopyOrMoveOperationDelegate::RunRecursively() {
|
| StartRecursiveOperation(src_root_, callback_);
|
| }
|
|
|
| -void CopyOrMoveOperationDelegate::ProcessFile(
|
| - const FileSystemURL& src_url,
|
| - const StatusCallback& callback) {
|
| +void CopyOrMoveOperationDelegate::ProcessFile(const FileSystemURL& src_url,
|
| + const StatusCallback& callback) {
|
| if (!progress_callback_.is_null()) {
|
| progress_callback_.Run(
|
| FileSystemOperation::BEGIN_COPY_ENTRY, src_url, FileSystemURL(), 0);
|
| @@ -738,9 +766,14 @@ void CopyOrMoveOperationDelegate::ProcessFile(
|
| CopyOrMoveImpl* impl = NULL;
|
| if (same_file_system_) {
|
| impl = new CopyOrMoveOnSameFileSystemImpl(
|
| - operation_runner(), operation_type_, src_url, dest_url, option_,
|
| + operation_runner(),
|
| + operation_type_,
|
| + src_url,
|
| + dest_url,
|
| + option_,
|
| base::Bind(&CopyOrMoveOperationDelegate::OnCopyFileProgress,
|
| - weak_factory_.GetWeakPtr(), src_url));
|
| + weak_factory_.GetWeakPtr(),
|
| + src_url));
|
| } else {
|
| // Cross filesystem case.
|
| base::File::Error error = base::File::FILE_ERROR_FAILED;
|
| @@ -753,34 +786,48 @@ void CopyOrMoveOperationDelegate::ProcessFile(
|
| }
|
|
|
| if (!validator_factory) {
|
| - scoped_ptr<webkit_blob::FileStreamReader> reader =
|
| + scoped_ptr<storage::FileStreamReader> reader =
|
| file_system_context()->CreateFileStreamReader(
|
| src_url, 0, base::Time());
|
| scoped_ptr<FileStreamWriter> writer =
|
| file_system_context()->CreateFileStreamWriter(dest_url, 0);
|
| if (reader && writer) {
|
| impl = new StreamCopyOrMoveImpl(
|
| - operation_runner(), operation_type_, src_url, dest_url, option_,
|
| - reader.Pass(), writer.Pass(),
|
| + operation_runner(),
|
| + operation_type_,
|
| + src_url,
|
| + dest_url,
|
| + option_,
|
| + reader.Pass(),
|
| + writer.Pass(),
|
| base::Bind(&CopyOrMoveOperationDelegate::OnCopyFileProgress,
|
| - weak_factory_.GetWeakPtr(), src_url));
|
| + weak_factory_.GetWeakPtr(),
|
| + src_url));
|
| }
|
| }
|
|
|
| if (!impl) {
|
| impl = new SnapshotCopyOrMoveImpl(
|
| - operation_runner(), operation_type_, src_url, dest_url, option_,
|
| + operation_runner(),
|
| + operation_type_,
|
| + src_url,
|
| + dest_url,
|
| + option_,
|
| validator_factory,
|
| base::Bind(&CopyOrMoveOperationDelegate::OnCopyFileProgress,
|
| - weak_factory_.GetWeakPtr(), src_url));
|
| + weak_factory_.GetWeakPtr(),
|
| + src_url));
|
| }
|
| }
|
|
|
| // Register the running task.
|
| running_copy_set_.insert(impl);
|
| - impl->Run(base::Bind(
|
| - &CopyOrMoveOperationDelegate::DidCopyOrMoveFile,
|
| - weak_factory_.GetWeakPtr(), src_url, dest_url, callback, impl));
|
| + impl->Run(base::Bind(&CopyOrMoveOperationDelegate::DidCopyOrMoveFile,
|
| + weak_factory_.GetWeakPtr(),
|
| + src_url,
|
| + dest_url,
|
| + callback,
|
| + impl));
|
| }
|
|
|
| void CopyOrMoveOperationDelegate::ProcessDirectory(
|
| @@ -795,7 +842,8 @@ void CopyOrMoveOperationDelegate::ProcessDirectory(
|
| operation_runner()->RemoveDirectory(
|
| dest_root_,
|
| base::Bind(&CopyOrMoveOperationDelegate::DidTryRemoveDestRoot,
|
| - weak_factory_.GetWeakPtr(), callback));
|
| + weak_factory_.GetWeakPtr(),
|
| + callback));
|
| return;
|
| }
|
|
|
| @@ -811,8 +859,7 @@ void CopyOrMoveOperationDelegate::PostProcessDirectory(
|
| const FileSystemURL& src_url,
|
| const StatusCallback& callback) {
|
| if (option_ == FileSystemOperation::OPTION_NONE) {
|
| - PostProcessDirectoryAfterTouchFile(
|
| - src_url, callback, base::File::FILE_OK);
|
| + PostProcessDirectoryAfterTouchFile(src_url, callback, base::File::FILE_OK);
|
| return;
|
| }
|
|
|
| @@ -820,13 +867,16 @@ void CopyOrMoveOperationDelegate::PostProcessDirectory(
|
| src_url,
|
| base::Bind(
|
| &CopyOrMoveOperationDelegate::PostProcessDirectoryAfterGetMetadata,
|
| - weak_factory_.GetWeakPtr(), src_url, callback));
|
| + weak_factory_.GetWeakPtr(),
|
| + src_url,
|
| + callback));
|
| }
|
|
|
| void CopyOrMoveOperationDelegate::OnCancel() {
|
| // Request to cancel all running Copy/Move file.
|
| for (std::set<CopyOrMoveImpl*>::iterator iter = running_copy_set_.begin();
|
| - iter != running_copy_set_.end(); ++iter)
|
| + iter != running_copy_set_.end();
|
| + ++iter)
|
| (*iter)->Cancel();
|
| }
|
|
|
| @@ -872,9 +922,14 @@ void CopyOrMoveOperationDelegate::ProcessDirectoryInternal(
|
| // negative performance impact.
|
| // See http://crbug.com/171284 for more details.
|
| operation_runner()->CreateDirectory(
|
| - dest_url, false /* exclusive */, false /* recursive */,
|
| + dest_url,
|
| + false /* exclusive */,
|
| + false /* recursive */,
|
| base::Bind(&CopyOrMoveOperationDelegate::DidCreateDirectory,
|
| - weak_factory_.GetWeakPtr(), src_url, dest_url, callback));
|
| + weak_factory_.GetWeakPtr(),
|
| + src_url,
|
| + dest_url,
|
| + callback));
|
| }
|
|
|
| void CopyOrMoveOperationDelegate::DidCreateDirectory(
|
| @@ -897,17 +952,19 @@ void CopyOrMoveOperationDelegate::PostProcessDirectoryAfterGetMetadata(
|
| const base::File::Info& file_info) {
|
| if (error != base::File::FILE_OK) {
|
| // Ignore the error, and run post process which should run after TouchFile.
|
| - PostProcessDirectoryAfterTouchFile(
|
| - src_url, callback, base::File::FILE_OK);
|
| + PostProcessDirectoryAfterTouchFile(src_url, callback, base::File::FILE_OK);
|
| return;
|
| }
|
|
|
| operation_runner()->TouchFile(
|
| - CreateDestURL(src_url), base::Time::Now() /* last access */,
|
| + CreateDestURL(src_url),
|
| + base::Time::Now() /* last access */,
|
| file_info.last_modified,
|
| base::Bind(
|
| &CopyOrMoveOperationDelegate::PostProcessDirectoryAfterTouchFile,
|
| - weak_factory_.GetWeakPtr(), src_url, callback));
|
| + weak_factory_.GetWeakPtr(),
|
| + src_url,
|
| + callback));
|
| }
|
|
|
| void CopyOrMoveOperationDelegate::PostProcessDirectoryAfterTouchFile(
|
| @@ -926,9 +983,11 @@ void CopyOrMoveOperationDelegate::PostProcessDirectoryAfterTouchFile(
|
| // All files and subdirectories in the directory should be moved here,
|
| // so remove the source directory for finalizing move operation.
|
| operation_runner()->Remove(
|
| - src_url, false /* recursive */,
|
| + src_url,
|
| + false /* recursive */,
|
| base::Bind(&CopyOrMoveOperationDelegate::DidRemoveSourceForMove,
|
| - weak_factory_.GetWeakPtr(), callback));
|
| + weak_factory_.GetWeakPtr(),
|
| + callback));
|
| }
|
|
|
| void CopyOrMoveOperationDelegate::DidRemoveSourceForMove(
|
| @@ -940,7 +999,8 @@ void CopyOrMoveOperationDelegate::DidRemoveSourceForMove(
|
| }
|
|
|
| void CopyOrMoveOperationDelegate::OnCopyFileProgress(
|
| - const FileSystemURL& src_url, int64 size) {
|
| + const FileSystemURL& src_url,
|
| + int64 size) {
|
| if (!progress_callback_.is_null()) {
|
| progress_callback_.Run(
|
| FileSystemOperation::PROGRESS, src_url, FileSystemURL(), size);
|
| @@ -956,9 +1016,7 @@ FileSystemURL CopyOrMoveOperationDelegate::CreateDestURL(
|
| src_root_.virtual_path().AppendRelativePath(src_url.virtual_path(),
|
| &relative);
|
| return file_system_context()->CreateCrackedFileSystemURL(
|
| - dest_root_.origin(),
|
| - dest_root_.mount_type(),
|
| - relative);
|
| + dest_root_.origin(), dest_root_.mount_type(), relative);
|
| }
|
|
|
| -} // namespace fileapi
|
| +} // namespace storage
|
|
|