Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: chrome/browser/history/history_backend.cc

Issue 6651014: Applied the IconType. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <list> 7 #include <list>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 1689 matching lines...) Expand 10 before | Expand all | Expand 10 after
1700 // Check only a single type was given when the page_url was specified. 1700 // Check only a single type was given when the page_url was specified.
1701 DCHECK(!page_url || (page_url && (icon_types == FAV_ICON || 1701 DCHECK(!page_url || (page_url && (icon_types == FAV_ICON ||
1702 icon_types == TOUCH_ICON || icon_types == TOUCH_PRECOMPOSED_ICON))); 1702 icon_types == TOUCH_ICON || icon_types == TOUCH_PRECOMPOSED_ICON)));
1703 1703
1704 if (request->canceled()) 1704 if (request->canceled())
1705 return; 1705 return;
1706 1706
1707 bool know_favicon = false; 1707 bool know_favicon = false;
1708 bool expired = true; 1708 bool expired = true;
1709 scoped_refptr<RefCountedBytes> data; 1709 scoped_refptr<RefCountedBytes> data;
1710 IconType returned_icon_type = INVALID_ICON;
1710 1711
1711 if (thumbnail_db_.get()) { 1712 if (thumbnail_db_.get()) {
1712 IconType returned_icon_type;
1713 const FavIconID favicon_id = 1713 const FavIconID favicon_id =
1714 thumbnail_db_->GetFavIconIDForFavIconURL( 1714 thumbnail_db_->GetFavIconIDForFavIconURL(
1715 icon_url, icon_types, &returned_icon_type); 1715 icon_url, icon_types, &returned_icon_type);
1716 if (favicon_id) { 1716 if (favicon_id) {
1717 data = new RefCountedBytes; 1717 data = new RefCountedBytes;
1718 know_favicon = true; 1718 know_favicon = true;
1719 Time last_updated; 1719 Time last_updated;
1720 if (thumbnail_db_->GetFavIcon(favicon_id, &last_updated, &data->data, 1720 if (thumbnail_db_->GetFavIcon(favicon_id, &last_updated, &data->data,
1721 NULL)) { 1721 NULL)) {
1722 expired = (Time::Now() - last_updated) > 1722 expired = (Time::Now() - last_updated) >
1723 TimeDelta::FromDays(kFavIconRefetchDays); 1723 TimeDelta::FromDays(kFavIconRefetchDays);
1724 } 1724 }
1725 1725
1726 if (page_url) 1726 if (page_url)
1727 SetFavIconMapping(*page_url, favicon_id, returned_icon_type); 1727 SetFavIconMapping(*page_url, favicon_id, returned_icon_type);
1728 } 1728 }
1729 // else case, haven't cached entry yet. Caller is responsible for 1729 // else case, haven't cached entry yet. Caller is responsible for
1730 // downloading the favicon and invoking SetFavIcon. 1730 // downloading the favicon and invoking SetFavIcon.
1731 } 1731 }
1732 request->ForwardResult(GetFavIconRequest::TupleType( 1732 request->ForwardResult(GetFavIconRequest::TupleType(
1733 request->handle(), know_favicon, data, expired, 1733 request->handle(), know_favicon, data, expired,
1734 icon_url)); 1734 icon_url, returned_icon_type));
1735 } 1735 }
1736 1736
1737 void HistoryBackend::GetFavIconForURL( 1737 void HistoryBackend::GetFavIconForURL(
1738 scoped_refptr<GetFavIconRequest> request, 1738 scoped_refptr<GetFavIconRequest> request,
1739 const GURL& page_url, 1739 const GURL& page_url,
1740 int icon_types) { 1740 int icon_types) {
1741 if (request->canceled()) 1741 if (request->canceled())
1742 return; 1742 return;
1743 1743
1744 bool know_favicon = false; 1744 bool know_favicon = false;
1745 bool expired = false; 1745 bool expired = false;
1746 GURL icon_url; 1746 GURL icon_url;
1747 IconType icon_type = INVALID_ICON;
1747 1748
1748 scoped_refptr<RefCountedBytes> data; 1749 scoped_refptr<RefCountedBytes> data;
1749 1750
1750 if (db_.get() && thumbnail_db_.get()) { 1751 if (db_.get() && thumbnail_db_.get()) {
1751 // Time the query. 1752 // Time the query.
1752 TimeTicks beginning_time = TimeTicks::Now(); 1753 TimeTicks beginning_time = TimeTicks::Now();
1753 1754
1754 std::vector<IconMapping> icon_mappings; 1755 std::vector<IconMapping> icon_mappings;
1755 data = new RefCountedBytes; 1756 data = new RefCountedBytes;
1756 Time last_updated; 1757 Time last_updated;
1757 if (thumbnail_db_->GetIconMappingsForPageURL(page_url, &icon_mappings) && 1758 if (thumbnail_db_->GetIconMappingsForPageURL(page_url, &icon_mappings) &&
1758 (icon_mappings.front().icon_type & icon_types) && 1759 (icon_mappings.front().icon_type & icon_types) &&
1759 thumbnail_db_->GetFavIcon(icon_mappings.front().icon_id, &last_updated, 1760 thumbnail_db_->GetFavIcon(icon_mappings.front().icon_id, &last_updated,
1760 &data->data, &icon_url)) { 1761 &data->data, &icon_url)) {
1761 know_favicon = true; 1762 know_favicon = true;
1762 expired = (Time::Now() - last_updated) > 1763 expired = (Time::Now() - last_updated) >
1763 TimeDelta::FromDays(kFavIconRefetchDays); 1764 TimeDelta::FromDays(kFavIconRefetchDays);
1765 icon_type = icon_mappings.front().icon_type;
1764 } 1766 }
1765 1767
1766 UMA_HISTOGRAM_TIMES("History.GetFavIconForURL", 1768 UMA_HISTOGRAM_TIMES("History.GetFavIconForURL",
1767 TimeTicks::Now() - beginning_time); 1769 TimeTicks::Now() - beginning_time);
1768 } 1770 }
1769 1771
1770 request->ForwardResult( 1772 request->ForwardResult(
1771 GetFavIconRequest::TupleType(request->handle(), know_favicon, data, 1773 GetFavIconRequest::TupleType(request->handle(), know_favicon, data,
1772 expired, icon_url)); 1774 expired, icon_url, icon_type));
1773 } 1775 }
1774 1776
1775 void HistoryBackend::SetFavIcon( 1777 void HistoryBackend::SetFavIcon(
1776 const GURL& page_url, 1778 const GURL& page_url,
1777 const GURL& icon_url, 1779 const GURL& icon_url,
1778 scoped_refptr<RefCountedMemory> data, 1780 scoped_refptr<RefCountedMemory> data,
1779 IconType icon_type) { 1781 IconType icon_type) {
1780 DCHECK(data.get()); 1782 DCHECK(data.get());
1781 if (!thumbnail_db_.get() || !db_.get()) 1783 if (!thumbnail_db_.get() || !db_.get())
1782 return; 1784 return;
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
2255 return true; 2257 return true;
2256 } 2258 }
2257 2259
2258 BookmarkService* HistoryBackend::GetBookmarkService() { 2260 BookmarkService* HistoryBackend::GetBookmarkService() {
2259 if (bookmark_service_) 2261 if (bookmark_service_)
2260 bookmark_service_->BlockTillLoaded(); 2262 bookmark_service_->BlockTillLoaded();
2261 return bookmark_service_; 2263 return bookmark_service_;
2262 } 2264 }
2263 2265
2264 } // namespace history 2266 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698