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