Chromium Code Reviews| 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 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 862 origin, type_string, false, &error); | 862 origin, type_string, false, &error); |
| 863 if (origin_type_path.empty()) | 863 if (origin_type_path.empty()) |
| 864 return true; | 864 return true; |
| 865 if (error != base::File::FILE_ERROR_NOT_FOUND) { | 865 if (error != base::File::FILE_ERROR_NOT_FOUND) { |
| 866 // TODO(dmikurube): Consider the return value of DestroyDirectoryDatabase. | 866 // TODO(dmikurube): Consider the return value of DestroyDirectoryDatabase. |
| 867 // We ignore its error now since 1) it doesn't matter the final result, and | 867 // We ignore its error now since 1) it doesn't matter the final result, and |
| 868 // 2) it always returns false in Windows because of LevelDB's | 868 // 2) it always returns false in Windows because of LevelDB's |
| 869 // implementation. | 869 // implementation. |
| 870 // Information about failure would be useful for debugging. | 870 // Information about failure would be useful for debugging. |
| 871 if (!type_string.empty()) | 871 if (!type_string.empty()) |
| 872 DestroyDirectoryDatabase(origin, type_string); | 872 DestroyDirectoryDatabase(origin, type_string); |
|
nhiroki
2014/09/19 17:17:19
Probably we need to make DestroyDirectoryDatabase(
| |
| 873 if (!base::DeleteFile(origin_type_path, true /* recursive */)) | 873 if (!base::DeleteFile(origin_type_path, true /* recursive */)) |
| 874 return false; | 874 return false; |
| 875 } | 875 } |
| 876 | 876 |
| 877 if (type_string.empty()) { | |
| 878 // The |origin_type_path| is the topmost origin directory if |type_string| | |
| 879 // is empty. We should have already deleted that directory. | |
| 880 // Now clear the database and we are done. | |
| 881 InitOriginDatabase(origin, false); | |
| 882 if (origin_database_) { | |
| 883 if (!origin_database_->RemovePathForOrigin( | |
| 884 storage::GetIdentifierFromOrigin(origin))) { | |
| 885 LOG(WARNING) << "Cannot remove path from origin database."; | |
| 886 } | |
| 887 } | |
| 888 return true; | |
| 889 } | |
| 890 | |
| 877 base::FilePath origin_path = VirtualPath::DirName(origin_type_path); | 891 base::FilePath origin_path = VirtualPath::DirName(origin_type_path); |
| 878 DCHECK_EQ(origin_path.value(), | 892 DCHECK_EQ(origin_path.value(), |
| 879 GetDirectoryForOrigin(origin, false, NULL).value()); | 893 GetDirectoryForOrigin(origin, false, NULL).value()); |
| 880 | 894 |
| 881 if (!type_string.empty()) { | 895 // At this point we are sure we had successfully deleted the origin/type |
| 882 // At this point we are sure we had successfully deleted the origin/type | 896 // directory (i.e. we're ready to just return true). |
| 883 // directory (i.e. we're ready to just return true). | 897 // See if we have other directories in this origin directory. |
| 884 // See if we have other directories in this origin directory. | 898 for (std::set<std::string>::iterator iter = known_type_strings_.begin(); |
| 885 for (std::set<std::string>::iterator iter = known_type_strings_.begin(); | 899 iter != known_type_strings_.end(); |
| 886 iter != known_type_strings_.end(); | 900 ++iter) { |
| 887 ++iter) { | 901 if (*iter == type_string) |
| 888 if (*iter == type_string) | 902 continue; |
| 889 continue; | 903 if (base::DirectoryExists(origin_path.AppendASCII(*iter))) { |
| 890 if (base::DirectoryExists(origin_path.AppendASCII(*iter))) { | 904 // Other type's directory exists; just return true here. |
| 891 // Other type's directory exists; just return true here. | 905 return true; |
| 892 return true; | |
| 893 } | |
| 894 } | 906 } |
| 895 } | 907 } |
| 896 | 908 |
| 897 // No other directories seem exist. Try deleting the entire origin directory. | 909 // No other directories seem exist. Try deleting the entire origin directory. |
| 898 InitOriginDatabase(origin, false); | 910 InitOriginDatabase(origin, false); |
| 899 if (origin_database_) { | 911 if (origin_database_) { |
| 900 origin_database_->RemovePathForOrigin( | 912 origin_database_->RemovePathForOrigin( |
| 901 storage::GetIdentifierFromOrigin(origin)); | 913 storage::GetIdentifierFromOrigin(origin)); |
| 902 } | 914 } |
| 903 if (!base::DeleteFile(origin_path, true /* recursive */)) | 915 if (!base::DeleteFile(origin_path, true /* recursive */)) |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1415 } | 1427 } |
| 1416 return file.Pass(); | 1428 return file.Pass(); |
| 1417 } | 1429 } |
| 1418 | 1430 |
| 1419 bool ObfuscatedFileUtil::HasIsolatedStorage(const GURL& origin) { | 1431 bool ObfuscatedFileUtil::HasIsolatedStorage(const GURL& origin) { |
| 1420 return special_storage_policy_.get() && | 1432 return special_storage_policy_.get() && |
| 1421 special_storage_policy_->HasIsolatedStorage(origin); | 1433 special_storage_policy_->HasIsolatedStorage(origin); |
| 1422 } | 1434 } |
| 1423 | 1435 |
| 1424 } // namespace storage | 1436 } // namespace storage |
| OLD | NEW |