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

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

Issue 565073002: [Blink-FileAPI] Add the notification of update observer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « chrome/browser/sync_file_system/local/local_file_change_tracker_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_runner.h" 5 #include "storage/browser/fileapi/file_system_operation_runner.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop_proxy.h" 8 #include "base/message_loop/message_loop_proxy.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "net/url_request/url_request_context.h" 10 #include "net/url_request/url_request_context.h"
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 const StatusCallback& callback) { 395 const StatusCallback& callback) {
396 base::File::Error error = base::File::FILE_OK; 396 base::File::Error error = base::File::FILE_OK;
397 FileSystemOperation* operation = 397 FileSystemOperation* operation =
398 file_system_context_->CreateFileSystemOperation(dest_url, &error); 398 file_system_context_->CreateFileSystemOperation(dest_url, &error);
399 BeginOperationScoper scope; 399 BeginOperationScoper scope;
400 OperationHandle handle = BeginOperation(operation, scope.AsWeakPtr()); 400 OperationHandle handle = BeginOperation(operation, scope.AsWeakPtr());
401 if (!operation) { 401 if (!operation) {
402 DidFinish(handle, callback, error); 402 DidFinish(handle, callback, error);
403 return handle.id; 403 return handle.id;
404 } 404 }
405 PrepareForWrite(handle.id, dest_url);
405 operation->CopyInForeignFile( 406 operation->CopyInForeignFile(
406 src_local_disk_path, dest_url, 407 src_local_disk_path, dest_url,
407 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(), 408 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(),
408 handle, callback)); 409 handle, callback));
409 return handle.id; 410 return handle.id;
410 } 411 }
411 412
412 OperationID FileSystemOperationRunner::RemoveFile( 413 OperationID FileSystemOperationRunner::RemoveFile(
413 const FileSystemURL& url, 414 const FileSystemURL& url,
414 const StatusCallback& callback) { 415 const StatusCallback& callback) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 const StatusCallback& callback) { 456 const StatusCallback& callback) {
456 base::File::Error error = base::File::FILE_OK; 457 base::File::Error error = base::File::FILE_OK;
457 FileSystemOperation* operation = 458 FileSystemOperation* operation =
458 file_system_context_->CreateFileSystemOperation(src_url, &error); 459 file_system_context_->CreateFileSystemOperation(src_url, &error);
459 BeginOperationScoper scope; 460 BeginOperationScoper scope;
460 OperationHandle handle = BeginOperation(operation, scope.AsWeakPtr()); 461 OperationHandle handle = BeginOperation(operation, scope.AsWeakPtr());
461 if (!operation) { 462 if (!operation) {
462 DidFinish(handle, callback, error); 463 DidFinish(handle, callback, error);
463 return handle.id; 464 return handle.id;
464 } 465 }
466 PrepareForRead(handle.id, src_url);
467 PrepareForWrite(handle.id, dest_url);
465 operation->CopyFileLocal( 468 operation->CopyFileLocal(
466 src_url, dest_url, option, progress_callback, 469 src_url, dest_url, option, progress_callback,
467 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(), 470 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(),
468 handle, callback)); 471 handle, callback));
469 return handle.id; 472 return handle.id;
470 } 473 }
471 474
472 OperationID FileSystemOperationRunner::MoveFileLocal( 475 OperationID FileSystemOperationRunner::MoveFileLocal(
473 const FileSystemURL& src_url, 476 const FileSystemURL& src_url,
474 const FileSystemURL& dest_url, 477 const FileSystemURL& dest_url,
475 CopyOrMoveOption option, 478 CopyOrMoveOption option,
476 const StatusCallback& callback) { 479 const StatusCallback& callback) {
477 base::File::Error error = base::File::FILE_OK; 480 base::File::Error error = base::File::FILE_OK;
478 FileSystemOperation* operation = 481 FileSystemOperation* operation =
479 file_system_context_->CreateFileSystemOperation(src_url, &error); 482 file_system_context_->CreateFileSystemOperation(src_url, &error);
480 BeginOperationScoper scope; 483 BeginOperationScoper scope;
481 OperationHandle handle = BeginOperation(operation, scope.AsWeakPtr()); 484 OperationHandle handle = BeginOperation(operation, scope.AsWeakPtr());
482 if (!operation) { 485 if (!operation) {
483 DidFinish(handle, callback, error); 486 DidFinish(handle, callback, error);
484 return handle.id; 487 return handle.id;
485 } 488 }
489 PrepareForWrite(handle.id, src_url);
490 PrepareForWrite(handle.id, dest_url);
486 operation->MoveFileLocal( 491 operation->MoveFileLocal(
487 src_url, dest_url, option, 492 src_url, dest_url, option,
488 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(), 493 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(),
489 handle, callback)); 494 handle, callback));
490 return handle.id; 495 return handle.id;
491 } 496 }
492 497
493 base::File::Error FileSystemOperationRunner::SyncGetPlatformPath( 498 base::File::Error FileSystemOperationRunner::SyncGetPlatformPath(
494 const FileSystemURL& url, 499 const FileSystemURL& url,
495 base::FilePath* platform_path) { 500 base::FilePath* platform_path) {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 stray_cancel_callbacks_.find(id); 683 stray_cancel_callbacks_.find(id);
679 if (found_cancel != stray_cancel_callbacks_.end()) { 684 if (found_cancel != stray_cancel_callbacks_.end()) {
680 // This cancel has been requested after the operation has finished, 685 // This cancel has been requested after the operation has finished,
681 // so report that we failed to stop it. 686 // so report that we failed to stop it.
682 found_cancel->second.Run(base::File::FILE_ERROR_INVALID_OPERATION); 687 found_cancel->second.Run(base::File::FILE_ERROR_INVALID_OPERATION);
683 stray_cancel_callbacks_.erase(found_cancel); 688 stray_cancel_callbacks_.erase(found_cancel);
684 } 689 }
685 } 690 }
686 691
687 } // namespace storage 692 } // namespace storage
OLDNEW
« no previous file with comments | « chrome/browser/sync_file_system/local/local_file_change_tracker_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698