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

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

Issue 226543008: Ensures TopSitesImpl::MergeCachedForcedURLs doesn't keep forced URLs if they are part of the redire… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/history/top_sites_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/history/top_sites_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698