Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: chrome/browser/history/expire_history_backend.cc

Issue 10380015: Now mark delete notifications for archived URLs specially (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review feedback. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 (bookmark_service && bookmark_service->IsBookmarked(*url)); 230 (bookmark_service && bookmark_service->IsBookmarked(*url));
231 231
232 DeleteOneURL(url_row, is_bookmarked, &dependencies); 232 DeleteOneURL(url_row, is_bookmarked, &dependencies);
233 } 233 }
234 234
235 DeleteFaviconsIfPossible(dependencies.affected_favicons); 235 DeleteFaviconsIfPossible(dependencies.affected_favicons);
236 236
237 if (text_db_) 237 if (text_db_)
238 text_db_->OptimizeChangedDatabases(dependencies.text_db_changes); 238 text_db_->OptimizeChangedDatabases(dependencies.text_db_changes);
239 239
240 BroadcastDeleteNotifications(&dependencies); 240 BroadcastDeleteNotifications(&dependencies, DELETION_USER_INITIATED);
241 } 241 }
242 242
243 void ExpireHistoryBackend::ExpireHistoryBetween( 243 void ExpireHistoryBackend::ExpireHistoryBetween(
244 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) {
245 if (!main_db_) 245 if (!main_db_)
246 return; 246 return;
247 247
248 // 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.
249 if (text_db_) 249 if (text_db_)
250 text_db_->DeleteFromUncommitted(restrict_urls, begin_time, end_time); 250 text_db_->DeleteFromUncommitted(restrict_urls, begin_time, end_time);
(...skipping 25 matching lines...) Expand all
276 DeleteDependencies dependencies; 276 DeleteDependencies dependencies;
277 DeleteVisitRelatedInfo(visits, &dependencies); 277 DeleteVisitRelatedInfo(visits, &dependencies);
278 278
279 // Delete or update the URLs affected. We want to update the visit counts 279 // Delete or update the URLs affected. We want to update the visit counts
280 // since this is called by the user who wants to delete their recent history, 280 // since this is called by the user who wants to delete their recent history,
281 // and we don't want to leave any evidence. 281 // and we don't want to leave any evidence.
282 ExpireURLsForVisits(visits, &dependencies); 282 ExpireURLsForVisits(visits, &dependencies);
283 DeleteFaviconsIfPossible(dependencies.affected_favicons); 283 DeleteFaviconsIfPossible(dependencies.affected_favicons);
284 284
285 // An is_null begin time means that all history should be deleted. 285 // An is_null begin time means that all history should be deleted.
286 BroadcastDeleteNotifications(&dependencies); 286 BroadcastDeleteNotifications(&dependencies, DELETION_USER_INITIATED);
287 287
288 // Pick up any bits possibly left over. 288 // Pick up any bits possibly left over.
289 ParanoidExpireHistory(); 289 ParanoidExpireHistory();
290 } 290 }
291 291
292 void ExpireHistoryBackend::ArchiveHistoryBefore(Time end_time) { 292 void ExpireHistoryBackend::ArchiveHistoryBefore(Time end_time) {
293 if (!main_db_) 293 if (!main_db_)
294 return; 294 return;
295 295
296 // Archive as much history as possible before the given date. 296 // Archive as much history as possible before the given date.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 return; 344 return;
345 345
346 for (std::set<FaviconID>::const_iterator i = favicon_set.begin(); 346 for (std::set<FaviconID>::const_iterator i = favicon_set.begin();
347 i != favicon_set.end(); ++i) { 347 i != favicon_set.end(); ++i) {
348 if (!thumb_db_->HasMappingFor(*i)) 348 if (!thumb_db_->HasMappingFor(*i))
349 thumb_db_->DeleteFavicon(*i); 349 thumb_db_->DeleteFavicon(*i);
350 } 350 }
351 } 351 }
352 352
353 void ExpireHistoryBackend::BroadcastDeleteNotifications( 353 void ExpireHistoryBackend::BroadcastDeleteNotifications(
354 DeleteDependencies* dependencies) { 354 DeleteDependencies* dependencies, DeletionType type) {
355 if (!dependencies->deleted_urls.empty()) { 355 if (!dependencies->deleted_urls.empty()) {
356 // Broadcast the URL deleted notification. Note that we also broadcast when 356 // Broadcast the URL deleted notification. Note that we also broadcast when
357 // we were requested to delete everything even if that was a NOP, since 357 // we were requested to delete everything even if that was a NOP, since
358 // some components care to know when history is deleted (it's up to them to 358 // some components care to know when history is deleted (it's up to them to
359 // determine if they care whether anything was deleted). 359 // determine if they care whether anything was deleted).
360 URLsDeletedDetails* deleted_details = new URLsDeletedDetails; 360 URLsDeletedDetails* deleted_details = new URLsDeletedDetails;
361 deleted_details->all_history = false; 361 deleted_details->all_history = false;
362 deleted_details->archived = (type == DELETION_ARCHIVED);
362 deleted_details->rows = dependencies->deleted_urls; 363 deleted_details->rows = dependencies->deleted_urls;
363 delegate_->BroadcastNotifications( 364 delegate_->BroadcastNotifications(
364 chrome::NOTIFICATION_HISTORY_URLS_DELETED, deleted_details); 365 chrome::NOTIFICATION_HISTORY_URLS_DELETED, deleted_details);
365 } 366 }
366 } 367 }
367 368
368 void ExpireHistoryBackend::DeleteVisitRelatedInfo( 369 void ExpireHistoryBackend::DeleteVisitRelatedInfo(
369 const VisitVector& visits, 370 const VisitVector& visits,
370 DeleteDependencies* dependencies) { 371 DeleteDependencies* dependencies) {
371 for (size_t i = 0; i < visits.size(); i++) { 372 for (size_t i = 0; i < visits.size(); i++) {
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 deleted_dependencies.affected_favicons.begin(); 659 deleted_dependencies.affected_favicons.begin();
659 i != deleted_dependencies.affected_favicons.end(); ++i) { 660 i != deleted_dependencies.affected_favicons.end(); ++i) {
660 affected_favicons.insert(*i); 661 affected_favicons.insert(*i);
661 } 662 }
662 DeleteFaviconsIfPossible(affected_favicons); 663 DeleteFaviconsIfPossible(affected_favicons);
663 664
664 // Send notifications for the stuff that was deleted. These won't normally be 665 // Send notifications for the stuff that was deleted. These won't normally be
665 // in history views since they were subframes, but they will be in the visited 666 // in history views since they were subframes, but they will be in the visited
666 // link system, which needs to be updated now. This function is smart enough 667 // link system, which needs to be updated now. This function is smart enough
667 // to not do anything if nothing was deleted. 668 // to not do anything if nothing was deleted.
668 BroadcastDeleteNotifications(&deleted_dependencies); 669 BroadcastDeleteNotifications(&deleted_dependencies, DELETION_ARCHIVED);
669 670
670 return more_to_expire; 671 return more_to_expire;
671 } 672 }
672 673
673 void ExpireHistoryBackend::ParanoidExpireHistory() { 674 void ExpireHistoryBackend::ParanoidExpireHistory() {
674 // TODO(brettw): Bug 1067331: write this to clean up any errors. 675 // TODO(brettw): Bug 1067331: write this to clean up any errors.
675 } 676 }
676 677
677 void ExpireHistoryBackend::ScheduleExpireHistoryIndexFiles() { 678 void ExpireHistoryBackend::ScheduleExpireHistoryIndexFiles() {
678 if (!text_db_) { 679 if (!text_db_) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 // 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
715 // 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
716 // 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
717 // loading. 718 // loading.
718 if (bookmark_service_) 719 if (bookmark_service_)
719 bookmark_service_->BlockTillLoaded(); 720 bookmark_service_->BlockTillLoaded();
720 return bookmark_service_; 721 return bookmark_service_;
721 } 722 }
722 723
723 } // namespace history 724 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/expire_history_backend.h ('k') | chrome/browser/history/expire_history_backend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698