OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/file_system_operation_impl.h" | 5 #include "storage/browser/fileapi/file_system_operation_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | |
9 #include <limits> | 8 #include <limits> |
| 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "base/trace_event/trace_event.h" | 15 #include "base/trace_event/trace_event.h" |
16 #include "net/base/escape.h" | 16 #include "net/base/escape.h" |
17 #include "net/url_request/url_request.h" | 17 #include "net/url_request/url_request.h" |
18 #include "storage/browser/blob/shareable_file_reference.h" | 18 #include "storage/browser/blob/shareable_file_reference.h" |
19 #include "storage/browser/fileapi/async_file_util.h" | 19 #include "storage/browser/fileapi/async_file_util.h" |
(...skipping 22 matching lines...) Expand all Loading... |
42 base::WeakPtr<FileSystemOperationImpl> operation, | 42 base::WeakPtr<FileSystemOperationImpl> operation, |
43 const FileSystemOperationImpl::OpenFileCallback& callback, | 43 const FileSystemOperationImpl::OpenFileCallback& callback, |
44 base::File file, | 44 base::File file, |
45 const base::Closure& on_close_callback) { | 45 const base::Closure& on_close_callback) { |
46 if (!operation) { | 46 if (!operation) { |
47 context->default_file_task_runner()->PostTask( | 47 context->default_file_task_runner()->PostTask( |
48 FROM_HERE, | 48 FROM_HERE, |
49 base::Bind(&Destruct, base::Passed(&file))); | 49 base::Bind(&Destruct, base::Passed(&file))); |
50 return; | 50 return; |
51 } | 51 } |
52 callback.Run(file.Pass(), on_close_callback); | 52 callback.Run(std::move(file), on_close_callback); |
53 } | 53 } |
54 | 54 |
55 } // namespace | 55 } // namespace |
56 | 56 |
57 FileSystemOperation* FileSystemOperation::Create( | 57 FileSystemOperation* FileSystemOperation::Create( |
58 const FileSystemURL& url, | 58 const FileSystemURL& url, |
59 FileSystemContext* file_system_context, | 59 FileSystemContext* file_system_context, |
60 scoped_ptr<FileSystemOperationContext> operation_context) { | 60 scoped_ptr<FileSystemOperationContext> operation_context) { |
61 return new FileSystemOperationImpl(url, file_system_context, | 61 return new FileSystemOperationImpl(url, file_system_context, |
62 operation_context.Pass()); | 62 std::move(operation_context)); |
63 } | 63 } |
64 | 64 |
65 FileSystemOperationImpl::~FileSystemOperationImpl() { | 65 FileSystemOperationImpl::~FileSystemOperationImpl() { |
66 } | 66 } |
67 | 67 |
68 void FileSystemOperationImpl::CreateFile(const FileSystemURL& url, | 68 void FileSystemOperationImpl::CreateFile(const FileSystemURL& url, |
69 bool exclusive, | 69 bool exclusive, |
70 const StatusCallback& callback) { | 70 const StatusCallback& callback) { |
71 // crbug.com/349708 | 71 // crbug.com/349708 |
72 TRACE_EVENT0("io", "FileSystemOperationImpl::CreateFile"); | 72 TRACE_EVENT0("io", "FileSystemOperationImpl::CreateFile"); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 FileSystemOperation::CopyProgressCallback(), | 128 FileSystemOperation::CopyProgressCallback(), |
129 base::Bind(&FileSystemOperationImpl::DidFinishOperation, | 129 base::Bind(&FileSystemOperationImpl::DidFinishOperation, |
130 weak_factory_.GetWeakPtr(), callback))); | 130 weak_factory_.GetWeakPtr(), callback))); |
131 recursive_operation_delegate_->RunRecursively(); | 131 recursive_operation_delegate_->RunRecursively(); |
132 } | 132 } |
133 | 133 |
134 void FileSystemOperationImpl::DirectoryExists(const FileSystemURL& url, | 134 void FileSystemOperationImpl::DirectoryExists(const FileSystemURL& url, |
135 const StatusCallback& callback) { | 135 const StatusCallback& callback) { |
136 DCHECK(SetPendingOperationType(kOperationDirectoryExists)); | 136 DCHECK(SetPendingOperationType(kOperationDirectoryExists)); |
137 async_file_util_->GetFileInfo( | 137 async_file_util_->GetFileInfo( |
138 operation_context_.Pass(), url, GET_METADATA_FIELD_IS_DIRECTORY, | 138 std::move(operation_context_), url, GET_METADATA_FIELD_IS_DIRECTORY, |
139 base::Bind(&FileSystemOperationImpl::DidDirectoryExists, | 139 base::Bind(&FileSystemOperationImpl::DidDirectoryExists, |
140 weak_factory_.GetWeakPtr(), callback)); | 140 weak_factory_.GetWeakPtr(), callback)); |
141 } | 141 } |
142 | 142 |
143 void FileSystemOperationImpl::FileExists(const FileSystemURL& url, | 143 void FileSystemOperationImpl::FileExists(const FileSystemURL& url, |
144 const StatusCallback& callback) { | 144 const StatusCallback& callback) { |
145 DCHECK(SetPendingOperationType(kOperationFileExists)); | 145 DCHECK(SetPendingOperationType(kOperationFileExists)); |
146 async_file_util_->GetFileInfo( | 146 async_file_util_->GetFileInfo( |
147 operation_context_.Pass(), url, GET_METADATA_FIELD_IS_DIRECTORY, | 147 std::move(operation_context_), url, GET_METADATA_FIELD_IS_DIRECTORY, |
148 base::Bind(&FileSystemOperationImpl::DidFileExists, | 148 base::Bind(&FileSystemOperationImpl::DidFileExists, |
149 weak_factory_.GetWeakPtr(), callback)); | 149 weak_factory_.GetWeakPtr(), callback)); |
150 } | 150 } |
151 | 151 |
152 void FileSystemOperationImpl::GetMetadata(const FileSystemURL& url, | 152 void FileSystemOperationImpl::GetMetadata(const FileSystemURL& url, |
153 int fields, | 153 int fields, |
154 const GetMetadataCallback& callback) { | 154 const GetMetadataCallback& callback) { |
155 DCHECK(SetPendingOperationType(kOperationGetMetadata)); | 155 DCHECK(SetPendingOperationType(kOperationGetMetadata)); |
156 async_file_util_->GetFileInfo(operation_context_.Pass(), url, fields, | 156 async_file_util_->GetFileInfo(std::move(operation_context_), url, fields, |
157 callback); | 157 callback); |
158 } | 158 } |
159 | 159 |
160 void FileSystemOperationImpl::ReadDirectory( | 160 void FileSystemOperationImpl::ReadDirectory( |
161 const FileSystemURL& url, const ReadDirectoryCallback& callback) { | 161 const FileSystemURL& url, const ReadDirectoryCallback& callback) { |
162 DCHECK(SetPendingOperationType(kOperationReadDirectory)); | 162 DCHECK(SetPendingOperationType(kOperationReadDirectory)); |
163 async_file_util_->ReadDirectory( | 163 async_file_util_->ReadDirectory(std::move(operation_context_), url, callback); |
164 operation_context_.Pass(), url, callback); | |
165 } | 164 } |
166 | 165 |
167 void FileSystemOperationImpl::Remove(const FileSystemURL& url, | 166 void FileSystemOperationImpl::Remove(const FileSystemURL& url, |
168 bool recursive, | 167 bool recursive, |
169 const StatusCallback& callback) { | 168 const StatusCallback& callback) { |
170 DCHECK(SetPendingOperationType(kOperationRemove)); | 169 DCHECK(SetPendingOperationType(kOperationRemove)); |
171 DCHECK(!recursive_operation_delegate_); | 170 DCHECK(!recursive_operation_delegate_); |
172 | 171 |
173 if (recursive) { | 172 if (recursive) { |
174 // For recursive removal, try to delegate the operation to AsyncFileUtil | 173 // For recursive removal, try to delegate the operation to AsyncFileUtil |
175 // first. If not supported, it is delegated to RemoveOperationDelegate | 174 // first. If not supported, it is delegated to RemoveOperationDelegate |
176 // in DidDeleteRecursively. | 175 // in DidDeleteRecursively. |
177 async_file_util_->DeleteRecursively( | 176 async_file_util_->DeleteRecursively( |
178 operation_context_.Pass(), url, | 177 std::move(operation_context_), url, |
179 base::Bind(&FileSystemOperationImpl::DidDeleteRecursively, | 178 base::Bind(&FileSystemOperationImpl::DidDeleteRecursively, |
180 weak_factory_.GetWeakPtr(), url, callback)); | 179 weak_factory_.GetWeakPtr(), url, callback)); |
181 return; | 180 return; |
182 } | 181 } |
183 | 182 |
184 recursive_operation_delegate_.reset( | 183 recursive_operation_delegate_.reset( |
185 new RemoveOperationDelegate( | 184 new RemoveOperationDelegate( |
186 file_system_context(), url, | 185 file_system_context(), url, |
187 base::Bind(&FileSystemOperationImpl::DidFinishOperation, | 186 base::Bind(&FileSystemOperationImpl::DidFinishOperation, |
188 weak_factory_.GetWeakPtr(), callback))); | 187 weak_factory_.GetWeakPtr(), callback))); |
189 recursive_operation_delegate_->Run(); | 188 recursive_operation_delegate_->Run(); |
190 } | 189 } |
191 | 190 |
192 void FileSystemOperationImpl::Write( | 191 void FileSystemOperationImpl::Write( |
193 const FileSystemURL& url, | 192 const FileSystemURL& url, |
194 scoped_ptr<FileWriterDelegate> writer_delegate, | 193 scoped_ptr<FileWriterDelegate> writer_delegate, |
195 scoped_ptr<net::URLRequest> blob_request, | 194 scoped_ptr<net::URLRequest> blob_request, |
196 const WriteCallback& callback) { | 195 const WriteCallback& callback) { |
197 DCHECK(SetPendingOperationType(kOperationWrite)); | 196 DCHECK(SetPendingOperationType(kOperationWrite)); |
198 file_writer_delegate_ = writer_delegate.Pass(); | 197 file_writer_delegate_ = std::move(writer_delegate); |
199 file_writer_delegate_->Start( | 198 file_writer_delegate_->Start( |
200 blob_request.Pass(), | 199 std::move(blob_request), |
201 base::Bind(&FileSystemOperationImpl::DidWrite, | 200 base::Bind(&FileSystemOperationImpl::DidWrite, weak_factory_.GetWeakPtr(), |
202 weak_factory_.GetWeakPtr(), url, callback)); | 201 url, callback)); |
203 } | 202 } |
204 | 203 |
205 void FileSystemOperationImpl::Truncate(const FileSystemURL& url, | 204 void FileSystemOperationImpl::Truncate(const FileSystemURL& url, |
206 int64_t length, | 205 int64_t length, |
207 const StatusCallback& callback) { | 206 const StatusCallback& callback) { |
208 DCHECK(SetPendingOperationType(kOperationTruncate)); | 207 DCHECK(SetPendingOperationType(kOperationTruncate)); |
209 | 208 |
210 // crbug.com/349708 | 209 // crbug.com/349708 |
211 TRACE_EVENT0("io", "FileSystemOperationImpl::Truncate"); | 210 TRACE_EVENT0("io", "FileSystemOperationImpl::Truncate"); |
212 | 211 |
213 GetUsageAndQuotaThenRunTask( | 212 GetUsageAndQuotaThenRunTask( |
214 url, | 213 url, |
215 base::Bind(&FileSystemOperationImpl::DoTruncate, | 214 base::Bind(&FileSystemOperationImpl::DoTruncate, |
216 weak_factory_.GetWeakPtr(), url, callback, length), | 215 weak_factory_.GetWeakPtr(), url, callback, length), |
217 base::Bind(callback, base::File::FILE_ERROR_FAILED)); | 216 base::Bind(callback, base::File::FILE_ERROR_FAILED)); |
218 } | 217 } |
219 | 218 |
220 void FileSystemOperationImpl::TouchFile(const FileSystemURL& url, | 219 void FileSystemOperationImpl::TouchFile(const FileSystemURL& url, |
221 const base::Time& last_access_time, | 220 const base::Time& last_access_time, |
222 const base::Time& last_modified_time, | 221 const base::Time& last_modified_time, |
223 const StatusCallback& callback) { | 222 const StatusCallback& callback) { |
224 DCHECK(SetPendingOperationType(kOperationTouchFile)); | 223 DCHECK(SetPendingOperationType(kOperationTouchFile)); |
225 | 224 |
226 // crbug.com/349708 | 225 // crbug.com/349708 |
227 TRACE_EVENT0("io", "FileSystemOperationImpl::TouchFile"); | 226 TRACE_EVENT0("io", "FileSystemOperationImpl::TouchFile"); |
228 | 227 |
229 async_file_util_->Touch( | 228 async_file_util_->Touch( |
230 operation_context_.Pass(), url, | 229 std::move(operation_context_), url, last_access_time, last_modified_time, |
231 last_access_time, last_modified_time, | |
232 base::Bind(&FileSystemOperationImpl::DidFinishOperation, | 230 base::Bind(&FileSystemOperationImpl::DidFinishOperation, |
233 weak_factory_.GetWeakPtr(), callback)); | 231 weak_factory_.GetWeakPtr(), callback)); |
234 } | 232 } |
235 | 233 |
236 void FileSystemOperationImpl::OpenFile(const FileSystemURL& url, | 234 void FileSystemOperationImpl::OpenFile(const FileSystemURL& url, |
237 int file_flags, | 235 int file_flags, |
238 const OpenFileCallback& callback) { | 236 const OpenFileCallback& callback) { |
239 DCHECK(SetPendingOperationType(kOperationOpenFile)); | 237 DCHECK(SetPendingOperationType(kOperationOpenFile)); |
240 | 238 |
241 if (file_flags & | 239 if (file_flags & |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 // For truncate we have no way to cancel the inflight operation (for now). | 272 // For truncate we have no way to cancel the inflight operation (for now). |
275 // Let it just run and dispatch cancel callback later. | 273 // Let it just run and dispatch cancel callback later. |
276 DCHECK_EQ(kOperationTruncate, pending_operation_); | 274 DCHECK_EQ(kOperationTruncate, pending_operation_); |
277 } | 275 } |
278 } | 276 } |
279 | 277 |
280 void FileSystemOperationImpl::CreateSnapshotFile( | 278 void FileSystemOperationImpl::CreateSnapshotFile( |
281 const FileSystemURL& url, | 279 const FileSystemURL& url, |
282 const SnapshotFileCallback& callback) { | 280 const SnapshotFileCallback& callback) { |
283 DCHECK(SetPendingOperationType(kOperationCreateSnapshotFile)); | 281 DCHECK(SetPendingOperationType(kOperationCreateSnapshotFile)); |
284 async_file_util_->CreateSnapshotFile( | 282 async_file_util_->CreateSnapshotFile(std::move(operation_context_), url, |
285 operation_context_.Pass(), url, callback); | 283 callback); |
286 } | 284 } |
287 | 285 |
288 void FileSystemOperationImpl::CopyInForeignFile( | 286 void FileSystemOperationImpl::CopyInForeignFile( |
289 const base::FilePath& src_local_disk_file_path, | 287 const base::FilePath& src_local_disk_file_path, |
290 const FileSystemURL& dest_url, | 288 const FileSystemURL& dest_url, |
291 const StatusCallback& callback) { | 289 const StatusCallback& callback) { |
292 DCHECK(SetPendingOperationType(kOperationCopyInForeignFile)); | 290 DCHECK(SetPendingOperationType(kOperationCopyInForeignFile)); |
293 | 291 |
294 // crbug.com/349708 | 292 // crbug.com/349708 |
295 TRACE_EVENT0("io", "FileSystemOperationImpl::CopyInForeinFile"); | 293 TRACE_EVENT0("io", "FileSystemOperationImpl::CopyInForeinFile"); |
296 | 294 |
297 GetUsageAndQuotaThenRunTask( | 295 GetUsageAndQuotaThenRunTask( |
298 dest_url, | 296 dest_url, |
299 base::Bind(&FileSystemOperationImpl::DoCopyInForeignFile, | 297 base::Bind(&FileSystemOperationImpl::DoCopyInForeignFile, |
300 weak_factory_.GetWeakPtr(), src_local_disk_file_path, dest_url, | 298 weak_factory_.GetWeakPtr(), src_local_disk_file_path, dest_url, |
301 callback), | 299 callback), |
302 base::Bind(callback, base::File::FILE_ERROR_FAILED)); | 300 base::Bind(callback, base::File::FILE_ERROR_FAILED)); |
303 } | 301 } |
304 | 302 |
305 void FileSystemOperationImpl::RemoveFile( | 303 void FileSystemOperationImpl::RemoveFile( |
306 const FileSystemURL& url, | 304 const FileSystemURL& url, |
307 const StatusCallback& callback) { | 305 const StatusCallback& callback) { |
308 DCHECK(SetPendingOperationType(kOperationRemove)); | 306 DCHECK(SetPendingOperationType(kOperationRemove)); |
309 async_file_util_->DeleteFile( | 307 async_file_util_->DeleteFile( |
310 operation_context_.Pass(), url, | 308 std::move(operation_context_), url, |
311 base::Bind(&FileSystemOperationImpl::DidFinishOperation, | 309 base::Bind(&FileSystemOperationImpl::DidFinishOperation, |
312 weak_factory_.GetWeakPtr(), callback)); | 310 weak_factory_.GetWeakPtr(), callback)); |
313 } | 311 } |
314 | 312 |
315 void FileSystemOperationImpl::RemoveDirectory( | 313 void FileSystemOperationImpl::RemoveDirectory( |
316 const FileSystemURL& url, | 314 const FileSystemURL& url, |
317 const StatusCallback& callback) { | 315 const StatusCallback& callback) { |
318 DCHECK(SetPendingOperationType(kOperationRemove)); | 316 DCHECK(SetPendingOperationType(kOperationRemove)); |
319 async_file_util_->DeleteDirectory( | 317 async_file_util_->DeleteDirectory( |
320 operation_context_.Pass(), url, | 318 std::move(operation_context_), url, |
321 base::Bind(&FileSystemOperationImpl::DidFinishOperation, | 319 base::Bind(&FileSystemOperationImpl::DidFinishOperation, |
322 weak_factory_.GetWeakPtr(), callback)); | 320 weak_factory_.GetWeakPtr(), callback)); |
323 } | 321 } |
324 | 322 |
325 void FileSystemOperationImpl::CopyFileLocal( | 323 void FileSystemOperationImpl::CopyFileLocal( |
326 const FileSystemURL& src_url, | 324 const FileSystemURL& src_url, |
327 const FileSystemURL& dest_url, | 325 const FileSystemURL& dest_url, |
328 CopyOrMoveOption option, | 326 CopyOrMoveOption option, |
329 const CopyFileProgressCallback& progress_callback, | 327 const CopyFileProgressCallback& progress_callback, |
330 const StatusCallback& callback) { | 328 const StatusCallback& callback) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 file_system_context()->sandbox_delegate()->sync_file_util(); | 369 file_system_context()->sandbox_delegate()->sync_file_util(); |
372 file_util->GetLocalFilePath(operation_context_.get(), url, platform_path); | 370 file_util->GetLocalFilePath(operation_context_.get(), url, platform_path); |
373 return base::File::FILE_OK; | 371 return base::File::FILE_OK; |
374 } | 372 } |
375 | 373 |
376 FileSystemOperationImpl::FileSystemOperationImpl( | 374 FileSystemOperationImpl::FileSystemOperationImpl( |
377 const FileSystemURL& url, | 375 const FileSystemURL& url, |
378 FileSystemContext* file_system_context, | 376 FileSystemContext* file_system_context, |
379 scoped_ptr<FileSystemOperationContext> operation_context) | 377 scoped_ptr<FileSystemOperationContext> operation_context) |
380 : file_system_context_(file_system_context), | 378 : file_system_context_(file_system_context), |
381 operation_context_(operation_context.Pass()), | 379 operation_context_(std::move(operation_context)), |
382 async_file_util_(NULL), | 380 async_file_util_(NULL), |
383 pending_operation_(kOperationNone), | 381 pending_operation_(kOperationNone), |
384 weak_factory_(this) { | 382 weak_factory_(this) { |
385 DCHECK(operation_context_.get()); | 383 DCHECK(operation_context_.get()); |
386 operation_context_->DetachUserDataThread(); | 384 operation_context_->DetachUserDataThread(); |
387 async_file_util_ = file_system_context_->GetAsyncFileUtil(url.type()); | 385 async_file_util_ = file_system_context_->GetAsyncFileUtil(url.type()); |
388 DCHECK(async_file_util_); | 386 DCHECK(async_file_util_); |
389 } | 387 } |
390 | 388 |
391 void FileSystemOperationImpl::GetUsageAndQuotaThenRunTask( | 389 void FileSystemOperationImpl::GetUsageAndQuotaThenRunTask( |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 | 425 |
428 operation_context_->set_allowed_bytes_growth(quota - usage); | 426 operation_context_->set_allowed_bytes_growth(quota - usage); |
429 task.Run(); | 427 task.Run(); |
430 } | 428 } |
431 | 429 |
432 void FileSystemOperationImpl::DoCreateFile( | 430 void FileSystemOperationImpl::DoCreateFile( |
433 const FileSystemURL& url, | 431 const FileSystemURL& url, |
434 const StatusCallback& callback, | 432 const StatusCallback& callback, |
435 bool exclusive) { | 433 bool exclusive) { |
436 async_file_util_->EnsureFileExists( | 434 async_file_util_->EnsureFileExists( |
437 operation_context_.Pass(), url, | 435 std::move(operation_context_), url, |
438 base::Bind( | 436 base::Bind( |
439 exclusive ? | 437 exclusive ? &FileSystemOperationImpl::DidEnsureFileExistsExclusive |
440 &FileSystemOperationImpl::DidEnsureFileExistsExclusive : | 438 : &FileSystemOperationImpl::DidEnsureFileExistsNonExclusive, |
441 &FileSystemOperationImpl::DidEnsureFileExistsNonExclusive, | |
442 weak_factory_.GetWeakPtr(), callback)); | 439 weak_factory_.GetWeakPtr(), callback)); |
443 } | 440 } |
444 | 441 |
445 void FileSystemOperationImpl::DoCreateDirectory( | 442 void FileSystemOperationImpl::DoCreateDirectory( |
446 const FileSystemURL& url, | 443 const FileSystemURL& url, |
447 const StatusCallback& callback, | 444 const StatusCallback& callback, |
448 bool exclusive, bool recursive) { | 445 bool exclusive, bool recursive) { |
449 async_file_util_->CreateDirectory( | 446 async_file_util_->CreateDirectory( |
450 operation_context_.Pass(), | 447 std::move(operation_context_), url, exclusive, recursive, |
451 url, exclusive, recursive, | |
452 base::Bind(&FileSystemOperationImpl::DidFinishOperation, | 448 base::Bind(&FileSystemOperationImpl::DidFinishOperation, |
453 weak_factory_.GetWeakPtr(), callback)); | 449 weak_factory_.GetWeakPtr(), callback)); |
454 } | 450 } |
455 | 451 |
456 void FileSystemOperationImpl::DoCopyFileLocal( | 452 void FileSystemOperationImpl::DoCopyFileLocal( |
457 const FileSystemURL& src_url, | 453 const FileSystemURL& src_url, |
458 const FileSystemURL& dest_url, | 454 const FileSystemURL& dest_url, |
459 CopyOrMoveOption option, | 455 CopyOrMoveOption option, |
460 const CopyFileProgressCallback& progress_callback, | 456 const CopyFileProgressCallback& progress_callback, |
461 const StatusCallback& callback) { | 457 const StatusCallback& callback) { |
462 async_file_util_->CopyFileLocal( | 458 async_file_util_->CopyFileLocal( |
463 operation_context_.Pass(), src_url, dest_url, option, progress_callback, | 459 std::move(operation_context_), src_url, dest_url, option, |
| 460 progress_callback, |
464 base::Bind(&FileSystemOperationImpl::DidFinishOperation, | 461 base::Bind(&FileSystemOperationImpl::DidFinishOperation, |
465 weak_factory_.GetWeakPtr(), callback)); | 462 weak_factory_.GetWeakPtr(), callback)); |
466 } | 463 } |
467 | 464 |
468 void FileSystemOperationImpl::DoMoveFileLocal( | 465 void FileSystemOperationImpl::DoMoveFileLocal( |
469 const FileSystemURL& src_url, | 466 const FileSystemURL& src_url, |
470 const FileSystemURL& dest_url, | 467 const FileSystemURL& dest_url, |
471 CopyOrMoveOption option, | 468 CopyOrMoveOption option, |
472 const StatusCallback& callback) { | 469 const StatusCallback& callback) { |
473 async_file_util_->MoveFileLocal( | 470 async_file_util_->MoveFileLocal( |
474 operation_context_.Pass(), src_url, dest_url, option, | 471 std::move(operation_context_), src_url, dest_url, option, |
475 base::Bind(&FileSystemOperationImpl::DidFinishOperation, | 472 base::Bind(&FileSystemOperationImpl::DidFinishOperation, |
476 weak_factory_.GetWeakPtr(), callback)); | 473 weak_factory_.GetWeakPtr(), callback)); |
477 } | 474 } |
478 | 475 |
479 void FileSystemOperationImpl::DoCopyInForeignFile( | 476 void FileSystemOperationImpl::DoCopyInForeignFile( |
480 const base::FilePath& src_local_disk_file_path, | 477 const base::FilePath& src_local_disk_file_path, |
481 const FileSystemURL& dest_url, | 478 const FileSystemURL& dest_url, |
482 const StatusCallback& callback) { | 479 const StatusCallback& callback) { |
483 async_file_util_->CopyInForeignFile( | 480 async_file_util_->CopyInForeignFile( |
484 operation_context_.Pass(), | 481 std::move(operation_context_), src_local_disk_file_path, dest_url, |
485 src_local_disk_file_path, dest_url, | |
486 base::Bind(&FileSystemOperationImpl::DidFinishOperation, | 482 base::Bind(&FileSystemOperationImpl::DidFinishOperation, |
487 weak_factory_.GetWeakPtr(), callback)); | 483 weak_factory_.GetWeakPtr(), callback)); |
488 } | 484 } |
489 | 485 |
490 void FileSystemOperationImpl::DoTruncate(const FileSystemURL& url, | 486 void FileSystemOperationImpl::DoTruncate(const FileSystemURL& url, |
491 const StatusCallback& callback, | 487 const StatusCallback& callback, |
492 int64_t length) { | 488 int64_t length) { |
493 async_file_util_->Truncate( | 489 async_file_util_->Truncate( |
494 operation_context_.Pass(), url, length, | 490 std::move(operation_context_), url, length, |
495 base::Bind(&FileSystemOperationImpl::DidFinishOperation, | 491 base::Bind(&FileSystemOperationImpl::DidFinishOperation, |
496 weak_factory_.GetWeakPtr(), callback)); | 492 weak_factory_.GetWeakPtr(), callback)); |
497 } | 493 } |
498 | 494 |
499 void FileSystemOperationImpl::DoOpenFile(const FileSystemURL& url, | 495 void FileSystemOperationImpl::DoOpenFile(const FileSystemURL& url, |
500 const OpenFileCallback& callback, | 496 const OpenFileCallback& callback, |
501 int file_flags) { | 497 int file_flags) { |
502 async_file_util_->CreateOrOpen( | 498 async_file_util_->CreateOrOpen( |
503 operation_context_.Pass(), url, file_flags, | 499 std::move(operation_context_), url, file_flags, |
504 base::Bind(&DidOpenFile, | 500 base::Bind(&DidOpenFile, file_system_context_, weak_factory_.GetWeakPtr(), |
505 file_system_context_, weak_factory_.GetWeakPtr(), callback)); | 501 callback)); |
506 } | 502 } |
507 | 503 |
508 void FileSystemOperationImpl::DidEnsureFileExistsExclusive( | 504 void FileSystemOperationImpl::DidEnsureFileExistsExclusive( |
509 const StatusCallback& callback, | 505 const StatusCallback& callback, |
510 base::File::Error rv, bool created) { | 506 base::File::Error rv, bool created) { |
511 if (rv == base::File::FILE_OK && !created) { | 507 if (rv == base::File::FILE_OK && !created) { |
512 callback.Run(base::File::FILE_ERROR_EXISTS); | 508 callback.Run(base::File::FILE_ERROR_EXISTS); |
513 } else { | 509 } else { |
514 DidFinishOperation(callback, rv); | 510 DidFinishOperation(callback, rv); |
515 } | 511 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 } | 591 } |
596 | 592 |
597 bool FileSystemOperationImpl::SetPendingOperationType(OperationType type) { | 593 bool FileSystemOperationImpl::SetPendingOperationType(OperationType type) { |
598 if (pending_operation_ != kOperationNone) | 594 if (pending_operation_ != kOperationNone) |
599 return false; | 595 return false; |
600 pending_operation_ = type; | 596 pending_operation_ = type; |
601 return true; | 597 return true; |
602 } | 598 } |
603 | 599 |
604 } // namespace storage | 600 } // namespace storage |
OLD | NEW |