| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 private: | 102 private: |
| 103 base::PlatformFileError error_; | 103 base::PlatformFileError error_; |
| 104 std::vector<Proxy::Entry> entries_; | 104 std::vector<Proxy::Entry> entries_; |
| 105 DISALLOW_COPY_AND_ASSIGN(ReadDirectoryHelper); | 105 DISALLOW_COPY_AND_ASSIGN(ReadDirectoryHelper); |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 } // namespace | 108 } // namespace |
| 109 | 109 |
| 110 // static | 110 // static |
| 111 bool FileSystemFileUtilProxy::Delete( | 111 bool FileSystemFileUtilProxy::DeleteFile( |
| 112 FileSystemOperationContext* context, | 112 FileSystemOperationContext* context, |
| 113 FileSystemFileUtil* file_util, | 113 FileSystemFileUtil* file_util, |
| 114 const FileSystemURL& url, | 114 const FileSystemURL& url, |
| 115 bool recursive, | |
| 116 const StatusCallback& callback) { | 115 const StatusCallback& callback) { |
| 117 return base::PostTaskAndReplyWithResult( | 116 return base::PostTaskAndReplyWithResult( |
| 118 context->task_runner(), FROM_HERE, | 117 context->task_runner(), FROM_HERE, |
| 119 Bind(&FileUtilHelper::Delete, context, file_util, url, recursive), | 118 Bind(&FileSystemFileUtil::DeleteFile, Unretained(file_util), |
| 119 context, url), |
| 120 callback); | 120 callback); |
| 121 } | 121 } |
| 122 | 122 |
| 123 // static |
| 124 bool FileSystemFileUtilProxy::DeleteDirectory( |
| 125 FileSystemOperationContext* context, |
| 126 FileSystemFileUtil* file_util, |
| 127 const FileSystemURL& url, |
| 128 const StatusCallback& callback) { |
| 129 return base::PostTaskAndReplyWithResult( |
| 130 context->task_runner(), FROM_HERE, |
| 131 Bind(&FileSystemFileUtil::DeleteDirectory, Unretained(file_util), |
| 132 context, url), |
| 133 callback); |
| 134 } |
| 135 |
| 123 // static | 136 // static |
| 124 bool FileSystemFileUtilProxy::CreateOrOpen( | 137 bool FileSystemFileUtilProxy::CreateOrOpen( |
| 125 FileSystemOperationContext* context, | 138 FileSystemOperationContext* context, |
| 126 FileSystemFileUtil* file_util, | 139 FileSystemFileUtil* file_util, |
| 127 const FileSystemURL& url, | 140 const FileSystemURL& url, |
| 128 int file_flags, | 141 int file_flags, |
| 129 const CreateOrOpenCallback& callback) { | 142 const CreateOrOpenCallback& callback) { |
| 130 return base::FileUtilProxy::RelayCreateOrOpen( | 143 return base::FileUtilProxy::RelayCreateOrOpen( |
| 131 context->task_runner(), | 144 context->task_runner(), |
| 132 Bind(&FileSystemFileUtil::CreateOrOpen, Unretained(file_util), | 145 Bind(&FileSystemFileUtil::CreateOrOpen, Unretained(file_util), |
| 133 context, url, file_flags), | 146 context, url, file_flags), |
| 134 Bind(&FileSystemFileUtil::Close, Unretained(file_util), | 147 Bind(&FileSystemFileUtil::Close, Unretained(file_util), |
| 135 context), | 148 context), |
| 136 callback); | 149 callback); |
| 137 } | 150 } |
| 138 | 151 |
| 139 // static | 152 // static |
| 140 bool FileSystemFileUtilProxy::Copy( | 153 bool FileSystemFileUtilProxy::CopyLocalFile( |
| 141 FileSystemOperationContext* context, | 154 FileSystemOperationContext* context, |
| 142 FileSystemFileUtil* src_util, | 155 FileSystemFileUtil* file_util, |
| 143 FileSystemFileUtil* dest_util, | |
| 144 const FileSystemURL& src_url, | 156 const FileSystemURL& src_url, |
| 145 const FileSystemURL& dest_url, | 157 const FileSystemURL& dest_url, |
| 146 const StatusCallback& callback) { | 158 const StatusCallback& callback) { |
| 147 return base::PostTaskAndReplyWithResult( | 159 return base::PostTaskAndReplyWithResult( |
| 148 context->task_runner(), FROM_HERE, | 160 context->task_runner(), FROM_HERE, |
| 149 Bind(&FileUtilHelper::Copy, | 161 Bind(&FileSystemFileUtil::CopyOrMoveFile, Unretained(file_util), |
| 150 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::MoveLocalFile( |
| 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 */), |
| 151 callback); | 177 callback); |
| 152 } | 178 } |
| 153 | 179 |
| 154 // static | 180 // static |
| 155 bool FileSystemFileUtilProxy::CopyInForeignFile( | 181 bool FileSystemFileUtilProxy::CopyInForeignFile( |
| 156 FileSystemOperationContext* context, | 182 FileSystemOperationContext* context, |
| 157 FileSystemFileUtil* dest_util, | 183 FileSystemFileUtil* file_util, |
| 158 const FilePath& src_local_disk_file_path, | 184 const FilePath& src_local_disk_file_path, |
| 159 const FileSystemURL& dest_url, | 185 const FileSystemURL& dest_url, |
| 160 const StatusCallback& callback) { | 186 const StatusCallback& callback) { |
| 161 return base::PostTaskAndReplyWithResult( | 187 return base::PostTaskAndReplyWithResult( |
| 162 context->task_runner(), FROM_HERE, | 188 context->task_runner(), FROM_HERE, |
| 163 Bind(&FileSystemFileUtil::CopyInForeignFile, Unretained(dest_util), | 189 Bind(&FileSystemFileUtil::CopyInForeignFile, Unretained(file_util), |
| 164 context, src_local_disk_file_path, dest_url), | 190 context, src_local_disk_file_path, dest_url), |
| 165 callback); | 191 callback); |
| 166 } | 192 } |
| 167 | 193 |
| 168 // static | |
| 169 bool FileSystemFileUtilProxy::Move( | |
| 170 FileSystemOperationContext* context, | |
| 171 FileSystemFileUtil* src_util, | |
| 172 FileSystemFileUtil* dest_util, | |
| 173 const FileSystemURL& src_url, | |
| 174 const FileSystemURL& dest_url, | |
| 175 const StatusCallback& callback) { | |
| 176 return base::PostTaskAndReplyWithResult( | |
| 177 context->task_runner(), FROM_HERE, | |
| 178 Bind(&FileUtilHelper::Move, | |
| 179 context, src_util, dest_util, src_url, dest_url), | |
| 180 callback); | |
| 181 } | |
| 182 | |
| 183 // static | 194 // static |
| 184 bool FileSystemFileUtilProxy::EnsureFileExists( | 195 bool FileSystemFileUtilProxy::EnsureFileExists( |
| 185 FileSystemOperationContext* context, | 196 FileSystemOperationContext* context, |
| 186 FileSystemFileUtil* file_util, | 197 FileSystemFileUtil* file_util, |
| 187 const FileSystemURL& url, | 198 const FileSystemURL& url, |
| 188 const EnsureFileExistsCallback& callback) { | 199 const EnsureFileExistsCallback& callback) { |
| 189 EnsureFileExistsHelper* helper = new EnsureFileExistsHelper; | 200 EnsureFileExistsHelper* helper = new EnsureFileExistsHelper; |
| 190 return context->task_runner()->PostTaskAndReply( | 201 return context->task_runner()->PostTaskAndReply( |
| 191 FROM_HERE, | 202 FROM_HERE, |
| 192 Bind(&EnsureFileExistsHelper::RunWork, Unretained(helper), | 203 Bind(&EnsureFileExistsHelper::RunWork, Unretained(helper), |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 int64 length, | 285 int64 length, |
| 275 const StatusCallback& callback) { | 286 const StatusCallback& callback) { |
| 276 return base::PostTaskAndReplyWithResult( | 287 return base::PostTaskAndReplyWithResult( |
| 277 context->task_runner(), FROM_HERE, | 288 context->task_runner(), FROM_HERE, |
| 278 Bind(&FileSystemFileUtil::Truncate, Unretained(file_util), | 289 Bind(&FileSystemFileUtil::Truncate, Unretained(file_util), |
| 279 context, url, length), | 290 context, url, length), |
| 280 callback); | 291 callback); |
| 281 } | 292 } |
| 282 | 293 |
| 283 } // namespace fileapi | 294 } // namespace fileapi |
| OLD | NEW |