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/sandbox_mount_point_provider.h" | 5 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
270 | 270 |
271 void PassPointerErrorByValue( | 271 void PassPointerErrorByValue( |
272 const base::Callback<void(PlatformFileError)>& callback, | 272 const base::Callback<void(PlatformFileError)>& callback, |
273 PlatformFileError* error_ptr) { | 273 PlatformFileError* error_ptr) { |
274 DCHECK(error_ptr); | 274 DCHECK(error_ptr); |
275 callback.Run(*error_ptr); | 275 callback.Run(*error_ptr); |
276 } | 276 } |
277 | 277 |
278 void DidValidateFileSystemRoot( | 278 void DidValidateFileSystemRoot( |
279 base::WeakPtr<SandboxMountPointProvider> mount_point_provider, | 279 base::WeakPtr<SandboxMountPointProvider> mount_point_provider, |
280 const base::Callback<void(PlatformFileError)>& callback, | 280 const FileSystemMountPointProvider::ValidateFileSystemCallback& callback, |
281 base::PlatformFileError* error) { | 281 base::PlatformFileError* error) { |
282 if (mount_point_provider.get()) | 282 if (mount_point_provider.get()) |
283 mount_point_provider.get()->CollectOpenFileSystemMetrics(*error); | 283 mount_point_provider.get()->CollectOpenFileSystemMetrics(*error); |
284 callback.Run(*error); | 284 callback.Run(*error); |
285 } | 285 } |
286 | 286 |
287 void ValidateRootOnFileThread( | 287 void ValidateRootOnFileThread( |
288 ObfuscatedFileUtil* file_util, | 288 ObfuscatedFileUtil* file_util, |
289 const GURL& origin_url, | 289 const GURL& origin_url, |
290 FileSystemType type, | 290 FileSystemType type, |
(...skipping 11 matching lines...) Expand all Loading... | |
302 kCreateDirectoryError, | 302 kCreateDirectoryError, |
303 kFileSystemErrorMax); | 303 kFileSystemErrorMax); |
304 } else { | 304 } else { |
305 UMA_HISTOGRAM_ENUMERATION(kOpenFileSystemLabel, kOK, kFileSystemErrorMax); | 305 UMA_HISTOGRAM_ENUMERATION(kOpenFileSystemLabel, kOK, kFileSystemErrorMax); |
306 } | 306 } |
307 // The reference of file_util will be derefed on the FILE thread | 307 // The reference of file_util will be derefed on the FILE thread |
308 // when the storage of this callback gets deleted regardless of whether | 308 // when the storage of this callback gets deleted regardless of whether |
309 // this method is called or not. | 309 // this method is called or not. |
310 } | 310 } |
311 | 311 |
312 void DidDeleteFileSystem( | |
313 const FileSystemMountPointProvider::DeleteFileSystemCallback& callback, | |
314 base::PlatformFileError* error) { | |
315 callback.Run(*error); | |
kinuko
2012/07/30 21:53:38
Please consider using PostTaskAndReplyWithResult t
nhiroki (google)
2012/07/31 15:50:32
I think we cannot get rid of like this adapter by
kinuko
2012/07/31 16:59:19
Can we just pass callback there?
nhiroki (google)
2012/07/31 17:17:12
I'm really sorry I misunderstood.
I modified to pa
| |
316 } | |
317 | |
318 void DeleteFileSystemOnFileThread( | |
319 const GURL& origin_url, | |
320 FileSystemType type, | |
321 FileSystemContext* context, | |
322 base::PlatformFileError* error_ptr) { | |
323 bool result = | |
324 context->DeleteDataForOriginAndTypeOnFileThread(origin_url, type); | |
325 *error_ptr = result ? | |
326 base::PLATFORM_FILE_OK : | |
327 base::PLATFORM_FILE_ERROR_FAILED; | |
328 } | |
329 | |
312 } // anonymous namespace | 330 } // anonymous namespace |
313 | 331 |
314 const FilePath::CharType SandboxMountPointProvider::kOldFileSystemDirectory[] = | 332 const FilePath::CharType SandboxMountPointProvider::kOldFileSystemDirectory[] = |
315 FILE_PATH_LITERAL("FileSystem"); | 333 FILE_PATH_LITERAL("FileSystem"); |
316 | 334 |
317 const FilePath::CharType SandboxMountPointProvider::kNewFileSystemDirectory[] = | 335 const FilePath::CharType SandboxMountPointProvider::kNewFileSystemDirectory[] = |
318 FILE_PATH_LITERAL("File System"); | 336 FILE_PATH_LITERAL("File System"); |
319 | 337 |
320 const FilePath::CharType | 338 const FilePath::CharType |
321 SandboxMountPointProvider::kRenamedOldFileSystemDirectory[] = | 339 SandboxMountPointProvider::kRenamedOldFileSystemDirectory[] = |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
452 const FileSystemURL& url, | 470 const FileSystemURL& url, |
453 int64 offset, | 471 int64 offset, |
454 FileSystemContext* context) const { | 472 FileSystemContext* context) const { |
455 return new SandboxFileStreamWriter(context, url, offset); | 473 return new SandboxFileStreamWriter(context, url, offset); |
456 } | 474 } |
457 | 475 |
458 FileSystemQuotaUtil* SandboxMountPointProvider::GetQuotaUtil() { | 476 FileSystemQuotaUtil* SandboxMountPointProvider::GetQuotaUtil() { |
459 return this; | 477 return this; |
460 } | 478 } |
461 | 479 |
480 void SandboxMountPointProvider::DeleteFileSystem( | |
481 const GURL& origin_url, | |
482 FileSystemType type, | |
483 FileSystemContext* context, | |
484 const DeleteFileSystemCallback& callback) const { | |
485 base::PlatformFileError* error_ptr = new base::PlatformFileError; | |
486 file_task_runner_->PostTaskAndReply( | |
487 FROM_HERE, | |
488 base::Bind(&DeleteFileSystemOnFileThread, | |
kinuko
2012/07/30 21:53:38
Wonder if we should rather make FSC::DeleteDataFor
nhiroki (google)
2012/07/31 15:50:32
Done.
| |
489 origin_url, | |
490 type, | |
491 base::Unretained(context), | |
kinuko
2012/07/30 21:53:38
Should we rather pass this with make_ref_ptr?
nhiroki (google)
2012/07/31 17:17:12
I forgot a reply. Done.
| |
492 base::Unretained(error_ptr)), | |
493 base::Bind(&DidDeleteFileSystem, callback, base::Owned(error_ptr))); | |
494 } | |
495 | |
462 FilePath SandboxMountPointProvider::old_base_path() const { | 496 FilePath SandboxMountPointProvider::old_base_path() const { |
463 return profile_path_.Append(kOldFileSystemDirectory); | 497 return profile_path_.Append(kOldFileSystemDirectory); |
464 } | 498 } |
465 | 499 |
466 FilePath SandboxMountPointProvider::new_base_path() const { | 500 FilePath SandboxMountPointProvider::new_base_path() const { |
467 return profile_path_.Append(kNewFileSystemDirectory); | 501 return profile_path_.Append(kNewFileSystemDirectory); |
468 } | 502 } |
469 | 503 |
470 FilePath SandboxMountPointProvider::renamed_old_base_path() const { | 504 FilePath SandboxMountPointProvider::renamed_old_base_path() const { |
471 return profile_path_.Append(kRenamedOldFileSystemDirectory); | 505 return profile_path_.Append(kRenamedOldFileSystemDirectory); |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
733 break; | 767 break; |
734 case base::PLATFORM_FILE_ERROR_FAILED: | 768 case base::PLATFORM_FILE_ERROR_FAILED: |
735 default: | 769 default: |
736 REPORT(kUnknownError); | 770 REPORT(kUnknownError); |
737 break; | 771 break; |
738 } | 772 } |
739 #undef REPORT | 773 #undef REPORT |
740 } | 774 } |
741 | 775 |
742 } // namespace fileapi | 776 } // namespace fileapi |
OLD | NEW |