| 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/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "chrome/browser/bookmarks/bookmark_service.h" | 13 #include "chrome/browser/bookmarks/bookmark_service.h" |
| 14 #include "chrome/browser/history/archived_database.h" | 14 #include "chrome/browser/history/archived_database.h" |
| 15 #include "chrome/browser/history/history_database.h" | 15 #include "chrome/browser/history/history_database.h" |
| 16 #include "chrome/browser/history/history_notifications.h" | 16 #include "chrome/browser/history/history_notifications.h" |
| 17 #include "chrome/browser/history/text_database.h" | 17 #include "chrome/browser/history/text_database.h" |
| 18 #include "chrome/browser/history/text_database_manager.h" | 18 #include "chrome/browser/history/text_database_manager.h" |
| 19 #include "chrome/browser/history/thumbnail_database.h" | 19 #include "chrome/browser/history/thumbnail_database.h" |
| 20 #include "content/common/notification_type.h" | 20 #include "chrome/common/chrome_notification_types.h" |
| 21 | 21 |
| 22 using base::Time; | 22 using base::Time; |
| 23 using base::TimeDelta; | 23 using base::TimeDelta; |
| 24 | 24 |
| 25 namespace history { | 25 namespace history { |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 // The number of days by which the expiration threshold is advanced for items | 29 // The number of days by which the expiration threshold is advanced for items |
| 30 // that we want to expire early, such as those of AUTO_SUBFRAME transition type. | 30 // that we want to expire early, such as those of AUTO_SUBFRAME transition type. |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 // some components care to know when history is deleted (it's up to them to | 339 // some components care to know when history is deleted (it's up to them to |
| 340 // determine if they care whether anything was deleted). | 340 // determine if they care whether anything was deleted). |
| 341 URLsDeletedDetails* deleted_details = new URLsDeletedDetails; | 341 URLsDeletedDetails* deleted_details = new URLsDeletedDetails; |
| 342 deleted_details->all_history = false; | 342 deleted_details->all_history = false; |
| 343 std::vector<URLRow> typed_urls_changed; // Collect this for later. | 343 std::vector<URLRow> typed_urls_changed; // Collect this for later. |
| 344 for (size_t i = 0; i < dependencies->deleted_urls.size(); i++) { | 344 for (size_t i = 0; i < dependencies->deleted_urls.size(); i++) { |
| 345 deleted_details->urls.insert(dependencies->deleted_urls[i].url()); | 345 deleted_details->urls.insert(dependencies->deleted_urls[i].url()); |
| 346 if (dependencies->deleted_urls[i].typed_count() > 0) | 346 if (dependencies->deleted_urls[i].typed_count() > 0) |
| 347 typed_urls_changed.push_back(dependencies->deleted_urls[i]); | 347 typed_urls_changed.push_back(dependencies->deleted_urls[i]); |
| 348 } | 348 } |
| 349 delegate_->BroadcastNotifications(NotificationType::HISTORY_URLS_DELETED, | 349 delegate_->BroadcastNotifications( |
| 350 deleted_details); | 350 chrome::NOTIFICATION_HISTORY_URLS_DELETED, deleted_details); |
| 351 } | 351 } |
| 352 } | 352 } |
| 353 | 353 |
| 354 void ExpireHistoryBackend::DeleteVisitRelatedInfo( | 354 void ExpireHistoryBackend::DeleteVisitRelatedInfo( |
| 355 const VisitVector& visits, | 355 const VisitVector& visits, |
| 356 DeleteDependencies* dependencies) { | 356 DeleteDependencies* dependencies) { |
| 357 for (size_t i = 0; i < visits.size(); i++) { | 357 for (size_t i = 0; i < visits.size(); i++) { |
| 358 // Delete the visit itself. | 358 // Delete the visit itself. |
| 359 main_db_->DeleteVisit(visits[i]); | 359 main_db_->DeleteVisit(visits[i]); |
| 360 | 360 |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 // We use the bookmark service to determine if a URL is bookmarked. The | 696 // We use the bookmark service to determine if a URL is bookmarked. The |
| 697 // bookmark service is loaded on a separate thread and may not be done by the | 697 // bookmark service is loaded on a separate thread and may not be done by the |
| 698 // time we get here. We therefor block until the bookmarks have finished | 698 // time we get here. We therefor block until the bookmarks have finished |
| 699 // loading. | 699 // loading. |
| 700 if (bookmark_service_) | 700 if (bookmark_service_) |
| 701 bookmark_service_->BlockTillLoaded(); | 701 bookmark_service_->BlockTillLoaded(); |
| 702 return bookmark_service_; | 702 return bookmark_service_; |
| 703 } | 703 } |
| 704 | 704 |
| 705 } // namespace history | 705 } // namespace history |
| OLD | NEW |