OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/fileapi/local_file_system_operation.h" | 5 #include "webkit/fileapi/local_file_system_operation.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
307 if (!writer.get()) { | 307 if (!writer.get()) { |
308 // Write is not supported. | 308 // Write is not supported. |
309 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY, 0, false); | 309 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY, 0, false); |
310 delete this; | 310 delete this; |
311 return; | 311 return; |
312 } | 312 } |
313 | 313 |
314 DCHECK(blob_url.is_valid()); | 314 DCHECK(blob_url.is_valid()); |
315 file_writer_delegate_.reset(new FileWriterDelegate( | 315 file_writer_delegate_.reset(new FileWriterDelegate( |
316 base::Bind(&LocalFileSystemOperation::DidWrite, | 316 base::Bind(&LocalFileSystemOperation::DidWrite, |
317 weak_factory_.GetWeakPtr()), | 317 weak_factory_.GetWeakPtr(), url), |
318 writer.Pass())); | 318 writer.Pass())); |
319 | 319 |
320 set_write_callback(callback); | 320 set_write_callback(callback); |
321 scoped_ptr<net::URLRequest> blob_request(url_request_context->CreateRequest( | 321 scoped_ptr<net::URLRequest> blob_request(url_request_context->CreateRequest( |
322 blob_url, file_writer_delegate_.get())); | 322 blob_url, file_writer_delegate_.get())); |
323 | 323 |
324 file_writer_delegate_->Start(blob_request.Pass()); | 324 file_writer_delegate_->Start(blob_request.Pass()); |
325 } | 325 } |
326 | 326 |
327 void LocalFileSystemOperation::Truncate(const FileSystemURL& url, int64 length, | 327 void LocalFileSystemOperation::Truncate(const FileSystemURL& url, int64 length, |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
670 | 670 |
671 void LocalFileSystemOperation::DidReadDirectory( | 671 void LocalFileSystemOperation::DidReadDirectory( |
672 const ReadDirectoryCallback& callback, | 672 const ReadDirectoryCallback& callback, |
673 base::PlatformFileError rv, | 673 base::PlatformFileError rv, |
674 const std::vector<base::FileUtilProxy::Entry>& entries, | 674 const std::vector<base::FileUtilProxy::Entry>& entries, |
675 bool has_more) { | 675 bool has_more) { |
676 callback.Run(rv, entries, has_more); | 676 callback.Run(rv, entries, has_more); |
677 } | 677 } |
678 | 678 |
679 void LocalFileSystemOperation::DidWrite( | 679 void LocalFileSystemOperation::DidWrite( |
680 const FileSystemURL& url, | |
680 base::PlatformFileError rv, | 681 base::PlatformFileError rv, |
681 int64 bytes, | 682 int64 bytes, |
682 bool complete) { | 683 FileWriterDelegate::WriteProgressStatus write_status) { |
683 if (write_callback_.is_null()) { | 684 if (write_callback_.is_null()) { |
684 // If cancelled, callback is already invoked and set to null in Cancel(). | 685 // If cancelled, callback is already invoked and set to null in Cancel(). |
685 // We must not call it twice. Just shut down this operation object. | 686 // We must not call it twice. Just shut down this operation object. |
686 delete this; | 687 delete this; |
687 return; | 688 return; |
688 } | 689 } |
690 | |
691 bool complete = (write_status != FileWriterDelegate::SUCCESS_IO_PENDING); | |
kinuko
2012/09/26 06:31:15
nit: const
calvinlo
2012/09/26 07:43:40
Done.
| |
692 if (complete && write_status != FileWriterDelegate::ERROR_WRITE_NOT_STARTED) { | |
693 operation_context_->change_observers()->Notify( | |
694 &FileChangeObserver::OnModifyFile, MakeTuple(url)); | |
695 } | |
696 | |
689 write_callback_.Run(rv, bytes, complete); | 697 write_callback_.Run(rv, bytes, complete); |
690 if (complete || rv != base::PLATFORM_FILE_OK) | 698 if (complete || rv != base::PLATFORM_FILE_OK) |
691 delete this; | 699 delete this; |
692 } | 700 } |
693 | 701 |
694 void LocalFileSystemOperation::DidTouchFile(const StatusCallback& callback, | 702 void LocalFileSystemOperation::DidTouchFile(const StatusCallback& callback, |
695 base::PlatformFileError rv) { | 703 base::PlatformFileError rv) { |
696 callback.Run(rv); | 704 callback.Run(rv); |
697 } | 705 } |
698 | 706 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
768 } | 776 } |
769 | 777 |
770 bool LocalFileSystemOperation::SetPendingOperationType(OperationType type) { | 778 bool LocalFileSystemOperation::SetPendingOperationType(OperationType type) { |
771 if (pending_operation_ != kOperationNone) | 779 if (pending_operation_ != kOperationNone) |
772 return false; | 780 return false; |
773 pending_operation_ = type; | 781 pending_operation_ = type; |
774 return true; | 782 return true; |
775 } | 783 } |
776 | 784 |
777 } // namespace fileapi | 785 } // namespace fileapi |
OLD | NEW |