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

Side by Side Diff: chrome/browser/history/history_service.cc

Issue 351553004: Port HistoryService::GetVisibleVisitCountToHost to CancelableTaskTracker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // The history system runs on a background thread so that potentially slow 5 // The history system runs on a background thread so that potentially slow
6 // database operations don't delay the browser. This backend processing is 6 // database operations don't delay the browser. This backend processing is
7 // represented by HistoryBackend. The HistoryService's job is to dispatch to 7 // represented by HistoryBackend. The HistoryService's job is to dispatch to
8 // that thread. 8 // that thread.
9 // 9 //
10 // Main thread History thread 10 // Main thread History thread
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 callback.Run(result->success, result->row, result->visits); 86 callback.Run(result->success, result->row, result->visits);
87 } 87 }
88 88
89 void RunWithQueryRedirectsResult( 89 void RunWithQueryRedirectsResult(
90 const HistoryService::QueryRedirectsCallback& callback, 90 const HistoryService::QueryRedirectsCallback& callback,
91 const GURL& url, 91 const GURL& url,
92 const history::QueryRedirectsResult* result) { 92 const history::QueryRedirectsResult* result) {
93 callback.Run(url, result->success, &result->redirects); 93 callback.Run(url, result->success, &result->redirects);
94 } 94 }
95 95
96 void RunWithVisibleVisitCountToHostResult(
97 const HistoryService::GetVisibleVisitCountToHostCallback& callback,
98 const history::VisibleVisitCountToHostResult* result) {
99 callback.Run(result->success, result->count, result->first_visit);
100 }
101
96 // Extract history::URLRows into GURLs for VisitedLinkMaster. 102 // Extract history::URLRows into GURLs for VisitedLinkMaster.
97 class URLIteratorFromURLRows 103 class URLIteratorFromURLRows
98 : public visitedlink::VisitedLinkMaster::URLIterator { 104 : public visitedlink::VisitedLinkMaster::URLIterator {
99 public: 105 public:
100 explicit URLIteratorFromURLRows(const history::URLRows& url_rows) 106 explicit URLIteratorFromURLRows(const history::URLRows& url_rows)
101 : itr_(url_rows.begin()), 107 : itr_(url_rows.begin()),
102 end_(url_rows.end()) { 108 end_(url_rows.end()) {
103 } 109 }
104 110
105 virtual const GURL& NextURL() OVERRIDE { 111 virtual const GURL& NextURL() OVERRIDE {
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 thread_->message_loop_proxy().get(), 839 thread_->message_loop_proxy().get(),
834 FROM_HERE, 840 FROM_HERE,
835 base::Bind(&HistoryBackend::QueryRedirectsTo, 841 base::Bind(&HistoryBackend::QueryRedirectsTo,
836 history_backend_.get(), 842 history_backend_.get(),
837 to_url, 843 to_url,
838 base::Unretained(result)), 844 base::Unretained(result)),
839 base::Bind( 845 base::Bind(
840 &RunWithQueryRedirectsResult, callback, to_url, base::Owned(result))); 846 &RunWithQueryRedirectsResult, callback, to_url, base::Owned(result)));
841 } 847 }
842 848
843 HistoryService::Handle HistoryService::GetVisibleVisitCountToHost( 849 base::CancelableTaskTracker::TaskId HistoryService::GetVisibleVisitCountToHost(
844 const GURL& url, 850 const GURL& url,
845 CancelableRequestConsumerBase* consumer, 851 const GetVisibleVisitCountToHostCallback& callback,
846 const GetVisibleVisitCountToHostCallback& callback) { 852 base::CancelableTaskTracker* tracker) {
847 DCHECK(thread_checker_.CalledOnValidThread()); 853 DCHECK(thread_checker_.CalledOnValidThread());
848 return Schedule(PRIORITY_UI, &HistoryBackend::GetVisibleVisitCountToHost, 854 history::VisibleVisitCountToHostResult* result =
849 consumer, new history::GetVisibleVisitCountToHostRequest(callback), url); 855 new history::VisibleVisitCountToHostResult();
856 return tracker->PostTaskAndReply(
857 thread_->message_loop_proxy().get(),
858 FROM_HERE,
859 base::Bind(&HistoryBackend::GetVisibleVisitCountToHost,
860 history_backend_.get(),
861 url,
862 base::Unretained(result)),
863 base::Bind(&RunWithVisibleVisitCountToHostResult,
864 callback,
865 base::Owned(result)));
850 } 866 }
851 867
852 HistoryService::Handle HistoryService::QueryTopURLsAndRedirects( 868 HistoryService::Handle HistoryService::QueryTopURLsAndRedirects(
853 int result_count, 869 int result_count,
854 CancelableRequestConsumerBase* consumer, 870 CancelableRequestConsumerBase* consumer,
855 const QueryTopURLsAndRedirectsCallback& callback) { 871 const QueryTopURLsAndRedirectsCallback& callback) {
856 DCHECK(thread_checker_.CalledOnValidThread()); 872 DCHECK(thread_checker_.CalledOnValidThread());
857 return Schedule(PRIORITY_NORMAL, &HistoryBackend::QueryTopURLsAndRedirects, 873 return Schedule(PRIORITY_NORMAL, &HistoryBackend::QueryTopURLsAndRedirects,
858 consumer, new history::QueryTopURLsAndRedirectsRequest(callback), 874 consumer, new history::QueryTopURLsAndRedirectsRequest(callback),
859 result_count); 875 result_count);
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 DCHECK(thread_checker_.CalledOnValidThread()); 1221 DCHECK(thread_checker_.CalledOnValidThread());
1206 visit_database_observers_.RemoveObserver(observer); 1222 visit_database_observers_.RemoveObserver(observer);
1207 } 1223 }
1208 1224
1209 void HistoryService::NotifyVisitDBObserversOnAddVisit( 1225 void HistoryService::NotifyVisitDBObserversOnAddVisit(
1210 const history::BriefVisitInfo& info) { 1226 const history::BriefVisitInfo& info) {
1211 DCHECK(thread_checker_.CalledOnValidThread()); 1227 DCHECK(thread_checker_.CalledOnValidThread());
1212 FOR_EACH_OBSERVER(history::VisitDatabaseObserver, visit_database_observers_, 1228 FOR_EACH_OBSERVER(history::VisitDatabaseObserver, visit_database_observers_,
1213 OnAddVisit(info)); 1229 OnAddVisit(info));
1214 } 1230 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698