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" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 std::map<URLID, URLRow> affected_urls; | 146 std::map<URLID, URLRow> affected_urls; |
147 | 147 |
148 // ----- Filled by DeleteOneURL ----- | 148 // ----- Filled by DeleteOneURL ----- |
149 | 149 |
150 // The URLs deleted during this operation. | 150 // The URLs deleted during this operation. |
151 std::vector<URLRow> deleted_urls; | 151 std::vector<URLRow> deleted_urls; |
152 | 152 |
153 // The list of all favicon IDs that the affected URLs had. Favicons will be | 153 // The list of all favicon IDs that the affected URLs had. Favicons will be |
154 // shared between all URLs with the same favicon, so this is the set of IDs | 154 // shared between all URLs with the same favicon, so this is the set of IDs |
155 // that we will need to check when the delete operations are complete. | 155 // that we will need to check when the delete operations are complete. |
156 std::set<FavIconID> affected_favicons; | 156 std::set<FaviconID> affected_favicons; |
157 | 157 |
158 // Tracks the set of databases that have changed so we can optimize when | 158 // Tracks the set of databases that have changed so we can optimize when |
159 // when we're done. | 159 // when we're done. |
160 TextDatabaseManager::ChangeSet text_db_changes; | 160 TextDatabaseManager::ChangeSet text_db_changes; |
161 }; | 161 }; |
162 | 162 |
163 ExpireHistoryBackend::ExpireHistoryBackend( | 163 ExpireHistoryBackend::ExpireHistoryBackend( |
164 BroadcastNotificationDelegate* delegate, | 164 BroadcastNotificationDelegate* delegate, |
165 BookmarkService* bookmark_service) | 165 BookmarkService* bookmark_service) |
166 : delegate_(delegate), | 166 : delegate_(delegate), |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 readers_.push_back(GetAllVisitsReader()); | 309 readers_.push_back(GetAllVisitsReader()); |
310 readers_.push_back(GetAutoSubframeVisitsReader()); | 310 readers_.push_back(GetAutoSubframeVisitsReader()); |
311 | 311 |
312 // Initialize the queue with all tasks for the first set of iterations. | 312 // Initialize the queue with all tasks for the first set of iterations. |
313 InitWorkQueue(); | 313 InitWorkQueue(); |
314 ScheduleArchive(); | 314 ScheduleArchive(); |
315 ScheduleExpireHistoryIndexFiles(); | 315 ScheduleExpireHistoryIndexFiles(); |
316 } | 316 } |
317 | 317 |
318 void ExpireHistoryBackend::DeleteFaviconsIfPossible( | 318 void ExpireHistoryBackend::DeleteFaviconsIfPossible( |
319 const std::set<FavIconID>& favicon_set) { | 319 const std::set<FaviconID>& favicon_set) { |
320 if (!thumb_db_) | 320 if (!thumb_db_) |
321 return; | 321 return; |
322 | 322 |
323 for (std::set<FavIconID>::const_iterator i = favicon_set.begin(); | 323 for (std::set<FaviconID>::const_iterator i = favicon_set.begin(); |
324 i != favicon_set.end(); ++i) { | 324 i != favicon_set.end(); ++i) { |
325 if (!thumb_db_->HasMappingFor(*i)) | 325 if (!thumb_db_->HasMappingFor(*i)) |
326 thumb_db_->DeleteFavIcon(*i); | 326 thumb_db_->DeleteFavIcon(*i); |
327 } | 327 } |
328 } | 328 } |
329 | 329 |
330 void ExpireHistoryBackend::BroadcastDeleteNotifications( | 330 void ExpireHistoryBackend::BroadcastDeleteNotifications( |
331 DeleteDependencies* dependencies) { | 331 DeleteDependencies* dependencies) { |
332 if (!dependencies->deleted_urls.empty()) { | 332 if (!dependencies->deleted_urls.empty()) { |
333 // Broadcast the URL deleted notification. Note that we also broadcast when | 333 // Broadcast the URL deleted notification. Note that we also broadcast when |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 | 637 |
638 // This will remove or archive all the affected URLs. Must do the deleting | 638 // This will remove or archive all the affected URLs. Must do the deleting |
639 // cleanup before archiving so the delete dependencies structure references | 639 // cleanup before archiving so the delete dependencies structure references |
640 // only those URLs that were actually deleted instead of having some visits | 640 // only those URLs that were actually deleted instead of having some visits |
641 // archived and then the rest deleted. | 641 // archived and then the rest deleted. |
642 ExpireURLsForVisits(deleted_visits, &deleted_dependencies); | 642 ExpireURLsForVisits(deleted_visits, &deleted_dependencies); |
643 ExpireURLsForVisits(archived_visits, &archived_dependencies); | 643 ExpireURLsForVisits(archived_visits, &archived_dependencies); |
644 | 644 |
645 // Create a union of all affected favicons (we don't store favicons for | 645 // Create a union of all affected favicons (we don't store favicons for |
646 // archived URLs) and delete them. | 646 // archived URLs) and delete them. |
647 std::set<FavIconID> affected_favicons( | 647 std::set<FaviconID> affected_favicons( |
648 archived_dependencies.affected_favicons); | 648 archived_dependencies.affected_favicons); |
649 for (std::set<FavIconID>::const_iterator i = | 649 for (std::set<FaviconID>::const_iterator i = |
650 deleted_dependencies.affected_favicons.begin(); | 650 deleted_dependencies.affected_favicons.begin(); |
651 i != deleted_dependencies.affected_favicons.end(); ++i) { | 651 i != deleted_dependencies.affected_favicons.end(); ++i) { |
652 affected_favicons.insert(*i); | 652 affected_favicons.insert(*i); |
653 } | 653 } |
654 DeleteFaviconsIfPossible(affected_favicons); | 654 DeleteFaviconsIfPossible(affected_favicons); |
655 | 655 |
656 // Send notifications for the stuff that was deleted. These won't normally be | 656 // Send notifications for the stuff that was deleted. These won't normally be |
657 // in history views since they were subframes, but they will be in the visited | 657 // in history views since they were subframes, but they will be in the visited |
658 // link system, which needs to be updated now. This function is smart enough | 658 // link system, which needs to be updated now. This function is smart enough |
659 // to not do anything if nothing was deleted. | 659 // to not do anything if nothing was deleted. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 // We use the bookmark service to determine if a URL is bookmarked. The | 705 // We use the bookmark service to determine if a URL is bookmarked. The |
706 // bookmark service is loaded on a separate thread and may not be done by the | 706 // bookmark service is loaded on a separate thread and may not be done by the |
707 // time we get here. We therefor block until the bookmarks have finished | 707 // time we get here. We therefor block until the bookmarks have finished |
708 // loading. | 708 // loading. |
709 if (bookmark_service_) | 709 if (bookmark_service_) |
710 bookmark_service_->BlockTillLoaded(); | 710 bookmark_service_->BlockTillLoaded(); |
711 return bookmark_service_; | 711 return bookmark_service_; |
712 } | 712 } |
713 | 713 |
714 } // namespace history | 714 } // namespace history |
OLD | NEW |