| 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_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 Loading... |
| 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 stray_cancel_callbacks_.find(id); | 679 stray_cancel_callbacks_.find(id); |
| 679 if (found_cancel != stray_cancel_callbacks_.end()) { | 680 if (found_cancel != stray_cancel_callbacks_.end()) { |
| 680 // This cancel has been requested after the operation has finished, | 681 // This cancel has been requested after the operation has finished, |
| 681 // so report that we failed to stop it. | 682 // so report that we failed to stop it. |
| 682 found_cancel->second.Run(base::File::FILE_ERROR_INVALID_OPERATION); | 683 found_cancel->second.Run(base::File::FILE_ERROR_INVALID_OPERATION); |
| 683 stray_cancel_callbacks_.erase(found_cancel); | 684 stray_cancel_callbacks_.erase(found_cancel); |
| 684 } | 685 } |
| 685 } | 686 } |
| 686 | 687 |
| 687 } // namespace storage | 688 } // namespace storage |
| OLD | NEW |