Index: storage/browser/fileapi/copy_or_move_operation_delegate.cc |
diff --git a/storage/browser/fileapi/copy_or_move_operation_delegate.cc b/storage/browser/fileapi/copy_or_move_operation_delegate.cc |
index 10955d9c7c098f402b9bd39f62e49b03fea36276..5b64fbf20c36b7faa12de1fd79d3c2c2421f0e08 100644 |
--- a/storage/browser/fileapi/copy_or_move_operation_delegate.cc |
+++ b/storage/browser/fileapi/copy_or_move_operation_delegate.cc |
@@ -46,6 +46,7 @@ class CopyOrMoveOnSameFileSystemImpl |
public: |
CopyOrMoveOnSameFileSystemImpl( |
FileSystemOperationRunner* operation_runner, |
+ FileSystemContext* file_system_context, |
CopyOrMoveOperationDelegate::OperationType operation_type, |
const FileSystemURL& src_url, |
const FileSystemURL& dest_url, |
@@ -53,21 +54,46 @@ class CopyOrMoveOnSameFileSystemImpl |
const FileSystemOperation::CopyFileProgressCallback& |
file_progress_callback) |
: operation_runner_(operation_runner), |
+ file_system_context_(file_system_context), |
operation_type_(operation_type), |
src_url_(src_url), |
dest_url_(dest_url), |
option_(option), |
- file_progress_callback_(file_progress_callback) { |
- } |
+ file_progress_callback_(file_progress_callback), |
+ weak_factory_(this) {} |
virtual void Run( |
const CopyOrMoveOperationDelegate::StatusCallback& callback) OVERRIDE { |
+ NotifyOnStartUpdate(dest_url_); |
tzik
2014/09/17 04:10:19
Since the notification is already sent by FileSyst
tzik
2014/09/17 05:03:05
Sorry, I misunderstood the structure.
This notific
iseki
2014/09/17 06:21:45
Done.
iseki
2014/09/17 06:21:45
Done.
|
if (operation_type_ == CopyOrMoveOperationDelegate::OPERATION_MOVE) { |
- operation_runner_->MoveFileLocal(src_url_, dest_url_, option_, callback); |
+ NotifyOnStartUpdate(src_url_); |
+ operation_runner_->MoveFileLocal( |
+ src_url_, |
+ dest_url_, |
+ option_, |
+ base::Bind(&CopyOrMoveOnSameFileSystemImpl::DidCopyOrMove, |
+ weak_factory_.GetWeakPtr(), |
+ callback)); |
} else { |
operation_runner_->CopyFileLocal( |
- src_url_, dest_url_, option_, file_progress_callback_, callback); |
+ src_url_, |
+ dest_url_, |
+ option_, |
+ file_progress_callback_, |
+ base::Bind(&CopyOrMoveOnSameFileSystemImpl::DidCopyOrMove, |
+ weak_factory_.GetWeakPtr(), |
+ callback)); |
+ } |
+ } |
+ |
+ void DidCopyOrMove( |
+ const CopyOrMoveOperationDelegate::StatusCallback& callback, |
+ base::File::Error error) { |
+ if (operation_type_ == CopyOrMoveOperationDelegate::OPERATION_MOVE) { |
+ NotifyOnEndUpdate(src_url_); |
} |
+ NotifyOnEndUpdate(dest_url_); |
+ callback.Run(error); |
} |
virtual void Cancel() OVERRIDE { |
@@ -77,12 +103,28 @@ class CopyOrMoveOnSameFileSystemImpl |
} |
private: |
+ void NotifyOnStartUpdate(const FileSystemURL& url) { |
+ if (file_system_context_->GetUpdateObservers(url.type())) { |
+ file_system_context_->GetUpdateObservers(url.type()) |
+ ->Notify(&FileUpdateObserver::OnStartUpdate, MakeTuple(url)); |
+ } |
+ } |
+ |
+ void NotifyOnEndUpdate(const FileSystemURL& url) { |
+ if (file_system_context_->GetUpdateObservers(url.type())) { |
+ file_system_context_->GetUpdateObservers(url.type()) |
+ ->Notify(&FileUpdateObserver::OnEndUpdate, MakeTuple(url)); |
+ } |
+ } |
+ |
FileSystemOperationRunner* operation_runner_; |
+ scoped_refptr<FileSystemContext> file_system_context_; |
CopyOrMoveOperationDelegate::OperationType operation_type_; |
FileSystemURL src_url_; |
FileSystemURL dest_url_; |
CopyOrMoveOperationDelegate::CopyOrMoveOption option_; |
FileSystemOperation::CopyFileProgressCallback file_progress_callback_; |
+ base::WeakPtrFactory<CopyOrMoveOnSameFileSystemImpl> weak_factory_; |
DISALLOW_COPY_AND_ASSIGN(CopyOrMoveOnSameFileSystemImpl); |
}; |
@@ -801,9 +843,15 @@ void CopyOrMoveOperationDelegate::ProcessFile( |
->HasInplaceCopyImplementation(src_url.type()) || |
operation_type_ == OPERATION_MOVE)) { |
impl = new CopyOrMoveOnSameFileSystemImpl( |
- operation_runner(), operation_type_, src_url, dest_url, option_, |
+ operation_runner(), |
+ file_system_context(), |
+ 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; |