| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/browser/fileapi/async_file_util_adapter.h" | 5 #include "webkit/browser/fileapi/async_file_util_adapter.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/sequenced_task_runner.h" | 8 #include "base/sequenced_task_runner.h" |
| 9 #include "base/task_runner_util.h" | 9 #include "base/task_runner_util.h" |
| 10 #include "webkit/browser/fileapi/file_system_context.h" | 10 #include "webkit/browser/fileapi/file_system_context.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 public: | 29 public: |
| 30 EnsureFileExistsHelper() : error_(base::PLATFORM_FILE_OK), created_(false) {} | 30 EnsureFileExistsHelper() : error_(base::PLATFORM_FILE_OK), created_(false) {} |
| 31 | 31 |
| 32 void RunWork(FileSystemFileUtil* file_util, | 32 void RunWork(FileSystemFileUtil* file_util, |
| 33 FileSystemOperationContext* context, | 33 FileSystemOperationContext* context, |
| 34 const FileSystemURL& url) { | 34 const FileSystemURL& url) { |
| 35 error_ = file_util->EnsureFileExists(context, url, &created_); | 35 error_ = file_util->EnsureFileExists(context, url, &created_); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void Reply(const AsyncFileUtil::EnsureFileExistsCallback& callback) { | 38 void Reply(const AsyncFileUtil::EnsureFileExistsCallback& callback) { |
| 39 if (!callback.is_null()) | 39 callback.Run(error_, created_); |
| 40 callback.Run(error_, created_); | |
| 41 } | 40 } |
| 42 | 41 |
| 43 private: | 42 private: |
| 44 base::PlatformFileError error_; | 43 base::PlatformFileError error_; |
| 45 bool created_; | 44 bool created_; |
| 46 DISALLOW_COPY_AND_ASSIGN(EnsureFileExistsHelper); | 45 DISALLOW_COPY_AND_ASSIGN(EnsureFileExistsHelper); |
| 47 }; | 46 }; |
| 48 | 47 |
| 49 class GetFileInfoHelper { | 48 class GetFileInfoHelper { |
| 50 public: | 49 public: |
| 51 GetFileInfoHelper() | 50 GetFileInfoHelper() |
| 52 : error_(base::PLATFORM_FILE_OK) {} | 51 : error_(base::PLATFORM_FILE_OK) {} |
| 53 | 52 |
| 54 void GetFileInfo(FileSystemFileUtil* file_util, | 53 void GetFileInfo(FileSystemFileUtil* file_util, |
| 55 FileSystemOperationContext* context, | 54 FileSystemOperationContext* context, |
| 56 const FileSystemURL& url) { | 55 const FileSystemURL& url) { |
| 57 error_ = file_util->GetFileInfo(context, url, &file_info_, &platform_path_); | 56 error_ = file_util->GetFileInfo(context, url, &file_info_, &platform_path_); |
| 58 } | 57 } |
| 59 | 58 |
| 60 void CreateSnapshotFile(FileSystemFileUtil* file_util, | 59 void CreateSnapshotFile(FileSystemFileUtil* file_util, |
| 61 FileSystemOperationContext* context, | 60 FileSystemOperationContext* context, |
| 62 const FileSystemURL& url) { | 61 const FileSystemURL& url) { |
| 63 scoped_file_ = file_util->CreateSnapshotFile( | 62 scoped_file_ = file_util->CreateSnapshotFile( |
| 64 context, url, &error_, &file_info_, &platform_path_); | 63 context, url, &error_, &file_info_, &platform_path_); |
| 65 } | 64 } |
| 66 | 65 |
| 67 void ReplyFileInfo(const AsyncFileUtil::GetFileInfoCallback& callback) { | 66 void ReplyFileInfo(const AsyncFileUtil::GetFileInfoCallback& callback) { |
| 68 if (!callback.is_null()) | 67 callback.Run(error_, file_info_); |
| 69 callback.Run(error_, file_info_); | |
| 70 } | 68 } |
| 71 | 69 |
| 72 void ReplySnapshotFile( | 70 void ReplySnapshotFile( |
| 73 const AsyncFileUtil::CreateSnapshotFileCallback& callback) { | 71 const AsyncFileUtil::CreateSnapshotFileCallback& callback) { |
| 74 if (!callback.is_null()) | 72 callback.Run(error_, file_info_, platform_path_, |
| 75 callback.Run(error_, file_info_, platform_path_, | 73 ShareableFileReference::GetOrCreate(scoped_file_.Pass())); |
| 76 ShareableFileReference::GetOrCreate(scoped_file_.Pass())); | |
| 77 } | 74 } |
| 78 | 75 |
| 79 private: | 76 private: |
| 80 base::PlatformFileError error_; | 77 base::PlatformFileError error_; |
| 81 base::PlatformFileInfo file_info_; | 78 base::PlatformFileInfo file_info_; |
| 82 base::FilePath platform_path_; | 79 base::FilePath platform_path_; |
| 83 webkit_blob::ScopedFile scoped_file_; | 80 webkit_blob::ScopedFile scoped_file_; |
| 84 DISALLOW_COPY_AND_ASSIGN(GetFileInfoHelper); | 81 DISALLOW_COPY_AND_ASSIGN(GetFileInfoHelper); |
| 85 }; | 82 }; |
| 86 | 83 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 113 entry.is_directory = file_enum->IsDirectory(); | 110 entry.is_directory = file_enum->IsDirectory(); |
| 114 entry.name = VirtualPath::BaseName(current).value(); | 111 entry.name = VirtualPath::BaseName(current).value(); |
| 115 entry.size = file_enum->Size(); | 112 entry.size = file_enum->Size(); |
| 116 entry.last_modified_time = file_enum->LastModifiedTime(); | 113 entry.last_modified_time = file_enum->LastModifiedTime(); |
| 117 entries_.push_back(entry); | 114 entries_.push_back(entry); |
| 118 } | 115 } |
| 119 error_ = base::PLATFORM_FILE_OK; | 116 error_ = base::PLATFORM_FILE_OK; |
| 120 } | 117 } |
| 121 | 118 |
| 122 void Reply(const AsyncFileUtil::ReadDirectoryCallback& callback) { | 119 void Reply(const AsyncFileUtil::ReadDirectoryCallback& callback) { |
| 123 if (!callback.is_null()) | 120 callback.Run(error_, entries_, false /* has_more */); |
| 124 callback.Run(error_, entries_, false /* has_more */); | |
| 125 } | 121 } |
| 126 | 122 |
| 127 private: | 123 private: |
| 128 base::PlatformFileError error_; | 124 base::PlatformFileError error_; |
| 129 std::vector<DirectoryEntry> entries_; | 125 std::vector<DirectoryEntry> entries_; |
| 130 DISALLOW_COPY_AND_ASSIGN(ReadDirectoryHelper); | 126 DISALLOW_COPY_AND_ASSIGN(ReadDirectoryHelper); |
| 131 }; | 127 }; |
| 132 | 128 |
| 133 void RunCreateOrOpenCallback( | 129 void RunCreateOrOpenCallback( |
| 134 const AsyncFileUtil::CreateOrOpenCallback& callback, | 130 const AsyncFileUtil::CreateOrOpenCallback& callback, |
| 135 base::PlatformFileError result, | 131 base::PlatformFileError result, |
| 136 base::PassPlatformFile file, | 132 base::PassPlatformFile file, |
| 137 bool created) { | 133 bool created) { |
| 138 callback.Run(result, file); | 134 callback.Run(result, file); |
| 139 } | 135 } |
| 140 | 136 |
| 141 } // namespace | 137 } // namespace |
| 142 | 138 |
| 143 AsyncFileUtilAdapter::AsyncFileUtilAdapter( | 139 AsyncFileUtilAdapter::AsyncFileUtilAdapter( |
| 144 FileSystemFileUtil* sync_file_util) | 140 FileSystemFileUtil* sync_file_util) |
| 145 : sync_file_util_(sync_file_util) { | 141 : sync_file_util_(sync_file_util) { |
| 146 DCHECK(sync_file_util_.get()); | 142 DCHECK(sync_file_util_.get()); |
| 147 } | 143 } |
| 148 | 144 |
| 149 AsyncFileUtilAdapter::~AsyncFileUtilAdapter() { | 145 AsyncFileUtilAdapter::~AsyncFileUtilAdapter() { |
| 150 } | 146 } |
| 151 | 147 |
| 152 bool AsyncFileUtilAdapter::CreateOrOpen( | 148 void AsyncFileUtilAdapter::CreateOrOpen( |
| 153 scoped_ptr<FileSystemOperationContext> context, | 149 scoped_ptr<FileSystemOperationContext> context, |
| 154 const FileSystemURL& url, | 150 const FileSystemURL& url, |
| 155 int file_flags, | 151 int file_flags, |
| 156 const CreateOrOpenCallback& callback) { | 152 const CreateOrOpenCallback& callback) { |
| 157 FileSystemOperationContext* context_ptr = context.release(); | 153 FileSystemOperationContext* context_ptr = context.release(); |
| 158 return base::FileUtilProxy::RelayCreateOrOpen( | 154 const bool success = base::FileUtilProxy::RelayCreateOrOpen( |
| 159 context_ptr->task_runner(), | 155 context_ptr->task_runner(), |
| 160 Bind(&FileSystemFileUtil::CreateOrOpen, Unretained(sync_file_util_.get()), | 156 Bind(&FileSystemFileUtil::CreateOrOpen, Unretained(sync_file_util_.get()), |
| 161 context_ptr, url, file_flags), | 157 context_ptr, url, file_flags), |
| 162 Bind(&FileSystemFileUtil::Close, Unretained(sync_file_util_.get()), | 158 Bind(&FileSystemFileUtil::Close, Unretained(sync_file_util_.get()), |
| 163 base::Owned(context_ptr)), | 159 base::Owned(context_ptr)), |
| 164 Bind(&RunCreateOrOpenCallback, callback)); | 160 Bind(&RunCreateOrOpenCallback, callback)); |
| 165 } | 161 DCHECK(success); |
| 166 | 162 } |
| 167 bool AsyncFileUtilAdapter::EnsureFileExists( | 163 |
| 164 void AsyncFileUtilAdapter::EnsureFileExists( |
| 168 scoped_ptr<FileSystemOperationContext> context, | 165 scoped_ptr<FileSystemOperationContext> context, |
| 169 const FileSystemURL& url, | 166 const FileSystemURL& url, |
| 170 const EnsureFileExistsCallback& callback) { | 167 const EnsureFileExistsCallback& callback) { |
| 171 EnsureFileExistsHelper* helper = new EnsureFileExistsHelper; | 168 EnsureFileExistsHelper* helper = new EnsureFileExistsHelper; |
| 172 FileSystemOperationContext* context_ptr = context.release(); | 169 FileSystemOperationContext* context_ptr = context.release(); |
| 173 return context_ptr->task_runner()->PostTaskAndReply( | 170 const bool success = context_ptr->task_runner()->PostTaskAndReply( |
| 174 FROM_HERE, | 171 FROM_HERE, |
| 175 Bind(&EnsureFileExistsHelper::RunWork, Unretained(helper), | 172 Bind(&EnsureFileExistsHelper::RunWork, Unretained(helper), |
| 176 sync_file_util_.get(), base::Owned(context_ptr), url), | 173 sync_file_util_.get(), base::Owned(context_ptr), url), |
| 177 Bind(&EnsureFileExistsHelper::Reply, Owned(helper), callback)); | 174 Bind(&EnsureFileExistsHelper::Reply, Owned(helper), callback)); |
| 178 } | 175 DCHECK(success); |
| 179 | 176 } |
| 180 bool AsyncFileUtilAdapter::CreateDirectory( | 177 |
| 178 void AsyncFileUtilAdapter::CreateDirectory( |
| 181 scoped_ptr<FileSystemOperationContext> context, | 179 scoped_ptr<FileSystemOperationContext> context, |
| 182 const FileSystemURL& url, | 180 const FileSystemURL& url, |
| 183 bool exclusive, | 181 bool exclusive, |
| 184 bool recursive, | 182 bool recursive, |
| 185 const StatusCallback& callback) { | 183 const StatusCallback& callback) { |
| 186 FileSystemOperationContext* context_ptr = context.release(); | 184 FileSystemOperationContext* context_ptr = context.release(); |
| 187 return base::PostTaskAndReplyWithResult( | 185 const bool success = base::PostTaskAndReplyWithResult( |
| 188 context_ptr->task_runner(), FROM_HERE, | 186 context_ptr->task_runner(), FROM_HERE, |
| 189 Bind(&FileSystemFileUtil::CreateDirectory, | 187 Bind(&FileSystemFileUtil::CreateDirectory, |
| 190 Unretained(sync_file_util_.get()), | 188 Unretained(sync_file_util_.get()), |
| 191 base::Owned(context_ptr), url, exclusive, recursive), | 189 base::Owned(context_ptr), url, exclusive, recursive), |
| 192 callback); | 190 callback); |
| 193 } | 191 DCHECK(success); |
| 194 | 192 } |
| 195 bool AsyncFileUtilAdapter::GetFileInfo( | 193 |
| 194 void AsyncFileUtilAdapter::GetFileInfo( |
| 196 scoped_ptr<FileSystemOperationContext> context, | 195 scoped_ptr<FileSystemOperationContext> context, |
| 197 const FileSystemURL& url, | 196 const FileSystemURL& url, |
| 198 const GetFileInfoCallback& callback) { | 197 const GetFileInfoCallback& callback) { |
| 199 FileSystemOperationContext* context_ptr = context.release(); | 198 FileSystemOperationContext* context_ptr = context.release(); |
| 200 GetFileInfoHelper* helper = new GetFileInfoHelper; | 199 GetFileInfoHelper* helper = new GetFileInfoHelper; |
| 201 return context_ptr->task_runner()->PostTaskAndReply( | 200 const bool success = context_ptr->task_runner()->PostTaskAndReply( |
| 202 FROM_HERE, | 201 FROM_HERE, |
| 203 Bind(&GetFileInfoHelper::GetFileInfo, Unretained(helper), | 202 Bind(&GetFileInfoHelper::GetFileInfo, Unretained(helper), |
| 204 sync_file_util_.get(), base::Owned(context_ptr), url), | 203 sync_file_util_.get(), base::Owned(context_ptr), url), |
| 205 Bind(&GetFileInfoHelper::ReplyFileInfo, Owned(helper), callback)); | 204 Bind(&GetFileInfoHelper::ReplyFileInfo, Owned(helper), callback)); |
| 206 } | 205 DCHECK(success); |
| 207 | 206 } |
| 208 bool AsyncFileUtilAdapter::ReadDirectory( | 207 |
| 208 void AsyncFileUtilAdapter::ReadDirectory( |
| 209 scoped_ptr<FileSystemOperationContext> context, | 209 scoped_ptr<FileSystemOperationContext> context, |
| 210 const FileSystemURL& url, | 210 const FileSystemURL& url, |
| 211 const ReadDirectoryCallback& callback) { | 211 const ReadDirectoryCallback& callback) { |
| 212 FileSystemOperationContext* context_ptr = context.release(); | 212 FileSystemOperationContext* context_ptr = context.release(); |
| 213 ReadDirectoryHelper* helper = new ReadDirectoryHelper; | 213 ReadDirectoryHelper* helper = new ReadDirectoryHelper; |
| 214 return context_ptr->task_runner()->PostTaskAndReply( | 214 const bool success = context_ptr->task_runner()->PostTaskAndReply( |
| 215 FROM_HERE, | 215 FROM_HERE, |
| 216 Bind(&ReadDirectoryHelper::RunWork, Unretained(helper), | 216 Bind(&ReadDirectoryHelper::RunWork, Unretained(helper), |
| 217 sync_file_util_.get(), base::Owned(context_ptr), url), | 217 sync_file_util_.get(), base::Owned(context_ptr), url), |
| 218 Bind(&ReadDirectoryHelper::Reply, Owned(helper), callback)); | 218 Bind(&ReadDirectoryHelper::Reply, Owned(helper), callback)); |
| 219 } | 219 DCHECK(success); |
| 220 | 220 } |
| 221 bool AsyncFileUtilAdapter::Touch( | 221 |
| 222 void AsyncFileUtilAdapter::Touch( |
| 222 scoped_ptr<FileSystemOperationContext> context, | 223 scoped_ptr<FileSystemOperationContext> context, |
| 223 const FileSystemURL& url, | 224 const FileSystemURL& url, |
| 224 const base::Time& last_access_time, | 225 const base::Time& last_access_time, |
| 225 const base::Time& last_modified_time, | 226 const base::Time& last_modified_time, |
| 226 const StatusCallback& callback) { | 227 const StatusCallback& callback) { |
| 227 FileSystemOperationContext* context_ptr = context.release(); | 228 FileSystemOperationContext* context_ptr = context.release(); |
| 228 return base::PostTaskAndReplyWithResult( | 229 const bool success = base::PostTaskAndReplyWithResult( |
| 229 context_ptr->task_runner(), FROM_HERE, | 230 context_ptr->task_runner(), FROM_HERE, |
| 230 Bind(&FileSystemFileUtil::Touch, Unretained(sync_file_util_.get()), | 231 Bind(&FileSystemFileUtil::Touch, Unretained(sync_file_util_.get()), |
| 231 base::Owned(context_ptr), url, | 232 base::Owned(context_ptr), url, |
| 232 last_access_time, last_modified_time), | 233 last_access_time, last_modified_time), |
| 233 callback); | 234 callback); |
| 234 } | 235 DCHECK(success); |
| 235 | 236 } |
| 236 bool AsyncFileUtilAdapter::Truncate( | 237 |
| 238 void AsyncFileUtilAdapter::Truncate( |
| 237 scoped_ptr<FileSystemOperationContext> context, | 239 scoped_ptr<FileSystemOperationContext> context, |
| 238 const FileSystemURL& url, | 240 const FileSystemURL& url, |
| 239 int64 length, | 241 int64 length, |
| 240 const StatusCallback& callback) { | 242 const StatusCallback& callback) { |
| 241 FileSystemOperationContext* context_ptr = context.release(); | 243 FileSystemOperationContext* context_ptr = context.release(); |
| 242 return base::PostTaskAndReplyWithResult( | 244 const bool success = base::PostTaskAndReplyWithResult( |
| 243 context_ptr->task_runner(), FROM_HERE, | 245 context_ptr->task_runner(), FROM_HERE, |
| 244 Bind(&FileSystemFileUtil::Truncate, Unretained(sync_file_util_.get()), | 246 Bind(&FileSystemFileUtil::Truncate, Unretained(sync_file_util_.get()), |
| 245 base::Owned(context_ptr), url, length), | 247 base::Owned(context_ptr), url, length), |
| 246 callback); | 248 callback); |
| 247 } | 249 DCHECK(success); |
| 248 | 250 } |
| 249 bool AsyncFileUtilAdapter::CopyFileLocal( | 251 |
| 252 void AsyncFileUtilAdapter::CopyFileLocal( |
| 250 scoped_ptr<FileSystemOperationContext> context, | 253 scoped_ptr<FileSystemOperationContext> context, |
| 251 const FileSystemURL& src_url, | 254 const FileSystemURL& src_url, |
| 252 const FileSystemURL& dest_url, | 255 const FileSystemURL& dest_url, |
| 253 const StatusCallback& callback) { | 256 const StatusCallback& callback) { |
| 254 FileSystemOperationContext* context_ptr = context.release(); | 257 FileSystemOperationContext* context_ptr = context.release(); |
| 255 return base::PostTaskAndReplyWithResult( | 258 const bool success = base::PostTaskAndReplyWithResult( |
| 256 context_ptr->task_runner(), FROM_HERE, | 259 context_ptr->task_runner(), FROM_HERE, |
| 257 Bind(&FileSystemFileUtil::CopyOrMoveFile, | 260 Bind(&FileSystemFileUtil::CopyOrMoveFile, |
| 258 Unretained(sync_file_util_.get()), | 261 Unretained(sync_file_util_.get()), |
| 259 base::Owned(context_ptr), src_url, dest_url, true /* copy */), | 262 base::Owned(context_ptr), src_url, dest_url, true /* copy */), |
| 260 callback); | 263 callback); |
| 261 } | 264 DCHECK(success); |
| 262 | 265 } |
| 263 bool AsyncFileUtilAdapter::MoveFileLocal( | 266 |
| 267 void AsyncFileUtilAdapter::MoveFileLocal( |
| 264 scoped_ptr<FileSystemOperationContext> context, | 268 scoped_ptr<FileSystemOperationContext> context, |
| 265 const FileSystemURL& src_url, | 269 const FileSystemURL& src_url, |
| 266 const FileSystemURL& dest_url, | 270 const FileSystemURL& dest_url, |
| 267 const StatusCallback& callback) { | 271 const StatusCallback& callback) { |
| 268 FileSystemOperationContext* context_ptr = context.release(); | 272 FileSystemOperationContext* context_ptr = context.release(); |
| 269 return base::PostTaskAndReplyWithResult( | 273 const bool success = base::PostTaskAndReplyWithResult( |
| 270 context_ptr->task_runner(), FROM_HERE, | 274 context_ptr->task_runner(), FROM_HERE, |
| 271 Bind(&FileSystemFileUtil::CopyOrMoveFile, | 275 Bind(&FileSystemFileUtil::CopyOrMoveFile, |
| 272 Unretained(sync_file_util_.get()), | 276 Unretained(sync_file_util_.get()), |
| 273 base::Owned(context_ptr), src_url, dest_url, false /* copy */), | 277 base::Owned(context_ptr), src_url, dest_url, false /* copy */), |
| 274 callback); | 278 callback); |
| 275 } | 279 DCHECK(success); |
| 276 | 280 } |
| 277 bool AsyncFileUtilAdapter::CopyInForeignFile( | 281 |
| 282 void AsyncFileUtilAdapter::CopyInForeignFile( |
| 278 scoped_ptr<FileSystemOperationContext> context, | 283 scoped_ptr<FileSystemOperationContext> context, |
| 279 const base::FilePath& src_file_path, | 284 const base::FilePath& src_file_path, |
| 280 const FileSystemURL& dest_url, | 285 const FileSystemURL& dest_url, |
| 281 const StatusCallback& callback) { | 286 const StatusCallback& callback) { |
| 282 FileSystemOperationContext* context_ptr = context.release(); | 287 FileSystemOperationContext* context_ptr = context.release(); |
| 283 return base::PostTaskAndReplyWithResult( | 288 const bool success = base::PostTaskAndReplyWithResult( |
| 284 context_ptr->task_runner(), FROM_HERE, | 289 context_ptr->task_runner(), FROM_HERE, |
| 285 Bind(&FileSystemFileUtil::CopyInForeignFile, | 290 Bind(&FileSystemFileUtil::CopyInForeignFile, |
| 286 Unretained(sync_file_util_.get()), | 291 Unretained(sync_file_util_.get()), |
| 287 base::Owned(context_ptr), src_file_path, dest_url), | 292 base::Owned(context_ptr), src_file_path, dest_url), |
| 288 callback); | 293 callback); |
| 289 } | 294 DCHECK(success); |
| 290 | 295 } |
| 291 bool AsyncFileUtilAdapter::DeleteFile( | 296 |
| 292 scoped_ptr<FileSystemOperationContext> context, | 297 void AsyncFileUtilAdapter::DeleteFile( |
| 293 const FileSystemURL& url, | 298 scoped_ptr<FileSystemOperationContext> context, |
| 294 const StatusCallback& callback) { | 299 const FileSystemURL& url, |
| 295 FileSystemOperationContext* context_ptr = context.release(); | 300 const StatusCallback& callback) { |
| 296 return base::PostTaskAndReplyWithResult( | 301 FileSystemOperationContext* context_ptr = context.release(); |
| 302 const bool success = base::PostTaskAndReplyWithResult( |
| 297 context_ptr->task_runner(), FROM_HERE, | 303 context_ptr->task_runner(), FROM_HERE, |
| 298 Bind(&FileSystemFileUtil::DeleteFile, | 304 Bind(&FileSystemFileUtil::DeleteFile, |
| 299 Unretained(sync_file_util_.get()), | 305 Unretained(sync_file_util_.get()), |
| 300 base::Owned(context_ptr), url), | 306 base::Owned(context_ptr), url), |
| 301 callback); | 307 callback); |
| 302 } | 308 DCHECK(success); |
| 303 | 309 } |
| 304 bool AsyncFileUtilAdapter::DeleteDirectory( | 310 |
| 305 scoped_ptr<FileSystemOperationContext> context, | 311 void AsyncFileUtilAdapter::DeleteDirectory( |
| 306 const FileSystemURL& url, | 312 scoped_ptr<FileSystemOperationContext> context, |
| 307 const StatusCallback& callback) { | 313 const FileSystemURL& url, |
| 308 FileSystemOperationContext* context_ptr = context.release(); | 314 const StatusCallback& callback) { |
| 309 return base::PostTaskAndReplyWithResult( | 315 FileSystemOperationContext* context_ptr = context.release(); |
| 316 const bool success = base::PostTaskAndReplyWithResult( |
| 310 context_ptr->task_runner(), FROM_HERE, | 317 context_ptr->task_runner(), FROM_HERE, |
| 311 Bind(&FileSystemFileUtil::DeleteDirectory, | 318 Bind(&FileSystemFileUtil::DeleteDirectory, |
| 312 Unretained(sync_file_util_.get()), | 319 Unretained(sync_file_util_.get()), |
| 313 base::Owned(context_ptr), url), | 320 base::Owned(context_ptr), url), |
| 314 callback); | 321 callback); |
| 315 } | 322 DCHECK(success); |
| 316 | 323 } |
| 317 bool AsyncFileUtilAdapter::DeleteRecursively( | 324 |
| 318 scoped_ptr<FileSystemOperationContext> context, | 325 void AsyncFileUtilAdapter::DeleteRecursively( |
| 319 const FileSystemURL& url, | 326 scoped_ptr<FileSystemOperationContext> context, |
| 320 const StatusCallback& callback) { | 327 const FileSystemURL& url, |
| 321 if (!callback.is_null()) | 328 const StatusCallback& callback) { |
| 322 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); | 329 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); |
| 323 return true; | 330 } |
| 324 } | 331 |
| 325 | 332 void AsyncFileUtilAdapter::CreateSnapshotFile( |
| 326 bool AsyncFileUtilAdapter::CreateSnapshotFile( | |
| 327 scoped_ptr<FileSystemOperationContext> context, | 333 scoped_ptr<FileSystemOperationContext> context, |
| 328 const FileSystemURL& url, | 334 const FileSystemURL& url, |
| 329 const CreateSnapshotFileCallback& callback) { | 335 const CreateSnapshotFileCallback& callback) { |
| 330 FileSystemOperationContext* context_ptr = context.release(); | 336 FileSystemOperationContext* context_ptr = context.release(); |
| 331 GetFileInfoHelper* helper = new GetFileInfoHelper; | 337 GetFileInfoHelper* helper = new GetFileInfoHelper; |
| 332 return context_ptr->task_runner()->PostTaskAndReply( | 338 const bool success = context_ptr->task_runner()->PostTaskAndReply( |
| 333 FROM_HERE, | 339 FROM_HERE, |
| 334 Bind(&GetFileInfoHelper::CreateSnapshotFile, Unretained(helper), | 340 Bind(&GetFileInfoHelper::CreateSnapshotFile, Unretained(helper), |
| 335 sync_file_util_.get(), base::Owned(context_ptr), url), | 341 sync_file_util_.get(), base::Owned(context_ptr), url), |
| 336 Bind(&GetFileInfoHelper::ReplySnapshotFile, Owned(helper), callback)); | 342 Bind(&GetFileInfoHelper::ReplySnapshotFile, Owned(helper), callback)); |
| 343 DCHECK(success); |
| 337 } | 344 } |
| 338 | 345 |
| 339 } // namespace fileapi | 346 } // namespace fileapi |
| OLD | NEW |