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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 const base::Callback<void(PODType)>& callback, PODType* pod_value) { | 77 const base::Callback<void(PODType)>& callback, PODType* pod_value) { |
78 callback.Run(*pod_value); | 78 callback.Run(*pod_value); |
79 } | 79 } |
80 | 80 |
81 void RunWithFaviconResults( | 81 void RunWithFaviconResults( |
82 const FaviconService::FaviconResultsCallback& callback, | 82 const FaviconService::FaviconResultsCallback& callback, |
83 std::vector<chrome::FaviconBitmapResult>* bitmap_results) { | 83 std::vector<chrome::FaviconBitmapResult>* bitmap_results) { |
84 callback.Run(*bitmap_results); | 84 callback.Run(*bitmap_results); |
85 } | 85 } |
86 | 86 |
| 87 void RunWithFaviconResult( |
| 88 const FaviconService::FaviconRawCallback& callback, |
| 89 chrome::FaviconBitmapResult* bitmap_result) { |
| 90 callback.Run(*bitmap_result); |
| 91 } |
| 92 |
87 // Extract history::URLRows into GURLs for VisitedLinkMaster. | 93 // Extract history::URLRows into GURLs for VisitedLinkMaster. |
88 class URLIteratorFromURLRows | 94 class URLIteratorFromURLRows |
89 : public visitedlink::VisitedLinkMaster::URLIterator { | 95 : public visitedlink::VisitedLinkMaster::URLIterator { |
90 public: | 96 public: |
91 explicit URLIteratorFromURLRows(const history::URLRows& url_rows) | 97 explicit URLIteratorFromURLRows(const history::URLRows& url_rows) |
92 : itr_(url_rows.begin()), | 98 : itr_(url_rows.begin()), |
93 end_(url_rows.end()) { | 99 end_(url_rows.end()) { |
94 } | 100 } |
95 | 101 |
96 virtual const GURL& NextURL() OVERRIDE { | 102 virtual const GURL& NextURL() OVERRIDE { |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 base::Bind(&HistoryBackend::GetFaviconsForURL, | 643 base::Bind(&HistoryBackend::GetFaviconsForURL, |
638 history_backend_.get(), | 644 history_backend_.get(), |
639 page_url, | 645 page_url, |
640 icon_types, | 646 icon_types, |
641 desired_size_in_dip, | 647 desired_size_in_dip, |
642 desired_scale_factors, | 648 desired_scale_factors, |
643 results), | 649 results), |
644 base::Bind(&RunWithFaviconResults, callback, base::Owned(results))); | 650 base::Bind(&RunWithFaviconResults, callback, base::Owned(results))); |
645 } | 651 } |
646 | 652 |
| 653 CancelableTaskTracker::TaskId HistoryService::GetLargestFaviconForURL( |
| 654 const GURL& page_url, |
| 655 const std::vector<int>& icon_types, |
| 656 int minimum_size_in_pixels, |
| 657 const FaviconService::FaviconRawCallback& callback, |
| 658 CancelableTaskTracker* tracker) { |
| 659 DCHECK(thread_checker_.CalledOnValidThread()); |
| 660 LoadBackendIfNecessary(); |
| 661 |
| 662 chrome::FaviconBitmapResult* result = new chrome::FaviconBitmapResult(); |
| 663 return tracker->PostTaskAndReply( |
| 664 thread_->message_loop_proxy().get(), |
| 665 FROM_HERE, |
| 666 base::Bind(&HistoryBackend::GetLargestFaviconForURL, |
| 667 history_backend_.get(), |
| 668 page_url, |
| 669 icon_types, |
| 670 minimum_size_in_pixels, |
| 671 result), |
| 672 base::Bind(&RunWithFaviconResult, callback, base::Owned(result))); |
| 673 } |
| 674 |
647 CancelableTaskTracker::TaskId HistoryService::GetFaviconForID( | 675 CancelableTaskTracker::TaskId HistoryService::GetFaviconForID( |
648 chrome::FaviconID favicon_id, | 676 chrome::FaviconID favicon_id, |
649 int desired_size_in_dip, | 677 int desired_size_in_dip, |
650 ui::ScaleFactor desired_scale_factor, | 678 ui::ScaleFactor desired_scale_factor, |
651 const FaviconService::FaviconResultsCallback& callback, | 679 const FaviconService::FaviconResultsCallback& callback, |
652 CancelableTaskTracker* tracker) { | 680 CancelableTaskTracker* tracker) { |
653 DCHECK(thread_checker_.CalledOnValidThread()); | 681 DCHECK(thread_checker_.CalledOnValidThread()); |
654 LoadBackendIfNecessary(); | 682 LoadBackendIfNecessary(); |
655 | 683 |
656 std::vector<chrome::FaviconBitmapResult>* results = | 684 std::vector<chrome::FaviconBitmapResult>* results = |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1241 DCHECK(thread_checker_.CalledOnValidThread()); | 1269 DCHECK(thread_checker_.CalledOnValidThread()); |
1242 visit_database_observers_.RemoveObserver(observer); | 1270 visit_database_observers_.RemoveObserver(observer); |
1243 } | 1271 } |
1244 | 1272 |
1245 void HistoryService::NotifyVisitDBObserversOnAddVisit( | 1273 void HistoryService::NotifyVisitDBObserversOnAddVisit( |
1246 const history::BriefVisitInfo& info) { | 1274 const history::BriefVisitInfo& info) { |
1247 DCHECK(thread_checker_.CalledOnValidThread()); | 1275 DCHECK(thread_checker_.CalledOnValidThread()); |
1248 FOR_EACH_OBSERVER(history::VisitDatabaseObserver, visit_database_observers_, | 1276 FOR_EACH_OBSERVER(history::VisitDatabaseObserver, visit_database_observers_, |
1249 OnAddVisit(info)); | 1277 OnAddVisit(info)); |
1250 } | 1278 } |
OLD | NEW |