| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/cross_operation_delegate.h" | 5 #include "webkit/fileapi/cross_operation_delegate.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "webkit/blob/shareable_file_reference.h" | 8 #include "webkit/blob/shareable_file_reference.h" |
| 9 #include "webkit/fileapi/file_system_context.h" | 9 #include "webkit/fileapi/file_system_context.h" |
| 10 #include "webkit/fileapi/file_system_operation_context.h" | 10 #include "webkit/fileapi/file_system_operation_context.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 src_operation->CreateSnapshotFile( | 162 src_operation->CreateSnapshotFile( |
| 163 src, base::Bind(&CrossOperationDelegate::DidCreateSnapshot, AsWeakPtr(), | 163 src, base::Bind(&CrossOperationDelegate::DidCreateSnapshot, AsWeakPtr(), |
| 164 dest, copy_callback)); | 164 dest, copy_callback)); |
| 165 } | 165 } |
| 166 | 166 |
| 167 void CrossOperationDelegate::DidCreateSnapshot( | 167 void CrossOperationDelegate::DidCreateSnapshot( |
| 168 const FileSystemURL& dest, | 168 const FileSystemURL& dest, |
| 169 const StatusCallback& callback, | 169 const StatusCallback& callback, |
| 170 base::PlatformFileError error, | 170 base::PlatformFileError error, |
| 171 const base::PlatformFileInfo& file_info, | 171 const base::PlatformFileInfo& file_info, |
| 172 const FilePath& platform_path, | 172 const base::FilePath& platform_path, |
| 173 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) { | 173 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) { |
| 174 if (error != base::PLATFORM_FILE_OK) { | 174 if (error != base::PLATFORM_FILE_OK) { |
| 175 callback.Run(error); | 175 callback.Run(error); |
| 176 return; | 176 return; |
| 177 } | 177 } |
| 178 current_file_ref_ = file_ref; | 178 current_file_ref_ = file_ref; |
| 179 | 179 |
| 180 // For now we assume CreateSnapshotFile always return a valid local file path. | 180 // For now we assume CreateSnapshotFile always return a valid local file path. |
| 181 // TODO(kinuko): Otherwise create a FileStreamReader to perform a copy/move. | 181 // TODO(kinuko): Otherwise create a FileStreamReader to perform a copy/move. |
| 182 DCHECK(!platform_path.empty()); | 182 DCHECK(!platform_path.empty()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 if (error == base::PLATFORM_FILE_ERROR_NOT_FOUND) | 215 if (error == base::PLATFORM_FILE_ERROR_NOT_FOUND) |
| 216 error = base::PLATFORM_FILE_OK; | 216 error = base::PLATFORM_FILE_OK; |
| 217 callback.Run(error); | 217 callback.Run(error); |
| 218 } | 218 } |
| 219 | 219 |
| 220 FileSystemURL CrossOperationDelegate::CreateDestURL( | 220 FileSystemURL CrossOperationDelegate::CreateDestURL( |
| 221 const FileSystemURL& src_url) const { | 221 const FileSystemURL& src_url) const { |
| 222 DCHECK_EQ(src_root_.type(), src_url.type()); | 222 DCHECK_EQ(src_root_.type(), src_url.type()); |
| 223 DCHECK_EQ(src_root_.origin(), src_url.origin()); | 223 DCHECK_EQ(src_root_.origin(), src_url.origin()); |
| 224 | 224 |
| 225 FilePath path = dest_root_.path(); | 225 base::FilePath path = dest_root_.path(); |
| 226 src_root_.path().AppendRelativePath(src_url.path(), &path); | 226 src_root_.path().AppendRelativePath(src_url.path(), &path); |
| 227 return dest_root_.WithPath(path); | 227 return dest_root_.WithPath(path); |
| 228 } | 228 } |
| 229 | 229 |
| 230 LocalFileSystemOperation* CrossOperationDelegate::NewDestOperation( | 230 LocalFileSystemOperation* CrossOperationDelegate::NewDestOperation( |
| 231 const FileSystemURL& url) { | 231 const FileSystemURL& url) { |
| 232 base::PlatformFileError error = base::PLATFORM_FILE_OK; | 232 base::PlatformFileError error = base::PLATFORM_FILE_OK; |
| 233 LocalFileSystemOperation* operation = | 233 LocalFileSystemOperation* operation = |
| 234 RecursiveOperationDelegate::NewOperation(url, &error); | 234 RecursiveOperationDelegate::NewOperation(url, &error); |
| 235 if (!operation) { | 235 if (!operation) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 258 DCHECK(local_operation); | 258 DCHECK(local_operation); |
| 259 DCHECK(src_root_operation_); | 259 DCHECK(src_root_operation_); |
| 260 | 260 |
| 261 // Let the new operation inherit from the root operation. | 261 // Let the new operation inherit from the root operation. |
| 262 local_operation->set_overriding_operation_context( | 262 local_operation->set_overriding_operation_context( |
| 263 src_root_operation_->operation_context()); | 263 src_root_operation_->operation_context()); |
| 264 return local_operation; | 264 return local_operation; |
| 265 } | 265 } |
| 266 | 266 |
| 267 } // namespace fileapi | 267 } // namespace fileapi |
| OLD | NEW |