| 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/browser/chromeos/fileapi/remote_file_system_operation.h" | 5 #include "webkit/browser/chromeos/fileapi/remote_file_system_operation.h" | 
| 6 | 6 | 
| 7 #include "base/bind.h" | 7 #include "base/bind.h" | 
| 8 #include "base/platform_file.h" | 8 #include "base/platform_file.h" | 
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" | 
| 10 #include "base/values.h" | 10 #include "base/values.h" | 
| 11 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" | 
| 12 #include "net/url_request/url_request_context.h" | 12 #include "net/url_request/url_request.h" | 
| 13 #include "webkit/browser/chromeos/fileapi/remote_file_stream_writer.h" | 13 #include "webkit/browser/chromeos/fileapi/remote_file_stream_writer.h" | 
| 14 #include "webkit/browser/fileapi/file_system_url.h" | 14 #include "webkit/browser/fileapi/file_system_url.h" | 
| 15 #include "webkit/browser/fileapi/file_writer_delegate.h" | 15 #include "webkit/browser/fileapi/file_writer_delegate.h" | 
| 16 | 16 | 
| 17 using fileapi::FileSystemURL; | 17 using fileapi::FileSystemURL; | 
| 18 | 18 | 
| 19 namespace chromeos { | 19 namespace chromeos { | 
| 20 | 20 | 
| 21 RemoteFileSystemOperation::RemoteFileSystemOperation( | 21 RemoteFileSystemOperation::RemoteFileSystemOperation( | 
| 22     scoped_refptr<fileapi::RemoteFileSystemProxyInterface> remote_proxy) | 22     scoped_refptr<fileapi::RemoteFileSystemProxyInterface> remote_proxy) | 
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 96                                      const FileSystemURL& dest_url, | 96                                      const FileSystemURL& dest_url, | 
| 97                                      const StatusCallback& callback) { | 97                                      const StatusCallback& callback) { | 
| 98   DCHECK(SetPendingOperationType(kOperationMove)); | 98   DCHECK(SetPendingOperationType(kOperationMove)); | 
| 99 | 99 | 
| 100   remote_proxy_->Move(src_url, dest_url, | 100   remote_proxy_->Move(src_url, dest_url, | 
| 101       base::Bind(&RemoteFileSystemOperation::DidFinishFileOperation, | 101       base::Bind(&RemoteFileSystemOperation::DidFinishFileOperation, | 
| 102                  AsWeakPtr(), callback)); | 102                  AsWeakPtr(), callback)); | 
| 103 } | 103 } | 
| 104 | 104 | 
| 105 void RemoteFileSystemOperation::Write( | 105 void RemoteFileSystemOperation::Write( | 
| 106     const net::URLRequestContext* url_request_context, |  | 
| 107     const FileSystemURL& url, | 106     const FileSystemURL& url, | 
| 108     const GURL& blob_url, | 107     scoped_ptr<fileapi::FileWriterDelegate> writer_delegate, | 
| 109     int64 offset, | 108     scoped_ptr<net::URLRequest> blob_request, | 
| 110     const WriteCallback& callback) { | 109     const WriteCallback& callback) { | 
| 111   DCHECK(SetPendingOperationType(kOperationWrite)); | 110   DCHECK(SetPendingOperationType(kOperationWrite)); | 
| 112   file_writer_delegate_.reset( | 111   file_writer_delegate_ = writer_delegate.Pass(); | 
| 113       new fileapi::FileWriterDelegate( | 112   file_writer_delegate_->Start( | 
| 114           base::Bind(&RemoteFileSystemOperation::DidWrite, | 113       blob_request.Pass(), | 
| 115                      AsWeakPtr(), callback), | 114       base::Bind(&RemoteFileSystemOperation::DidWrite, AsWeakPtr(), callback)); | 
| 116           scoped_ptr<fileapi::FileStreamWriter>( |  | 
| 117               new fileapi::RemoteFileStreamWriter(remote_proxy_, |  | 
| 118                                                   url, |  | 
| 119                                                   offset)))); |  | 
| 120 |  | 
| 121   scoped_ptr<net::URLRequest> blob_request(url_request_context->CreateRequest( |  | 
| 122       blob_url, file_writer_delegate_.get())); |  | 
| 123 |  | 
| 124   file_writer_delegate_->Start(blob_request.Pass()); |  | 
| 125 } | 115 } | 
| 126 | 116 | 
| 127 void RemoteFileSystemOperation::Truncate(const FileSystemURL& url, | 117 void RemoteFileSystemOperation::Truncate(const FileSystemURL& url, | 
| 128                                          int64 length, | 118                                          int64 length, | 
| 129                                          const StatusCallback& callback) { | 119                                          const StatusCallback& callback) { | 
| 130   DCHECK(SetPendingOperationType(kOperationTruncate)); | 120   DCHECK(SetPendingOperationType(kOperationTruncate)); | 
| 131 | 121 | 
| 132   remote_proxy_->Truncate(url, length, | 122   remote_proxy_->Truncate(url, length, | 
| 133       base::Bind(&RemoteFileSystemOperation::DidFinishFileOperation, | 123       base::Bind(&RemoteFileSystemOperation::DidFinishFileOperation, | 
| 134                  AsWeakPtr(), callback)); | 124                  AsWeakPtr(), callback)); | 
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 248     base::PlatformFile file, | 238     base::PlatformFile file, | 
| 249     base::ProcessHandle peer_handle) { | 239     base::ProcessHandle peer_handle) { | 
| 250   callback.Run( | 240   callback.Run( | 
| 251       result, file, | 241       result, file, | 
| 252       base::Bind(&fileapi::RemoteFileSystemProxyInterface::NotifyCloseFile, | 242       base::Bind(&fileapi::RemoteFileSystemProxyInterface::NotifyCloseFile, | 
| 253                  remote_proxy_, url), | 243                  remote_proxy_, url), | 
| 254       peer_handle); | 244       peer_handle); | 
| 255 } | 245 } | 
| 256 | 246 | 
| 257 }  // namespace chromeos | 247 }  // namespace chromeos | 
| OLD | NEW | 
|---|