summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/autocomplete/network_action_predictor.cc7
-rw-r--r--chrome/browser/autocomplete/network_action_predictor.h5
-rw-r--r--chrome/browser/autocomplete/network_action_predictor_unittest.cc10
-rw-r--r--chrome/browser/history/android/android_provider_backend.cc2
-rw-r--r--chrome/browser/history/android/android_provider_backend_unittest.cc15
-rw-r--r--chrome/browser/history/expire_history_backend.cc3
-rw-r--r--chrome/browser/history/expire_history_backend_unittest.cc9
-rw-r--r--chrome/browser/history/history.cc2
-rw-r--r--chrome/browser/history/history_extension_api.cc7
-rw-r--r--chrome/browser/history/history_notifications.h10
-rw-r--r--chrome/browser/history/history_types.h13
-rw-r--r--chrome/browser/history/in_memory_url_index_unittest.cc33
-rw-r--r--chrome/browser/history/shortcuts_backend.cc8
-rw-r--r--chrome/browser/history/top_sites.cc8
-rw-r--r--chrome/browser/sync/glue/typed_url_change_processor.cc7
-rw-r--r--chrome/browser/sync/profile_sync_service_typed_url_unittest.cc2
-rw-r--r--chrome/browser/ui/webui/history_ui.cc20
-rw-r--r--chrome/browser/visitedlink/visitedlink_master.cc20
-rw-r--r--chrome/browser/visitedlink/visitedlink_master.h5
-rw-r--r--chrome/browser/visitedlink/visitedlink_unittest.cc12
20 files changed, 78 insertions, 120 deletions
diff --git a/chrome/browser/autocomplete/network_action_predictor.cc b/chrome/browser/autocomplete/network_action_predictor.cc
index 310200e..7afc9f8 100644
--- a/chrome/browser/autocomplete/network_action_predictor.cc
+++ b/chrome/browser/autocomplete/network_action_predictor.cc
@@ -202,7 +202,7 @@ void NetworkActionPredictor::Observe(
if (urls_deleted_details->all_history)
DeleteAllRows();
else
- DeleteRowsWithURLs(urls_deleted_details->rows);
+ DeleteRowsWithURLs(urls_deleted_details->urls);
break;
}
@@ -465,15 +465,14 @@ void NetworkActionPredictor::DeleteAllRows() {
DATABASE_ACTION_DELETE_ALL, DATABASE_ACTION_COUNT);
}
-void NetworkActionPredictor::DeleteRowsWithURLs(const history::URLRows& rows) {
+void NetworkActionPredictor::DeleteRowsWithURLs(const std::set<GURL>& urls) {
if (!initialized_)
return;
std::vector<NetworkActionPredictorDatabase::Row::Id> id_list;
for (DBCacheMap::iterator it = db_cache_.begin(); it != db_cache_.end();) {
- if (std::find_if(rows.begin(), rows.end(),
- history::URLRow::URLRowHasURL(it->first.url)) != rows.end()) {
+ if (urls.find(it->first.url) != urls.end()) {
const DBIdCacheMap::iterator id_it = db_id_cache_.find(it->first);
DCHECK(id_it != db_id_cache_.end());
id_list.push_back(id_it->second);
diff --git a/chrome/browser/autocomplete/network_action_predictor.h b/chrome/browser/autocomplete/network_action_predictor.h
index 0cf02a4..a8351e4 100644
--- a/chrome/browser/autocomplete/network_action_predictor.h
+++ b/chrome/browser/autocomplete/network_action_predictor.h
@@ -13,7 +13,6 @@
#include "base/memory/weak_ptr.h"
#include "base/string16.h"
#include "chrome/browser/autocomplete/network_action_predictor_database.h"
-#include "chrome/browser/history/history_types.h"
#include "chrome/browser/profiles/profile_keyed_service.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
@@ -177,8 +176,8 @@ class NetworkActionPredictor
// Removes all rows from the database and caches.
void DeleteAllRows();
- // Removes rows from the database and caches that contain a URL in |rows|.
- void DeleteRowsWithURLs(const history::URLRows& rows);
+ // Removes rows from the database and caches that contain a URL in |urls|.
+ void DeleteRowsWithURLs(const std::set<GURL>& urls);
// Used to batch operations on the database.
void BeginTransaction();
diff --git a/chrome/browser/autocomplete/network_action_predictor_unittest.cc b/chrome/browser/autocomplete/network_action_predictor_unittest.cc
index e5ce30b..25bff10 100644
--- a/chrome/browser/autocomplete/network_action_predictor_unittest.cc
+++ b/chrome/browser/autocomplete/network_action_predictor_unittest.cc
@@ -170,8 +170,8 @@ class NetworkActionPredictorTest : public testing::Test {
predictor_->DeleteAllRows();
}
- void DeleteRowsWithURLs(const history::URLRows& rows) {
- predictor_->DeleteRowsWithURLs(rows);
+ void DeleteRowsWithURLs(const std::set<GURL>& urls) {
+ predictor_->DeleteRowsWithURLs(urls);
}
void DeleteOldIdsFromCaches(
@@ -278,11 +278,11 @@ TEST_F(NetworkActionPredictorTest, DeleteRowsWithURLs) {
EXPECT_EQ(arraysize(test_url_db), db_cache()->size());
EXPECT_EQ(arraysize(test_url_db), db_id_cache()->size());
- history::URLRows rows;
+ std::set<GURL> urls;
for (size_t i = 0; i < 2; ++i)
- rows.push_back(history::URLRow(test_url_db[i].url));
+ urls.insert(test_url_db[i].url);
- DeleteRowsWithURLs(rows);
+ DeleteRowsWithURLs(urls);
EXPECT_EQ(arraysize(test_url_db) - 2, db_cache()->size());
EXPECT_EQ(arraysize(test_url_db) - 2, db_id_cache()->size());
diff --git a/chrome/browser/history/android/android_provider_backend.cc b/chrome/browser/history/android/android_provider_backend.cc
index 077e45f..3a06a7a 100644
--- a/chrome/browser/history/android/android_provider_backend.cc
+++ b/chrome/browser/history/android/android_provider_backend.cc
@@ -900,6 +900,7 @@ bool AndroidProviderBackend::SimulateUpdateURL(
if (!history_db_->GetURLRow(ids[0].url_id, &old_url_row))
return false;
deleted_details->rows.push_back(old_url_row);
+ deleted_details->urls.insert(old_url_row.url());
FaviconID favicon_id = statement->statement()->ColumnInt64(4);
if (favicon_id) {
@@ -1025,6 +1026,7 @@ bool AndroidProviderBackend::DeleteHistoryInternal(
if (!history_db_->GetURLRow(i->url_id, &url_row))
return false;
deleted_details->rows.push_back(url_row);
+ deleted_details->urls.insert(url_row.url());
if (thumbnail_db_->GetIconMappingsForPageURL(url_row.url(), NULL))
favicon->urls.insert(url_row.url());
}
diff --git a/chrome/browser/history/android/android_provider_backend_unittest.cc b/chrome/browser/history/android/android_provider_backend_unittest.cc
index d2c9107..989ce60 100644
--- a/chrome/browser/history/android/android_provider_backend_unittest.cc
+++ b/chrome/browser/history/android/android_provider_backend_unittest.cc
@@ -547,6 +547,9 @@ TEST_F(AndroidProviderBackendTest, DeleteHistoryAndBookmarks) {
ASSERT_TRUE(delegate_.deleted_details());
EXPECT_FALSE(delegate_.modified_details());
EXPECT_EQ(1u, delegate_.deleted_details()->rows.size());
+ EXPECT_EQ(1u, delegate_.deleted_details()->urls.size());
+ EXPECT_TRUE(delegate_.deleted_details()->urls.end() !=
+ delegate_.deleted_details()->urls.find(row1.url()));
EXPECT_EQ(row1.url(), delegate_.deleted_details()->rows[0].url());
EXPECT_EQ(row1.last_visit_time(),
delegate_.deleted_details()->rows[0].last_visit());
@@ -594,6 +597,9 @@ TEST_F(AndroidProviderBackendTest, DeleteHistoryAndBookmarks) {
ASSERT_TRUE(delegate_.deleted_details());
EXPECT_FALSE(delegate_.modified_details());
EXPECT_EQ(1u, delegate_.deleted_details()->rows.size());
+ EXPECT_EQ(1u, delegate_.deleted_details()->urls.size());
+ EXPECT_TRUE(delegate_.deleted_details()->urls.end() !=
+ delegate_.deleted_details()->urls.find(row2.url()));
EXPECT_EQ(row2.url(), delegate_.deleted_details()->rows[0].url());
EXPECT_EQ(row2.last_visit_time(),
delegate_.deleted_details()->rows[0].last_visit());
@@ -749,6 +755,9 @@ TEST_F(AndroidProviderBackendTest, UpdateURL) {
// Verify notifications, Update involves insert and delete URLS.
ASSERT_TRUE(delegate_.deleted_details());
EXPECT_EQ(1u, delegate_.deleted_details()->rows.size());
+ EXPECT_EQ(1u, delegate_.deleted_details()->urls.size());
+ EXPECT_TRUE(delegate_.deleted_details()->urls.end() !=
+ delegate_.deleted_details()->urls.find(row1.url()));
EXPECT_EQ(row1.url(), delegate_.deleted_details()->rows[0].url());
EXPECT_EQ(row1.last_visit_time(),
delegate_.deleted_details()->rows[0].last_visit());
@@ -801,6 +810,9 @@ TEST_F(AndroidProviderBackendTest, UpdateURL) {
// Verify notifications, Update involves insert and delete URLS.
ASSERT_TRUE(delegate_.deleted_details());
EXPECT_EQ(1u, delegate_.deleted_details()->rows.size());
+ EXPECT_EQ(1u, delegate_.deleted_details()->urls.size());
+ EXPECT_TRUE(delegate_.deleted_details()->urls.end() !=
+ delegate_.deleted_details()->urls.find(row2.url()));
EXPECT_EQ(row2.url(), delegate_.deleted_details()->rows[0].url());
EXPECT_EQ(row2.last_visit_time(),
delegate_.deleted_details()->rows[0].last_visit());
@@ -1484,6 +1496,9 @@ TEST_F(AndroidProviderBackendTest, DeleteHistory) {
// Verify notification
ASSERT_TRUE(delegate_.deleted_details());
ASSERT_EQ(2u, delegate_.deleted_details()->rows.size());
+ ASSERT_EQ(2u, delegate_.deleted_details()->urls.size());
+ ASSERT_TRUE(delegate_.modified_details());
+ ASSERT_EQ(1u, delegate_.modified_details()->changed_urls.size());
EXPECT_EQ(row1.url(),
delegate_.modified_details()->changed_urls[0].url());
EXPECT_EQ(Time::UnixEpoch(),
diff --git a/chrome/browser/history/expire_history_backend.cc b/chrome/browser/history/expire_history_backend.cc
index 9ccdd59..2946588 100644
--- a/chrome/browser/history/expire_history_backend.cc
+++ b/chrome/browser/history/expire_history_backend.cc
@@ -359,7 +359,8 @@ void ExpireHistoryBackend::BroadcastDeleteNotifications(
// determine if they care whether anything was deleted).
URLsDeletedDetails* deleted_details = new URLsDeletedDetails;
deleted_details->all_history = false;
- deleted_details->rows = dependencies->deleted_urls;
+ for (size_t i = 0; i < dependencies->deleted_urls.size(); i++)
+ deleted_details->urls.insert(dependencies->deleted_urls[i].url());
delegate_->BroadcastNotifications(
chrome::NOTIFICATION_HISTORY_URLS_DELETED, deleted_details);
}
diff --git a/chrome/browser/history/expire_history_backend_unittest.cc b/chrome/browser/history/expire_history_backend_unittest.cc
index ab2d570..691681f 100644
--- a/chrome/browser/history/expire_history_backend_unittest.cc
+++ b/chrome/browser/history/expire_history_backend_unittest.cc
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <algorithm>
#include <string>
#include <utility>
@@ -382,10 +381,10 @@ void ExpireHistoryTest::EnsureURLInfoGone(const URLRow& row) {
bool found_delete_notification = false;
for (size_t i = 0; i < notifications_.size(); i++) {
if (notifications_[i].first == chrome::NOTIFICATION_HISTORY_URLS_DELETED) {
- const history::URLRows& rows(reinterpret_cast<URLsDeletedDetails*>(
- notifications_[i].second)->rows);
- if (std::find_if(rows.begin(), rows.end(),
- history::URLRow::URLRowHasURL(row.url())) != rows.end()) {
+ const URLsDeletedDetails* deleted_details =
+ reinterpret_cast<URLsDeletedDetails*>(notifications_[i].second);
+ if (deleted_details->urls.find(row.url()) !=
+ deleted_details->urls.end()) {
found_delete_notification = true;
}
} else {
diff --git a/chrome/browser/history/history.cc b/chrome/browser/history/history.cc
index 9e234eb..781d8aa 100644
--- a/chrome/browser/history/history.cc
+++ b/chrome/browser/history/history.cc
@@ -687,7 +687,7 @@ void HistoryService::Observe(int type,
if (deleted_details->all_history)
visited_links->DeleteAllURLs();
else // Delete individual ones.
- visited_links->DeleteURLs(deleted_details->rows);
+ visited_links->DeleteURLs(deleted_details->urls);
break;
}
diff --git a/chrome/browser/history/history_extension_api.cc b/chrome/browser/history/history_extension_api.cc
index af0f8ca..02536b4 100644
--- a/chrome/browser/history/history_extension_api.cc
+++ b/chrome/browser/history/history_extension_api.cc
@@ -145,9 +145,10 @@ void HistoryExtensionEventRouter::HistoryUrlsRemoved(
DictionaryValue* dict = new DictionaryValue();
dict->SetBoolean(kAllHistoryKey, details->all_history);
ListValue* urls = new ListValue();
- for (history::URLRows::const_iterator iterator = details->rows.begin();
- iterator != details->rows.end(); ++iterator) {
- urls->Append(new StringValue(iterator->url().spec()));
+ for (std::set<GURL>::const_iterator iterator = details->urls.begin();
+ iterator != details->urls.end();
+ ++iterator) {
+ urls->Append(new StringValue(iterator->spec()));
}
dict->Set(kUrlsKey, urls);
args.Append(dict);
diff --git a/chrome/browser/history/history_notifications.h b/chrome/browser/history/history_notifications.h
index 25e0b4f..ac750e1 100644
--- a/chrome/browser/history/history_notifications.h
+++ b/chrome/browser/history/history_notifications.h
@@ -57,9 +57,15 @@ struct URLsDeletedDetails : public HistoryDetails {
// Set when all history was deleted. False means just a subset was deleted.
bool all_history;
- // The URLRows of URLs deleted. This is valid only when all_history is false
- // indicating that a subset of history has been deleted.
+ // The URLRows which have been deleted.
URLRows rows;
+
+ // The list of unique URLs affected. This is valid only when a subset of
+ // history is deleted. When all of it is deleted, this will be empty, since
+ // we do not bother to list all URLs. (This information can be gleaned from
+ // |rows| but, since there are several clients who need the set, we pre-build
+ // it so that the clients don't have to.)
+ std::set<GURL> urls;
};
// Details for NOTIFY_URLS_STARRED.
diff --git a/chrome/browser/history/history_types.h b/chrome/browser/history/history_types.h
index b2e7ca8..30ded66 100644
--- a/chrome/browser/history/history_types.h
+++ b/chrome/browser/history/history_types.h
@@ -132,19 +132,6 @@ class URLRow {
hidden_ = hidden;
}
- // Helper functor that determines if an URLRow refers to a given URL.
- class URLRowHasURL {
- public:
- explicit URLRowHasURL(const GURL& url) : url_(url) {}
-
- bool operator()(const URLRow& row) {
- return row.url() == url_;
- }
-
- private:
- const GURL& url_;
- };
-
protected:
// Swaps the contents of this URLRow with another, which allows it to be
// destructively copied without memory allocations.
diff --git a/chrome/browser/history/in_memory_url_index_unittest.cc b/chrome/browser/history/in_memory_url_index_unittest.cc
index ee34125..607a032 100644
--- a/chrome/browser/history/in_memory_url_index_unittest.cc
+++ b/chrome/browser/history/in_memory_url_index_unittest.cc
@@ -17,14 +17,10 @@
#include "chrome/browser/history/history.h"
#include "chrome/browser/history/history_backend.h"
#include "chrome/browser/history/history_database.h"
-#include "chrome/browser/history/history_notifications.h"
#include "chrome/browser/history/in_memory_url_index_types.h"
#include "chrome/browser/history/in_memory_url_index.h"
#include "chrome/browser/history/url_index_private_data.h"
-#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_paths.h"
-#include "content/public/browser/notification_details.h"
-#include "content/public/browser/notification_source.h"
#include "chrome/test/base/testing_profile.h"
#include "content/test/test_browser_thread.h"
#include "sql/transaction.h"
@@ -133,9 +129,6 @@ class InMemoryURLIndexTest : public testing::Test {
bool GetCacheFilePath(FilePath* file_path) const;
void PostRestoreFromCacheFileTask();
void PostSaveToCacheFileTask();
- void Observe(int notification_type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details);
const std::set<std::string>& scheme_whitelist();
@@ -193,13 +186,6 @@ void InMemoryURLIndexTest::PostSaveToCacheFileTask() {
url_index_->PostSaveToCacheFileTask();
}
-void InMemoryURLIndexTest::Observe(
- int notification_type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- url_index_->Observe(notification_type, source, details);
-}
-
const std::set<std::string>& InMemoryURLIndexTest::scheme_whitelist() {
return url_index_->scheme_whitelist();
}
@@ -845,7 +831,7 @@ TEST_F(InMemoryURLIndexTest, DeleteRows) {
url_index_->HistoryItemsForTerms(ASCIIToUTF16("DrudgeReport"));
ASSERT_EQ(1U, matches.size());
- // Delete the URL for then search again.
+ // Determine the row id for that result, delete that id, then search again.
EXPECT_TRUE(DeleteURL(matches[0].url_info.url()));
EXPECT_TRUE(url_index_->HistoryItemsForTerms(
ASCIIToUTF16("DrudgeReport")).empty());
@@ -855,23 +841,6 @@ TEST_F(InMemoryURLIndexTest, DeleteRows) {
EXPECT_FALSE(DeleteURL(url));
}
-TEST_F(InMemoryURLIndexTest, ExpireRow) {
- ScoredHistoryMatches matches =
- url_index_->HistoryItemsForTerms(ASCIIToUTF16("DrudgeReport"));
- ASSERT_EQ(1U, matches.size());
-
- // Determine the row id for the result, remember that id, broadcast a
- // delete notification, then ensure that the row has been deleted.
- URLsDeletedDetails* deleted_details = new URLsDeletedDetails;
- deleted_details->all_history = false;
- deleted_details->rows.push_back(matches[0].url_info);
- Observe(chrome::NOTIFICATION_HISTORY_URLS_DELETED,
- content::Source<InMemoryURLIndexTest>(this),
- content::Details<history::HistoryDetails>(deleted_details));
- EXPECT_TRUE(url_index_->HistoryItemsForTerms(
- ASCIIToUTF16("DrudgeReport")).empty());
-}
-
TEST_F(InMemoryURLIndexTest, WhitelistedURLs) {
struct TestData {
const std::string url_spec;
diff --git a/chrome/browser/history/shortcuts_backend.cc b/chrome/browser/history/shortcuts_backend.cc
index dfa6982..db350e5 100644
--- a/chrome/browser/history/shortcuts_backend.cc
+++ b/chrome/browser/history/shortcuts_backend.cc
@@ -227,15 +227,13 @@ void ShortcutsBackend::Observe(int type,
all_history) {
DeleteAllShortcuts();
}
- const URLRows& rows(
- content::Details<const history::URLsDeletedDetails>(details)->rows);
+ const std::set<GURL>& urls =
+ content::Details<const history::URLsDeletedDetails>(details)->urls;
std::vector<std::string> shortcut_ids;
for (GuidToShortcutsIteratorMap::iterator it = guid_map_.begin();
it != guid_map_.end(); ++it) {
- if (std::find_if(rows.begin(), rows.end(),
- URLRow::URLRowHasURL(it->second->second.url)) !=
- rows.end())
+ if (urls.find(it->second->second.url) != urls.end())
shortcut_ids.push_back(it->first);
}
DeleteShortcutsWithIds(shortcut_ids);
diff --git a/chrome/browser/history/top_sites.cc b/chrome/browser/history/top_sites.cc
index ac13506..e6416dc 100644
--- a/chrome/browser/history/top_sites.cc
+++ b/chrome/browser/history/top_sites.cc
@@ -682,10 +682,10 @@ void TopSites::Observe(int type,
backend_->ResetDatabase();
} else {
std::set<size_t> indices_to_delete; // Indices into top_sites_.
- for (URLRows::const_iterator i = deleted_details->rows.begin();
- i != deleted_details->rows.end(); ++i) {
- if (cache_->IsKnownURL(i->url()))
- indices_to_delete.insert(cache_->GetURLIndex(i->url()));
+ for (std::set<GURL>::iterator i = deleted_details->urls.begin();
+ i != deleted_details->urls.end(); ++i) {
+ if (cache_->IsKnownURL(*i))
+ indices_to_delete.insert(cache_->GetURLIndex(*i));
}
if (indices_to_delete.empty())
diff --git a/chrome/browser/sync/glue/typed_url_change_processor.cc b/chrome/browser/sync/glue/typed_url_change_processor.cc
index 9c853f7..194f822 100644
--- a/chrome/browser/sync/glue/typed_url_change_processor.cc
+++ b/chrome/browser/sync/glue/typed_url_change_processor.cc
@@ -151,13 +151,12 @@ void TypedUrlChangeProcessor::HandleURLsDeleted(
return;
}
} else {
- for (history::URLRows::const_iterator row = details->rows.begin();
- row != details->rows.end(); ++row) {
+ for (std::set<GURL>::iterator url = details->urls.begin();
+ url != details->urls.end(); ++url) {
sync_api::WriteNode sync_node(&trans);
// The deleted URL could have been non-typed, so it might not be found
// in the sync DB.
- if (sync_node.InitByClientTagLookup(syncable::TYPED_URLS,
- row->url().spec()))
+ if (sync_node.InitByClientTagLookup(syncable::TYPED_URLS, url->spec()))
sync_node.Remove();
}
}
diff --git a/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc b/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc
index 98ccc6a..7ebe6b5 100644
--- a/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc
@@ -714,7 +714,7 @@ TEST_F(ProfileSyncServiceTypedUrlTest, ProcessUserChangeRemove) {
history::URLsDeletedDetails changes;
changes.all_history = false;
- changes.rows.push_back(history::URLRow(GURL("http://mine.com")));
+ changes.urls.insert(GURL("http://mine.com"));
scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(&history_thread_));
notifier->Notify(chrome::NOTIFICATION_HISTORY_URLS_DELETED,
content::Source<Profile>(&profile_),
diff --git a/chrome/browser/ui/webui/history_ui.cc b/chrome/browser/ui/webui/history_ui.cc
index 76bf780..5735fe5 100644
--- a/chrome/browser/ui/webui/history_ui.cc
+++ b/chrome/browser/ui/webui/history_ui.cc
@@ -429,20 +429,6 @@ history::QueryOptions BrowsingHistoryHandler::CreateMonthQueryOptions(
return options;
}
-// Helper function for Observe that determines if there are any differences
-// between the URLs noticed for deletion and the ones we are expecting.
-static bool DeletionsDiffer(const history::URLRows& deleted_rows,
- const std::set<GURL>& urls_to_be_deleted) {
- if (deleted_rows.size() != urls_to_be_deleted.size())
- return true;
- for (history::URLRows::const_iterator i = deleted_rows.begin();
- i != deleted_rows.end(); ++i) {
- if (urls_to_be_deleted.find(i->url()) == urls_to_be_deleted.end())
- return true;
- }
- return false;
-}
-
void BrowsingHistoryHandler::Observe(
int type,
const content::NotificationSource& source,
@@ -453,9 +439,11 @@ void BrowsingHistoryHandler::Observe(
}
history::URLsDeletedDetails* deletedDetails =
content::Details<history::URLsDeletedDetails>(details).ptr();
- if (deletedDetails->all_history ||
- DeletionsDiffer(deletedDetails->rows, urls_to_be_deleted_))
+ if (deletedDetails->urls != urls_to_be_deleted_ ||
+ deletedDetails->all_history) {
+ // Notify the page that someone else deleted from the history.
web_ui()->CallJavascriptFunction("historyDeleted");
+ }
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/visitedlink/visitedlink_master.cc b/chrome/browser/visitedlink/visitedlink_master.cc
index c80f0d5..38c87ca 100644
--- a/chrome/browser/visitedlink/visitedlink_master.cc
+++ b/chrome/browser/visitedlink/visitedlink_master.cc
@@ -289,10 +289,10 @@ void VisitedLinkMaster::DeleteAllURLs() {
listener_->Reset();
}
-void VisitedLinkMaster::DeleteURLs(const history::URLRows& rows) {
+void VisitedLinkMaster::DeleteURLs(const std::set<GURL>& urls) {
typedef std::set<GURL>::const_iterator SetIterator;
- if (rows.empty())
+ if (urls.empty())
return;
listener_->Reset();
@@ -300,14 +300,12 @@ void VisitedLinkMaster::DeleteURLs(const history::URLRows& rows) {
if (table_builder_) {
// A rebuild is in progress, save this deletion in the temporary list so
// it can be added once rebuild is complete.
- for (history::URLRows::const_iterator i = rows.begin(); i != rows.end();
- ++i) {
- const GURL& url(i->url());
- if (!url.is_valid())
+ for (SetIterator i = urls.begin(); i != urls.end(); ++i) {
+ if (!i->is_valid())
continue;
Fingerprint fingerprint =
- ComputeURLFingerprint(url.spec().data(), url.spec().size(), salt_);
+ ComputeURLFingerprint(i->spec().data(), i->spec().size(), salt_);
deleted_since_rebuild_.insert(fingerprint);
// If the URL was just added and now we're deleting it, it may be in the
@@ -326,13 +324,11 @@ void VisitedLinkMaster::DeleteURLs(const history::URLRows& rows) {
// Compute the deleted URLs' fingerprints and delete them
std::set<Fingerprint> deleted_fingerprints;
- for (history::URLRows::const_iterator i = rows.begin(); i != rows.end();
- ++i) {
- const GURL& url(i->url());
- if (!url.is_valid())
+ for (SetIterator i = urls.begin(); i != urls.end(); ++i) {
+ if (!i->is_valid())
continue;
deleted_fingerprints.insert(
- ComputeURLFingerprint(url.spec().data(), url.spec().size(), salt_));
+ ComputeURLFingerprint(i->spec().data(), i->spec().size(), salt_));
}
DeleteFingerprintsFromCurrentTable(deleted_fingerprints);
}
diff --git a/chrome/browser/visitedlink/visitedlink_master.h b/chrome/browser/visitedlink/visitedlink_master.h
index 5e2afd7..1771afe 100644
--- a/chrome/browser/visitedlink/visitedlink_master.h
+++ b/chrome/browser/visitedlink/visitedlink_master.h
@@ -19,7 +19,6 @@
#include "base/shared_memory.h"
#include "base/threading/sequenced_worker_pool.h"
#include "chrome/browser/history/history.h"
-#include "chrome/browser/history/history_types.h"
#include "chrome/common/visitedlink_common.h"
class GURL;
@@ -90,8 +89,8 @@ class VisitedLinkMaster : public VisitedLinkCommon {
// Adds a set of URLs to the table.
void AddURLs(const std::vector<GURL>& url);
- // Deletes the specified URLs from |rows| from the table.
- void DeleteURLs(const history::URLRows& rows);
+ // Deletes the specified URLs from the table.
+ void DeleteURLs(const std::set<GURL>& urls);
// Clears the visited links table by deleting the file from disk. Used as
// part of history clearing.
diff --git a/chrome/browser/visitedlink/visitedlink_unittest.cc b/chrome/browser/visitedlink/visitedlink_unittest.cc
index b6ca5c0..54228bb 100644
--- a/chrome/browser/visitedlink/visitedlink_unittest.cc
+++ b/chrome/browser/visitedlink/visitedlink_unittest.cc
@@ -263,11 +263,11 @@ TEST_F(VisitedLinkTest, BigDelete) {
// Add more URLs than necessary to trigger this case.
const int kTestDeleteCount = VisitedLinkMaster::kBigDeleteThreshold + 2;
- history::URLRows urls_to_delete;
+ std::set<GURL> urls_to_delete;
for (int32 i = g_test_count; i < g_test_count + kTestDeleteCount; i++) {
GURL url(TestURL(i));
master_->AddURL(url);
- urls_to_delete.push_back(history::URLRow(url));
+ urls_to_delete.insert(url);
}
master_->DeleteURLs(urls_to_delete);
@@ -399,8 +399,8 @@ TEST_F(VisitedLinkTest, Rebuild) {
// Add one more and then delete it.
master_->AddURL(TestURL(g_test_count));
- history::URLRows deleted_urls;
- deleted_urls.push_back(history::URLRow(TestURL(g_test_count)));
+ std::set<GURL> deleted_urls;
+ deleted_urls.insert(TestURL(g_test_count));
master_->DeleteURLs(deleted_urls);
// Wait for the rebuild to complete. The task will terminate the message
@@ -447,8 +447,8 @@ TEST_F(VisitedLinkTest, Listener) {
ASSERT_EQ(i + 1, master_->GetUsedCount());
}
- history::URLRows deleted_urls;
- deleted_urls.push_back(history::URLRow(TestURL(0)));
+ std::set<GURL> deleted_urls;
+ deleted_urls.insert(TestURL(0));
// Delete an URL.
master_->DeleteURLs(deleted_urls);
// ... and all of the remaining ones.