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 // The TopSitesBackend may not be created during unit tests. |
| 384 if (backend_) |
| 385 backend_->Shutdown(); |
383 } | 386 } |
384 | 387 |
385 // static | 388 // static |
386 void TopSitesImpl::DiffMostVisited(const MostVisitedURLList& old_list, | 389 void TopSitesImpl::DiffMostVisited(const MostVisitedURLList& old_list, |
387 const MostVisitedURLList& new_list, | 390 const MostVisitedURLList& new_list, |
388 TopSitesDelta* delta) { | 391 TopSitesDelta* delta) { |
389 | 392 |
390 // Add all the old URLs for quick lookup. This maps URLs to the corresponding | 393 // Add all the old URLs for quick lookup. This maps URLs to the corresponding |
391 // index in the input. | 394 // index in the input. |
392 std::map<GURL, size_t> all_old_urls; | 395 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)); | 922 base::TimeDelta::FromSeconds(kUpdateIntervalSecs)); |
920 } | 923 } |
921 | 924 |
922 void TopSitesImpl::OnTopSitesAvailableFromHistory( | 925 void TopSitesImpl::OnTopSitesAvailableFromHistory( |
923 const MostVisitedURLList* pages) { | 926 const MostVisitedURLList* pages) { |
924 DCHECK(pages); | 927 DCHECK(pages); |
925 SetTopSites(*pages); | 928 SetTopSites(*pages); |
926 } | 929 } |
927 | 930 |
928 } // namespace history | 931 } // namespace history |
OLD | NEW |