| 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 "webkit/fileapi/file_system_context.h" | 10 #include "webkit/fileapi/file_system_context.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 } // namespace | 107 } // namespace |
| 108 | 108 |
| 109 // static | 109 // static |
| 110 bool FileSystemFileUtilProxy::Delete( | 110 bool FileSystemFileUtilProxy::Delete( |
| 111 FileSystemOperationContext* context, | 111 FileSystemOperationContext* context, |
| 112 FileSystemFileUtil* file_util, | 112 FileSystemFileUtil* file_util, |
| 113 const FileSystemURL& url, | 113 const FileSystemURL& url, |
| 114 bool recursive, | 114 bool recursive, |
| 115 const StatusCallback& callback) { | 115 const StatusCallback& callback) { |
| 116 return base::FileUtilProxy::RelayFileTask( | 116 return base::FileUtilProxy::RelayFileTask( |
| 117 context->file_task_runner(), FROM_HERE, | 117 context->task_runner(), FROM_HERE, |
| 118 Bind(&FileUtilHelper::Delete, context, file_util, url, recursive), | 118 Bind(&FileUtilHelper::Delete, context, file_util, url, recursive), |
| 119 callback); | 119 callback); |
| 120 } | 120 } |
| 121 | 121 |
| 122 // static | 122 // static |
| 123 bool FileSystemFileUtilProxy::CreateOrOpen( | 123 bool FileSystemFileUtilProxy::CreateOrOpen( |
| 124 FileSystemOperationContext* context, | 124 FileSystemOperationContext* context, |
| 125 FileSystemFileUtil* file_util, | 125 FileSystemFileUtil* file_util, |
| 126 const FileSystemURL& url, | 126 const FileSystemURL& url, |
| 127 int file_flags, | 127 int file_flags, |
| 128 const CreateOrOpenCallback& callback) { | 128 const CreateOrOpenCallback& callback) { |
| 129 return base::FileUtilProxy::RelayCreateOrOpen( | 129 return base::FileUtilProxy::RelayCreateOrOpen( |
| 130 context->file_task_runner(), | 130 context->task_runner(), |
| 131 Bind(&FileSystemFileUtil::CreateOrOpen, Unretained(file_util), | 131 Bind(&FileSystemFileUtil::CreateOrOpen, Unretained(file_util), |
| 132 context, url, file_flags), | 132 context, url, file_flags), |
| 133 Bind(&FileSystemFileUtil::Close, Unretained(file_util), | 133 Bind(&FileSystemFileUtil::Close, Unretained(file_util), |
| 134 context), | 134 context), |
| 135 callback); | 135 callback); |
| 136 } | 136 } |
| 137 | 137 |
| 138 // static | 138 // static |
| 139 bool FileSystemFileUtilProxy::Copy( | 139 bool FileSystemFileUtilProxy::Copy( |
| 140 FileSystemOperationContext* context, | 140 FileSystemOperationContext* context, |
| 141 FileSystemFileUtil* src_util, | 141 FileSystemFileUtil* src_util, |
| 142 FileSystemFileUtil* dest_util, | 142 FileSystemFileUtil* dest_util, |
| 143 const FileSystemURL& src_url, | 143 const FileSystemURL& src_url, |
| 144 const FileSystemURL& dest_url, | 144 const FileSystemURL& dest_url, |
| 145 const StatusCallback& callback) { | 145 const StatusCallback& callback) { |
| 146 return base::FileUtilProxy::RelayFileTask( | 146 return base::FileUtilProxy::RelayFileTask( |
| 147 context->file_task_runner(), FROM_HERE, | 147 context->task_runner(), FROM_HERE, |
| 148 Bind(&FileUtilHelper::Copy, | 148 Bind(&FileUtilHelper::Copy, |
| 149 context, src_util, dest_util, src_url, dest_url), | 149 context, src_util, dest_util, src_url, dest_url), |
| 150 callback); | 150 callback); |
| 151 } | 151 } |
| 152 | 152 |
| 153 // static | 153 // static |
| 154 bool FileSystemFileUtilProxy::Move( | 154 bool FileSystemFileUtilProxy::Move( |
| 155 FileSystemOperationContext* context, | 155 FileSystemOperationContext* context, |
| 156 FileSystemFileUtil* src_util, | 156 FileSystemFileUtil* src_util, |
| 157 FileSystemFileUtil* dest_util, | 157 FileSystemFileUtil* dest_util, |
| 158 const FileSystemURL& src_url, | 158 const FileSystemURL& src_url, |
| 159 const FileSystemURL& dest_url, | 159 const FileSystemURL& dest_url, |
| 160 const StatusCallback& callback) { | 160 const StatusCallback& callback) { |
| 161 return base::FileUtilProxy::RelayFileTask( | 161 return base::FileUtilProxy::RelayFileTask( |
| 162 context->file_task_runner(), FROM_HERE, | 162 context->task_runner(), FROM_HERE, |
| 163 Bind(&FileUtilHelper::Move, | 163 Bind(&FileUtilHelper::Move, |
| 164 context, src_util, dest_util, src_url, dest_url), | 164 context, src_util, dest_util, src_url, dest_url), |
| 165 callback); | 165 callback); |
| 166 } | 166 } |
| 167 | 167 |
| 168 // static | 168 // static |
| 169 bool FileSystemFileUtilProxy::EnsureFileExists( | 169 bool FileSystemFileUtilProxy::EnsureFileExists( |
| 170 FileSystemOperationContext* context, | 170 FileSystemOperationContext* context, |
| 171 FileSystemFileUtil* file_util, | 171 FileSystemFileUtil* file_util, |
| 172 const FileSystemURL& url, | 172 const FileSystemURL& url, |
| 173 const EnsureFileExistsCallback& callback) { | 173 const EnsureFileExistsCallback& callback) { |
| 174 EnsureFileExistsHelper* helper = new EnsureFileExistsHelper; | 174 EnsureFileExistsHelper* helper = new EnsureFileExistsHelper; |
| 175 return context->file_task_runner()->PostTaskAndReply( | 175 return context->task_runner()->PostTaskAndReply( |
| 176 FROM_HERE, | 176 FROM_HERE, |
| 177 Bind(&EnsureFileExistsHelper::RunWork, Unretained(helper), | 177 Bind(&EnsureFileExistsHelper::RunWork, Unretained(helper), |
| 178 file_util, context, url), | 178 file_util, context, url), |
| 179 Bind(&EnsureFileExistsHelper::Reply, Owned(helper), callback)); | 179 Bind(&EnsureFileExistsHelper::Reply, Owned(helper), callback)); |
| 180 } | 180 } |
| 181 | 181 |
| 182 // static | 182 // static |
| 183 bool FileSystemFileUtilProxy::CreateDirectory( | 183 bool FileSystemFileUtilProxy::CreateDirectory( |
| 184 FileSystemOperationContext* context, | 184 FileSystemOperationContext* context, |
| 185 FileSystemFileUtil* file_util, | 185 FileSystemFileUtil* file_util, |
| 186 const FileSystemURL& url, | 186 const FileSystemURL& url, |
| 187 bool exclusive, | 187 bool exclusive, |
| 188 bool recursive, | 188 bool recursive, |
| 189 const StatusCallback& callback) { | 189 const StatusCallback& callback) { |
| 190 return base::FileUtilProxy::RelayFileTask( | 190 return base::FileUtilProxy::RelayFileTask( |
| 191 context->file_task_runner(), FROM_HERE, | 191 context->task_runner(), FROM_HERE, |
| 192 Bind(&FileSystemFileUtil::CreateDirectory, Unretained(file_util), | 192 Bind(&FileSystemFileUtil::CreateDirectory, Unretained(file_util), |
| 193 context, url, exclusive, recursive), | 193 context, url, exclusive, recursive), |
| 194 callback); | 194 callback); |
| 195 } | 195 } |
| 196 | 196 |
| 197 // static | 197 // static |
| 198 bool FileSystemFileUtilProxy::GetFileInfo( | 198 bool FileSystemFileUtilProxy::GetFileInfo( |
| 199 FileSystemOperationContext* context, | 199 FileSystemOperationContext* context, |
| 200 FileSystemFileUtil* file_util, | 200 FileSystemFileUtil* file_util, |
| 201 const FileSystemURL& url, | 201 const FileSystemURL& url, |
| 202 const GetFileInfoCallback& callback) { | 202 const GetFileInfoCallback& callback) { |
| 203 GetFileInfoHelper* helper = new GetFileInfoHelper; | 203 GetFileInfoHelper* helper = new GetFileInfoHelper; |
| 204 return context->file_task_runner()->PostTaskAndReply( | 204 return context->task_runner()->PostTaskAndReply( |
| 205 FROM_HERE, | 205 FROM_HERE, |
| 206 Bind(&GetFileInfoHelper::GetFileInfo, Unretained(helper), | 206 Bind(&GetFileInfoHelper::GetFileInfo, Unretained(helper), |
| 207 file_util, context, url), | 207 file_util, context, url), |
| 208 Bind(&GetFileInfoHelper::ReplyFileInfo, Owned(helper), callback)); | 208 Bind(&GetFileInfoHelper::ReplyFileInfo, Owned(helper), callback)); |
| 209 } | 209 } |
| 210 | 210 |
| 211 // static | 211 // static |
| 212 bool FileSystemFileUtilProxy::CreateSnapshotFile( | 212 bool FileSystemFileUtilProxy::CreateSnapshotFile( |
| 213 FileSystemOperationContext* context, | 213 FileSystemOperationContext* context, |
| 214 FileSystemFileUtil* file_util, | 214 FileSystemFileUtil* file_util, |
| 215 const FileSystemURL& url, | 215 const FileSystemURL& url, |
| 216 const SnapshotFileCallback& callback) { | 216 const SnapshotFileCallback& callback) { |
| 217 GetFileInfoHelper* helper = new GetFileInfoHelper; | 217 GetFileInfoHelper* helper = new GetFileInfoHelper; |
| 218 return context->file_task_runner()->PostTaskAndReply( | 218 return context->task_runner()->PostTaskAndReply( |
| 219 FROM_HERE, | 219 FROM_HERE, |
| 220 Bind(&GetFileInfoHelper::CreateSnapshotFile, Unretained(helper), | 220 Bind(&GetFileInfoHelper::CreateSnapshotFile, Unretained(helper), |
| 221 file_util, context, url), | 221 file_util, context, url), |
| 222 Bind(&GetFileInfoHelper::ReplySnapshotFile, Owned(helper), callback)); | 222 Bind(&GetFileInfoHelper::ReplySnapshotFile, Owned(helper), callback)); |
| 223 } | 223 } |
| 224 | 224 |
| 225 // static | 225 // static |
| 226 bool FileSystemFileUtilProxy::ReadDirectory( | 226 bool FileSystemFileUtilProxy::ReadDirectory( |
| 227 FileSystemOperationContext* context, | 227 FileSystemOperationContext* context, |
| 228 FileSystemFileUtil* file_util, | 228 FileSystemFileUtil* file_util, |
| 229 const FileSystemURL& url, | 229 const FileSystemURL& url, |
| 230 const ReadDirectoryCallback& callback) { | 230 const ReadDirectoryCallback& callback) { |
| 231 ReadDirectoryHelper* helper = new ReadDirectoryHelper; | 231 ReadDirectoryHelper* helper = new ReadDirectoryHelper; |
| 232 return context->file_task_runner()->PostTaskAndReply( | 232 return context->task_runner()->PostTaskAndReply( |
| 233 FROM_HERE, | 233 FROM_HERE, |
| 234 Bind(&ReadDirectoryHelper::RunWork, Unretained(helper), | 234 Bind(&ReadDirectoryHelper::RunWork, Unretained(helper), |
| 235 file_util, context, url), | 235 file_util, context, url), |
| 236 Bind(&ReadDirectoryHelper::Reply, Owned(helper), callback)); | 236 Bind(&ReadDirectoryHelper::Reply, Owned(helper), callback)); |
| 237 } | 237 } |
| 238 | 238 |
| 239 // static | 239 // static |
| 240 bool FileSystemFileUtilProxy::Touch( | 240 bool FileSystemFileUtilProxy::Touch( |
| 241 FileSystemOperationContext* context, | 241 FileSystemOperationContext* context, |
| 242 FileSystemFileUtil* file_util, | 242 FileSystemFileUtil* file_util, |
| 243 const FileSystemURL& url, | 243 const FileSystemURL& url, |
| 244 const base::Time& last_access_time, | 244 const base::Time& last_access_time, |
| 245 const base::Time& last_modified_time, | 245 const base::Time& last_modified_time, |
| 246 const StatusCallback& callback) { | 246 const StatusCallback& callback) { |
| 247 return base::FileUtilProxy::RelayFileTask( | 247 return base::FileUtilProxy::RelayFileTask( |
| 248 context->file_task_runner(), FROM_HERE, | 248 context->task_runner(), FROM_HERE, |
| 249 Bind(&FileSystemFileUtil::Touch, Unretained(file_util), | 249 Bind(&FileSystemFileUtil::Touch, Unretained(file_util), |
| 250 context, url, last_access_time, last_modified_time), | 250 context, url, last_access_time, last_modified_time), |
| 251 callback); | 251 callback); |
| 252 } | 252 } |
| 253 | 253 |
| 254 // static | 254 // static |
| 255 bool FileSystemFileUtilProxy::Truncate( | 255 bool FileSystemFileUtilProxy::Truncate( |
| 256 FileSystemOperationContext* context, | 256 FileSystemOperationContext* context, |
| 257 FileSystemFileUtil* file_util, | 257 FileSystemFileUtil* file_util, |
| 258 const FileSystemURL& url, | 258 const FileSystemURL& url, |
| 259 int64 length, | 259 int64 length, |
| 260 const StatusCallback& callback) { | 260 const StatusCallback& callback) { |
| 261 return base::FileUtilProxy::RelayFileTask( | 261 return base::FileUtilProxy::RelayFileTask( |
| 262 context->file_task_runner(), FROM_HERE, | 262 context->task_runner(), FROM_HERE, |
| 263 Bind(&FileSystemFileUtil::Truncate, Unretained(file_util), | 263 Bind(&FileSystemFileUtil::Truncate, Unretained(file_util), |
| 264 context, url, length), | 264 context, url, length), |
| 265 callback); | 265 callback); |
| 266 } | 266 } |
| 267 | 267 |
| 268 } // namespace fileapi | 268 } // namespace fileapi |
| OLD | NEW |