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 #include "chrome/browser/history/history_backend.h" | 5 #include "chrome/browser/history/history_backend.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <list> | 9 #include <list> |
10 #include <map> | 10 #include <map> |
(...skipping 1679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1690 const std::vector<GURL>& icon_urls, | 1690 const std::vector<GURL>& icon_urls, |
1691 int icon_types, | 1691 int icon_types, |
1692 int desired_size_in_dip, | 1692 int desired_size_in_dip, |
1693 const std::vector<ui::ScaleFactor>& desired_scale_factors, | 1693 const std::vector<ui::ScaleFactor>& desired_scale_factors, |
1694 std::vector<chrome::FaviconBitmapResult>* bitmap_results) { | 1694 std::vector<chrome::FaviconBitmapResult>* bitmap_results) { |
1695 UpdateFaviconMappingsAndFetchImpl(NULL, icon_urls, icon_types, | 1695 UpdateFaviconMappingsAndFetchImpl(NULL, icon_urls, icon_types, |
1696 desired_size_in_dip, desired_scale_factors, | 1696 desired_size_in_dip, desired_scale_factors, |
1697 bitmap_results); | 1697 bitmap_results); |
1698 } | 1698 } |
1699 | 1699 |
1700 void HistoryBackend::GetFaviconsForURL( | 1700 void HistoryBackend::GetFaviconsForURL( |
pkotwicz
2013/10/11 16:14:19
I think it may be best to create a new method in H
michaelbai
2013/10/11 16:34:32
I had discussed adding new method with sky offline
sky
2013/10/11 18:03:29
In looking at this bit more I agree with Peter. Th
| |
1701 const GURL& page_url, | 1701 const GURL& page_url, |
1702 int icon_types, | 1702 const std::vector<int>& icon_types, |
1703 int desired_size_in_dip, | 1703 int desired_size_in_dip, |
1704 const std::vector<ui::ScaleFactor>& desired_scale_factors, | 1704 const std::vector<ui::ScaleFactor>& desired_scale_factors, |
1705 int threshold_for_next_icon_types, | |
1705 std::vector<chrome::FaviconBitmapResult>* bitmap_results) { | 1706 std::vector<chrome::FaviconBitmapResult>* bitmap_results) { |
1706 DCHECK(bitmap_results); | 1707 DCHECK(bitmap_results); |
1707 GetFaviconsFromDB(page_url, icon_types, desired_size_in_dip, | 1708 chrome::FaviconBitmapResult bitmap_result; |
1708 desired_scale_factors, bitmap_results); | 1709 int bitmap_size_in_pixel = 0; |
1710 for (std::vector<int>::const_iterator i = icon_types.begin(); | |
1711 i != icon_types.end(); i++) { | |
sky
2013/10/11 18:03:29
always use pre-increment for iterators.
| |
1712 GetFaviconsFromDB(page_url, *i, desired_size_in_dip, desired_scale_factors, | |
1713 bitmap_results); | |
1714 if (icon_types.size() == 1) | |
1715 return; | |
1716 | |
1717 for (std::vector<chrome::FaviconBitmapResult>::const_iterator j = | |
1718 bitmap_results->begin(); j != bitmap_results->end(); j++) { | |
1719 if (bitmap_size_in_pixel < j->pixel_size.width() && | |
1720 bitmap_size_in_pixel < j->pixel_size.height()) { | |
1721 bitmap_size_in_pixel = std::min(j->pixel_size.width(), | |
1722 j->pixel_size.height()); | |
1723 bitmap_result = *j; | |
1724 } | |
1725 } | |
1726 bitmap_results->clear(); | |
sky
2013/10/11 18:03:29
Don't reuse the passed in vector, that's just conf
| |
1727 if (bitmap_size_in_pixel > threshold_for_next_icon_types) | |
sky
2013/10/11 18:03:29
Why is threshold_for_next_icon_types applied to al
| |
1728 break; | |
1729 } | |
1730 if (bitmap_size_in_pixel != 0) | |
1731 bitmap_results->push_back(bitmap_result); | |
1709 } | 1732 } |
1710 | 1733 |
1711 void HistoryBackend::GetFaviconForID( | 1734 void HistoryBackend::GetFaviconForID( |
1712 chrome::FaviconID favicon_id, | 1735 chrome::FaviconID favicon_id, |
1713 int desired_size_in_dip, | 1736 int desired_size_in_dip, |
1714 ui::ScaleFactor desired_scale_factor, | 1737 ui::ScaleFactor desired_scale_factor, |
1715 std::vector<chrome::FaviconBitmapResult>* bitmap_results) { | 1738 std::vector<chrome::FaviconBitmapResult>* bitmap_results) { |
1716 std::vector<chrome::FaviconID> favicon_ids; | 1739 std::vector<chrome::FaviconID> favicon_ids; |
1717 favicon_ids.push_back(favicon_id); | 1740 favicon_ids.push_back(favicon_id); |
1718 std::vector<ui::ScaleFactor> desired_scale_factors; | 1741 std::vector<ui::ScaleFactor> desired_scale_factors; |
(...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2883 int rank = kPageVisitStatsMaxTopSites; | 2906 int rank = kPageVisitStatsMaxTopSites; |
2884 std::map<GURL, int>::const_iterator it = most_visited_urls_map_.find(url); | 2907 std::map<GURL, int>::const_iterator it = most_visited_urls_map_.find(url); |
2885 if (it != most_visited_urls_map_.end()) | 2908 if (it != most_visited_urls_map_.end()) |
2886 rank = (*it).second; | 2909 rank = (*it).second; |
2887 UMA_HISTOGRAM_ENUMERATION("History.TopSitesVisitsByRank", | 2910 UMA_HISTOGRAM_ENUMERATION("History.TopSitesVisitsByRank", |
2888 rank, kPageVisitStatsMaxTopSites + 1); | 2911 rank, kPageVisitStatsMaxTopSites + 1); |
2889 } | 2912 } |
2890 #endif | 2913 #endif |
2891 | 2914 |
2892 } // namespace history | 2915 } // namespace history |
OLD | NEW |