Commit b294bdc5 authored by Christian Dullweber's avatar Christian Dullweber Committed by Commit Bot

Migrate HistoryServiceObservers in components/history/

Change HistoryServiceObservers to use the new OnUrlsDeleted method.

Bug: 839798
Change-Id: Ia5e01bcf60a43d7b1112f69f816a06e9ae1e51ab
Reviewed-on: https://chromium-review.googlesource.com/1051767Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Christian Dullweber <dullweber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558232}
parent a3e6e355
...@@ -742,11 +742,9 @@ static bool DeletionsDiffer(const URLRows& deleted_rows, ...@@ -742,11 +742,9 @@ static bool DeletionsDiffer(const URLRows& deleted_rows,
} }
void BrowsingHistoryService::OnURLsDeleted(HistoryService* history_service, void BrowsingHistoryService::OnURLsDeleted(HistoryService* history_service,
bool all_history, const DeletionInfo& deletion_info) {
bool expired, if (deletion_info.IsAllHistory() ||
const URLRows& deleted_rows, DeletionsDiffer(deletion_info.deleted_rows(), urls_to_be_deleted_))
const std::set<GURL>& favicon_urls) {
if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_))
driver_->HistoryDeleted(); driver_->HistoryDeleted();
} }
......
...@@ -202,10 +202,7 @@ class BrowsingHistoryService : public HistoryServiceObserver, ...@@ -202,10 +202,7 @@ class BrowsingHistoryService : public HistoryServiceObserver,
// HistoryServiceObserver implementation. // HistoryServiceObserver implementation.
void OnURLsDeleted(HistoryService* history_service, void OnURLsDeleted(HistoryService* history_service,
bool all_history, const DeletionInfo& deletion_info) override;
bool expired,
const URLRows& deleted_rows,
const std::set<GURL>& favicon_urls) override;
// WebHistoryServiceObserver implementation. // WebHistoryServiceObserver implementation.
void OnWebHistoryDeleted() override; void OnWebHistoryDeleted() override;
......
...@@ -226,10 +226,7 @@ class HistoryBackendTestBase : public testing::Test { ...@@ -226,10 +226,7 @@ class HistoryBackendTestBase : public testing::Test {
} }
void NotifyURLsDeleted(DeletionInfo deletion_info) { void NotifyURLsDeleted(DeletionInfo deletion_info) {
mem_backend_->OnURLsDeleted(nullptr, deletion_info.IsAllHistory(), mem_backend_->OnURLsDeleted(nullptr, deletion_info);
deletion_info.is_from_expiration(),
deletion_info.deleted_rows(),
deletion_info.favicon_urls());
urls_deleted_notifications_.push_back(std::make_pair( urls_deleted_notifications_.push_back(std::make_pair(
deletion_info.IsAllHistory(), deletion_info.is_from_expiration())); deletion_info.IsAllHistory(), deletion_info.is_from_expiration()));
} }
...@@ -3946,8 +3943,7 @@ TEST_F(InMemoryHistoryBackendTest, OnURLsDeletedEnMasse) { ...@@ -3946,8 +3943,7 @@ TEST_F(InMemoryHistoryBackendTest, OnURLsDeletedEnMasse) {
SimulateNotificationURLsModified(mem_backend_.get(), &row1, &row2, &row3); SimulateNotificationURLsModified(mem_backend_.get(), &row1, &row2, &row3);
// Now notify the in-memory database that all history has been deleted. // Now notify the in-memory database that all history has been deleted.
mem_backend_->OnURLsDeleted(nullptr, true, false, URLRows(), mem_backend_->OnURLsDeleted(nullptr, history::DeletionInfo::ForAllHistory());
std::set<GURL>());
// Expect that everything goes away. // Expect that everything goes away.
EXPECT_EQ(0, mem_backend_->db()->GetRowForURL(row1.url(), nullptr)); EXPECT_EQ(0, mem_backend_->db()->GetRowForURL(row1.url(), nullptr));
......
...@@ -58,13 +58,10 @@ void InMemoryHistoryBackend::OnURLsModified(HistoryService* history_service, ...@@ -58,13 +58,10 @@ void InMemoryHistoryBackend::OnURLsModified(HistoryService* history_service,
} }
void InMemoryHistoryBackend::OnURLsDeleted(HistoryService* history_service, void InMemoryHistoryBackend::OnURLsDeleted(HistoryService* history_service,
bool all_history, const DeletionInfo& deletion_info) {
bool expired,
const URLRows& deleted_rows,
const std::set<GURL>& favicon_urls) {
DCHECK(db_); DCHECK(db_);
if (all_history) { if (deletion_info.IsAllHistory()) {
// When all history is deleted, the individual URLs won't be listed. Just // When all history is deleted, the individual URLs won't be listed. Just
// create a new database to quickly clear everything out. // create a new database to quickly clear everything out.
db_.reset(new InMemoryDatabase); db_.reset(new InMemoryDatabase);
...@@ -74,7 +71,7 @@ void InMemoryHistoryBackend::OnURLsDeleted(HistoryService* history_service, ...@@ -74,7 +71,7 @@ void InMemoryHistoryBackend::OnURLsDeleted(HistoryService* history_service,
} }
// Delete all matching URLs in our database. // Delete all matching URLs in our database.
for (const auto& row : deleted_rows) { for (const auto& row : deletion_info.deleted_rows()) {
// This will also delete the corresponding keyword search term. // This will also delete the corresponding keyword search term.
// Ignore errors, as we typically only cache a subset of URLRows. // Ignore errors, as we typically only cache a subset of URLRows.
db_->DeleteURLRow(row.id()); db_->DeleteURLRow(row.id());
......
...@@ -78,10 +78,7 @@ class InMemoryHistoryBackend : public HistoryServiceObserver { ...@@ -78,10 +78,7 @@ class InMemoryHistoryBackend : public HistoryServiceObserver {
void OnURLsModified(HistoryService* history_service, void OnURLsModified(HistoryService* history_service,
const URLRows& changed_urls) override; const URLRows& changed_urls) override;
void OnURLsDeleted(HistoryService* history_service, void OnURLsDeleted(HistoryService* history_service,
bool all_history, const DeletionInfo& deletion_info) override;
bool expired,
const URLRows& deleted_rows,
const std::set<GURL>& favicon_urls) override;
void OnKeywordSearchTermUpdated(HistoryService* history_service, void OnKeywordSearchTermUpdated(HistoryService* history_service,
const URLRow& row, const URLRow& row,
KeywordID keyword_id, KeywordID keyword_id,
......
...@@ -890,19 +890,16 @@ void TopSitesImpl::OnTopSitesAvailableFromHistory( ...@@ -890,19 +890,16 @@ void TopSitesImpl::OnTopSitesAvailableFromHistory(
} }
void TopSitesImpl::OnURLsDeleted(HistoryService* history_service, void TopSitesImpl::OnURLsDeleted(HistoryService* history_service,
bool all_history, const DeletionInfo& deletion_info) {
bool expired,
const URLRows& deleted_rows,
const std::set<GURL>& favicon_urls) {
if (!loaded_) if (!loaded_)
return; return;
if (all_history) { if (deletion_info.IsAllHistory()) {
SetTopSites(MostVisitedURLList(), CALL_LOCATION_FROM_OTHER_PLACES); SetTopSites(MostVisitedURLList(), CALL_LOCATION_FROM_OTHER_PLACES);
backend_->ResetDatabase(); backend_->ResetDatabase();
} else { } else {
std::set<size_t> indices_to_delete; // Indices into top_sites_. std::set<size_t> indices_to_delete; // Indices into top_sites_.
for (const auto& row : deleted_rows) { for (const auto& row : deletion_info.deleted_rows()) {
if (cache_->IsKnownURL(row.url())) if (cache_->IsKnownURL(row.url()))
indices_to_delete.insert(cache_->GetURLIndex(row.url())); indices_to_delete.insert(cache_->GetURLIndex(row.url()));
} }
......
...@@ -268,10 +268,7 @@ class TopSitesImpl : public TopSites, public HistoryServiceObserver { ...@@ -268,10 +268,7 @@ class TopSitesImpl : public TopSites, public HistoryServiceObserver {
// history::HistoryServiceObserver: // history::HistoryServiceObserver:
void OnURLsDeleted(HistoryService* history_service, void OnURLsDeleted(HistoryService* history_service,
bool all_history, const DeletionInfo& deletion_info) override;
bool expired,
const URLRows& deleted_rows,
const std::set<GURL>& favicon_urls) override;
// Ensures that non thread-safe methods are called on the correct thread. // Ensures that non thread-safe methods are called on the correct thread.
base::ThreadChecker thread_checker_; base::ThreadChecker thread_checker_;
......
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