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/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/metrics/field_trial.h" | 7 #include "base/metrics/field_trial.h" |
8 #include "base/port.h" | 8 #include "base/port.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 3455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3466 std::set<std::string> keys_to_match(key_pool); | 3466 std::set<std::string> keys_to_match(key_pool); |
3467 void* iter = NULL; | 3467 void* iter = NULL; |
3468 size_t count = 0; | 3468 size_t count = 0; |
3469 ASSERT_TRUE(EnumerateAndMatchKeys(-1, &iter, &keys_to_match, &count)); | 3469 ASSERT_TRUE(EnumerateAndMatchKeys(-1, &iter, &keys_to_match, &count)); |
3470 cache_->EndEnumeration(&iter); | 3470 cache_->EndEnumeration(&iter); |
3471 | 3471 |
3472 EXPECT_EQ(key_pool.size(), count); | 3472 EXPECT_EQ(key_pool.size(), count); |
3473 EXPECT_TRUE(keys_to_match.empty()); | 3473 EXPECT_TRUE(keys_to_match.empty()); |
3474 } | 3474 } |
3475 | 3475 |
| 3476 // Tests that enumerations don't leak memory when the backend is destructed |
| 3477 // mid-enumeration. |
| 3478 TEST_F(DiskCacheBackendTest, SimpleCacheEnumerationDestruction) { |
| 3479 SetSimpleCacheMode(); |
| 3480 InitCache(); |
| 3481 std::set<std::string> key_pool; |
| 3482 ASSERT_TRUE(CreateSetOfRandomEntries(&key_pool)); |
| 3483 |
| 3484 void* iter = NULL; |
| 3485 disk_cache::Entry* entry = NULL; |
| 3486 ASSERT_EQ(net::OK, OpenNextEntry(&iter, &entry)); |
| 3487 EXPECT_TRUE(entry); |
| 3488 disk_cache::ScopedEntryPtr entry_closer(entry); |
| 3489 |
| 3490 cache_.reset(); |
| 3491 // This test passes if we don't leak memory. |
| 3492 } |
| 3493 |
3476 #endif // defined(OS_POSIX) | 3494 #endif // defined(OS_POSIX) |
OLD | NEW |