| 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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 const StatusCallback& callback) { | 415 const StatusCallback& callback) { |
| 416 base::File::Error error = base::File::FILE_OK; | 416 base::File::Error error = base::File::FILE_OK; |
| 417 FileSystemOperation* operation = | 417 FileSystemOperation* operation = |
| 418 file_system_context_->CreateFileSystemOperation(url, &error); | 418 file_system_context_->CreateFileSystemOperation(url, &error); |
| 419 BeginOperationScoper scope; | 419 BeginOperationScoper scope; |
| 420 OperationHandle handle = BeginOperation(operation, scope.AsWeakPtr()); | 420 OperationHandle handle = BeginOperation(operation, scope.AsWeakPtr()); |
| 421 if (!operation) { | 421 if (!operation) { |
| 422 DidFinish(handle, callback, error); | 422 DidFinish(handle, callback, error); |
| 423 return handle.id; | 423 return handle.id; |
| 424 } | 424 } |
| 425 PrepareForWrite(handle.id, url); |
| 425 operation->RemoveFile( | 426 operation->RemoveFile( |
| 426 url, | 427 url, |
| 427 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(), | 428 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(), |
| 428 handle, callback)); | 429 handle, callback)); |
| 429 return handle.id; | 430 return handle.id; |
| 430 } | 431 } |
| 431 | 432 |
| 432 OperationID FileSystemOperationRunner::RemoveDirectory( | 433 OperationID FileSystemOperationRunner::RemoveDirectory( |
| 433 const FileSystemURL& url, | 434 const FileSystemURL& url, |
| 434 const StatusCallback& callback) { | 435 const StatusCallback& callback) { |
| 435 base::File::Error error = base::File::FILE_OK; | 436 base::File::Error error = base::File::FILE_OK; |
| 436 FileSystemOperation* operation = | 437 FileSystemOperation* operation = |
| 437 file_system_context_->CreateFileSystemOperation(url, &error); | 438 file_system_context_->CreateFileSystemOperation(url, &error); |
| 438 BeginOperationScoper scope; | 439 BeginOperationScoper scope; |
| 439 OperationHandle handle = BeginOperation(operation, scope.AsWeakPtr()); | 440 OperationHandle handle = BeginOperation(operation, scope.AsWeakPtr()); |
| 440 if (!operation) { | 441 if (!operation) { |
| 441 DidFinish(handle, callback, error); | 442 DidFinish(handle, callback, error); |
| 442 return handle.id; | 443 return handle.id; |
| 443 } | 444 } |
| 445 PrepareForWrite(handle.id, url); |
| 444 operation->RemoveDirectory( | 446 operation->RemoveDirectory( |
| 445 url, | 447 url, |
| 446 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(), | 448 base::Bind(&FileSystemOperationRunner::DidFinish, AsWeakPtr(), |
| 447 handle, callback)); | 449 handle, callback)); |
| 448 return handle.id; | 450 return handle.id; |
| 449 } | 451 } |
| 450 | 452 |
| 451 OperationID FileSystemOperationRunner::CopyFileLocal( | 453 OperationID FileSystemOperationRunner::CopyFileLocal( |
| 452 const FileSystemURL& src_url, | 454 const FileSystemURL& src_url, |
| 453 const FileSystemURL& dest_url, | 455 const FileSystemURL& dest_url, |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 stray_cancel_callbacks_.find(id); | 685 stray_cancel_callbacks_.find(id); |
| 684 if (found_cancel != stray_cancel_callbacks_.end()) { | 686 if (found_cancel != stray_cancel_callbacks_.end()) { |
| 685 // This cancel has been requested after the operation has finished, | 687 // This cancel has been requested after the operation has finished, |
| 686 // so report that we failed to stop it. | 688 // so report that we failed to stop it. |
| 687 found_cancel->second.Run(base::File::FILE_ERROR_INVALID_OPERATION); | 689 found_cancel->second.Run(base::File::FILE_ERROR_INVALID_OPERATION); |
| 688 stray_cancel_callbacks_.erase(found_cancel); | 690 stray_cancel_callbacks_.erase(found_cancel); |
| 689 } | 691 } |
| 690 } | 692 } |
| 691 | 693 |
| 692 } // namespace storage | 694 } // namespace storage |
| OLD | NEW |