| 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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 { | 366 { |
| 367 DictionaryPrefUpdate update(profile_->GetPrefs(), | 367 DictionaryPrefUpdate update(profile_->GetPrefs(), |
| 368 prefs::kNtpMostVisitedURLsBlacklist); | 368 prefs::kNtpMostVisitedURLsBlacklist); |
| 369 base::DictionaryValue* blacklist = update.Get(); | 369 base::DictionaryValue* blacklist = update.Get(); |
| 370 blacklist->Clear(); | 370 blacklist->Clear(); |
| 371 } | 371 } |
| 372 ResetThreadSafeCache(); | 372 ResetThreadSafeCache(); |
| 373 NotifyTopSitesChanged(); | 373 NotifyTopSitesChanged(); |
| 374 } | 374 } |
| 375 | 375 |
| 376 void TopSitesImpl::Shutdown() { | 376 void TopSitesImpl::ShutdownOnUIThread() { |
| 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 cancelable_task_tracker_.TryCancelAll(); | 381 cancelable_task_tracker_.TryCancelAll(); |
| 382 backend_->Shutdown(); | 382 registrar_.RemoveAll(); |
| 383 if (backend_) |
| 384 backend_->Shutdown(); |
| 383 } | 385 } |
| 384 | 386 |
| 385 // static | 387 // static |
| 386 void TopSitesImpl::DiffMostVisited(const MostVisitedURLList& old_list, | 388 void TopSitesImpl::DiffMostVisited(const MostVisitedURLList& old_list, |
| 387 const MostVisitedURLList& new_list, | 389 const MostVisitedURLList& new_list, |
| 388 TopSitesDelta* delta) { | 390 TopSitesDelta* delta) { |
| 389 | 391 |
| 390 // Add all the old URLs for quick lookup. This maps URLs to the corresponding | 392 // Add all the old URLs for quick lookup. This maps URLs to the corresponding |
| 391 // index in the input. | 393 // index in the input. |
| 392 std::map<GURL, size_t> all_old_urls; | 394 std::map<GURL, size_t> all_old_urls; |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 base::TimeDelta::FromSeconds(kUpdateIntervalSecs)); | 921 base::TimeDelta::FromSeconds(kUpdateIntervalSecs)); |
| 920 } | 922 } |
| 921 | 923 |
| 922 void TopSitesImpl::OnTopSitesAvailableFromHistory( | 924 void TopSitesImpl::OnTopSitesAvailableFromHistory( |
| 923 const MostVisitedURLList* pages) { | 925 const MostVisitedURLList* pages) { |
| 924 DCHECK(pages); | 926 DCHECK(pages); |
| 925 SetTopSites(*pages); | 927 SetTopSites(*pages); |
| 926 } | 928 } |
| 927 | 929 |
| 928 } // namespace history | 930 } // namespace history |
| OLD | NEW |