| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 std::string origin_string = database.GetPrimaryOrigin(); | 955 std::string origin_string = database.GetPrimaryOrigin(); |
| 956 if (origin_string.empty() || !database.HasOriginPath(origin_string)) | 956 if (origin_string.empty() || !database.HasOriginPath(origin_string)) |
| 957 return; | 957 return; |
| 958 const GURL origin = storage::GetOriginFromIdentifier(origin_string); | 958 const GURL origin = storage::GetOriginFromIdentifier(origin_string); |
| 959 | 959 |
| 960 // Prepopulate the directory database(s) if and only if this instance | 960 // Prepopulate the directory database(s) if and only if this instance |
| 961 // has primary origin and the directory database is already there. | 961 // has primary origin and the directory database is already there. |
| 962 for (size_t i = 0; i < type_strings_to_prepopulate.size(); ++i) { | 962 for (size_t i = 0; i < type_strings_to_prepopulate.size(); ++i) { |
| 963 const std::string type_string = type_strings_to_prepopulate[i]; | 963 const std::string type_string = type_strings_to_prepopulate[i]; |
| 964 // Only handles known types. | 964 // Only handles known types. |
| 965 if (!ContainsKey(known_type_strings_, type_string)) | 965 if (!base::ContainsKey(known_type_strings_, type_string)) |
| 966 continue; | 966 continue; |
| 967 base::File::Error error = base::File::FILE_ERROR_FAILED; | 967 base::File::Error error = base::File::FILE_ERROR_FAILED; |
| 968 base::FilePath path = GetDirectoryForOriginAndType( | 968 base::FilePath path = GetDirectoryForOriginAndType( |
| 969 origin, type_string, false, &error); | 969 origin, type_string, false, &error); |
| 970 if (error != base::File::FILE_OK) | 970 if (error != base::File::FILE_OK) |
| 971 continue; | 971 continue; |
| 972 std::unique_ptr<SandboxDirectoryDatabase> db( | 972 std::unique_ptr<SandboxDirectoryDatabase> db( |
| 973 new SandboxDirectoryDatabase(path, env_override_)); | 973 new SandboxDirectoryDatabase(path, env_override_)); |
| 974 if (db->Init(SandboxDirectoryDatabase::FAIL_ON_CORRUPTION)) { | 974 if (db->Init(SandboxDirectoryDatabase::FAIL_ON_CORRUPTION)) { |
| 975 directories_[GetDirectoryDatabaseKey(origin, type_string)] = db.release(); | 975 directories_[GetDirectoryDatabaseKey(origin, type_string)] = db.release(); |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1257 } else { | 1257 } else { |
| 1258 timer_->Start(FROM_HERE, | 1258 timer_->Start(FROM_HERE, |
| 1259 base::TimeDelta::FromSeconds(db_flush_delay_seconds_), | 1259 base::TimeDelta::FromSeconds(db_flush_delay_seconds_), |
| 1260 base::Bind(&ObfuscatedFileUtil::DropDatabases, | 1260 base::Bind(&ObfuscatedFileUtil::DropDatabases, |
| 1261 base::Unretained(this))); | 1261 base::Unretained(this))); |
| 1262 } | 1262 } |
| 1263 } | 1263 } |
| 1264 | 1264 |
| 1265 void ObfuscatedFileUtil::DropDatabases() { | 1265 void ObfuscatedFileUtil::DropDatabases() { |
| 1266 origin_database_.reset(); | 1266 origin_database_.reset(); |
| 1267 STLDeleteContainerPairSecondPointers( | 1267 base::STLDeleteContainerPairSecondPointers(directories_.begin(), |
| 1268 directories_.begin(), directories_.end()); | 1268 directories_.end()); |
| 1269 directories_.clear(); | 1269 directories_.clear(); |
| 1270 timer_.reset(); | 1270 timer_.reset(); |
| 1271 } | 1271 } |
| 1272 | 1272 |
| 1273 bool ObfuscatedFileUtil::InitOriginDatabase(const GURL& origin_hint, | 1273 bool ObfuscatedFileUtil::InitOriginDatabase(const GURL& origin_hint, |
| 1274 bool create) { | 1274 bool create) { |
| 1275 if (origin_database_) | 1275 if (origin_database_) |
| 1276 return true; | 1276 return true; |
| 1277 | 1277 |
| 1278 if (!create && !base::DirectoryExists(file_system_directory_)) | 1278 if (!create && !base::DirectoryExists(file_system_directory_)) |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1419 } | 1419 } |
| 1420 return file; | 1420 return file; |
| 1421 } | 1421 } |
| 1422 | 1422 |
| 1423 bool ObfuscatedFileUtil::HasIsolatedStorage(const GURL& origin) { | 1423 bool ObfuscatedFileUtil::HasIsolatedStorage(const GURL& origin) { |
| 1424 return special_storage_policy_.get() && | 1424 return special_storage_policy_.get() && |
| 1425 special_storage_policy_->HasIsolatedStorage(origin); | 1425 special_storage_policy_->HasIsolatedStorage(origin); |
| 1426 } | 1426 } |
| 1427 | 1427 |
| 1428 } // namespace storage | 1428 } // namespace storage |
| OLD | NEW |