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