| 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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 const WriteCallback& callback) { | 280 const WriteCallback& callback) { |
| 281 DCHECK(SetPendingOperationType(kOperationWrite)); | 281 DCHECK(SetPendingOperationType(kOperationWrite)); |
| 282 | 282 |
| 283 base::PlatformFileError result = SetUpFileSystemPath( | 283 base::PlatformFileError result = SetUpFileSystemPath( |
| 284 path_url, &src_path_, &src_util_, PATH_FOR_WRITE); | 284 path_url, &src_path_, &src_util_, PATH_FOR_WRITE); |
| 285 if (result != base::PLATFORM_FILE_OK) { | 285 if (result != base::PLATFORM_FILE_OK) { |
| 286 callback.Run(result, 0, false); | 286 callback.Run(result, 0, false); |
| 287 delete this; | 287 delete this; |
| 288 return; | 288 return; |
| 289 } | 289 } |
| 290 |
| 291 FileSystemMountPointProvider* provider = file_system_context()-> |
| 292 GetMountPointProvider(src_path_.type()); |
| 293 DCHECK(provider); |
| 294 scoped_ptr<FileStreamWriter> writer(provider->CreateFileStreamWriter( |
| 295 path_url, offset, file_system_context())); |
| 296 |
| 297 if (!writer.get()) { |
| 298 // Write is not supported. |
| 299 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY, 0, false); |
| 300 delete this; |
| 301 return; |
| 302 } |
| 303 |
| 290 DCHECK(blob_url.is_valid()); | 304 DCHECK(blob_url.is_valid()); |
| 291 file_writer_delegate_.reset(new FileWriterDelegate( | 305 file_writer_delegate_.reset(new FileWriterDelegate( |
| 292 base::Bind(&FileSystemOperation::DidWrite, weak_factory_.GetWeakPtr()), | 306 base::Bind(&FileSystemOperation::DidWrite, weak_factory_.GetWeakPtr()), |
| 293 scoped_ptr<FileStreamWriter>( | 307 writer.Pass())); |
| 294 new SandboxFileStreamWriter(file_system_context(), | 308 |
| 295 path_url, | |
| 296 offset)))); | |
| 297 set_write_callback(callback); | 309 set_write_callback(callback); |
| 298 scoped_ptr<net::URLRequest> blob_request( | 310 scoped_ptr<net::URLRequest> blob_request( |
| 299 new net::URLRequest(blob_url, file_writer_delegate_.get())); | 311 new net::URLRequest(blob_url, file_writer_delegate_.get())); |
| 300 blob_request->set_context(url_request_context); | 312 blob_request->set_context(url_request_context); |
| 301 | 313 |
| 302 file_writer_delegate_->Start(blob_request.Pass()); | 314 file_writer_delegate_->Start(blob_request.Pass()); |
| 303 } | 315 } |
| 304 | 316 |
| 305 void FileSystemOperation::Truncate(const GURL& path_url, int64 length, | 317 void FileSystemOperation::Truncate(const GURL& path_url, int64 length, |
| 306 const StatusCallback& callback) { | 318 const StatusCallback& callback) { |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 } | 727 } |
| 716 | 728 |
| 717 bool FileSystemOperation::SetPendingOperationType(OperationType type) { | 729 bool FileSystemOperation::SetPendingOperationType(OperationType type) { |
| 718 if (pending_operation_ != kOperationNone) | 730 if (pending_operation_ != kOperationNone) |
| 719 return false; | 731 return false; |
| 720 pending_operation_ = type; | 732 pending_operation_ = type; |
| 721 return true; | 733 return true; |
| 722 } | 734 } |
| 723 | 735 |
| 724 } // namespace fileapi | 736 } // namespace fileapi |
| OLD | NEW |