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

Side by Side Diff: chrome/browser/media_galleries/linux/mtp_read_file_worker.cc

Issue 1551503002: Convert Pass()→std::move() in //chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/media_galleries/linux/mtp_read_file_worker.h" 5 #include "chrome/browser/media_galleries/linux/mtp_read_file_worker.h"
6 6
7 #include <utility>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
10 #include "base/numerics/safe_conversions.h" 12 #include "base/numerics/safe_conversions.h"
11 #include "chrome/browser/media_galleries/linux/snapshot_file_details.h" 13 #include "chrome/browser/media_galleries/linux/snapshot_file_details.h"
12 #include "components/storage_monitor/storage_monitor.h" 14 #include "components/storage_monitor/storage_monitor.h"
13 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
14 #include "device/media_transfer_protocol/media_transfer_protocol_manager.h" 16 #include "device/media_transfer_protocol/media_transfer_protocol_manager.h"
15 #include "third_party/cros_system_api/dbus/service_constants.h" 17 #include "third_party/cros_system_api/dbus/service_constants.h"
16 18
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 78
77 void MTPReadFileWorker::OnDidReadDataChunkFromDeviceFile( 79 void MTPReadFileWorker::OnDidReadDataChunkFromDeviceFile(
78 scoped_ptr<SnapshotFileDetails> snapshot_file_details, 80 scoped_ptr<SnapshotFileDetails> snapshot_file_details,
79 const std::string& data, 81 const std::string& data,
80 bool error) { 82 bool error) {
81 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 83 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
82 DCHECK(snapshot_file_details.get()); 84 DCHECK(snapshot_file_details.get());
83 snapshot_file_details->set_error_occurred( 85 snapshot_file_details->set_error_occurred(
84 error || (data.size() != snapshot_file_details->BytesToRead())); 86 error || (data.size() != snapshot_file_details->BytesToRead()));
85 if (snapshot_file_details->error_occurred()) { 87 if (snapshot_file_details->error_occurred()) {
86 OnDidWriteIntoSnapshotFile(snapshot_file_details.Pass()); 88 OnDidWriteIntoSnapshotFile(std::move(snapshot_file_details));
87 return; 89 return;
88 } 90 }
89 91
90 // To avoid calling |snapshot_file_details| methods and passing ownership of 92 // To avoid calling |snapshot_file_details| methods and passing ownership of
91 // |snapshot_file_details| in the same_line. 93 // |snapshot_file_details| in the same_line.
92 SnapshotFileDetails* snapshot_file_details_ptr = snapshot_file_details.get(); 94 SnapshotFileDetails* snapshot_file_details_ptr = snapshot_file_details.get();
93 content::BrowserThread::PostTaskAndReplyWithResult( 95 content::BrowserThread::PostTaskAndReplyWithResult(
94 content::BrowserThread::FILE, 96 content::BrowserThread::FILE,
95 FROM_HERE, 97 FROM_HERE,
96 base::Bind(&WriteDataChunkIntoSnapshotFileOnFileThread, 98 base::Bind(&WriteDataChunkIntoSnapshotFileOnFileThread,
97 snapshot_file_details_ptr->snapshot_file_path(), 99 snapshot_file_details_ptr->snapshot_file_path(),
98 data), 100 data),
99 base::Bind(&MTPReadFileWorker::OnDidWriteDataChunkIntoSnapshotFile, 101 base::Bind(&MTPReadFileWorker::OnDidWriteDataChunkIntoSnapshotFile,
100 weak_ptr_factory_.GetWeakPtr(), 102 weak_ptr_factory_.GetWeakPtr(),
101 base::Passed(&snapshot_file_details))); 103 base::Passed(&snapshot_file_details)));
102 } 104 }
103 105
104 void MTPReadFileWorker::OnDidWriteDataChunkIntoSnapshotFile( 106 void MTPReadFileWorker::OnDidWriteDataChunkIntoSnapshotFile(
105 scoped_ptr<SnapshotFileDetails> snapshot_file_details, 107 scoped_ptr<SnapshotFileDetails> snapshot_file_details,
106 uint32_t bytes_written) { 108 uint32_t bytes_written) {
107 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 109 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
108 DCHECK(snapshot_file_details.get()); 110 DCHECK(snapshot_file_details.get());
109 if (snapshot_file_details->AddBytesWritten(bytes_written)) { 111 if (snapshot_file_details->AddBytesWritten(bytes_written)) {
110 if (!snapshot_file_details->IsSnapshotFileWriteComplete()) { 112 if (!snapshot_file_details->IsSnapshotFileWriteComplete()) {
111 ReadDataChunkFromDeviceFile(snapshot_file_details.Pass()); 113 ReadDataChunkFromDeviceFile(std::move(snapshot_file_details));
112 return; 114 return;
113 } 115 }
114 } else { 116 } else {
115 snapshot_file_details->set_error_occurred(true); 117 snapshot_file_details->set_error_occurred(true);
116 } 118 }
117 OnDidWriteIntoSnapshotFile(snapshot_file_details.Pass()); 119 OnDidWriteIntoSnapshotFile(std::move(snapshot_file_details));
118 } 120 }
119 121
120 void MTPReadFileWorker::OnDidWriteIntoSnapshotFile( 122 void MTPReadFileWorker::OnDidWriteIntoSnapshotFile(
121 scoped_ptr<SnapshotFileDetails> snapshot_file_details) { 123 scoped_ptr<SnapshotFileDetails> snapshot_file_details) {
122 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 124 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
123 DCHECK(snapshot_file_details.get()); 125 DCHECK(snapshot_file_details.get());
124 126
125 if (snapshot_file_details->error_occurred()) { 127 if (snapshot_file_details->error_occurred()) {
126 content::BrowserThread::PostTask( 128 content::BrowserThread::PostTask(
127 content::BrowserThread::IO, 129 content::BrowserThread::IO,
128 FROM_HERE, 130 FROM_HERE,
129 base::Bind(snapshot_file_details->error_callback(), 131 base::Bind(snapshot_file_details->error_callback(),
130 base::File::FILE_ERROR_FAILED)); 132 base::File::FILE_ERROR_FAILED));
131 return; 133 return;
132 } 134 }
133 content::BrowserThread::PostTask( 135 content::BrowserThread::PostTask(
134 content::BrowserThread::IO, 136 content::BrowserThread::IO,
135 FROM_HERE, 137 FROM_HERE,
136 base::Bind(snapshot_file_details->success_callback(), 138 base::Bind(snapshot_file_details->success_callback(),
137 snapshot_file_details->file_info(), 139 snapshot_file_details->file_info(),
138 snapshot_file_details->snapshot_file_path())); 140 snapshot_file_details->snapshot_file_path()));
139 } 141 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698