| 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 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 filtered_urls_nonforced.assign(thread_safe_cache_->top_sites().begin() + | 867 filtered_urls_nonforced.assign(thread_safe_cache_->top_sites().begin() + |
| 868 thread_safe_cache_->GetNumForcedURLs(), | 868 thread_safe_cache_->GetNumForcedURLs(), |
| 869 thread_safe_cache_->top_sites().end()); | 869 thread_safe_cache_->top_sites().end()); |
| 870 pending_callbacks.swap(pending_callbacks_); | 870 pending_callbacks.swap(pending_callbacks_); |
| 871 } | 871 } |
| 872 } | 872 } |
| 873 | 873 |
| 874 for (size_t i = 0; i < pending_callbacks.size(); i++) | 874 for (size_t i = 0; i < pending_callbacks.size(); i++) |
| 875 pending_callbacks[i].Run(filtered_urls_all, filtered_urls_nonforced); | 875 pending_callbacks[i].Run(filtered_urls_all, filtered_urls_nonforced); |
| 876 | 876 |
| 877 content::NotificationService::current()->Notify( | 877 NotifyTopSitesLoaded(); |
| 878 chrome::NOTIFICATION_TOP_SITES_LOADED, | |
| 879 content::Source<Profile>(profile_), | |
| 880 content::Details<TopSites>(this)); | |
| 881 } | 878 } |
| 882 | 879 |
| 883 void TopSitesImpl::ResetThreadSafeCache() { | 880 void TopSitesImpl::ResetThreadSafeCache() { |
| 884 base::AutoLock lock(lock_); | 881 base::AutoLock lock(lock_); |
| 885 MostVisitedURLList cached; | 882 MostVisitedURLList cached; |
| 886 ApplyBlacklist(cache_->top_sites(), &cached); | 883 ApplyBlacklist(cache_->top_sites(), &cached); |
| 887 thread_safe_cache_->SetTopSites(cached); | 884 thread_safe_cache_->SetTopSites(cached); |
| 888 } | 885 } |
| 889 | 886 |
| 890 void TopSitesImpl::ResetThreadSafeImageCache() { | 887 void TopSitesImpl::ResetThreadSafeImageCache() { |
| 891 base::AutoLock lock(lock_); | 888 base::AutoLock lock(lock_); |
| 892 thread_safe_cache_->SetThumbnails(cache_->images()); | 889 thread_safe_cache_->SetThumbnails(cache_->images()); |
| 893 } | 890 } |
| 894 | 891 |
| 895 void TopSitesImpl::NotifyTopSitesChanged() { | |
| 896 content::NotificationService::current()->Notify( | |
| 897 chrome::NOTIFICATION_TOP_SITES_CHANGED, | |
| 898 content::Source<TopSites>(this), | |
| 899 content::NotificationService::NoDetails()); | |
| 900 } | |
| 901 | |
| 902 void TopSitesImpl::RestartQueryForTopSitesTimer(base::TimeDelta delta) { | 892 void TopSitesImpl::RestartQueryForTopSitesTimer(base::TimeDelta delta) { |
| 903 if (timer_.IsRunning() && ((timer_start_time_ + timer_.GetCurrentDelay()) < | 893 if (timer_.IsRunning() && ((timer_start_time_ + timer_.GetCurrentDelay()) < |
| 904 (base::TimeTicks::Now() + delta))) { | 894 (base::TimeTicks::Now() + delta))) { |
| 905 return; | 895 return; |
| 906 } | 896 } |
| 907 | 897 |
| 908 timer_start_time_ = base::TimeTicks::Now(); | 898 timer_start_time_ = base::TimeTicks::Now(); |
| 909 timer_.Stop(); | 899 timer_.Stop(); |
| 910 timer_.Start(FROM_HERE, delta, this, &TopSitesImpl::TimerFired); | 900 timer_.Start(FROM_HERE, delta, this, &TopSitesImpl::TimerFired); |
| 911 } | 901 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 929 base::TimeDelta::FromSeconds(kUpdateIntervalSecs)); | 919 base::TimeDelta::FromSeconds(kUpdateIntervalSecs)); |
| 930 } | 920 } |
| 931 | 921 |
| 932 void TopSitesImpl::OnTopSitesAvailableFromHistory( | 922 void TopSitesImpl::OnTopSitesAvailableFromHistory( |
| 933 const MostVisitedURLList* pages) { | 923 const MostVisitedURLList* pages) { |
| 934 DCHECK(pages); | 924 DCHECK(pages); |
| 935 SetTopSites(*pages); | 925 SetTopSites(*pages); |
| 936 } | 926 } |
| 937 | 927 |
| 938 } // namespace history | 928 } // namespace history |
| OLD | NEW |