Commit 6cc6c707 authored by engedy@chromium.org's avatar engedy@chromium.org

Make NOTIFICATION_HISTORY_URLS_MODIFIED fired consistently for both typed and non-typed URLs.

The semantics for NOTIFICATION_HISTORY_URLS_MODIFIED was changed as of revision 131865 (https://chromiumcodereview.appspot.com/9852002) so that it would be fired not only for typed URLs, but also for non-typed ones (that is, URLs having |typed_count| == 0).

However, HistoryBackend::AddPagesWithDetails() was not updated to reflect these new semantics. Rectify this omission to make the code less mysterious.

BUG=None

Review URL: https://codereview.chromium.org/323043004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276622 0039d316-1c4b-4281-b951-d872f2087c98
parent b80059fc
...@@ -792,10 +792,8 @@ void HistoryBackend::AddPagesWithDetails(const URLRows& urls, ...@@ -792,10 +792,8 @@ void HistoryBackend::AddPagesWithDetails(const URLRows& urls,
return; return;
} }
if (i->typed_count() > 0) { modified->changed_urls.push_back(*i);
modified->changed_urls.push_back(*i); modified->changed_urls.back().set_id(url_id); // i->id_ is likely 0.
modified->changed_urls.back().set_id(url_id); // i->id_ is likely 0.
}
} }
// Sync code manages the visits itself. // Sync code manages the visits itself.
......
...@@ -942,20 +942,28 @@ TEST_F(HistoryBackendTest, AddPagesWithDetails) { ...@@ -942,20 +942,28 @@ TEST_F(HistoryBackendTest, AddPagesWithDetails) {
EXPECT_NE(0, backend_->db_->GetRowForURL(row3.url(), &stored_row3)); EXPECT_NE(0, backend_->db_->GetRowForURL(row3.url(), &stored_row3));
EXPECT_EQ(0, backend_->db_->GetRowForURL(row4.url(), &stored_row4)); EXPECT_EQ(0, backend_->db_->GetRowForURL(row4.url(), &stored_row4));
// Ensure that a notification was fired, and further verify that the IDs in // Ensure that a notification was fired for both typed and non-typed URLs.
// the notification are set to those that are in effect in the main database. // Further verify that the IDs in the notification are set to those that are
// The InMemoryHistoryBackend relies on this for caching. // in effect in the main database. The InMemoryHistoryBackend relies on this
// for caching.
ASSERT_EQ(1u, broadcasted_notifications().size()); ASSERT_EQ(1u, broadcasted_notifications().size());
ASSERT_EQ(chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, ASSERT_EQ(chrome::NOTIFICATION_HISTORY_URLS_MODIFIED,
broadcasted_notifications()[0].first); broadcasted_notifications()[0].first);
const URLsModifiedDetails* details = static_cast<const URLsModifiedDetails*>( const URLsModifiedDetails* details = static_cast<const URLsModifiedDetails*>(
broadcasted_notifications()[0].second); broadcasted_notifications()[0].second);
EXPECT_EQ(2u, details->changed_urls.size()); EXPECT_EQ(3u, details->changed_urls.size());
URLRows::const_iterator it_row2 = std::find_if( URLRows::const_iterator it_row1 = std::find_if(
details->changed_urls.begin(), details->changed_urls.begin(),
details->changed_urls.end(), details->changed_urls.end(),
history::URLRow::URLRowHasURL(row2.url())); history::URLRow::URLRowHasURL(row1.url()));
ASSERT_NE(details->changed_urls.end(), it_row1);
EXPECT_EQ(stored_row1.id(), it_row1->id());
URLRows::const_iterator it_row2 = std::find_if(
details->changed_urls.begin(),
details->changed_urls.end(),
history::URLRow::URLRowHasURL(row2.url()));
ASSERT_NE(details->changed_urls.end(), it_row2); ASSERT_NE(details->changed_urls.end(), it_row2);
EXPECT_EQ(stored_row2.id(), it_row2->id()); EXPECT_EQ(stored_row2.id(), it_row2->id());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment