| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/platform_thread.h" | 8 #include "base/platform_thread.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
| (...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1240 BackendDoomAll(); | 1240 BackendDoomAll(); |
| 1241 } | 1241 } |
| 1242 | 1242 |
| 1243 // We should be able to create the same entry on multiple simultaneous instances | 1243 // We should be able to create the same entry on multiple simultaneous instances |
| 1244 // of the cache. | 1244 // of the cache. |
| 1245 TEST_F(DiskCacheTest, MultipleInstances) { | 1245 TEST_F(DiskCacheTest, MultipleInstances) { |
| 1246 ScopedTestCache store1; | 1246 ScopedTestCache store1; |
| 1247 ScopedTestCache store2(L"cache_test2"); | 1247 ScopedTestCache store2(L"cache_test2"); |
| 1248 ScopedTestCache store3(L"cache_test3"); | 1248 ScopedTestCache store3(L"cache_test3"); |
| 1249 | 1249 |
| 1250 const int kNumberOfCaches = 3; | 1250 const int kNumberOfCaches = 2; |
| 1251 scoped_ptr<disk_cache::Backend> cache[kNumberOfCaches]; | 1251 scoped_ptr<disk_cache::Backend> cache[kNumberOfCaches]; |
| 1252 | 1252 |
| 1253 cache[0].reset(disk_cache::CreateCacheBackend(store1.path_wstring(), false, 0, | 1253 cache[0].reset(disk_cache::CreateCacheBackend(store1.path_wstring(), false, 0, |
| 1254 net::DISK_CACHE)); | 1254 net::DISK_CACHE)); |
| 1255 cache[1].reset(disk_cache::CreateCacheBackend(store2.path_wstring(), false, 0, | 1255 cache[1].reset(disk_cache::CreateCacheBackend(store2.path_wstring(), false, 0, |
| 1256 net::MEDIA_CACHE)); | 1256 net::MEDIA_CACHE)); |
| 1257 cache[2].reset(disk_cache::CreateCacheBackend(store3.path_wstring(), false, 0, | |
| 1258 net::TEMP_MEDIA_CACHE)); | |
| 1259 | 1257 |
| 1260 ASSERT_TRUE(cache[0].get() != NULL && cache[1].get() != NULL && | 1258 ASSERT_TRUE(cache[0].get() != NULL && cache[1].get() != NULL); |
| 1261 cache[2].get() != NULL); | |
| 1262 | 1259 |
| 1263 std::string key("the first key"); | 1260 std::string key("the first key"); |
| 1264 disk_cache::Entry* entry; | 1261 disk_cache::Entry* entry; |
| 1265 for (int i = 0; i < kNumberOfCaches; i++) { | 1262 for (int i = 0; i < kNumberOfCaches; i++) { |
| 1266 ASSERT_TRUE(cache[i]->CreateEntry(key, &entry)); | 1263 ASSERT_TRUE(cache[i]->CreateEntry(key, &entry)); |
| 1267 entry->Close(); | 1264 entry->Close(); |
| 1268 } | 1265 } |
| 1269 } | 1266 } |
| 1270 | 1267 |
| 1271 // Test the four regions of the curve that determines the max cache size. | 1268 // Test the four regions of the curve that determines the max cache size. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1290 EXPECT_EQ(kDefaultSize * 5 / 2, | 1287 EXPECT_EQ(kDefaultSize * 5 / 2, |
| 1291 disk_cache::PreferedCacheSize(large_size * 100 / 2)); | 1288 disk_cache::PreferedCacheSize(large_size * 100 / 2)); |
| 1292 EXPECT_EQ(kDefaultSize * 5 / 2, | 1289 EXPECT_EQ(kDefaultSize * 5 / 2, |
| 1293 disk_cache::PreferedCacheSize(large_size * 500 / 2)); | 1290 disk_cache::PreferedCacheSize(large_size * 500 / 2)); |
| 1294 | 1291 |
| 1295 EXPECT_EQ(kDefaultSize * 6 / 2, | 1292 EXPECT_EQ(kDefaultSize * 6 / 2, |
| 1296 disk_cache::PreferedCacheSize(large_size * 600 / 2)); | 1293 disk_cache::PreferedCacheSize(large_size * 600 / 2)); |
| 1297 EXPECT_EQ(kDefaultSize * 7 / 2, | 1294 EXPECT_EQ(kDefaultSize * 7 / 2, |
| 1298 disk_cache::PreferedCacheSize(large_size * 700 / 2)); | 1295 disk_cache::PreferedCacheSize(large_size * 700 / 2)); |
| 1299 } | 1296 } |
| OLD | NEW |