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/file_system_operation.h" | 5 #include "webkit/fileapi/file_system_operation.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/sequenced_task_runner.h" | 8 #include "base/sequenced_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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 } | 289 } |
290 DCHECK(blob_url.is_valid()); | 290 DCHECK(blob_url.is_valid()); |
291 file_writer_delegate_.reset(new FileWriterDelegate( | 291 file_writer_delegate_.reset(new FileWriterDelegate( |
292 base::Bind(&FileSystemOperation::DidWrite, weak_factory_.GetWeakPtr()), | 292 base::Bind(&FileSystemOperation::DidWrite, weak_factory_.GetWeakPtr()), |
293 scoped_ptr<FileStreamWriter>( | 293 scoped_ptr<FileStreamWriter>( |
294 new SandboxFileStreamWriter(file_system_context(), | 294 new SandboxFileStreamWriter(file_system_context(), |
295 path_url, | 295 path_url, |
296 offset)))); | 296 offset)))); |
297 set_write_callback(callback); | 297 set_write_callback(callback); |
298 scoped_ptr<net::URLRequest> blob_request( | 298 scoped_ptr<net::URLRequest> blob_request( |
299 new net::URLRequest(blob_url, file_writer_delegate_.get())); | 299 new net::URLRequest(blob_url, |
300 blob_request->set_context(url_request_context); | 300 file_writer_delegate_.get(), |
| 301 url_request_context)); |
301 | 302 |
302 file_writer_delegate_->Start(blob_request.Pass()); | 303 file_writer_delegate_->Start(blob_request.Pass()); |
303 } | 304 } |
304 | 305 |
305 void FileSystemOperation::Truncate(const GURL& path_url, int64 length, | 306 void FileSystemOperation::Truncate(const GURL& path_url, int64 length, |
306 const StatusCallback& callback) { | 307 const StatusCallback& callback) { |
307 DCHECK(SetPendingOperationType(kOperationTruncate)); | 308 DCHECK(SetPendingOperationType(kOperationTruncate)); |
308 | 309 |
309 base::PlatformFileError result = SetUpFileSystemPath( | 310 base::PlatformFileError result = SetUpFileSystemPath( |
310 path_url, &src_path_, &src_util_, PATH_FOR_WRITE); | 311 path_url, &src_path_, &src_util_, PATH_FOR_WRITE); |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 } | 716 } |
716 | 717 |
717 bool FileSystemOperation::SetPendingOperationType(OperationType type) { | 718 bool FileSystemOperation::SetPendingOperationType(OperationType type) { |
718 if (pending_operation_ != kOperationNone) | 719 if (pending_operation_ != kOperationNone) |
719 return false; | 720 return false; |
720 pending_operation_ = type; | 721 pending_operation_ = type; |
721 return true; | 722 return true; |
722 } | 723 } |
723 | 724 |
724 } // namespace fileapi | 725 } // namespace fileapi |
OLD | NEW |