| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 const favicon_base::FaviconResultsCallback& callback, | 74 const favicon_base::FaviconResultsCallback& callback, |
| 75 std::vector<favicon_base::FaviconBitmapResult>* bitmap_results) { | 75 std::vector<favicon_base::FaviconBitmapResult>* bitmap_results) { |
| 76 callback.Run(*bitmap_results); | 76 callback.Run(*bitmap_results); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void RunWithFaviconResult(const favicon_base::FaviconRawCallback& callback, | 79 void RunWithFaviconResult(const favicon_base::FaviconRawCallback& callback, |
| 80 favicon_base::FaviconBitmapResult* bitmap_result) { | 80 favicon_base::FaviconBitmapResult* bitmap_result) { |
| 81 callback.Run(*bitmap_result); | 81 callback.Run(*bitmap_result); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void RunWithQueryURLResult(const HistoryService::QueryURLCallback& callback, |
| 85 const HistoryBackend::QueryURLResult& result) { |
| 86 callback.Run(result.success, result.row, result.visits); |
| 87 } |
| 88 |
| 84 // Extract history::URLRows into GURLs for VisitedLinkMaster. | 89 // Extract history::URLRows into GURLs for VisitedLinkMaster. |
| 85 class URLIteratorFromURLRows | 90 class URLIteratorFromURLRows |
| 86 : public visitedlink::VisitedLinkMaster::URLIterator { | 91 : public visitedlink::VisitedLinkMaster::URLIterator { |
| 87 public: | 92 public: |
| 88 explicit URLIteratorFromURLRows(const history::URLRows& url_rows) | 93 explicit URLIteratorFromURLRows(const history::URLRows& url_rows) |
| 89 : itr_(url_rows.begin()), | 94 : itr_(url_rows.begin()), |
| 90 end_(url_rows.end()) { | 95 end_(url_rows.end()) { |
| 91 } | 96 } |
| 92 | 97 |
| 93 virtual const GURL& NextURL() OVERRIDE { | 98 virtual const GURL& NextURL() OVERRIDE { |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 old_page_url, new_page_url); | 701 old_page_url, new_page_url); |
| 697 } | 702 } |
| 698 | 703 |
| 699 void HistoryService::SetImportedFavicons( | 704 void HistoryService::SetImportedFavicons( |
| 700 const std::vector<ImportedFaviconUsage>& favicon_usage) { | 705 const std::vector<ImportedFaviconUsage>& favicon_usage) { |
| 701 DCHECK(thread_checker_.CalledOnValidThread()); | 706 DCHECK(thread_checker_.CalledOnValidThread()); |
| 702 ScheduleAndForget(PRIORITY_NORMAL, | 707 ScheduleAndForget(PRIORITY_NORMAL, |
| 703 &HistoryBackend::SetImportedFavicons, favicon_usage); | 708 &HistoryBackend::SetImportedFavicons, favicon_usage); |
| 704 } | 709 } |
| 705 | 710 |
| 706 HistoryService::Handle HistoryService::QueryURL( | 711 base::CancelableTaskTracker::TaskId HistoryService::QueryURL( |
| 707 const GURL& url, | 712 const GURL& url, |
| 708 bool want_visits, | 713 bool want_visits, |
| 709 CancelableRequestConsumerBase* consumer, | 714 const QueryURLCallback& callback, |
| 710 const QueryURLCallback& callback) { | 715 base::CancelableTaskTracker* tracker) { |
| 711 DCHECK(thread_checker_.CalledOnValidThread()); | 716 DCHECK(thread_checker_.CalledOnValidThread()); |
| 712 return Schedule(PRIORITY_UI, &HistoryBackend::QueryURL, consumer, | 717 return PostTaskAndReplyWithResult( |
| 713 new history::QueryURLRequest(callback), url, want_visits); | 718 thread_->message_loop_proxy().get(), |
| 719 FROM_HERE, |
| 720 base::Bind( |
| 721 &HistoryBackend::QueryURL, history_backend_.get(), url, want_visits), |
| 722 base::Bind(&RunWithQueryURLResult, callback)); |
| 714 } | 723 } |
| 715 | 724 |
| 716 // Downloads ------------------------------------------------------------------- | 725 // Downloads ------------------------------------------------------------------- |
| 717 | 726 |
| 718 // Handle creation of a download by creating an entry in the history service's | 727 // Handle creation of a download by creating an entry in the history service's |
| 719 // 'downloads' table. | 728 // 'downloads' table. |
| 720 void HistoryService::CreateDownload( | 729 void HistoryService::CreateDownload( |
| 721 const history::DownloadRow& create_info, | 730 const history::DownloadRow& create_info, |
| 722 const HistoryService::DownloadCreateCallback& callback) { | 731 const HistoryService::DownloadCreateCallback& callback) { |
| 723 DCHECK(thread_) << "History service being called after cleanup"; | 732 DCHECK(thread_) << "History service being called after cleanup"; |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1167 DCHECK(thread_checker_.CalledOnValidThread()); | 1176 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1168 visit_database_observers_.RemoveObserver(observer); | 1177 visit_database_observers_.RemoveObserver(observer); |
| 1169 } | 1178 } |
| 1170 | 1179 |
| 1171 void HistoryService::NotifyVisitDBObserversOnAddVisit( | 1180 void HistoryService::NotifyVisitDBObserversOnAddVisit( |
| 1172 const history::BriefVisitInfo& info) { | 1181 const history::BriefVisitInfo& info) { |
| 1173 DCHECK(thread_checker_.CalledOnValidThread()); | 1182 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1174 FOR_EACH_OBSERVER(history::VisitDatabaseObserver, visit_database_observers_, | 1183 FOR_EACH_OBSERVER(history::VisitDatabaseObserver, visit_database_observers_, |
| 1175 OnAddVisit(info)); | 1184 OnAddVisit(info)); |
| 1176 } | 1185 } |
| OLD | NEW |