| 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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 if (!profile_) | 449 if (!profile_) |
| 450 return 0; | 450 return 0; |
| 451 | 451 |
| 452 HistoryService* hs = HistoryServiceFactory::GetForProfile( | 452 HistoryService* hs = HistoryServiceFactory::GetForProfile( |
| 453 profile_, Profile::EXPLICIT_ACCESS); | 453 profile_, Profile::EXPLICIT_ACCESS); |
| 454 // |hs| may be null during unit tests. | 454 // |hs| may be null during unit tests. |
| 455 if (hs) { | 455 if (hs) { |
| 456 return hs->QueryMostVisitedURLs( | 456 return hs->QueryMostVisitedURLs( |
| 457 num_results_to_request_from_history(), | 457 num_results_to_request_from_history(), |
| 458 kDaysOfHistory, | 458 kDaysOfHistory, |
| 459 &history_consumer_, | |
| 460 base::Bind(&TopSitesImpl::OnTopSitesAvailableFromHistory, | 459 base::Bind(&TopSitesImpl::OnTopSitesAvailableFromHistory, |
| 461 base::Unretained(this))); | 460 base::Unretained(this)), |
| 461 &cancelable_task_tracker_); |
| 462 } | 462 } |
| 463 return 0; | 463 return 0; |
| 464 } | 464 } |
| 465 | 465 |
| 466 bool TopSitesImpl::IsKnownURL(const GURL& url) { | 466 bool TopSitesImpl::IsKnownURL(const GURL& url) { |
| 467 return loaded_ && cache_->IsKnownURL(url); | 467 return loaded_ && cache_->IsKnownURL(url); |
| 468 } | 468 } |
| 469 | 469 |
| 470 const std::string& TopSitesImpl::GetCanonicalURLString(const GURL& url) const { | 470 const std::string& TopSitesImpl::GetCanonicalURLString(const GURL& url) const { |
| 471 return cache_->GetCanonicalURL(url).spec(); | 471 return cache_->GetCanonicalURL(url).spec(); |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 ResetThreadSafeImageCache(); | 923 ResetThreadSafeImageCache(); |
| 924 | 924 |
| 925 MoveStateToLoaded(); | 925 MoveStateToLoaded(); |
| 926 | 926 |
| 927 // Start a timer that refreshes top sites from history. | 927 // Start a timer that refreshes top sites from history. |
| 928 RestartQueryForTopSitesTimer( | 928 RestartQueryForTopSitesTimer( |
| 929 base::TimeDelta::FromSeconds(kUpdateIntervalSecs)); | 929 base::TimeDelta::FromSeconds(kUpdateIntervalSecs)); |
| 930 } | 930 } |
| 931 | 931 |
| 932 void TopSitesImpl::OnTopSitesAvailableFromHistory( | 932 void TopSitesImpl::OnTopSitesAvailableFromHistory( |
| 933 CancelableRequestProvider::Handle handle, | 933 const MostVisitedURLList* pages) { |
| 934 MostVisitedURLList pages) { | 934 DCHECK(pages); |
| 935 SetTopSites(pages); | 935 SetTopSites(*pages); |
| 936 } | 936 } |
| 937 | 937 |
| 938 } // namespace history | 938 } // namespace history |
| OLD | NEW |