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

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

Issue 815983002: Topsites become keyedService based. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: For trybot Created 5 years, 11 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
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 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 // since this is almost always where it needs to go, unless the user's local 630 // since this is almost always where it needs to go, unless the user's local
631 // clock is fiddled with. 631 // clock is fiddled with.
632 MostVisitedURLList::iterator mid = new_list.begin() + num_forced; 632 MostVisitedURLList::iterator mid = new_list.begin() + num_forced;
633 new_list.insert(mid, new_url); 633 new_list.insert(mid, new_url);
634 mid = new_list.begin() + num_forced; // Mid was invalidated. 634 mid = new_list.begin() + num_forced; // Mid was invalidated.
635 std::inplace_merge(new_list.begin(), mid, mid + 1, ForcedURLComparator); 635 std::inplace_merge(new_list.begin(), mid, mid + 1, ForcedURLComparator);
636 SetTopSites(new_list); 636 SetTopSites(new_list);
637 return true; 637 return true;
638 } 638 }
639 639
640 void TopSitesImpl::ShutdownOnUIThread() {
641 registrar_.RemoveAll();
642 }
643
640 bool TopSitesImpl::AddPrepopulatedPages(MostVisitedURLList* urls, 644 bool TopSitesImpl::AddPrepopulatedPages(MostVisitedURLList* urls,
641 size_t num_forced_urls) { 645 size_t num_forced_urls) {
642 bool added = false; 646 bool added = false;
643 MostVisitedURLList prepopulate_urls = GetPrepopulatePages(); 647 MostVisitedURLList prepopulate_urls = GetPrepopulatePages();
644 for (size_t i = 0; i < prepopulate_urls.size(); ++i) { 648 for (size_t i = 0; i < prepopulate_urls.size(); ++i) {
645 if (urls->size() - num_forced_urls < kNonForcedTopSitesNumber && 649 if (urls->size() - num_forced_urls < kNonForcedTopSitesNumber &&
646 IndexOf(*urls, prepopulate_urls[i].url) == -1) { 650 IndexOf(*urls, prepopulate_urls[i].url) == -1) {
647 urls->push_back(prepopulate_urls[i]); 651 urls->push_back(prepopulate_urls[i]);
648 added = true; 652 added = true;
649 } 653 }
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 base::TimeDelta::FromSeconds(kUpdateIntervalSecs)); 923 base::TimeDelta::FromSeconds(kUpdateIntervalSecs));
920 } 924 }
921 925
922 void TopSitesImpl::OnTopSitesAvailableFromHistory( 926 void TopSitesImpl::OnTopSitesAvailableFromHistory(
923 const MostVisitedURLList* pages) { 927 const MostVisitedURLList* pages) {
924 DCHECK(pages); 928 DCHECK(pages);
925 SetTopSites(*pages); 929 SetTopSites(*pages);
926 } 930 }
927 931
928 } // namespace history 932 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698