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