Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1268)

Side by Side Diff: components/history/core/browser/top_sites_impl.cc

Issue 1144153004: components: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/location.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/md5.h" 14 #include "base/md5.h"
14 #include "base/memory/ref_counted_memory.h" 15 #include "base/memory/ref_counted_memory.h"
15 #include "base/message_loop/message_loop_proxy.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/prefs/pref_service.h" 17 #include "base/prefs/pref_service.h"
18 #include "base/prefs/scoped_user_pref_update.h" 18 #include "base/prefs/scoped_user_pref_update.h"
19 #include "base/single_thread_task_runner.h" 19 #include "base/single_thread_task_runner.h"
20 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
21 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
22 #include "base/task_runner.h" 22 #include "base/task_runner.h"
23 #include "base/thread_task_runner_handle.h"
23 #include "base/values.h" 24 #include "base/values.h"
24 #include "components/history/core/browser/history_backend.h" 25 #include "components/history/core/browser/history_backend.h"
25 #include "components/history/core/browser/history_constants.h" 26 #include "components/history/core/browser/history_constants.h"
26 #include "components/history/core/browser/history_db_task.h" 27 #include "components/history/core/browser/history_db_task.h"
27 #include "components/history/core/browser/page_usage_data.h" 28 #include "components/history/core/browser/page_usage_data.h"
28 #include "components/history/core/browser/top_sites_cache.h" 29 #include "components/history/core/browser/top_sites_cache.h"
29 #include "components/history/core/browser/url_utils.h" 30 #include "components/history/core/browser/url_utils.h"
30 #include "components/history/core/common/thumbnail_score.h" 31 #include "components/history/core/common/thumbnail_score.h"
31 #include "ui/base/l10n/l10n_util.h" 32 #include "ui/base/l10n/l10n_util.h"
32 #include "ui/base/layout.h" 33 #include "ui/base/layout.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 // WARNING: this function may be invoked on any thread. 204 // WARNING: this function may be invoked on any thread.
204 void TopSitesImpl::GetMostVisitedURLs( 205 void TopSitesImpl::GetMostVisitedURLs(
205 const GetMostVisitedURLsCallback& callback, 206 const GetMostVisitedURLsCallback& callback,
206 bool include_forced_urls) { 207 bool include_forced_urls) {
207 MostVisitedURLList filtered_urls; 208 MostVisitedURLList filtered_urls;
208 { 209 {
209 base::AutoLock lock(lock_); 210 base::AutoLock lock(lock_);
210 if (!loaded_) { 211 if (!loaded_) {
211 // A request came in before we finished loading. Store the callback and 212 // A request came in before we finished loading. Store the callback and
212 // we'll run it on current thread when we finish loading. 213 // we'll run it on current thread when we finish loading.
213 pending_callbacks_.push_back( 214 pending_callbacks_.push_back(base::Bind(
214 base::Bind(&RunOrPostGetMostVisitedURLsCallback, 215 &RunOrPostGetMostVisitedURLsCallback,
215 base::MessageLoopProxy::current(), 216 base::ThreadTaskRunnerHandle::Get(), include_forced_urls, callback));
216 include_forced_urls,
217 callback));
218 return; 217 return;
219 } 218 }
220 if (include_forced_urls) { 219 if (include_forced_urls) {
221 filtered_urls = thread_safe_cache_->top_sites(); 220 filtered_urls = thread_safe_cache_->top_sites();
222 } else { 221 } else {
223 filtered_urls.assign(thread_safe_cache_->top_sites().begin() + 222 filtered_urls.assign(thread_safe_cache_->top_sites().begin() +
224 thread_safe_cache_->GetNumForcedURLs(), 223 thread_safe_cache_->GetNumForcedURLs(),
225 thread_safe_cache_->top_sites().end()); 224 thread_safe_cache_->top_sites().end());
226 } 225 }
227 } 226 }
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 for (std::set<size_t>::reverse_iterator i = indices_to_delete.rbegin(); 912 for (std::set<size_t>::reverse_iterator i = indices_to_delete.rbegin();
914 i != indices_to_delete.rend(); i++) { 913 i != indices_to_delete.rend(); i++) {
915 new_top_sites.erase(new_top_sites.begin() + *i); 914 new_top_sites.erase(new_top_sites.begin() + *i);
916 } 915 }
917 SetTopSites(new_top_sites, CALL_LOCATION_FROM_OTHER_PLACES); 916 SetTopSites(new_top_sites, CALL_LOCATION_FROM_OTHER_PLACES);
918 } 917 }
919 StartQueryForMostVisited(); 918 StartQueryForMostVisited();
920 } 919 }
921 920
922 } // namespace history 921 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698