| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 9 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 9 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
| 10 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
| (...skipping 2338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2349 DisableFirstCleanup(); | 2349 DisableFirstCleanup(); |
| 2350 SetMaxSize(20 * 1024 * 1024); | 2350 SetMaxSize(20 * 1024 * 1024); |
| 2351 SetNewEviction(); | 2351 SetNewEviction(); |
| 2352 InitCache(); | 2352 InitCache(); |
| 2353 BackendDoomAll2(); | 2353 BackendDoomAll2(); |
| 2354 } | 2354 } |
| 2355 | 2355 |
| 2356 // We should be able to create the same entry on multiple simultaneous instances | 2356 // We should be able to create the same entry on multiple simultaneous instances |
| 2357 // of the cache. | 2357 // of the cache. |
| 2358 TEST_F(DiskCacheTest, MultipleInstances) { | 2358 TEST_F(DiskCacheTest, MultipleInstances) { |
| 2359 ScopedTempDir store1, store2; | 2359 base::ScopedTempDir store1, store2; |
| 2360 ASSERT_TRUE(store1.CreateUniqueTempDir()); | 2360 ASSERT_TRUE(store1.CreateUniqueTempDir()); |
| 2361 ASSERT_TRUE(store2.CreateUniqueTempDir()); | 2361 ASSERT_TRUE(store2.CreateUniqueTempDir()); |
| 2362 | 2362 |
| 2363 base::Thread cache_thread("CacheThread"); | 2363 base::Thread cache_thread("CacheThread"); |
| 2364 ASSERT_TRUE(cache_thread.StartWithOptions( | 2364 ASSERT_TRUE(cache_thread.StartWithOptions( |
| 2365 base::Thread::Options(MessageLoop::TYPE_IO, 0))); | 2365 base::Thread::Options(MessageLoop::TYPE_IO, 0))); |
| 2366 net::TestCompletionCallback cb; | 2366 net::TestCompletionCallback cb; |
| 2367 | 2367 |
| 2368 const int kNumberOfCaches = 2; | 2368 const int kNumberOfCaches = 2; |
| 2369 disk_cache::Backend* cache[kNumberOfCaches]; | 2369 disk_cache::Backend* cache[kNumberOfCaches]; |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2568 // Ping the oldest entry. | 2568 // Ping the oldest entry. |
| 2569 cache_->OnExternalCacheHit("key0"); | 2569 cache_->OnExternalCacheHit("key0"); |
| 2570 | 2570 |
| 2571 TrimForTest(false); | 2571 TrimForTest(false); |
| 2572 | 2572 |
| 2573 // Make sure the older key remains. | 2573 // Make sure the older key remains. |
| 2574 EXPECT_EQ(1, cache_->GetEntryCount()); | 2574 EXPECT_EQ(1, cache_->GetEntryCount()); |
| 2575 ASSERT_EQ(net::OK, OpenEntry("key0", &entry)); | 2575 ASSERT_EQ(net::OK, OpenEntry("key0", &entry)); |
| 2576 entry->Close(); | 2576 entry->Close(); |
| 2577 } | 2577 } |
| OLD | NEW |