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 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 } | 894 } |
895 return base::DeleteFile(origin_path, true /* recursive */); | 895 return base::DeleteFile(origin_path, true /* recursive */); |
896 } | 896 } |
897 | 897 |
898 void ObfuscatedFileUtil::CloseFileSystemForOriginAndType( | 898 void ObfuscatedFileUtil::CloseFileSystemForOriginAndType( |
899 const GURL& origin, | 899 const GURL& origin, |
900 const std::string& type_string) { | 900 const std::string& type_string) { |
901 const std::string key_prefix = GetDirectoryDatabaseKey(origin, type_string); | 901 const std::string key_prefix = GetDirectoryDatabaseKey(origin, type_string); |
902 for (DirectoryMap::iterator iter = directories_.lower_bound(key_prefix); | 902 for (DirectoryMap::iterator iter = directories_.lower_bound(key_prefix); |
903 iter != directories_.end();) { | 903 iter != directories_.end();) { |
904 if (!base::StartsWithASCII(iter->first, key_prefix, true)) | 904 if (!base::StartsWith(iter->first, key_prefix, |
| 905 base::CompareCase::SENSITIVE)) |
905 break; | 906 break; |
906 DCHECK(type_string.empty() || iter->first == key_prefix); | 907 DCHECK(type_string.empty() || iter->first == key_prefix); |
907 scoped_ptr<SandboxDirectoryDatabase> database(iter->second); | 908 scoped_ptr<SandboxDirectoryDatabase> database(iter->second); |
908 directories_.erase(iter++); | 909 directories_.erase(iter++); |
909 } | 910 } |
910 } | 911 } |
911 | 912 |
912 ObfuscatedFileUtil::AbstractOriginEnumerator* | 913 ObfuscatedFileUtil::AbstractOriginEnumerator* |
913 ObfuscatedFileUtil::CreateOriginEnumerator() { | 914 ObfuscatedFileUtil::CreateOriginEnumerator() { |
914 std::vector<SandboxOriginDatabase::OriginRecord> origins; | 915 std::vector<SandboxOriginDatabase::OriginRecord> origins; |
915 | 916 |
916 InitOriginDatabase(GURL(), false); | 917 InitOriginDatabase(GURL(), false); |
917 return new ObfuscatedOriginEnumerator( | 918 return new ObfuscatedOriginEnumerator( |
918 origin_database_.get(), file_system_directory_); | 919 origin_database_.get(), file_system_directory_); |
919 } | 920 } |
920 | 921 |
921 void ObfuscatedFileUtil::DestroyDirectoryDatabase( | 922 void ObfuscatedFileUtil::DestroyDirectoryDatabase( |
922 const GURL& origin, | 923 const GURL& origin, |
923 const std::string& type_string) { | 924 const std::string& type_string) { |
924 // If |type_string| is empty, delete all filesystem types under |origin|. | 925 // If |type_string| is empty, delete all filesystem types under |origin|. |
925 const std::string key_prefix = GetDirectoryDatabaseKey(origin, type_string); | 926 const std::string key_prefix = GetDirectoryDatabaseKey(origin, type_string); |
926 for (DirectoryMap::iterator iter = directories_.lower_bound(key_prefix); | 927 for (DirectoryMap::iterator iter = directories_.lower_bound(key_prefix); |
927 iter != directories_.end();) { | 928 iter != directories_.end();) { |
928 if (!base::StartsWithASCII(iter->first, key_prefix, true)) | 929 if (!base::StartsWith(iter->first, key_prefix, |
| 930 base::CompareCase::SENSITIVE)) |
929 break; | 931 break; |
930 DCHECK(type_string.empty() || iter->first == key_prefix); | 932 DCHECK(type_string.empty() || iter->first == key_prefix); |
931 scoped_ptr<SandboxDirectoryDatabase> database(iter->second); | 933 scoped_ptr<SandboxDirectoryDatabase> database(iter->second); |
932 directories_.erase(iter++); | 934 directories_.erase(iter++); |
933 | 935 |
934 // Continue to destroy databases even if it failed because it doesn't affect | 936 // Continue to destroy databases even if it failed because it doesn't affect |
935 // the final result. | 937 // the final result. |
936 database->DestroyDatabase(); | 938 database->DestroyDatabase(); |
937 } | 939 } |
938 } | 940 } |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1413 } | 1415 } |
1414 return file.Pass(); | 1416 return file.Pass(); |
1415 } | 1417 } |
1416 | 1418 |
1417 bool ObfuscatedFileUtil::HasIsolatedStorage(const GURL& origin) { | 1419 bool ObfuscatedFileUtil::HasIsolatedStorage(const GURL& origin) { |
1418 return special_storage_policy_.get() && | 1420 return special_storage_policy_.get() && |
1419 special_storage_policy_->HasIsolatedStorage(origin); | 1421 special_storage_policy_->HasIsolatedStorage(origin); |
1420 } | 1422 } |
1421 | 1423 |
1422 } // namespace storage | 1424 } // namespace storage |
OLD | NEW |