OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/history/expire_history_backend.h" | 5 #include "chrome/browser/history/expire_history_backend.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 ArchivedDatabase* archived_db, | 190 ArchivedDatabase* archived_db, |
191 ThumbnailDatabase* thumb_db, | 191 ThumbnailDatabase* thumb_db, |
192 TextDatabaseManager* text_db) { | 192 TextDatabaseManager* text_db) { |
193 main_db_ = main_db; | 193 main_db_ = main_db; |
194 archived_db_ = archived_db; | 194 archived_db_ = archived_db; |
195 thumb_db_ = thumb_db; | 195 thumb_db_ = thumb_db; |
196 text_db_ = text_db; | 196 text_db_ = text_db; |
197 } | 197 } |
198 | 198 |
199 void ExpireHistoryBackend::DeleteURL(const GURL& url) { | 199 void ExpireHistoryBackend::DeleteURL(const GURL& url) { |
200 DeleteURLs(std::vector<GURL>(1, url)); | |
201 } | |
202 | |
203 void ExpireHistoryBackend::DeleteURLs(const std::vector<GURL>& urls) { | |
200 if (!main_db_) | 204 if (!main_db_) |
201 return; | 205 return; |
202 | 206 |
203 URLRow url_row; | 207 DeleteDependencies dependencies; |
204 if (!main_db_->GetRowForURL(url, &url_row)) | 208 for (std::vector<GURL>::const_iterator url = urls.begin(); url != urls.end(); |
205 return; // Nothing to delete. | 209 ++url) { |
210 URLRow url_row; | |
211 if (!main_db_->GetRowForURL(*url, &url_row)) | |
212 return; // Nothing to delete. | |
sky
2011/12/16 22:00:11
This should be continue now.
| |
206 | 213 |
207 // Collect all the visits and delete them. Note that we don't give up if | 214 // Collect all the visits and delete them. Note that we don't give |
208 // there are no visits, since the URL could still have an entry that we should | 215 // up if there are no visits, since the URL could still have an |
209 // delete. | 216 // entry that we should delete. TODO(brettw): bug 1171148: We |
210 // TODO(brettw): bug 1171148: We should also delete from the archived DB. | 217 // should also delete from the archived DB. |
211 VisitVector visits; | 218 VisitVector visits; |
212 main_db_->GetVisitsForURL(url_row.id(), &visits); | 219 main_db_->GetVisitsForURL(url_row.id(), &visits); |
213 | 220 |
214 DeleteDependencies dependencies; | 221 DeleteVisitRelatedInfo(visits, &dependencies); |
215 DeleteVisitRelatedInfo(visits, &dependencies); | |
216 | 222 |
217 // We skip ExpireURLsForVisits (since we are deleting from the URL, and not | 223 // We skip ExpireURLsForVisits (since we are deleting from the |
218 // starting with visits in a given time range). We therefore need to call the | 224 // URL, and not starting with visits in a given time range). We |
219 // deletion and favicon update functions manually. | 225 // therefore need to call the deletion and favicon update |
226 // functions manually. | |
220 | 227 |
221 BookmarkService* bookmark_service = GetBookmarkService(); | 228 BookmarkService* bookmark_service = GetBookmarkService(); |
222 bool is_bookmarked = | 229 bool is_bookmarked = |
223 (bookmark_service && bookmark_service->IsBookmarked(url)); | 230 (bookmark_service && bookmark_service->IsBookmarked(*url)); |
224 | 231 |
225 DeleteOneURL(url_row, is_bookmarked, &dependencies); | 232 DeleteOneURL(url_row, is_bookmarked, &dependencies); |
226 if (!is_bookmarked) | 233 if (!is_bookmarked) |
227 DeleteFaviconsIfPossible(dependencies.affected_favicons); | 234 DeleteFaviconsIfPossible(dependencies.affected_favicons); |
sky
2011/12/16 22:00:11
This is wrong now. In particular if the previous u
| |
228 | 235 |
229 if (text_db_) | 236 if (text_db_) |
sky
2011/12/16 22:00:11
This should be outside the loop.
| |
230 text_db_->OptimizeChangedDatabases(dependencies.text_db_changes); | 237 text_db_->OptimizeChangedDatabases(dependencies.text_db_changes); |
238 } | |
231 | 239 |
232 BroadcastDeleteNotifications(&dependencies); | 240 BroadcastDeleteNotifications(&dependencies); |
233 } | 241 } |
234 | 242 |
235 void ExpireHistoryBackend::ExpireHistoryBetween( | 243 void ExpireHistoryBackend::ExpireHistoryBetween( |
236 const std::set<GURL>& restrict_urls, Time begin_time, Time end_time) { | 244 const std::set<GURL>& restrict_urls, Time begin_time, Time end_time) { |
237 if (!main_db_) | 245 if (!main_db_) |
238 return; | 246 return; |
239 | 247 |
240 // There may be stuff in the text database manager's temporary cache. | 248 // There may be stuff in the text database manager's temporary cache. |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
707 // We use the bookmark service to determine if a URL is bookmarked. The | 715 // We use the bookmark service to determine if a URL is bookmarked. The |
708 // bookmark service is loaded on a separate thread and may not be done by the | 716 // bookmark service is loaded on a separate thread and may not be done by the |
709 // time we get here. We therefor block until the bookmarks have finished | 717 // time we get here. We therefor block until the bookmarks have finished |
710 // loading. | 718 // loading. |
711 if (bookmark_service_) | 719 if (bookmark_service_) |
712 bookmark_service_->BlockTillLoaded(); | 720 bookmark_service_->BlockTillLoaded(); |
713 return bookmark_service_; | 721 return bookmark_service_; |
714 } | 722 } |
715 | 723 |
716 } // namespace history | 724 } // namespace history |
OLD | NEW |