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

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

Issue 24030002: Adds callbacks to notify progress into Copy's API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
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 "webkit/browser/fileapi/file_system_operation_runner.h" 5 #include "webkit/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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 operation->CreateDirectory( 78 operation->CreateDirectory(
79 url, exclusive, recursive, 79 url, exclusive, recursive,
80 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(), 80 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(),
81 handle, callback)); 81 handle, callback));
82 return handle.id; 82 return handle.id;
83 } 83 }
84 84
85 OperationID FileSystemOperationRunner::Copy( 85 OperationID FileSystemOperationRunner::Copy(
86 const FileSystemURL& src_url, 86 const FileSystemURL& src_url,
87 const FileSystemURL& dest_url, 87 const FileSystemURL& dest_url,
88 const CopyProgressCallback& progress_callback,
88 const StatusCallback& callback) { 89 const StatusCallback& callback) {
89 base::PlatformFileError error = base::PLATFORM_FILE_OK; 90 base::PlatformFileError error = base::PLATFORM_FILE_OK;
90 FileSystemOperation* operation = 91 FileSystemOperation* operation =
91 file_system_context_->CreateFileSystemOperation(dest_url, &error); 92 file_system_context_->CreateFileSystemOperation(dest_url, &error);
92 BeginOperationScoper scope; 93 BeginOperationScoper scope;
93 OperationHandle handle = BeginOperation(operation, scope.AsWeakPtr()); 94 OperationHandle handle = BeginOperation(operation, scope.AsWeakPtr());
94 if (!operation) { 95 if (!operation) {
95 DidFinish(handle, callback, error); 96 DidFinish(handle, callback, error);
96 return handle.id; 97 return handle.id;
97 } 98 }
98 PrepareForWrite(handle.id, dest_url); 99 PrepareForWrite(handle.id, dest_url);
99 PrepareForRead(handle.id, src_url); 100 PrepareForRead(handle.id, src_url);
100 operation->Copy( 101 operation->Copy(
101 src_url, dest_url, 102 src_url, dest_url, progress_callback,
102 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(), 103 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(),
103 handle, callback)); 104 handle, callback));
104 return handle.id; 105 return handle.id;
105 } 106 }
106 107
107 OperationID FileSystemOperationRunner::Move( 108 OperationID FileSystemOperationRunner::Move(
108 const FileSystemURL& src_url, 109 const FileSystemURL& src_url,
109 const FileSystemURL& dest_url, 110 const FileSystemURL& dest_url,
110 const StatusCallback& callback) { 111 const StatusCallback& callback) {
111 base::PlatformFileError error = base::PLATFORM_FILE_OK; 112 base::PlatformFileError error = base::PLATFORM_FILE_OK;
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 operation->RemoveDirectory( 429 operation->RemoveDirectory(
429 url, 430 url,
430 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(), 431 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(),
431 handle, callback)); 432 handle, callback));
432 return handle.id; 433 return handle.id;
433 } 434 }
434 435
435 OperationID FileSystemOperationRunner::CopyFileLocal( 436 OperationID FileSystemOperationRunner::CopyFileLocal(
436 const FileSystemURL& src_url, 437 const FileSystemURL& src_url,
437 const FileSystemURL& dest_url, 438 const FileSystemURL& dest_url,
439 const CopyFileProgressCallback& progress_callback,
438 const StatusCallback& callback) { 440 const StatusCallback& callback) {
439 base::PlatformFileError error = base::PLATFORM_FILE_OK; 441 base::PlatformFileError error = base::PLATFORM_FILE_OK;
440 FileSystemOperation* operation = 442 FileSystemOperation* operation =
441 file_system_context_->CreateFileSystemOperation(src_url, &error); 443 file_system_context_->CreateFileSystemOperation(src_url, &error);
442 BeginOperationScoper scope; 444 BeginOperationScoper scope;
443 OperationHandle handle = BeginOperation(operation, scope.AsWeakPtr()); 445 OperationHandle handle = BeginOperation(operation, scope.AsWeakPtr());
444 if (!operation) { 446 if (!operation) {
445 DidFinish(handle, callback, error); 447 DidFinish(handle, callback, error);
446 return handle.id; 448 return handle.id;
447 } 449 }
448 operation->CopyFileLocal( 450 operation->CopyFileLocal(
449 src_url, dest_url, 451 src_url, dest_url, progress_callback,
450 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(), 452 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(),
451 handle, callback)); 453 handle, callback));
452 return handle.id; 454 return handle.id;
453 } 455 }
454 456
455 OperationID FileSystemOperationRunner::MoveFileLocal( 457 OperationID FileSystemOperationRunner::MoveFileLocal(
456 const FileSystemURL& src_url, 458 const FileSystemURL& src_url,
457 const FileSystemURL& dest_url, 459 const FileSystemURL& dest_url,
458 const StatusCallback& callback) { 460 const StatusCallback& callback) {
459 base::PlatformFileError error = base::PLATFORM_FILE_OK; 461 base::PlatformFileError error = base::PLATFORM_FILE_OK;
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 stray_cancel_callbacks_.find(id); 647 stray_cancel_callbacks_.find(id);
646 if (found_cancel != stray_cancel_callbacks_.end()) { 648 if (found_cancel != stray_cancel_callbacks_.end()) {
647 // This cancel has been requested after the operation has finished, 649 // This cancel has been requested after the operation has finished,
648 // so report that we failed to stop it. 650 // so report that we failed to stop it.
649 found_cancel->second.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); 651 found_cancel->second.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
650 stray_cancel_callbacks_.erase(found_cancel); 652 stray_cancel_callbacks_.erase(found_cancel);
651 } 653 }
652 } 654 }
653 655
654 } // namespace fileapi 656 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698