Index: storage/browser/fileapi/sandbox_file_system_backend_delegate.cc |
diff --git a/storage/browser/fileapi/sandbox_file_system_backend_delegate.cc b/storage/browser/fileapi/sandbox_file_system_backend_delegate.cc |
index 9fb6b0edb56d2f9e3e9ef50392059a80ea8ea07e..18b1a5eb0848428506ca62b768960b4ccbfb1300 100644 |
--- a/storage/browser/fileapi/sandbox_file_system_backend_delegate.cc |
+++ b/storage/browser/fileapi/sandbox_file_system_backend_delegate.cc |
@@ -648,6 +648,36 @@ void SandboxFileSystemBackendDelegate::CollectOpenFileSystemMetrics( |
#undef REPORT |
} |
+void SandboxFileSystemBackendDelegate::CopyFileSystem( |
+ const GURL& origin_url, |
+ FileSystemType type, |
+ SandboxFileSystemBackendDelegate* destination) { |
+ DCHECK(file_task_runner()->RunsTasksOnCurrentThread()); |
+ |
+ base::FilePath base_path = |
+ GetBaseDirectoryForOriginAndType(origin_url, type, false /* create */); |
+ if (base::PathExists(base_path)) { |
+ // Delete any existing file system directories in the destination. A |
+ // previously failed migration |
+ // may have left behind partially copied directories. |
+ base::FilePath dest_path = destination->GetBaseDirectoryForOriginAndType( |
+ origin_url, type, false /* create */); |
+ if (base::PathExists(dest_path)) { |
cmumford
2015/01/06 15:30:27
Consider disposing of the exists check and just ca
|
+ // Make sure we're not about to delete our own file system. |
+ CHECK(base_path != dest_path); |
cmumford
2015/01/06 15:30:27
CHECK_NE
|
+ base::DeleteFile(dest_path, true); |
+ } |
+ |
+ // Create the required path in the destination |
+ dest_path = destination->GetBaseDirectoryForOriginAndType( |
+ origin_url, type, true /* create */); |
+ |
+ obfuscated_file_util()->CloseFileSystemForOriginAndType( |
+ origin_url, GetTypeString(type)); |
+ base::CopyDirectory(base_path, dest_path.DirName(), true /* rescursive */); |
+ } |
+} |
+ |
ObfuscatedFileUtil* SandboxFileSystemBackendDelegate::obfuscated_file_util() { |
return static_cast<ObfuscatedFileUtil*>(sync_file_util()); |
} |