| OLD | NEW |
| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 const favicon_base::FaviconRawBitmapCallback& callback, | 81 const favicon_base::FaviconRawBitmapCallback& callback, |
| 82 favicon_base::FaviconRawBitmapResult* bitmap_result) { | 82 favicon_base::FaviconRawBitmapResult* bitmap_result) { |
| 83 callback.Run(*bitmap_result); | 83 callback.Run(*bitmap_result); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void RunWithQueryURLResult(const HistoryService::QueryURLCallback& callback, | 86 void RunWithQueryURLResult(const HistoryService::QueryURLCallback& callback, |
| 87 const history::QueryURLResult* result) { | 87 const history::QueryURLResult* result) { |
| 88 callback.Run(result->success, result->row, result->visits); | 88 callback.Run(result->success, result->row, result->visits); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void RunWithVisibleVisitCountToHostResult( |
| 92 const HistoryService::GetVisibleVisitCountToHostCallback& callback, |
| 93 const history::VisibleVisitCountToHostResult* result) { |
| 94 callback.Run(result->success, result->count, result->first_visit); |
| 95 } |
| 96 |
| 91 // Extract history::URLRows into GURLs for VisitedLinkMaster. | 97 // Extract history::URLRows into GURLs for VisitedLinkMaster. |
| 92 class URLIteratorFromURLRows | 98 class URLIteratorFromURLRows |
| 93 : public visitedlink::VisitedLinkMaster::URLIterator { | 99 : public visitedlink::VisitedLinkMaster::URLIterator { |
| 94 public: | 100 public: |
| 95 explicit URLIteratorFromURLRows(const history::URLRows& url_rows) | 101 explicit URLIteratorFromURLRows(const history::URLRows& url_rows) |
| 96 : itr_(url_rows.begin()), | 102 : itr_(url_rows.begin()), |
| 97 end_(url_rows.end()) { | 103 end_(url_rows.end()) { |
| 98 } | 104 } |
| 99 | 105 |
| 100 virtual const GURL& NextURL() OVERRIDE { | 106 virtual const GURL& NextURL() OVERRIDE { |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 history::RedirectList* result = new history::RedirectList(); | 805 history::RedirectList* result = new history::RedirectList(); |
| 800 return tracker->PostTaskAndReply(thread_->message_loop_proxy().get(), | 806 return tracker->PostTaskAndReply(thread_->message_loop_proxy().get(), |
| 801 FROM_HERE, | 807 FROM_HERE, |
| 802 base::Bind(&HistoryBackend::QueryRedirectsTo, | 808 base::Bind(&HistoryBackend::QueryRedirectsTo, |
| 803 history_backend_.get(), | 809 history_backend_.get(), |
| 804 to_url, | 810 to_url, |
| 805 base::Unretained(result)), | 811 base::Unretained(result)), |
| 806 base::Bind(callback, base::Owned(result))); | 812 base::Bind(callback, base::Owned(result))); |
| 807 } | 813 } |
| 808 | 814 |
| 809 HistoryService::Handle HistoryService::GetVisibleVisitCountToHost( | 815 base::CancelableTaskTracker::TaskId HistoryService::GetVisibleVisitCountToHost( |
| 810 const GURL& url, | 816 const GURL& url, |
| 811 CancelableRequestConsumerBase* consumer, | 817 const GetVisibleVisitCountToHostCallback& callback, |
| 812 const GetVisibleVisitCountToHostCallback& callback) { | 818 base::CancelableTaskTracker* tracker) { |
| 813 DCHECK(thread_checker_.CalledOnValidThread()); | 819 DCHECK(thread_checker_.CalledOnValidThread()); |
| 814 return Schedule(PRIORITY_UI, &HistoryBackend::GetVisibleVisitCountToHost, | 820 history::VisibleVisitCountToHostResult* result = |
| 815 consumer, new history::GetVisibleVisitCountToHostRequest(callback), url); | 821 new history::VisibleVisitCountToHostResult(); |
| 822 return tracker->PostTaskAndReply( |
| 823 thread_->message_loop_proxy().get(), |
| 824 FROM_HERE, |
| 825 base::Bind(&HistoryBackend::GetVisibleVisitCountToHost, |
| 826 history_backend_.get(), |
| 827 url, |
| 828 base::Unretained(result)), |
| 829 base::Bind(&RunWithVisibleVisitCountToHostResult, |
| 830 callback, |
| 831 base::Owned(result))); |
| 816 } | 832 } |
| 817 | 833 |
| 818 base::CancelableTaskTracker::TaskId HistoryService::QueryMostVisitedURLs( | 834 base::CancelableTaskTracker::TaskId HistoryService::QueryMostVisitedURLs( |
| 819 int result_count, | 835 int result_count, |
| 820 int days_back, | 836 int days_back, |
| 821 const QueryMostVisitedURLsCallback& callback, | 837 const QueryMostVisitedURLsCallback& callback, |
| 822 base::CancelableTaskTracker* tracker) { | 838 base::CancelableTaskTracker* tracker) { |
| 823 DCHECK(thread_checker_.CalledOnValidThread()); | 839 DCHECK(thread_checker_.CalledOnValidThread()); |
| 824 history::MostVisitedURLList* result = new history::MostVisitedURLList(); | 840 history::MostVisitedURLList* result = new history::MostVisitedURLList(); |
| 825 return tracker->PostTaskAndReply( | 841 return tracker->PostTaskAndReply( |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1162 DCHECK(thread_checker_.CalledOnValidThread()); | 1178 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1163 visit_database_observers_.RemoveObserver(observer); | 1179 visit_database_observers_.RemoveObserver(observer); |
| 1164 } | 1180 } |
| 1165 | 1181 |
| 1166 void HistoryService::NotifyVisitDBObserversOnAddVisit( | 1182 void HistoryService::NotifyVisitDBObserversOnAddVisit( |
| 1167 const history::BriefVisitInfo& info) { | 1183 const history::BriefVisitInfo& info) { |
| 1168 DCHECK(thread_checker_.CalledOnValidThread()); | 1184 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1169 FOR_EACH_OBSERVER(history::VisitDatabaseObserver, visit_database_observers_, | 1185 FOR_EACH_OBSERVER(history::VisitDatabaseObserver, visit_database_observers_, |
| 1170 OnAddVisit(info)); | 1186 OnAddVisit(info)); |
| 1171 } | 1187 } |
| OLD | NEW |