| 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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 return; | 306 return; |
| 307 } | 307 } |
| 308 | 308 |
| 309 DCHECK(blob_url.is_valid()); | 309 DCHECK(blob_url.is_valid()); |
| 310 file_writer_delegate_.reset(new FileWriterDelegate( | 310 file_writer_delegate_.reset(new FileWriterDelegate( |
| 311 base::Bind(&LocalFileSystemOperation::DidWrite, | 311 base::Bind(&LocalFileSystemOperation::DidWrite, |
| 312 weak_factory_.GetWeakPtr()), | 312 weak_factory_.GetWeakPtr()), |
| 313 writer.Pass())); | 313 writer.Pass())); |
| 314 | 314 |
| 315 set_write_callback(callback); | 315 set_write_callback(callback); |
| 316 scoped_ptr<net::URLRequest> blob_request( | 316 scoped_ptr<net::URLRequest> blob_request(url_request_context->CreateRequest( |
| 317 new net::URLRequest(blob_url, | 317 blob_url, file_writer_delegate_.get())); |
| 318 file_writer_delegate_.get(), | |
| 319 url_request_context)); | |
| 320 | 318 |
| 321 file_writer_delegate_->Start(blob_request.Pass()); | 319 file_writer_delegate_->Start(blob_request.Pass()); |
| 322 } | 320 } |
| 323 | 321 |
| 324 void LocalFileSystemOperation::Truncate(const FileSystemURL& url, int64 length, | 322 void LocalFileSystemOperation::Truncate(const FileSystemURL& url, int64 length, |
| 325 const StatusCallback& callback) { | 323 const StatusCallback& callback) { |
| 326 DCHECK(SetPendingOperationType(kOperationTruncate)); | 324 DCHECK(SetPendingOperationType(kOperationTruncate)); |
| 327 | 325 |
| 328 base::PlatformFileError result = SetUp(url, &src_util_, SETUP_FOR_WRITE); | 326 base::PlatformFileError result = SetUp(url, &src_util_, SETUP_FOR_WRITE); |
| 329 if (result != base::PLATFORM_FILE_OK) { | 327 if (result != base::PLATFORM_FILE_OK) { |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 } | 764 } |
| 767 | 765 |
| 768 bool LocalFileSystemOperation::SetPendingOperationType(OperationType type) { | 766 bool LocalFileSystemOperation::SetPendingOperationType(OperationType type) { |
| 769 if (pending_operation_ != kOperationNone) | 767 if (pending_operation_ != kOperationNone) |
| 770 return false; | 768 return false; |
| 771 pending_operation_ = type; | 769 pending_operation_ = type; |
| 772 return true; | 770 return true; |
| 773 } | 771 } |
| 774 | 772 |
| 775 } // namespace fileapi | 773 } // namespace fileapi |
| OLD | NEW |