diff options
-rw-r--r-- | chrome/browser/visitedlink_master.cc | 4 | ||||
-rw-r--r-- | chrome/browser/visitedlink_master.h | 1 | ||||
-rw-r--r-- | chrome/browser/visitedlink_unittest.cc | 19 |
3 files changed, 22 insertions, 2 deletions
diff --git a/chrome/browser/visitedlink_master.cc b/chrome/browser/visitedlink_master.cc index 3f2f3c0..0e1ac9c 100644 --- a/chrome/browser/visitedlink_master.cc +++ b/chrome/browser/visitedlink_master.cc @@ -884,7 +884,7 @@ bool VisitedLinkMaster::RebuildTableFromHistory() { return true; } -// See the TableBuilder definition in the header file for how this works. +// See the TableBuilder declaration above for how this works. void VisitedLinkMaster::OnTableRebuildComplete( bool success, const std::vector<Fingerprint>& fingerprints) { @@ -897,7 +897,7 @@ void VisitedLinkMaster::OnTableRebuildComplete( base::SharedMemory* old_shared_memory = shared_memory_; int new_table_size = NewTableSizeForCount( - static_cast<int>(fingerprints.size())); + static_cast<int>(fingerprints.size() + added_since_rebuild_.size())); if (BeginReplaceURLTable(new_table_size)) { // Free the old table. delete old_shared_memory; diff --git a/chrome/browser/visitedlink_master.h b/chrome/browser/visitedlink_master.h index a07a1f7..3355436 100644 --- a/chrome/browser/visitedlink_master.h +++ b/chrome/browser/visitedlink_master.h @@ -138,6 +138,7 @@ class VisitedLinkMaster : public VisitedLinkCommon { private: FRIEND_TEST(VisitedLinkTest, Delete); FRIEND_TEST(VisitedLinkTest, BigDelete); + FRIEND_TEST(VisitedLinkTest, BigImport); // Object to rebuild the table on the history thread (see the .cc file). class TableBuilder; diff --git a/chrome/browser/visitedlink_unittest.cc b/chrome/browser/visitedlink_unittest.cc index 8775f9e..fb4b109 100644 --- a/chrome/browser/visitedlink_unittest.cc +++ b/chrome/browser/visitedlink_unittest.cc @@ -399,6 +399,25 @@ TEST_F(VisitedLinkTest, Rebuild) { EXPECT_FALSE(master_->IsVisited(TestURL(g_test_count))); } +// Test that importing a large number of URLs will work +TEST_F(VisitedLinkTest, BigImport) { + ASSERT_TRUE(InitHistory()); + ASSERT_TRUE(InitVisited(0, false)); + + // Before the table rebuilds, add a large number of URLs + int total_count = VisitedLinkMaster::kDefaultTableSize + 10; + for (int i = 0; i < total_count; i++) + master_->AddURL(TestURL(i)); + + // Wait for the rebuild to complete. + master_->set_rebuild_complete_task(new MessageLoop::QuitTask); + MessageLoop::current()->Run(); + + // Ensure that the right number of URLs are present + int used_count = master_->GetUsedCount(); + ASSERT_EQ(used_count, total_count); +} + TEST_F(VisitedLinkTest, Listener) { ASSERT_TRUE(InitHistory()); ASSERT_TRUE(InitVisited(0, true)); |