| 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_file_util_proxy.h" | 5 #include "webkit/fileapi/file_system_file_util_proxy.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/sequenced_task_runner.h" | 9 #include "base/sequenced_task_runner.h" |
| 10 #include "base/task_runner_util.h" | 10 #include "base/task_runner_util.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 return base::FileUtilProxy::RelayCreateOrOpen( | 143 return base::FileUtilProxy::RelayCreateOrOpen( |
| 144 context->task_runner(), | 144 context->task_runner(), |
| 145 Bind(&FileSystemFileUtil::CreateOrOpen, Unretained(file_util), | 145 Bind(&FileSystemFileUtil::CreateOrOpen, Unretained(file_util), |
| 146 context, url, file_flags), | 146 context, url, file_flags), |
| 147 Bind(&FileSystemFileUtil::Close, Unretained(file_util), | 147 Bind(&FileSystemFileUtil::Close, Unretained(file_util), |
| 148 context), | 148 context), |
| 149 callback); | 149 callback); |
| 150 } | 150 } |
| 151 | 151 |
| 152 // static | 152 // static |
| 153 bool FileSystemFileUtilProxy::Copy( | 153 bool FileSystemFileUtilProxy::CopyFileLocal( |
| 154 FileSystemOperationContext* context, | 154 FileSystemOperationContext* context, |
| 155 FileSystemFileUtil* src_util, | 155 FileSystemFileUtil* file_util, |
| 156 FileSystemFileUtil* dest_util, | |
| 157 const FileSystemURL& src_url, | 156 const FileSystemURL& src_url, |
| 158 const FileSystemURL& dest_url, | 157 const FileSystemURL& dest_url, |
| 159 const StatusCallback& callback) { | 158 const StatusCallback& callback) { |
| 160 return base::PostTaskAndReplyWithResult( | 159 return base::PostTaskAndReplyWithResult( |
| 161 context->task_runner(), FROM_HERE, | 160 context->task_runner(), FROM_HERE, |
| 162 Bind(&FileUtilHelper::Copy, | 161 Bind(&FileSystemFileUtil::CopyOrMoveFile, Unretained(file_util), |
| 163 context, src_util, dest_util, src_url, dest_url), | 162 context, src_url, dest_url, true /* copy */), |
| 163 callback); |
| 164 } |
| 165 |
| 166 // static |
| 167 bool FileSystemFileUtilProxy::MoveFileLocal( |
| 168 FileSystemOperationContext* context, |
| 169 FileSystemFileUtil* file_util, |
| 170 const FileSystemURL& src_url, |
| 171 const FileSystemURL& dest_url, |
| 172 const StatusCallback& callback) { |
| 173 return base::PostTaskAndReplyWithResult( |
| 174 context->task_runner(), FROM_HERE, |
| 175 Bind(&FileSystemFileUtil::CopyOrMoveFile, Unretained(file_util), |
| 176 context, src_url, dest_url, false /* copy */), |
| 164 callback); | 177 callback); |
| 165 } | 178 } |
| 166 | 179 |
| 167 // static | 180 // static |
| 168 bool FileSystemFileUtilProxy::CopyInForeignFile( | 181 bool FileSystemFileUtilProxy::CopyInForeignFile( |
| 169 FileSystemOperationContext* context, | 182 FileSystemOperationContext* context, |
| 170 FileSystemFileUtil* dest_util, | 183 FileSystemFileUtil* file_util, |
| 171 const FilePath& src_local_disk_file_path, | 184 const FilePath& src_local_disk_file_path, |
| 172 const FileSystemURL& dest_url, | 185 const FileSystemURL& dest_url, |
| 173 const StatusCallback& callback) { | 186 const StatusCallback& callback) { |
| 174 return base::PostTaskAndReplyWithResult( | 187 return base::PostTaskAndReplyWithResult( |
| 175 context->task_runner(), FROM_HERE, | 188 context->task_runner(), FROM_HERE, |
| 176 Bind(&FileSystemFileUtil::CopyInForeignFile, Unretained(dest_util), | 189 Bind(&FileSystemFileUtil::CopyInForeignFile, Unretained(file_util), |
| 177 context, src_local_disk_file_path, dest_url), | 190 context, src_local_disk_file_path, dest_url), |
| 178 callback); | 191 callback); |
| 179 } | 192 } |
| 180 | 193 |
| 181 // static | |
| 182 bool FileSystemFileUtilProxy::Move( | |
| 183 FileSystemOperationContext* context, | |
| 184 FileSystemFileUtil* src_util, | |
| 185 FileSystemFileUtil* dest_util, | |
| 186 const FileSystemURL& src_url, | |
| 187 const FileSystemURL& dest_url, | |
| 188 const StatusCallback& callback) { | |
| 189 return base::PostTaskAndReplyWithResult( | |
| 190 context->task_runner(), FROM_HERE, | |
| 191 Bind(&FileUtilHelper::Move, | |
| 192 context, src_util, dest_util, src_url, dest_url), | |
| 193 callback); | |
| 194 } | |
| 195 | |
| 196 // static | 194 // static |
| 197 bool FileSystemFileUtilProxy::EnsureFileExists( | 195 bool FileSystemFileUtilProxy::EnsureFileExists( |
| 198 FileSystemOperationContext* context, | 196 FileSystemOperationContext* context, |
| 199 FileSystemFileUtil* file_util, | 197 FileSystemFileUtil* file_util, |
| 200 const FileSystemURL& url, | 198 const FileSystemURL& url, |
| 201 const EnsureFileExistsCallback& callback) { | 199 const EnsureFileExistsCallback& callback) { |
| 202 EnsureFileExistsHelper* helper = new EnsureFileExistsHelper; | 200 EnsureFileExistsHelper* helper = new EnsureFileExistsHelper; |
| 203 return context->task_runner()->PostTaskAndReply( | 201 return context->task_runner()->PostTaskAndReply( |
| 204 FROM_HERE, | 202 FROM_HERE, |
| 205 Bind(&EnsureFileExistsHelper::RunWork, Unretained(helper), | 203 Bind(&EnsureFileExistsHelper::RunWork, Unretained(helper), |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 int64 length, | 285 int64 length, |
| 288 const StatusCallback& callback) { | 286 const StatusCallback& callback) { |
| 289 return base::PostTaskAndReplyWithResult( | 287 return base::PostTaskAndReplyWithResult( |
| 290 context->task_runner(), FROM_HERE, | 288 context->task_runner(), FROM_HERE, |
| 291 Bind(&FileSystemFileUtil::Truncate, Unretained(file_util), | 289 Bind(&FileSystemFileUtil::Truncate, Unretained(file_util), |
| 292 context, url, length), | 290 context, url, length), |
| 293 callback); | 291 callback); |
| 294 } | 292 } |
| 295 | 293 |
| 296 } // namespace fileapi | 294 } // namespace fileapi |
| OLD | NEW |