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/obfuscated_file_util.h" | 5 #include "webkit/fileapi/obfuscated_file_util.h" |
6 | 6 |
7 #include <queue> | 7 #include <queue> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 return false; | 953 return false; |
954 } | 954 } |
955 | 955 |
956 FilePath origin_path = origin_type_path.DirName(); | 956 FilePath origin_path = origin_type_path.DirName(); |
957 DCHECK_EQ(origin_path.value(), | 957 DCHECK_EQ(origin_path.value(), |
958 GetDirectoryForOrigin(origin, false, NULL).value()); | 958 GetDirectoryForOrigin(origin, false, NULL).value()); |
959 | 959 |
960 // Delete the origin directory if the deleted one was the last remaining | 960 // Delete the origin directory if the deleted one was the last remaining |
961 // type for the origin, i.e. if the *other* type doesn't exist. | 961 // type for the origin, i.e. if the *other* type doesn't exist. |
962 FileSystemType other_type = kFileSystemTypeUnknown; | 962 FileSystemType other_type = kFileSystemTypeUnknown; |
963 switch (type) { | 963 if (type == kFileSystemTypeTemporary) |
964 case kFileSystemTypeTemporary: | 964 other_type = kFileSystemTypePersistent; |
965 other_type = kFileSystemTypePersistent; | 965 else if (type == kFileSystemTypePersistent) |
966 break; | 966 other_type = kFileSystemTypeTemporary; |
967 case kFileSystemTypePersistent: | 967 else |
968 other_type = kFileSystemTypeTemporary; | 968 NOTREACHED(); |
969 break; | 969 |
970 // These types shouldn't be used. | |
971 case kFileSystemTypeUnknown: | |
972 case kFileSystemTypeIsolated: | |
973 case kFileSystemTypeExternal: | |
974 case kFileSystemTypeTest: | |
975 case kFileSystemTypeDragged: | |
976 NOTREACHED(); | |
977 } | |
978 if (!file_util::DirectoryExists( | 970 if (!file_util::DirectoryExists( |
979 origin_path.Append(GetDirectoryNameForType(other_type)))) { | 971 origin_path.Append(GetDirectoryNameForType(other_type)))) { |
980 InitOriginDatabase(false); | 972 InitOriginDatabase(false); |
981 if (origin_database_.get()) | 973 if (origin_database_.get()) |
982 origin_database_->RemovePathForOrigin(GetOriginIdentifierFromURL(origin)); | 974 origin_database_->RemovePathForOrigin(GetOriginIdentifierFromURL(origin)); |
983 if (!file_util::Delete(origin_path, true /* recursive */)) | 975 if (!file_util::Delete(origin_path, true /* recursive */)) |
984 return false; | 976 return false; |
985 } | 977 } |
986 | 978 |
987 // At this point we are sure we had successfully deleted the origin/type | 979 // At this point we are sure we had successfully deleted the origin/type |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1396 error = NativeFileUtil::CreateDirectory( | 1388 error = NativeFileUtil::CreateDirectory( |
1397 new_local_path, false /* exclusive */, false /* recursive */); | 1389 new_local_path, false /* exclusive */, false /* recursive */); |
1398 if (error != base::PLATFORM_FILE_OK) | 1390 if (error != base::PLATFORM_FILE_OK) |
1399 return error; | 1391 return error; |
1400 | 1392 |
1401 *local_path = new_local_path.AppendASCII(StringPrintf("%08" PRId64, number)); | 1393 *local_path = new_local_path.AppendASCII(StringPrintf("%08" PRId64, number)); |
1402 return base::PLATFORM_FILE_OK; | 1394 return base::PLATFORM_FILE_OK; |
1403 } | 1395 } |
1404 | 1396 |
1405 } // namespace fileapi | 1397 } // namespace fileapi |
OLD | NEW |