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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 base::Callback<void(PlatformFileError)>& callback, |
| 314 base::PlatformFileError* error) { |
| 315 callback.Run(*error); |
| 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 base::Callback<void(PlatformFileError)>& callback) const { |
| 485 base::PlatformFileError* error_ptr = new base::PlatformFileError; |
| 486 file_task_runner_->PostTaskAndReply( |
| 487 FROM_HERE, |
| 488 base::Bind(&DeleteFileSystemOnFileThread, |
| 489 origin_url, |
| 490 type, |
| 491 base::Unretained(context), |
| 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 |