| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <functional> | 6 #include <functional> |
| 7 | 7 |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/hash.h" | 9 #include "base/hash.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 index()->Insert(hashes_.at<3>()); | 531 index()->Insert(hashes_.at<3>()); |
| 532 // Confirm index is as expected: No eviction, everything there. | 532 // Confirm index is as expected: No eviction, everything there. |
| 533 EXPECT_EQ(3, index()->GetEntryCount()); | 533 EXPECT_EQ(3, index()->GetEntryCount()); |
| 534 EXPECT_EQ(0, doom_entries_calls()); | 534 EXPECT_EQ(0, doom_entries_calls()); |
| 535 EXPECT_TRUE(index()->Has(hashes_.at<1>())); | 535 EXPECT_TRUE(index()->Has(hashes_.at<1>())); |
| 536 EXPECT_TRUE(index()->Has(hashes_.at<2>())); | 536 EXPECT_TRUE(index()->Has(hashes_.at<2>())); |
| 537 EXPECT_TRUE(index()->Has(hashes_.at<3>())); | 537 EXPECT_TRUE(index()->Has(hashes_.at<3>())); |
| 538 | 538 |
| 539 // Trigger an eviction, and make sure the right things are tossed. | 539 // Trigger an eviction, and make sure the right things are tossed. |
| 540 // TODO(rdsmith): This is dependent on the innards of the implementation | 540 // TODO(rdsmith): This is dependent on the innards of the implementation |
| 541 // as to at exactly what point we trigger eviction. Not sure how to fix | 541 // as to at exactly what point we trigger eviction. Not sure how to fix |
| 542 // that. | 542 // that. |
| 543 index()->UpdateEntrySize(hashes_.at<3>(), 475); | 543 index()->UpdateEntrySize(hashes_.at<3>(), 475); |
| 544 EXPECT_EQ(1, doom_entries_calls()); | 544 EXPECT_EQ(1, doom_entries_calls()); |
| 545 EXPECT_EQ(1, index()->GetEntryCount()); | 545 EXPECT_EQ(1, index()->GetEntryCount()); |
| 546 EXPECT_FALSE(index()->Has(hashes_.at<1>())); | 546 EXPECT_FALSE(index()->Has(hashes_.at<1>())); |
| 547 EXPECT_FALSE(index()->Has(hashes_.at<2>())); | 547 EXPECT_FALSE(index()->Has(hashes_.at<2>())); |
| 548 EXPECT_TRUE(index()->Has(hashes_.at<3>())); | 548 EXPECT_TRUE(index()->Has(hashes_.at<3>())); |
| 549 ASSERT_EQ(2u, last_doom_entry_hashes().size()); | 549 ASSERT_EQ(2u, last_doom_entry_hashes().size()); |
| 550 } | 550 } |
| 551 | 551 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 WaitForTimeChange(); | 620 WaitForTimeChange(); |
| 621 EXPECT_EQ(expected_trigger, index()->write_to_disk_timer_.desired_run_time()); | 621 EXPECT_EQ(expected_trigger, index()->write_to_disk_timer_.desired_run_time()); |
| 622 index()->Insert(hashes_.at<2>()); | 622 index()->Insert(hashes_.at<2>()); |
| 623 index()->UpdateEntrySize(hashes_.at<2>(), 40); | 623 index()->UpdateEntrySize(hashes_.at<2>(), 40); |
| 624 EXPECT_TRUE(index()->write_to_disk_timer_.IsRunning()); | 624 EXPECT_TRUE(index()->write_to_disk_timer_.IsRunning()); |
| 625 EXPECT_LT(expected_trigger, index()->write_to_disk_timer_.desired_run_time()); | 625 EXPECT_LT(expected_trigger, index()->write_to_disk_timer_.desired_run_time()); |
| 626 index()->write_to_disk_timer_.Stop(); | 626 index()->write_to_disk_timer_.Stop(); |
| 627 } | 627 } |
| 628 | 628 |
| 629 } // namespace disk_cache | 629 } // namespace disk_cache |
| OLD | NEW |