| 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 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 origin_database_.get(), file_system_directory_); | 915 origin_database_.get(), file_system_directory_); |
| 916 } | 916 } |
| 917 | 917 |
| 918 bool ObfuscatedFileUtil::DestroyDirectoryDatabase( | 918 bool ObfuscatedFileUtil::DestroyDirectoryDatabase( |
| 919 const GURL& origin, | 919 const GURL& origin, |
| 920 const std::string& type_string) { | 920 const std::string& type_string) { |
| 921 std::string key = GetDirectoryDatabaseKey(origin, type_string); | 921 std::string key = GetDirectoryDatabaseKey(origin, type_string); |
| 922 if (key.empty()) | 922 if (key.empty()) |
| 923 return true; | 923 return true; |
| 924 DirectoryMap::iterator iter = directories_.find(key); | 924 DirectoryMap::iterator iter = directories_.find(key); |
| 925 if (iter != directories_.end()) { | 925 if (iter == directories_.end()) |
| 926 SandboxDirectoryDatabase* database = iter->second; | |
| 927 directories_.erase(iter); | |
| 928 delete database; | |
| 929 } | |
| 930 | |
| 931 base::File::Error error = base::File::FILE_OK; | |
| 932 base::FilePath path = GetDirectoryForOriginAndType( | |
| 933 origin, type_string, false, &error); | |
| 934 if (path.empty() || error == base::File::FILE_ERROR_NOT_FOUND) | |
| 935 return true; | 926 return true; |
| 936 return SandboxDirectoryDatabase::DestroyDatabase(path, env_override_); | 927 scoped_ptr<SandboxDirectoryDatabase> database(iter->second); |
| 928 directories_.erase(iter); |
| 929 return database->DestroyDatabase(); |
| 937 } | 930 } |
| 938 | 931 |
| 939 // static | 932 // static |
| 940 int64 ObfuscatedFileUtil::ComputeFilePathCost(const base::FilePath& path) { | 933 int64 ObfuscatedFileUtil::ComputeFilePathCost(const base::FilePath& path) { |
| 941 return UsageForPath(VirtualPath::BaseName(path).value().size()); | 934 return UsageForPath(VirtualPath::BaseName(path).value().size()); |
| 942 } | 935 } |
| 943 | 936 |
| 944 void ObfuscatedFileUtil::MaybePrepopulateDatabase( | 937 void ObfuscatedFileUtil::MaybePrepopulateDatabase( |
| 945 const std::vector<std::string>& type_strings_to_prepopulate) { | 938 const std::vector<std::string>& type_strings_to_prepopulate) { |
| 946 SandboxPrioritizedOriginDatabase database(file_system_directory_, | 939 SandboxPrioritizedOriginDatabase database(file_system_directory_, |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1415 } | 1408 } |
| 1416 return file.Pass(); | 1409 return file.Pass(); |
| 1417 } | 1410 } |
| 1418 | 1411 |
| 1419 bool ObfuscatedFileUtil::HasIsolatedStorage(const GURL& origin) { | 1412 bool ObfuscatedFileUtil::HasIsolatedStorage(const GURL& origin) { |
| 1420 return special_storage_policy_.get() && | 1413 return special_storage_policy_.get() && |
| 1421 special_storage_policy_->HasIsolatedStorage(origin); | 1414 special_storage_policy_->HasIsolatedStorage(origin); |
| 1422 } | 1415 } |
| 1423 | 1416 |
| 1424 } // namespace storage | 1417 } // namespace storage |
| OLD | NEW |