| 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 "components/history/core/browser/top_sites_impl.h" | 5 #include "components/history/core/browser/top_sites_impl.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 // WARNING: this function may be invoked on any thread. | 210 // WARNING: this function may be invoked on any thread. |
| 211 void TopSitesImpl::GetMostVisitedURLs( | 211 void TopSitesImpl::GetMostVisitedURLs( |
| 212 const GetMostVisitedURLsCallback& callback, | 212 const GetMostVisitedURLsCallback& callback, |
| 213 bool include_forced_urls) { | 213 bool include_forced_urls) { |
| 214 MostVisitedURLList filtered_urls; | 214 MostVisitedURLList filtered_urls; |
| 215 { | 215 { |
| 216 base::AutoLock lock(lock_); | 216 base::AutoLock lock(lock_); |
| 217 if (!loaded_) { | 217 if (!loaded_) { |
| 218 // A request came in before we finished loading. Store the callback and | 218 // A request came in before we finished loading. Store the callback and |
| 219 // we'll run it on current thread when we finish loading. | 219 // we'll run it on current thread when we finish loading. |
| 220 pending_callbacks_.push_back(base::Bind( | 220 pending_callbacks_.push_back( |
| 221 &RunOrPostGetMostVisitedURLsCallback, | 221 base::Bind(&RunOrPostGetMostVisitedURLsCallback, |
| 222 base::ThreadTaskRunnerHandle::Get(), include_forced_urls, callback)); | 222 base::RetainedRef(base::ThreadTaskRunnerHandle::Get()), |
| 223 include_forced_urls, callback)); |
| 223 return; | 224 return; |
| 224 } | 225 } |
| 225 if (include_forced_urls) { | 226 if (include_forced_urls) { |
| 226 filtered_urls = thread_safe_cache_->top_sites(); | 227 filtered_urls = thread_safe_cache_->top_sites(); |
| 227 } else { | 228 } else { |
| 228 filtered_urls.assign(thread_safe_cache_->top_sites().begin() + | 229 filtered_urls.assign(thread_safe_cache_->top_sites().begin() + |
| 229 thread_safe_cache_->GetNumForcedURLs(), | 230 thread_safe_cache_->GetNumForcedURLs(), |
| 230 thread_safe_cache_->top_sites().end()); | 231 thread_safe_cache_->top_sites().end()); |
| 231 } | 232 } |
| 232 } | 233 } |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 for (std::set<size_t>::reverse_iterator i = indices_to_delete.rbegin(); | 935 for (std::set<size_t>::reverse_iterator i = indices_to_delete.rbegin(); |
| 935 i != indices_to_delete.rend(); i++) { | 936 i != indices_to_delete.rend(); i++) { |
| 936 new_top_sites.erase(new_top_sites.begin() + *i); | 937 new_top_sites.erase(new_top_sites.begin() + *i); |
| 937 } | 938 } |
| 938 SetTopSites(new_top_sites, CALL_LOCATION_FROM_OTHER_PLACES); | 939 SetTopSites(new_top_sites, CALL_LOCATION_FROM_OTHER_PLACES); |
| 939 } | 940 } |
| 940 StartQueryForMostVisited(); | 941 StartQueryForMostVisited(); |
| 941 } | 942 } |
| 942 | 943 |
| 943 } // namespace history | 944 } // namespace history |
| OLD | NEW |