| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "storage/browser/fileapi/sandbox_file_system_backend_delegate.h" | 5 #include "storage/browser/fileapi/sandbox_file_system_backend_delegate.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 REPORT(kNotFound); | 641 REPORT(kNotFound); |
| 642 break; | 642 break; |
| 643 case base::File::FILE_ERROR_FAILED: | 643 case base::File::FILE_ERROR_FAILED: |
| 644 default: | 644 default: |
| 645 REPORT(kUnknownError); | 645 REPORT(kUnknownError); |
| 646 break; | 646 break; |
| 647 } | 647 } |
| 648 #undef REPORT | 648 #undef REPORT |
| 649 } | 649 } |
| 650 | 650 |
| 651 void SandboxFileSystemBackendDelegate::CopyFileSystem( |
| 652 const GURL& origin_url, |
| 653 FileSystemType type, |
| 654 SandboxFileSystemBackendDelegate* destination) { |
| 655 DCHECK(file_task_runner()->RunsTasksOnCurrentThread()); |
| 656 |
| 657 base::FilePath base_path = |
| 658 GetBaseDirectoryForOriginAndType(origin_url, type, false /* create */); |
| 659 if (base::PathExists(base_path)) { |
| 660 // There shouldn't be an existing file system directory in the destination. |
| 661 DCHECK(!base::PathExists(destination->GetBaseDirectoryForOriginAndType( |
| 662 origin_url, type, false /* create */))); |
| 663 |
| 664 base::FilePath dest_path = destination->GetBaseDirectoryForOriginAndType( |
| 665 origin_url, type, true /* create */); |
| 666 |
| 667 obfuscated_file_util()->CloseFileSystemForOriginAndType( |
| 668 origin_url, GetTypeString(type)); |
| 669 base::CopyDirectory(base_path, dest_path.DirName(), true /* rescursive */); |
| 670 } |
| 671 } |
| 672 |
| 651 ObfuscatedFileUtil* SandboxFileSystemBackendDelegate::obfuscated_file_util() { | 673 ObfuscatedFileUtil* SandboxFileSystemBackendDelegate::obfuscated_file_util() { |
| 652 return static_cast<ObfuscatedFileUtil*>(sync_file_util()); | 674 return static_cast<ObfuscatedFileUtil*>(sync_file_util()); |
| 653 } | 675 } |
| 654 | 676 |
| 655 // Declared in obfuscated_file_util.h. | 677 // Declared in obfuscated_file_util.h. |
| 656 // static | 678 // static |
| 657 ObfuscatedFileUtil* ObfuscatedFileUtil::CreateForTesting( | 679 ObfuscatedFileUtil* ObfuscatedFileUtil::CreateForTesting( |
| 658 storage::SpecialStoragePolicy* special_storage_policy, | 680 storage::SpecialStoragePolicy* special_storage_policy, |
| 659 const base::FilePath& file_system_directory, | 681 const base::FilePath& file_system_directory, |
| 660 leveldb::Env* env_override, | 682 leveldb::Env* env_override, |
| 661 base::SequencedTaskRunner* file_task_runner) { | 683 base::SequencedTaskRunner* file_task_runner) { |
| 662 return new ObfuscatedFileUtil(special_storage_policy, | 684 return new ObfuscatedFileUtil(special_storage_policy, |
| 663 file_system_directory, | 685 file_system_directory, |
| 664 env_override, | 686 env_override, |
| 665 file_task_runner, | 687 file_task_runner, |
| 666 base::Bind(&GetTypeStringForURL), | 688 base::Bind(&GetTypeStringForURL), |
| 667 GetKnownTypeStrings(), | 689 GetKnownTypeStrings(), |
| 668 NULL); | 690 NULL); |
| 669 } | 691 } |
| 670 | 692 |
| 671 } // namespace storage | 693 } // namespace storage |
| OLD | NEW |