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

Side by Side Diff: storage/browser/fileapi/copy_or_move_operation_delegate.cc

Issue 669603008: Standardize usage of virtual/override/final in storage/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "storage/browser/fileapi/copy_or_move_operation_delegate.h" 5 #include "storage/browser/fileapi/copy_or_move_operation_delegate.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "net/base/io_buffer.h" 9 #include "net/base/io_buffer.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 const FileSystemOperation::CopyFileProgressCallback& 53 const FileSystemOperation::CopyFileProgressCallback&
54 file_progress_callback) 54 file_progress_callback)
55 : operation_runner_(operation_runner), 55 : operation_runner_(operation_runner),
56 operation_type_(operation_type), 56 operation_type_(operation_type),
57 src_url_(src_url), 57 src_url_(src_url),
58 dest_url_(dest_url), 58 dest_url_(dest_url),
59 option_(option), 59 option_(option),
60 file_progress_callback_(file_progress_callback) { 60 file_progress_callback_(file_progress_callback) {
61 } 61 }
62 62
63 virtual void Run( 63 void Run(
64 const CopyOrMoveOperationDelegate::StatusCallback& callback) override { 64 const CopyOrMoveOperationDelegate::StatusCallback& callback) override {
65 if (operation_type_ == CopyOrMoveOperationDelegate::OPERATION_MOVE) { 65 if (operation_type_ == CopyOrMoveOperationDelegate::OPERATION_MOVE) {
66 operation_runner_->MoveFileLocal(src_url_, dest_url_, option_, callback); 66 operation_runner_->MoveFileLocal(src_url_, dest_url_, option_, callback);
67 } else { 67 } else {
68 operation_runner_->CopyFileLocal( 68 operation_runner_->CopyFileLocal(
69 src_url_, dest_url_, option_, file_progress_callback_, callback); 69 src_url_, dest_url_, option_, file_progress_callback_, callback);
70 } 70 }
71 } 71 }
72 72
73 virtual void Cancel() override { 73 void Cancel() override {
74 // We can do nothing for the copy/move operation on a local file system. 74 // We can do nothing for the copy/move operation on a local file system.
75 // Assuming the operation is quickly done, it should be ok to just wait 75 // Assuming the operation is quickly done, it should be ok to just wait
76 // for the completion. 76 // for the completion.
77 } 77 }
78 78
79 private: 79 private:
80 FileSystemOperationRunner* operation_runner_; 80 FileSystemOperationRunner* operation_runner_;
81 CopyOrMoveOperationDelegate::OperationType operation_type_; 81 CopyOrMoveOperationDelegate::OperationType operation_type_;
82 FileSystemURL src_url_; 82 FileSystemURL src_url_;
83 FileSystemURL dest_url_; 83 FileSystemURL dest_url_;
(...skipping 22 matching lines...) Expand all
106 operation_type_(operation_type), 106 operation_type_(operation_type),
107 src_url_(src_url), 107 src_url_(src_url),
108 dest_url_(dest_url), 108 dest_url_(dest_url),
109 option_(option), 109 option_(option),
110 validator_factory_(validator_factory), 110 validator_factory_(validator_factory),
111 file_progress_callback_(file_progress_callback), 111 file_progress_callback_(file_progress_callback),
112 cancel_requested_(false), 112 cancel_requested_(false),
113 weak_factory_(this) { 113 weak_factory_(this) {
114 } 114 }
115 115
116 virtual void Run( 116 void Run(
117 const CopyOrMoveOperationDelegate::StatusCallback& callback) override { 117 const CopyOrMoveOperationDelegate::StatusCallback& callback) override {
118 file_progress_callback_.Run(0); 118 file_progress_callback_.Run(0);
119 operation_runner_->CreateSnapshotFile( 119 operation_runner_->CreateSnapshotFile(
120 src_url_, 120 src_url_,
121 base::Bind(&SnapshotCopyOrMoveImpl::RunAfterCreateSnapshot, 121 base::Bind(&SnapshotCopyOrMoveImpl::RunAfterCreateSnapshot,
122 weak_factory_.GetWeakPtr(), callback)); 122 weak_factory_.GetWeakPtr(), callback));
123 } 123 }
124 124
125 virtual void Cancel() override { 125 void Cancel() override { cancel_requested_ = true; }
126 cancel_requested_ = true;
127 }
128 126
129 private: 127 private:
130 void RunAfterCreateSnapshot( 128 void RunAfterCreateSnapshot(
131 const CopyOrMoveOperationDelegate::StatusCallback& callback, 129 const CopyOrMoveOperationDelegate::StatusCallback& callback,
132 base::File::Error error, 130 base::File::Error error,
133 const base::File::Info& file_info, 131 const base::File::Info& file_info,
134 const base::FilePath& platform_path, 132 const base::FilePath& platform_path,
135 const scoped_refptr<storage::ShareableFileReference>& file_ref) { 133 const scoped_refptr<storage::ShareableFileReference>& file_ref) {
136 if (cancel_requested_) 134 if (cancel_requested_)
137 error = base::File::FILE_ERROR_ABORT; 135 error = base::File::FILE_ERROR_ABORT;
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 operation_type_(operation_type), 379 operation_type_(operation_type),
382 src_url_(src_url), 380 src_url_(src_url),
383 dest_url_(dest_url), 381 dest_url_(dest_url),
384 option_(option), 382 option_(option),
385 reader_(reader.Pass()), 383 reader_(reader.Pass()),
386 writer_(writer.Pass()), 384 writer_(writer.Pass()),
387 file_progress_callback_(file_progress_callback), 385 file_progress_callback_(file_progress_callback),
388 cancel_requested_(false), 386 cancel_requested_(false),
389 weak_factory_(this) {} 387 weak_factory_(this) {}
390 388
391 virtual void Run( 389 void Run(
392 const CopyOrMoveOperationDelegate::StatusCallback& callback) override { 390 const CopyOrMoveOperationDelegate::StatusCallback& callback) override {
393 // Reader can be created even if the entry does not exist or the entry is 391 // Reader can be created even if the entry does not exist or the entry is
394 // a directory. To check errors before destination file creation, 392 // a directory. To check errors before destination file creation,
395 // check metadata first. 393 // check metadata first.
396 operation_runner_->GetMetadata( 394 operation_runner_->GetMetadata(
397 src_url_, 395 src_url_,
398 base::Bind(&StreamCopyOrMoveImpl::RunAfterGetMetadataForSource, 396 base::Bind(&StreamCopyOrMoveImpl::RunAfterGetMetadataForSource,
399 weak_factory_.GetWeakPtr(), callback)); 397 weak_factory_.GetWeakPtr(), callback));
400 } 398 }
401 399
402 virtual void Cancel() override { 400 void Cancel() override {
403 cancel_requested_ = true; 401 cancel_requested_ = true;
404 if (copy_helper_) 402 if (copy_helper_)
405 copy_helper_->Cancel(); 403 copy_helper_->Cancel();
406 } 404 }
407 405
408 private: 406 private:
409 void NotifyOnStartUpdate(const FileSystemURL& url) { 407 void NotifyOnStartUpdate(const FileSystemURL& url) {
410 if (file_system_context_->GetUpdateObservers(url.type())) { 408 if (file_system_context_->GetUpdateObservers(url.type())) {
411 file_system_context_->GetUpdateObservers(url.type()) 409 file_system_context_->GetUpdateObservers(url.type())
412 ->Notify(&FileUpdateObserver::OnStartUpdate, MakeTuple(url)); 410 ->Notify(&FileUpdateObserver::OnStartUpdate, MakeTuple(url));
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 base::FilePath relative = dest_root_.virtual_path(); 1023 base::FilePath relative = dest_root_.virtual_path();
1026 src_root_.virtual_path().AppendRelativePath(src_url.virtual_path(), 1024 src_root_.virtual_path().AppendRelativePath(src_url.virtual_path(),
1027 &relative); 1025 &relative);
1028 return file_system_context()->CreateCrackedFileSystemURL( 1026 return file_system_context()->CreateCrackedFileSystemURL(
1029 dest_root_.origin(), 1027 dest_root_.origin(),
1030 dest_root_.mount_type(), 1028 dest_root_.mount_type(),
1031 relative); 1029 relative);
1032 } 1030 }
1033 1031
1034 } // namespace storage 1032 } // namespace storage
OLDNEW
« no previous file with comments | « storage/browser/fileapi/copy_or_move_operation_delegate.h ('k') | storage/browser/fileapi/dragged_file_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698