Commit eb03f07c authored by akalin@chromium.org's avatar akalin@chromium.org

Add ExpireHistoryBackend::DeleteURLs method

This is primarily used by the sync typed URL performance tests.  This
method helps stabilize the perf numbers since there's only a single
notification that is emitted (instead of one per URL).

BUG=107040
TEST=


Review URL: http://codereview.chromium.org/8910024

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114572 0039d316-1c4b-4281-b951-d872f2087c98
parent ee1e1a24
...@@ -197,37 +197,45 @@ void ExpireHistoryBackend::SetDatabases(HistoryDatabase* main_db, ...@@ -197,37 +197,45 @@ void ExpireHistoryBackend::SetDatabases(HistoryDatabase* main_db,
} }
void ExpireHistoryBackend::DeleteURL(const GURL& url) { void ExpireHistoryBackend::DeleteURL(const GURL& url) {
DeleteURLs(std::vector<GURL>(1, url));
}
void ExpireHistoryBackend::DeleteURLs(const std::vector<GURL>& urls) {
if (!main_db_) if (!main_db_)
return; return;
URLRow url_row;
if (!main_db_->GetRowForURL(url, &url_row))
return; // Nothing to delete.
// Collect all the visits and delete them. Note that we don't give up if
// there are no visits, since the URL could still have an entry that we should
// delete.
// TODO(brettw): bug 1171148: We should also delete from the archived DB.
VisitVector visits;
main_db_->GetVisitsForURL(url_row.id(), &visits);
DeleteDependencies dependencies; DeleteDependencies dependencies;
DeleteVisitRelatedInfo(visits, &dependencies); for (std::vector<GURL>::const_iterator url = urls.begin(); url != urls.end();
++url) {
// We skip ExpireURLsForVisits (since we are deleting from the URL, and not URLRow url_row;
// starting with visits in a given time range). We therefore need to call the if (!main_db_->GetRowForURL(*url, &url_row))
// deletion and favicon update functions manually. return; // Nothing to delete.
BookmarkService* bookmark_service = GetBookmarkService(); // Collect all the visits and delete them. Note that we don't give
bool is_bookmarked = // up if there are no visits, since the URL could still have an
(bookmark_service && bookmark_service->IsBookmarked(url)); // entry that we should delete. TODO(brettw): bug 1171148: We
// should also delete from the archived DB.
VisitVector visits;
main_db_->GetVisitsForURL(url_row.id(), &visits);
DeleteVisitRelatedInfo(visits, &dependencies);
// We skip ExpireURLsForVisits (since we are deleting from the
// URL, and not starting with visits in a given time range). We
// therefore need to call the deletion and favicon update
// functions manually.
BookmarkService* bookmark_service = GetBookmarkService();
bool is_bookmarked =
(bookmark_service && bookmark_service->IsBookmarked(*url));
DeleteOneURL(url_row, is_bookmarked, &dependencies); DeleteOneURL(url_row, is_bookmarked, &dependencies);
if (!is_bookmarked) if (!is_bookmarked)
DeleteFaviconsIfPossible(dependencies.affected_favicons); DeleteFaviconsIfPossible(dependencies.affected_favicons);
if (text_db_) if (text_db_)
text_db_->OptimizeChangedDatabases(dependencies.text_db_changes); text_db_->OptimizeChangedDatabases(dependencies.text_db_changes);
}
BroadcastDeleteNotifications(&dependencies); BroadcastDeleteNotifications(&dependencies);
} }
......
...@@ -83,6 +83,9 @@ class ExpireHistoryBackend { ...@@ -83,6 +83,9 @@ class ExpireHistoryBackend {
// Deletes everything associated with a URL. // Deletes everything associated with a URL.
void DeleteURL(const GURL& url); void DeleteURL(const GURL& url);
// Deletes everything associated with each URL in the list.
void DeleteURLs(const std::vector<GURL>& url);
// Removes all visits to restrict_urls (or all URLs if empty) in the given // Removes all visits to restrict_urls (or all URLs if empty) in the given
// time range, updating the URLs accordingly, // time range, updating the URLs accordingly,
void ExpireHistoryBetween(const std::set<GURL>& restrict_urls, void ExpireHistoryBetween(const std::set<GURL>& restrict_urls,
...@@ -106,7 +109,6 @@ class ExpireHistoryBackend { ...@@ -106,7 +109,6 @@ class ExpireHistoryBackend {
} }
private: private:
FRIEND_TEST_ALL_PREFIXES(ExpireHistoryTest, DeleteTextIndexForURL);
FRIEND_TEST_ALL_PREFIXES(ExpireHistoryTest, DeleteFaviconsIfPossible); FRIEND_TEST_ALL_PREFIXES(ExpireHistoryTest, DeleteFaviconsIfPossible);
FRIEND_TEST_ALL_PREFIXES(ExpireHistoryTest, ArchiveSomeOldHistory); FRIEND_TEST_ALL_PREFIXES(ExpireHistoryTest, ArchiveSomeOldHistory);
FRIEND_TEST_ALL_PREFIXES(ExpireHistoryTest, ExpiringVisitsReader); FRIEND_TEST_ALL_PREFIXES(ExpireHistoryTest, ExpiringVisitsReader);
...@@ -115,17 +117,6 @@ class ExpireHistoryBackend { ...@@ -115,17 +117,6 @@ class ExpireHistoryBackend {
struct DeleteDependencies; struct DeleteDependencies;
// Removes the data from the full text index associated with the given URL
// string/ID pair. If |update_visits| is set, the visits that reference the
// indexed data will be updated to reflect the fact that the indexed data is
// gone. Setting this to false is a performance optimization when the caller
// knows that the visits will be deleted after the call.
//
// TODO(brettw) when we have an "archived" history database, this should take
// a flag to optionally delete from there. This way it can be used for page
// re-indexing as well as for full URL deletion.
void DeleteTextIndexForURL(const GURL& url, URLID url_id, bool update_visits);
// Deletes the visit-related stuff for all the visits in the given list, and // Deletes the visit-related stuff for all the visits in the given list, and
// adds the rows for unique URLs affected to the affected_urls list in // adds the rows for unique URLs affected to the affected_urls list in
// the dependencies structure. // the dependencies structure.
......
...@@ -1994,10 +1994,7 @@ void HistoryBackend::ReleaseDBTasks() { ...@@ -1994,10 +1994,7 @@ void HistoryBackend::ReleaseDBTasks() {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void HistoryBackend::DeleteURLs(const std::vector<GURL>& urls) { void HistoryBackend::DeleteURLs(const std::vector<GURL>& urls) {
for (std::vector<GURL>::const_iterator url = urls.begin(); url != urls.end(); expirer_.DeleteURLs(urls);
++url) {
expirer_.DeleteURL(*url);
}
db_->GetStartDate(&first_recorded_time_); db_->GetStartDate(&first_recorded_time_);
// Force a commit, if the user is deleting something for privacy reasons, we // Force a commit, if the user is deleting something for privacy reasons, we
......
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