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

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

Issue 1546243002: Convert Pass()→std::move() in //storage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 <stdint.h> 7 #include <stdint.h>
8 #include <utility>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "net/base/io_buffer.h" 13 #include "net/base/io_buffer.h"
13 #include "net/base/net_errors.h" 14 #include "net/base/net_errors.h"
14 #include "storage/browser/blob/shareable_file_reference.h" 15 #include "storage/browser/blob/shareable_file_reference.h"
15 #include "storage/browser/fileapi/copy_or_move_file_validator.h" 16 #include "storage/browser/fileapi/copy_or_move_file_validator.h"
16 #include "storage/browser/fileapi/file_observers.h" 17 #include "storage/browser/fileapi/file_observers.h"
17 #include "storage/browser/fileapi/file_stream_reader.h" 18 #include "storage/browser/fileapi/file_stream_reader.h"
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 scoped_ptr<storage::FileStreamReader> reader, 376 scoped_ptr<storage::FileStreamReader> reader,
376 scoped_ptr<FileStreamWriter> writer, 377 scoped_ptr<FileStreamWriter> writer,
377 const FileSystemOperation::CopyFileProgressCallback& 378 const FileSystemOperation::CopyFileProgressCallback&
378 file_progress_callback) 379 file_progress_callback)
379 : operation_runner_(operation_runner), 380 : operation_runner_(operation_runner),
380 file_system_context_(file_system_context), 381 file_system_context_(file_system_context),
381 operation_type_(operation_type), 382 operation_type_(operation_type),
382 src_url_(src_url), 383 src_url_(src_url),
383 dest_url_(dest_url), 384 dest_url_(dest_url),
384 option_(option), 385 option_(option),
385 reader_(reader.Pass()), 386 reader_(std::move(reader)),
386 writer_(writer.Pass()), 387 writer_(std::move(writer)),
387 file_progress_callback_(file_progress_callback), 388 file_progress_callback_(file_progress_callback),
388 cancel_requested_(false), 389 cancel_requested_(false),
389 weak_factory_(this) {} 390 weak_factory_(this) {}
390 391
391 void Run( 392 void Run(
392 const CopyOrMoveOperationDelegate::StatusCallback& callback) override { 393 const CopyOrMoveOperationDelegate::StatusCallback& callback) override {
393 // Reader can be created even if the entry does not exist or the entry is 394 // 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, 395 // a directory. To check errors before destination file creation,
395 // check metadata first. 396 // check metadata first.
396 operation_runner_->GetMetadata( 397 operation_runner_->GetMetadata(
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 error = base::File::FILE_ERROR_ABORT; 496 error = base::File::FILE_ERROR_ABORT;
496 497
497 if (error != base::File::FILE_OK) { 498 if (error != base::File::FILE_OK) {
498 callback.Run(error); 499 callback.Run(error);
499 return; 500 return;
500 } 501 }
501 502
502 NotifyOnStartUpdate(dest_url_); 503 NotifyOnStartUpdate(dest_url_);
503 DCHECK(!copy_helper_); 504 DCHECK(!copy_helper_);
504 copy_helper_.reset(new CopyOrMoveOperationDelegate::StreamCopyHelper( 505 copy_helper_.reset(new CopyOrMoveOperationDelegate::StreamCopyHelper(
505 reader_.Pass(), writer_.Pass(), dest_url_.mount_option().flush_policy(), 506 std::move(reader_), std::move(writer_),
506 kReadBufferSize, file_progress_callback_, 507 dest_url_.mount_option().flush_policy(), kReadBufferSize,
508 file_progress_callback_,
507 base::TimeDelta::FromMilliseconds( 509 base::TimeDelta::FromMilliseconds(
508 kMinProgressCallbackInvocationSpanInMilliseconds))); 510 kMinProgressCallbackInvocationSpanInMilliseconds)));
509 copy_helper_->Run( 511 copy_helper_->Run(
510 base::Bind(&StreamCopyOrMoveImpl::RunAfterStreamCopy, 512 base::Bind(&StreamCopyOrMoveImpl::RunAfterStreamCopy,
511 weak_factory_.GetWeakPtr(), callback, last_modified)); 513 weak_factory_.GetWeakPtr(), callback, last_modified));
512 } 514 }
513 515
514 void RunAfterStreamCopy( 516 void RunAfterStreamCopy(
515 const CopyOrMoveOperationDelegate::StatusCallback& callback, 517 const CopyOrMoveOperationDelegate::StatusCallback& callback,
516 const base::Time& last_modified, 518 const base::Time& last_modified,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 588
587 } // namespace 589 } // namespace
588 590
589 CopyOrMoveOperationDelegate::StreamCopyHelper::StreamCopyHelper( 591 CopyOrMoveOperationDelegate::StreamCopyHelper::StreamCopyHelper(
590 scoped_ptr<storage::FileStreamReader> reader, 592 scoped_ptr<storage::FileStreamReader> reader,
591 scoped_ptr<FileStreamWriter> writer, 593 scoped_ptr<FileStreamWriter> writer,
592 storage::FlushPolicy flush_policy, 594 storage::FlushPolicy flush_policy,
593 int buffer_size, 595 int buffer_size,
594 const FileSystemOperation::CopyFileProgressCallback& file_progress_callback, 596 const FileSystemOperation::CopyFileProgressCallback& file_progress_callback,
595 const base::TimeDelta& min_progress_callback_invocation_span) 597 const base::TimeDelta& min_progress_callback_invocation_span)
596 : reader_(reader.Pass()), 598 : reader_(std::move(reader)),
597 writer_(writer.Pass()), 599 writer_(std::move(writer)),
598 flush_policy_(flush_policy), 600 flush_policy_(flush_policy),
599 file_progress_callback_(file_progress_callback), 601 file_progress_callback_(file_progress_callback),
600 io_buffer_(new net::IOBufferWithSize(buffer_size)), 602 io_buffer_(new net::IOBufferWithSize(buffer_size)),
601 num_copied_bytes_(0), 603 num_copied_bytes_(0),
602 previous_flush_offset_(0), 604 previous_flush_offset_(0),
603 min_progress_callback_invocation_span_( 605 min_progress_callback_invocation_span_(
604 min_progress_callback_invocation_span), 606 min_progress_callback_invocation_span),
605 cancel_requested_(false), 607 cancel_requested_(false),
606 weak_factory_(this) { 608 weak_factory_(this) {}
607 }
608 609
609 CopyOrMoveOperationDelegate::StreamCopyHelper::~StreamCopyHelper() { 610 CopyOrMoveOperationDelegate::StreamCopyHelper::~StreamCopyHelper() {
610 } 611 }
611 612
612 void CopyOrMoveOperationDelegate::StreamCopyHelper::Run( 613 void CopyOrMoveOperationDelegate::StreamCopyHelper::Run(
613 const StatusCallback& callback) { 614 const StatusCallback& callback) {
614 file_progress_callback_.Run(0); 615 file_progress_callback_.Run(0);
615 last_progress_callback_invocation_time_ = base::Time::Now(); 616 last_progress_callback_invocation_time_ = base::Time::Now();
616 Read(callback); 617 Read(callback);
617 } 618 }
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 } 818 }
818 819
819 if (!validator_factory) { 820 if (!validator_factory) {
820 scoped_ptr<storage::FileStreamReader> reader = 821 scoped_ptr<storage::FileStreamReader> reader =
821 file_system_context()->CreateFileStreamReader( 822 file_system_context()->CreateFileStreamReader(
822 src_url, 0 /* offset */, storage::kMaximumLength, base::Time()); 823 src_url, 0 /* offset */, storage::kMaximumLength, base::Time());
823 scoped_ptr<FileStreamWriter> writer = 824 scoped_ptr<FileStreamWriter> writer =
824 file_system_context()->CreateFileStreamWriter(dest_url, 0); 825 file_system_context()->CreateFileStreamWriter(dest_url, 0);
825 if (reader && writer) { 826 if (reader && writer) {
826 impl = new StreamCopyOrMoveImpl( 827 impl = new StreamCopyOrMoveImpl(
827 operation_runner(), 828 operation_runner(), file_system_context(), operation_type_, src_url,
828 file_system_context(), 829 dest_url, option_, std::move(reader), std::move(writer),
829 operation_type_,
830 src_url,
831 dest_url,
832 option_,
833 reader.Pass(),
834 writer.Pass(),
835 base::Bind(&CopyOrMoveOperationDelegate::OnCopyFileProgress, 830 base::Bind(&CopyOrMoveOperationDelegate::OnCopyFileProgress,
836 weak_factory_.GetWeakPtr(), 831 weak_factory_.GetWeakPtr(), src_url));
837 src_url));
838 } 832 }
839 } 833 }
840 834
841 if (!impl) { 835 if (!impl) {
842 impl = new SnapshotCopyOrMoveImpl( 836 impl = new SnapshotCopyOrMoveImpl(
843 operation_runner(), operation_type_, src_url, dest_url, option_, 837 operation_runner(), operation_type_, src_url, dest_url, option_,
844 validator_factory, 838 validator_factory,
845 base::Bind(&CopyOrMoveOperationDelegate::OnCopyFileProgress, 839 base::Bind(&CopyOrMoveOperationDelegate::OnCopyFileProgress,
846 weak_factory_.GetWeakPtr(), src_url)); 840 weak_factory_.GetWeakPtr(), src_url));
847 } 841 }
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 base::FilePath relative = dest_root_.virtual_path(); 1026 base::FilePath relative = dest_root_.virtual_path();
1033 src_root_.virtual_path().AppendRelativePath(src_url.virtual_path(), 1027 src_root_.virtual_path().AppendRelativePath(src_url.virtual_path(),
1034 &relative); 1028 &relative);
1035 return file_system_context()->CreateCrackedFileSystemURL( 1029 return file_system_context()->CreateCrackedFileSystemURL(
1036 dest_root_.origin(), 1030 dest_root_.origin(),
1037 dest_root_.mount_type(), 1031 dest_root_.mount_type(),
1038 relative); 1032 relative);
1039 } 1033 }
1040 1034
1041 } // namespace storage 1035 } // namespace storage
OLDNEW
« no previous file with comments | « storage/browser/fileapi/async_file_util_adapter.cc ('k') | storage/browser/fileapi/file_system_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698