| 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 "webkit/fileapi/file_system_context.h" | 11 #include "webkit/fileapi/file_system_context.h" |
| 11 #include "webkit/fileapi/file_system_file_util.h" | 12 #include "webkit/fileapi/file_system_file_util.h" |
| 12 #include "webkit/fileapi/file_system_operation_context.h" | 13 #include "webkit/fileapi/file_system_operation_context.h" |
| 13 #include "webkit/fileapi/file_util_helper.h" | 14 #include "webkit/fileapi/file_util_helper.h" |
| 14 | 15 |
| 15 namespace fileapi { | 16 namespace fileapi { |
| 16 | 17 |
| 17 using base::Bind; | 18 using base::Bind; |
| 18 using base::Callback; | 19 using base::Callback; |
| 19 using base::Owned; | 20 using base::Owned; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 107 |
| 107 } // namespace | 108 } // namespace |
| 108 | 109 |
| 109 // static | 110 // static |
| 110 bool FileSystemFileUtilProxy::Delete( | 111 bool FileSystemFileUtilProxy::Delete( |
| 111 FileSystemOperationContext* context, | 112 FileSystemOperationContext* context, |
| 112 FileSystemFileUtil* file_util, | 113 FileSystemFileUtil* file_util, |
| 113 const FileSystemURL& url, | 114 const FileSystemURL& url, |
| 114 bool recursive, | 115 bool recursive, |
| 115 const StatusCallback& callback) { | 116 const StatusCallback& callback) { |
| 116 return base::FileUtilProxy::RelayFileTask( | 117 return base::PostTaskAndReplyWithResult( |
| 117 context->task_runner(), FROM_HERE, | 118 context->task_runner(), FROM_HERE, |
| 118 Bind(&FileUtilHelper::Delete, context, file_util, url, recursive), | 119 Bind(&FileUtilHelper::Delete, context, file_util, url, recursive), |
| 119 callback); | 120 callback); |
| 120 } | 121 } |
| 121 | 122 |
| 122 // static | 123 // static |
| 123 bool FileSystemFileUtilProxy::CreateOrOpen( | 124 bool FileSystemFileUtilProxy::CreateOrOpen( |
| 124 FileSystemOperationContext* context, | 125 FileSystemOperationContext* context, |
| 125 FileSystemFileUtil* file_util, | 126 FileSystemFileUtil* file_util, |
| 126 const FileSystemURL& url, | 127 const FileSystemURL& url, |
| 127 int file_flags, | 128 int file_flags, |
| 128 const CreateOrOpenCallback& callback) { | 129 const CreateOrOpenCallback& callback) { |
| 129 return base::FileUtilProxy::RelayCreateOrOpen( | 130 return base::FileUtilProxy::RelayCreateOrOpen( |
| 130 context->task_runner(), | 131 context->task_runner(), |
| 131 Bind(&FileSystemFileUtil::CreateOrOpen, Unretained(file_util), | 132 Bind(&FileSystemFileUtil::CreateOrOpen, Unretained(file_util), |
| 132 context, url, file_flags), | 133 context, url, file_flags), |
| 133 Bind(&FileSystemFileUtil::Close, Unretained(file_util), | 134 Bind(&FileSystemFileUtil::Close, Unretained(file_util), |
| 134 context), | 135 context), |
| 135 callback); | 136 callback); |
| 136 } | 137 } |
| 137 | 138 |
| 138 // static | 139 // static |
| 139 bool FileSystemFileUtilProxy::Copy( | 140 bool FileSystemFileUtilProxy::Copy( |
| 140 FileSystemOperationContext* context, | 141 FileSystemOperationContext* context, |
| 141 FileSystemFileUtil* src_util, | 142 FileSystemFileUtil* src_util, |
| 142 FileSystemFileUtil* dest_util, | 143 FileSystemFileUtil* dest_util, |
| 143 const FileSystemURL& src_url, | 144 const FileSystemURL& src_url, |
| 144 const FileSystemURL& dest_url, | 145 const FileSystemURL& dest_url, |
| 145 const StatusCallback& callback) { | 146 const StatusCallback& callback) { |
| 146 return base::FileUtilProxy::RelayFileTask( | 147 return base::PostTaskAndReplyWithResult( |
| 147 context->task_runner(), FROM_HERE, | 148 context->task_runner(), FROM_HERE, |
| 148 Bind(&FileUtilHelper::Copy, | 149 Bind(&FileUtilHelper::Copy, |
| 149 context, src_util, dest_util, src_url, dest_url), | 150 context, src_util, dest_util, src_url, dest_url), |
| 150 callback); | 151 callback); |
| 151 } | 152 } |
| 152 | 153 |
| 153 // static | 154 // static |
| 154 bool FileSystemFileUtilProxy::CopyInForeignFile( | 155 bool FileSystemFileUtilProxy::CopyInForeignFile( |
| 155 FileSystemOperationContext* context, | 156 FileSystemOperationContext* context, |
| 156 FileSystemFileUtil* dest_util, | 157 FileSystemFileUtil* dest_util, |
| 157 const FilePath& src_local_disk_file_path, | 158 const FilePath& src_local_disk_file_path, |
| 158 const FileSystemURL& dest_url, | 159 const FileSystemURL& dest_url, |
| 159 const StatusCallback& callback) { | 160 const StatusCallback& callback) { |
| 160 return base::FileUtilProxy::RelayFileTask( | 161 return base::PostTaskAndReplyWithResult( |
| 161 context->task_runner(), FROM_HERE, | 162 context->task_runner(), FROM_HERE, |
| 162 Bind(&FileSystemFileUtil::CopyInForeignFile, Unretained(dest_util), | 163 Bind(&FileSystemFileUtil::CopyInForeignFile, Unretained(dest_util), |
| 163 context, src_local_disk_file_path, dest_url), | 164 context, src_local_disk_file_path, dest_url), |
| 164 callback); | 165 callback); |
| 165 } | 166 } |
| 166 | 167 |
| 167 // static | 168 // static |
| 168 bool FileSystemFileUtilProxy::Move( | 169 bool FileSystemFileUtilProxy::Move( |
| 169 FileSystemOperationContext* context, | 170 FileSystemOperationContext* context, |
| 170 FileSystemFileUtil* src_util, | 171 FileSystemFileUtil* src_util, |
| 171 FileSystemFileUtil* dest_util, | 172 FileSystemFileUtil* dest_util, |
| 172 const FileSystemURL& src_url, | 173 const FileSystemURL& src_url, |
| 173 const FileSystemURL& dest_url, | 174 const FileSystemURL& dest_url, |
| 174 const StatusCallback& callback) { | 175 const StatusCallback& callback) { |
| 175 return base::FileUtilProxy::RelayFileTask( | 176 return base::PostTaskAndReplyWithResult( |
| 176 context->task_runner(), FROM_HERE, | 177 context->task_runner(), FROM_HERE, |
| 177 Bind(&FileUtilHelper::Move, | 178 Bind(&FileUtilHelper::Move, |
| 178 context, src_util, dest_util, src_url, dest_url), | 179 context, src_util, dest_util, src_url, dest_url), |
| 179 callback); | 180 callback); |
| 180 } | 181 } |
| 181 | 182 |
| 182 // static | 183 // static |
| 183 bool FileSystemFileUtilProxy::EnsureFileExists( | 184 bool FileSystemFileUtilProxy::EnsureFileExists( |
| 184 FileSystemOperationContext* context, | 185 FileSystemOperationContext* context, |
| 185 FileSystemFileUtil* file_util, | 186 FileSystemFileUtil* file_util, |
| 186 const FileSystemURL& url, | 187 const FileSystemURL& url, |
| 187 const EnsureFileExistsCallback& callback) { | 188 const EnsureFileExistsCallback& callback) { |
| 188 EnsureFileExistsHelper* helper = new EnsureFileExistsHelper; | 189 EnsureFileExistsHelper* helper = new EnsureFileExistsHelper; |
| 189 return context->task_runner()->PostTaskAndReply( | 190 return context->task_runner()->PostTaskAndReply( |
| 190 FROM_HERE, | 191 FROM_HERE, |
| 191 Bind(&EnsureFileExistsHelper::RunWork, Unretained(helper), | 192 Bind(&EnsureFileExistsHelper::RunWork, Unretained(helper), |
| 192 file_util, context, url), | 193 file_util, context, url), |
| 193 Bind(&EnsureFileExistsHelper::Reply, Owned(helper), callback)); | 194 Bind(&EnsureFileExistsHelper::Reply, Owned(helper), callback)); |
| 194 } | 195 } |
| 195 | 196 |
| 196 // static | 197 // static |
| 197 bool FileSystemFileUtilProxy::CreateDirectory( | 198 bool FileSystemFileUtilProxy::CreateDirectory( |
| 198 FileSystemOperationContext* context, | 199 FileSystemOperationContext* context, |
| 199 FileSystemFileUtil* file_util, | 200 FileSystemFileUtil* file_util, |
| 200 const FileSystemURL& url, | 201 const FileSystemURL& url, |
| 201 bool exclusive, | 202 bool exclusive, |
| 202 bool recursive, | 203 bool recursive, |
| 203 const StatusCallback& callback) { | 204 const StatusCallback& callback) { |
| 204 return base::FileUtilProxy::RelayFileTask( | 205 return base::PostTaskAndReplyWithResult( |
| 205 context->task_runner(), FROM_HERE, | 206 context->task_runner(), FROM_HERE, |
| 206 Bind(&FileSystemFileUtil::CreateDirectory, Unretained(file_util), | 207 Bind(&FileSystemFileUtil::CreateDirectory, Unretained(file_util), |
| 207 context, url, exclusive, recursive), | 208 context, url, exclusive, recursive), |
| 208 callback); | 209 callback); |
| 209 } | 210 } |
| 210 | 211 |
| 211 // static | 212 // static |
| 212 bool FileSystemFileUtilProxy::GetFileInfo( | 213 bool FileSystemFileUtilProxy::GetFileInfo( |
| 213 FileSystemOperationContext* context, | 214 FileSystemOperationContext* context, |
| 214 FileSystemFileUtil* file_util, | 215 FileSystemFileUtil* file_util, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 } | 252 } |
| 252 | 253 |
| 253 // static | 254 // static |
| 254 bool FileSystemFileUtilProxy::Touch( | 255 bool FileSystemFileUtilProxy::Touch( |
| 255 FileSystemOperationContext* context, | 256 FileSystemOperationContext* context, |
| 256 FileSystemFileUtil* file_util, | 257 FileSystemFileUtil* file_util, |
| 257 const FileSystemURL& url, | 258 const FileSystemURL& url, |
| 258 const base::Time& last_access_time, | 259 const base::Time& last_access_time, |
| 259 const base::Time& last_modified_time, | 260 const base::Time& last_modified_time, |
| 260 const StatusCallback& callback) { | 261 const StatusCallback& callback) { |
| 261 return base::FileUtilProxy::RelayFileTask( | 262 return base::PostTaskAndReplyWithResult( |
| 262 context->task_runner(), FROM_HERE, | 263 context->task_runner(), FROM_HERE, |
| 263 Bind(&FileSystemFileUtil::Touch, Unretained(file_util), | 264 Bind(&FileSystemFileUtil::Touch, Unretained(file_util), |
| 264 context, url, last_access_time, last_modified_time), | 265 context, url, last_access_time, last_modified_time), |
| 265 callback); | 266 callback); |
| 266 } | 267 } |
| 267 | 268 |
| 268 // static | 269 // static |
| 269 bool FileSystemFileUtilProxy::Truncate( | 270 bool FileSystemFileUtilProxy::Truncate( |
| 270 FileSystemOperationContext* context, | 271 FileSystemOperationContext* context, |
| 271 FileSystemFileUtil* file_util, | 272 FileSystemFileUtil* file_util, |
| 272 const FileSystemURL& url, | 273 const FileSystemURL& url, |
| 273 int64 length, | 274 int64 length, |
| 274 const StatusCallback& callback) { | 275 const StatusCallback& callback) { |
| 275 return base::FileUtilProxy::RelayFileTask( | 276 return base::PostTaskAndReplyWithResult( |
| 276 context->task_runner(), FROM_HERE, | 277 context->task_runner(), FROM_HERE, |
| 277 Bind(&FileSystemFileUtil::Truncate, Unretained(file_util), | 278 Bind(&FileSystemFileUtil::Truncate, Unretained(file_util), |
| 278 context, url, length), | 279 context, url, length), |
| 279 callback); | 280 callback); |
| 280 } | 281 } |
| 281 | 282 |
| 282 } // namespace fileapi | 283 } // namespace fileapi |
| OLD | NEW |