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

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

Issue 349153006: Port HistoryService::QueryRedirects{From,To} 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 const favicon_base::FaviconRawBitmapCallback& callback, 79 const favicon_base::FaviconRawBitmapCallback& callback,
80 favicon_base::FaviconRawBitmapResult* bitmap_result) { 80 favicon_base::FaviconRawBitmapResult* bitmap_result) {
81 callback.Run(*bitmap_result); 81 callback.Run(*bitmap_result);
82 } 82 }
83 83
84 void RunWithQueryURLResult(const HistoryService::QueryURLCallback& callback, 84 void RunWithQueryURLResult(const HistoryService::QueryURLCallback& callback,
85 const history::QueryURLResult* result) { 85 const history::QueryURLResult* result) {
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(
droger 2014/06/23 16:50:35 If I understand correctly, you need this helper ju
sdefresne 2014/06/24 13:41:00 PostTaskAndReplyWithResult does not works with Can
90 const HistoryService::QueryRedirectsCallback& callback,
91 const GURL& url,
92 const history::QueryRedirectsResult* result) {
93 callback.Run(url, result->success, &result->redirects);
94 }
95
89 // Extract history::URLRows into GURLs for VisitedLinkMaster. 96 // Extract history::URLRows into GURLs for VisitedLinkMaster.
90 class URLIteratorFromURLRows 97 class URLIteratorFromURLRows
91 : public visitedlink::VisitedLinkMaster::URLIterator { 98 : public visitedlink::VisitedLinkMaster::URLIterator {
92 public: 99 public:
93 explicit URLIteratorFromURLRows(const history::URLRows& url_rows) 100 explicit URLIteratorFromURLRows(const history::URLRows& url_rows)
94 : itr_(url_rows.begin()), 101 : itr_(url_rows.begin()),
95 end_(url_rows.end()) { 102 end_(url_rows.end()) {
96 } 103 }
97 104
98 virtual const GURL& NextURL() OVERRIDE { 105 virtual const GURL& NextURL() OVERRIDE {
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 thread_->message_loop_proxy().get(), 797 thread_->message_loop_proxy().get(),
791 FROM_HERE, 798 FROM_HERE,
792 base::Bind(&HistoryBackend::QueryHistory, 799 base::Bind(&HistoryBackend::QueryHistory,
793 history_backend_.get(), 800 history_backend_.get(),
794 text_query, 801 text_query,
795 options, 802 options,
796 base::Unretained(query_results)), 803 base::Unretained(query_results)),
797 base::Bind(callback, base::Owned(query_results))); 804 base::Bind(callback, base::Owned(query_results)));
798 } 805 }
799 806
800 HistoryService::Handle HistoryService::QueryRedirectsFrom( 807 base::CancelableTaskTracker::TaskId HistoryService::QueryRedirectsFrom(
droger 2014/06/23 16:50:35 Is this function actually used? I see it only call
sdefresne 2014/06/24 13:41:00 It's only called from unit tests and browser tests
801 const GURL& from_url, 808 const GURL& from_url,
802 CancelableRequestConsumerBase* consumer, 809 const QueryRedirectsCallback& callback,
803 const QueryRedirectsCallback& callback) { 810 base::CancelableTaskTracker* tracker) {
804 DCHECK(thread_checker_.CalledOnValidThread()); 811 DCHECK(thread_checker_.CalledOnValidThread());
805 return Schedule(PRIORITY_UI, &HistoryBackend::QueryRedirectsFrom, consumer, 812 history::QueryRedirectsResult* result = new history::QueryRedirectsResult();
806 new history::QueryRedirectsRequest(callback), from_url); 813 return tracker->PostTaskAndReply(
814 thread_->message_loop_proxy().get(),
815 FROM_HERE,
816 base::Bind(&HistoryBackend::QueryRedirectsFrom,
817 history_backend_.get(),
818 from_url,
819 base::Unretained(result)),
820 base::Bind(&RunWithQueryRedirectsResult,
821 callback,
822 from_url,
823 base::Owned(result)));
807 } 824 }
808 825
809 HistoryService::Handle HistoryService::QueryRedirectsTo( 826 base::CancelableTaskTracker::TaskId HistoryService::QueryRedirectsTo(
810 const GURL& to_url, 827 const GURL& to_url,
811 CancelableRequestConsumerBase* consumer, 828 const QueryRedirectsCallback& callback,
812 const QueryRedirectsCallback& callback) { 829 base::CancelableTaskTracker* tracker) {
813 DCHECK(thread_checker_.CalledOnValidThread()); 830 DCHECK(thread_checker_.CalledOnValidThread());
814 return Schedule(PRIORITY_NORMAL, &HistoryBackend::QueryRedirectsTo, consumer, 831 history::QueryRedirectsResult* result = new history::QueryRedirectsResult();
815 new history::QueryRedirectsRequest(callback), to_url); 832 return tracker->PostTaskAndReply(
833 thread_->message_loop_proxy().get(),
834 FROM_HERE,
835 base::Bind(&HistoryBackend::QueryRedirectsTo,
836 history_backend_.get(),
837 to_url,
838 base::Unretained(result)),
839 base::Bind(
840 &RunWithQueryRedirectsResult, callback, to_url, base::Owned(result)));
816 } 841 }
817 842
818 HistoryService::Handle HistoryService::GetVisibleVisitCountToHost( 843 HistoryService::Handle HistoryService::GetVisibleVisitCountToHost(
819 const GURL& url, 844 const GURL& url,
820 CancelableRequestConsumerBase* consumer, 845 CancelableRequestConsumerBase* consumer,
821 const GetVisibleVisitCountToHostCallback& callback) { 846 const GetVisibleVisitCountToHostCallback& callback) {
822 DCHECK(thread_checker_.CalledOnValidThread()); 847 DCHECK(thread_checker_.CalledOnValidThread());
823 return Schedule(PRIORITY_UI, &HistoryBackend::GetVisibleVisitCountToHost, 848 return Schedule(PRIORITY_UI, &HistoryBackend::GetVisibleVisitCountToHost,
824 consumer, new history::GetVisibleVisitCountToHostRequest(callback), url); 849 consumer, new history::GetVisibleVisitCountToHostRequest(callback), url);
825 } 850 }
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 DCHECK(thread_checker_.CalledOnValidThread()); 1205 DCHECK(thread_checker_.CalledOnValidThread());
1181 visit_database_observers_.RemoveObserver(observer); 1206 visit_database_observers_.RemoveObserver(observer);
1182 } 1207 }
1183 1208
1184 void HistoryService::NotifyVisitDBObserversOnAddVisit( 1209 void HistoryService::NotifyVisitDBObserversOnAddVisit(
1185 const history::BriefVisitInfo& info) { 1210 const history::BriefVisitInfo& info) {
1186 DCHECK(thread_checker_.CalledOnValidThread()); 1211 DCHECK(thread_checker_.CalledOnValidThread());
1187 FOR_EACH_OBSERVER(history::VisitDatabaseObserver, visit_database_observers_, 1212 FOR_EACH_OBSERVER(history::VisitDatabaseObserver, visit_database_observers_,
1188 OnAddVisit(info)); 1213 OnAddVisit(info));
1189 } 1214 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698