| 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/chromeos/fileapi/remote_file_system_operation.h" | 5 #include "webkit/chromeos/fileapi/remote_file_system_operation.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "base/platform_file.h" | 9 #include "base/platform_file.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 DCHECK(SetPendingOperationType(kOperationMove)); | 103 DCHECK(SetPendingOperationType(kOperationMove)); |
| 104 | 104 |
| 105 remote_proxy_->Move(src_url, dest_url, | 105 remote_proxy_->Move(src_url, dest_url, |
| 106 base::Bind(&RemoteFileSystemOperation::DidFinishFileOperation, | 106 base::Bind(&RemoteFileSystemOperation::DidFinishFileOperation, |
| 107 base::Owned(this), callback)); | 107 base::Owned(this), callback)); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void RemoteFileSystemOperation::Write( | 110 void RemoteFileSystemOperation::Write( |
| 111 const net::URLRequestContext* url_request_context, | 111 const net::URLRequestContext* url_request_context, |
| 112 const FileSystemURL& url, | 112 const FileSystemURL& url, |
| 113 const GURL& blob_url, | 113 scoped_ptr<webkit_blob::BlobDataHandle> blob_handle, |
| 114 int64 offset, | 114 int64 offset, |
| 115 const WriteCallback& callback) { | 115 const WriteCallback& callback) { |
| 116 DCHECK(SetPendingOperationType(kOperationWrite)); | 116 DCHECK(SetPendingOperationType(kOperationWrite)); |
| 117 DCHECK(write_callback_.is_null()); | 117 DCHECK(write_callback_.is_null()); |
| 118 | 118 |
| 119 write_callback_ = callback; | 119 write_callback_ = callback; |
| 120 file_writer_delegate_.reset( | 120 file_writer_delegate_.reset( |
| 121 new fileapi::FileWriterDelegate( | 121 new fileapi::FileWriterDelegate( |
| 122 base::Bind(&RemoteFileSystemOperation::DidWrite, | 122 base::Bind(&RemoteFileSystemOperation::DidWrite, |
| 123 // FileWriterDelegate is owned by |this|. So Unretained. | 123 // FileWriterDelegate is owned by |this|. So Unretained. |
| 124 base::Unretained(this)), | 124 base::Unretained(this)), |
| 125 scoped_ptr<fileapi::FileStreamWriter>( | 125 scoped_ptr<fileapi::FileStreamWriter>( |
| 126 new fileapi::RemoteFileStreamWriter(remote_proxy_, | 126 new fileapi::RemoteFileStreamWriter(remote_proxy_, |
| 127 url, | 127 url, |
| 128 offset)))); | 128 offset)))); |
| 129 | 129 |
| 130 // Use a URLRequest to read the blob data that's to be written to the file. |
| 130 scoped_ptr<net::URLRequest> blob_request(url_request_context->CreateRequest( | 131 scoped_ptr<net::URLRequest> blob_request(url_request_context->CreateRequest( |
| 131 blob_url, file_writer_delegate_.get())); | 132 GURL("blob://see_user_data/"), file_writer_delegate_.get())); |
| 133 webkit_blob::BlobProtocolHandler::SetRequestedBlobDataHandle( |
| 134 blob_request.get(), |
| 135 blob_handle.Pass()); |
| 132 | 136 |
| 133 file_writer_delegate_->Start(blob_request.Pass()); | 137 file_writer_delegate_->Start(blob_request.Pass()); |
| 134 } | 138 } |
| 135 | 139 |
| 136 void RemoteFileSystemOperation::Truncate(const FileSystemURL& url, | 140 void RemoteFileSystemOperation::Truncate(const FileSystemURL& url, |
| 137 int64 length, | 141 int64 length, |
| 138 const StatusCallback& callback) { | 142 const StatusCallback& callback) { |
| 139 DCHECK(SetPendingOperationType(kOperationTruncate)); | 143 DCHECK(SetPendingOperationType(kOperationTruncate)); |
| 140 | 144 |
| 141 remote_proxy_->Truncate(url, length, | 145 remote_proxy_->Truncate(url, length, |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 | 321 |
| 318 void RemoteFileSystemOperation::DidOpenFile( | 322 void RemoteFileSystemOperation::DidOpenFile( |
| 319 const OpenFileCallback& callback, | 323 const OpenFileCallback& callback, |
| 320 base::PlatformFileError result, | 324 base::PlatformFileError result, |
| 321 base::PlatformFile file, | 325 base::PlatformFile file, |
| 322 base::ProcessHandle peer_handle) { | 326 base::ProcessHandle peer_handle) { |
| 323 callback.Run(result, file, peer_handle); | 327 callback.Run(result, file, peer_handle); |
| 324 } | 328 } |
| 325 | 329 |
| 326 } // namespace chromeos | 330 } // namespace chromeos |
| OLD | NEW |