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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
371 } | 371 } |
372 ResetThreadSafeCache(); | 372 ResetThreadSafeCache(); |
373 NotifyTopSitesChanged(); | 373 NotifyTopSitesChanged(); |
374 } | 374 } |
375 | 375 |
376 void TopSitesImpl::Shutdown() { | 376 void TopSitesImpl::Shutdown() { |
377 profile_ = NULL; | 377 profile_ = NULL; |
378 // Cancel all requests so that the service doesn't callback to us after we've | 378 // Cancel all requests so that the service doesn't callback to us after we've |
379 // invoked Shutdown (this could happen if we have a pending request and | 379 // invoked Shutdown (this could happen if we have a pending request and |
380 // Shutdown is invoked). | 380 // Shutdown is invoked). |
381 history_consumer_.CancelAllRequests(); | 381 cancelable_task_tracker_.TryCancelAll(); |
blundell
2014/07/22 15:19:57
This is a behavioral change, as the two trackers h
| |
382 backend_->Shutdown(); | 382 backend_->Shutdown(); |
383 } | 383 } |
384 | 384 |
385 // static | 385 // static |
386 void TopSitesImpl::DiffMostVisited(const MostVisitedURLList& old_list, | 386 void TopSitesImpl::DiffMostVisited(const MostVisitedURLList& old_list, |
387 const MostVisitedURLList& new_list, | 387 const MostVisitedURLList& new_list, |
388 TopSitesDelta* delta) { | 388 TopSitesDelta* delta) { |
389 | 389 |
390 // Add all the old URLs for quick lookup. This maps URLs to the corresponding | 390 // Add all the old URLs for quick lookup. This maps URLs to the corresponding |
391 // index in the input. | 391 // index in the input. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
437 | 437 |
438 // Any member without the special marker in the all_old_urls list means that | 438 // Any member without the special marker in the all_old_urls list means that |
439 // there wasn't a "new" URL that mapped to it, so it was deleted. | 439 // there wasn't a "new" URL that mapped to it, so it was deleted. |
440 for (std::map<GURL, size_t>::const_iterator i = all_old_urls.begin(); | 440 for (std::map<GURL, size_t>::const_iterator i = all_old_urls.begin(); |
441 i != all_old_urls.end(); ++i) { | 441 i != all_old_urls.end(); ++i) { |
442 if (i->second != kAlreadyFoundMarker) | 442 if (i->second != kAlreadyFoundMarker) |
443 delta->deleted.push_back(old_list[i->second]); | 443 delta->deleted.push_back(old_list[i->second]); |
444 } | 444 } |
445 } | 445 } |
446 | 446 |
447 CancelableRequestProvider::Handle TopSitesImpl::StartQueryForMostVisited() { | 447 base::CancelableTaskTracker::TaskId TopSitesImpl::StartQueryForMostVisited() { |
448 DCHECK(loaded_); | 448 DCHECK(loaded_); |
449 if (!profile_) | 449 if (!profile_) |
450 return 0; | 450 return base::CancelableTaskTracker::kBadTaskId; |
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 base::Bind(&TopSitesImpl::OnTopSitesAvailableFromHistory, | 459 base::Bind(&TopSitesImpl::OnTopSitesAvailableFromHistory, |
460 base::Unretained(this)), | 460 base::Unretained(this)), |
461 &cancelable_task_tracker_); | 461 &cancelable_task_tracker_); |
462 } | 462 } |
463 return 0; | 463 return base::CancelableTaskTracker::kBadTaskId; |
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(); |
472 } | 472 } |
473 | 473 |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
929 base::TimeDelta::FromSeconds(kUpdateIntervalSecs)); | 929 base::TimeDelta::FromSeconds(kUpdateIntervalSecs)); |
930 } | 930 } |
931 | 931 |
932 void TopSitesImpl::OnTopSitesAvailableFromHistory( | 932 void TopSitesImpl::OnTopSitesAvailableFromHistory( |
933 const MostVisitedURLList* pages) { | 933 const MostVisitedURLList* pages) { |
934 DCHECK(pages); | 934 DCHECK(pages); |
935 SetTopSites(*pages); | 935 SetTopSites(*pages); |
936 } | 936 } |
937 | 937 |
938 } // namespace history | 938 } // namespace history |
OLD | NEW |