Chromium Code Reviews| Index: chrome/browser/history/expire_history_backend.cc |
| diff --git a/chrome/browser/history/expire_history_backend.cc b/chrome/browser/history/expire_history_backend.cc |
| index 0f2ea68ed4d1451cd6064d557404d0a4b8eba3f6..5718c41c0ca29873405a6b39c7e851dd924dcd7c 100644 |
| --- a/chrome/browser/history/expire_history_backend.cc |
| +++ b/chrome/browser/history/expire_history_backend.cc |
| @@ -200,34 +200,21 @@ void ExpireHistoryBackend::DeleteURL(const GURL& url) { |
| if (!main_db_) |
|
sky
2011/12/14 23:16:49
Implement this in terms of DeleteURLs.
akalin
2011/12/14 23:43:08
Done.
|
| 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; |
| - 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. |
| + DeleteURLHelper(url, &dependencies); |
| - BookmarkService* bookmark_service = GetBookmarkService(); |
| - bool is_bookmarked = |
| - (bookmark_service && bookmark_service->IsBookmarked(url)); |
| + BroadcastDeleteNotifications(&dependencies); |
| +} |
| - DeleteOneURL(url_row, is_bookmarked, &dependencies); |
| - if (!is_bookmarked) |
| - DeleteFaviconsIfPossible(dependencies.affected_favicons); |
| +void ExpireHistoryBackend::DeleteURLs(const std::vector<GURL>& urls) { |
| + if (!main_db_) |
| + return; |
| - if (text_db_) |
| - text_db_->OptimizeChangedDatabases(dependencies.text_db_changes); |
| + DeleteDependencies dependencies; |
| + for (std::vector<GURL>::const_iterator url = urls.begin(); url != urls.end(); |
| + ++url) { |
| + DeleteURLHelper(*url, &dependencies); |
| + } |
| BroadcastDeleteNotifications(&dependencies); |
| } |
| @@ -358,6 +345,37 @@ void ExpireHistoryBackend::BroadcastDeleteNotifications( |
| } |
| } |
| +void ExpireHistoryBackend::DeleteURLHelper( |
| + const GURL& url, DeleteDependencies* dependencies) { |
| + 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); |
| + |
| + 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); |
| + if (!is_bookmarked) |
| + DeleteFaviconsIfPossible(dependencies->affected_favicons); |
| + |
| + if (text_db_) |
| + text_db_->OptimizeChangedDatabases(dependencies->text_db_changes); |
| +} |
| + |
| void ExpireHistoryBackend::DeleteVisitRelatedInfo( |
| const VisitVector& visits, |
| DeleteDependencies* dependencies) { |