| 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 "storage/browser/fileapi/obfuscated_file_util.h" | 5 #include "storage/browser/fileapi/obfuscated_file_util.h" |
| 6 | 6 |
| 7 #include <queue> | 7 #include <queue> |
| 8 | 8 |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| (...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1045 FileInfo* dest_file_info, int file_flags) { | 1045 FileInfo* dest_file_info, int file_flags) { |
| 1046 SandboxDirectoryDatabase* db = GetDirectoryDatabase(dest_url, true); | 1046 SandboxDirectoryDatabase* db = GetDirectoryDatabase(dest_url, true); |
| 1047 | 1047 |
| 1048 base::FilePath root, dest_local_path; | 1048 base::FilePath root, dest_local_path; |
| 1049 base::File::Error error = GenerateNewLocalPath(db, context, dest_url, &root, | 1049 base::File::Error error = GenerateNewLocalPath(db, context, dest_url, &root, |
| 1050 &dest_local_path); | 1050 &dest_local_path); |
| 1051 if (error != base::File::FILE_OK) | 1051 if (error != base::File::FILE_OK) |
| 1052 return base::File(error); | 1052 return base::File(error); |
| 1053 | 1053 |
| 1054 if (base::PathExists(dest_local_path)) { | 1054 if (base::PathExists(dest_local_path)) { |
| 1055 if (!base::DeleteFile(dest_local_path, true /* recursive */)) | 1055 if (!base::DeleteFile(dest_local_path, false /* recursive */)) |
| 1056 return base::File(base::File::FILE_ERROR_FAILED); | 1056 return base::File(base::File::FILE_ERROR_FAILED); |
| 1057 LOG(WARNING) << "A stray file detected"; | 1057 LOG(WARNING) << "A stray file detected"; |
| 1058 InvalidateUsageCache(context, dest_url.origin(), dest_url.type()); | 1058 InvalidateUsageCache(context, dest_url.origin(), dest_url.type()); |
| 1059 } | 1059 } |
| 1060 | 1060 |
| 1061 base::File file = NativeFileUtil::CreateOrOpen(dest_local_path, file_flags); | 1061 base::File file = NativeFileUtil::CreateOrOpen(dest_local_path, file_flags); |
| 1062 if (!file.IsValid()) | 1062 if (!file.IsValid()) |
| 1063 return file.Pass(); | 1063 return file.Pass(); |
| 1064 | 1064 |
| 1065 if (!file.created()) { | 1065 if (!file.created()) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1087 | 1087 |
| 1088 base::FilePath root, dest_local_path; | 1088 base::FilePath root, dest_local_path; |
| 1089 base::File::Error error = GenerateNewLocalPath(db, context, dest_url, &root, | 1089 base::File::Error error = GenerateNewLocalPath(db, context, dest_url, &root, |
| 1090 &dest_local_path); | 1090 &dest_local_path); |
| 1091 if (error != base::File::FILE_OK) | 1091 if (error != base::File::FILE_OK) |
| 1092 return error; | 1092 return error; |
| 1093 | 1093 |
| 1094 bool created = false; | 1094 bool created = false; |
| 1095 if (src_file_path.empty()) { | 1095 if (src_file_path.empty()) { |
| 1096 if (base::PathExists(dest_local_path)) { | 1096 if (base::PathExists(dest_local_path)) { |
| 1097 if (!base::DeleteFile(dest_local_path, true /* recursive */)) | 1097 if (!base::DeleteFile(dest_local_path, false /* recursive */)) |
| 1098 return base::File::FILE_ERROR_FAILED; | 1098 return base::File::FILE_ERROR_FAILED; |
| 1099 LOG(WARNING) << "A stray file detected"; | 1099 LOG(WARNING) << "A stray file detected"; |
| 1100 InvalidateUsageCache(context, dest_url.origin(), dest_url.type()); | 1100 InvalidateUsageCache(context, dest_url.origin(), dest_url.type()); |
| 1101 } | 1101 } |
| 1102 | 1102 |
| 1103 error = NativeFileUtil::EnsureFileExists(dest_local_path, &created); | 1103 error = NativeFileUtil::EnsureFileExists(dest_local_path, &created); |
| 1104 } else { | 1104 } else { |
| 1105 error = NativeFileUtil::CopyOrMoveFile( | 1105 error = NativeFileUtil::CopyOrMoveFile( |
| 1106 src_file_path, | 1106 src_file_path, |
| 1107 dest_local_path, | 1107 dest_local_path, |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1415 } | 1415 } |
| 1416 return file.Pass(); | 1416 return file.Pass(); |
| 1417 } | 1417 } |
| 1418 | 1418 |
| 1419 bool ObfuscatedFileUtil::HasIsolatedStorage(const GURL& origin) { | 1419 bool ObfuscatedFileUtil::HasIsolatedStorage(const GURL& origin) { |
| 1420 return special_storage_policy_.get() && | 1420 return special_storage_policy_.get() && |
| 1421 special_storage_policy_->HasIsolatedStorage(origin); | 1421 special_storage_policy_->HasIsolatedStorage(origin); |
| 1422 } | 1422 } |
| 1423 | 1423 |
| 1424 } // namespace storage | 1424 } // namespace storage |
| OLD | NEW |