OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/top_sites_impl.h" | 5 #include "chrome/browser/history/top_sites_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 return added; | 654 return added; |
655 } | 655 } |
656 | 656 |
657 size_t TopSitesImpl::MergeCachedForcedURLs(MostVisitedURLList* new_list) { | 657 size_t TopSitesImpl::MergeCachedForcedURLs(MostVisitedURLList* new_list) { |
658 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 658 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
659 // Add all the new URLs for quick lookup. Take that opportunity to count the | 659 // Add all the new URLs for quick lookup. Take that opportunity to count the |
660 // number of forced URLs in |new_list|. | 660 // number of forced URLs in |new_list|. |
661 std::set<GURL> all_new_urls; | 661 std::set<GURL> all_new_urls; |
662 size_t num_forced = 0; | 662 size_t num_forced = 0; |
663 for (size_t i = 0; i < new_list->size(); ++i) { | 663 for (size_t i = 0; i < new_list->size(); ++i) { |
664 all_new_urls.insert((*new_list)[i].url); | 664 for (size_t j = 0; j < (*new_list)[i].redirects.size(); j++) { |
| 665 all_new_urls.insert((*new_list)[i].redirects[j]); |
| 666 } |
665 if (!(*new_list)[i].last_forced_time.is_null()) | 667 if (!(*new_list)[i].last_forced_time.is_null()) |
666 ++num_forced; | 668 ++num_forced; |
667 } | 669 } |
668 | 670 |
669 // Keep the forced URLs from |cache_| that are not found in |new_list|. | 671 // Keep the forced URLs from |cache_| that are not found in |new_list|. |
670 MostVisitedURLList filtered_forced_urls; | 672 MostVisitedURLList filtered_forced_urls; |
671 for (size_t i = 0; i < cache_->GetNumForcedURLs(); ++i) { | 673 for (size_t i = 0; i < cache_->GetNumForcedURLs(); ++i) { |
672 if (all_new_urls.find(cache_->top_sites()[i].url) == all_new_urls.end()) | 674 if (all_new_urls.find(cache_->top_sites()[i].url) == all_new_urls.end()) |
673 filtered_forced_urls.push_back(cache_->top_sites()[i]); | 675 filtered_forced_urls.push_back(cache_->top_sites()[i]); |
674 } | 676 } |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 base::TimeDelta::FromSeconds(kUpdateIntervalSecs)); | 932 base::TimeDelta::FromSeconds(kUpdateIntervalSecs)); |
931 } | 933 } |
932 | 934 |
933 void TopSitesImpl::OnTopSitesAvailableFromHistory( | 935 void TopSitesImpl::OnTopSitesAvailableFromHistory( |
934 CancelableRequestProvider::Handle handle, | 936 CancelableRequestProvider::Handle handle, |
935 MostVisitedURLList pages) { | 937 MostVisitedURLList pages) { |
936 SetTopSites(pages); | 938 SetTopSites(pages); |
937 } | 939 } |
938 | 940 |
939 } // namespace history | 941 } // namespace history |
OLD | NEW |