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

Side by Side Diff: components/history/core/browser/history_backend.cc

Issue 2721363002: Extend LargeIconService to fetch missing favicons from a Google server (Closed)
Patch Set: Added missing dependencies. Created 3 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
OLDNEW
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 "components/history/core/browser/history_backend.h" 5 #include "components/history/core/browser/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 1681 matching lines...) Expand 10 before | Expand all | Expand 10 after
1692 if (!favicon_created && (!bitmap_identical || favicon_bitmaps_copied)) { 1692 if (!favicon_created && (!bitmap_identical || favicon_bitmaps_copied)) {
1693 // If there was a favicon at |icon_url| prior to MergeFavicon() being 1693 // If there was a favicon at |icon_url| prior to MergeFavicon() being
1694 // called, there may be page URLs which also use the favicon at |icon_url|. 1694 // called, there may be page URLs which also use the favicon at |icon_url|.
1695 // Notify the UI that the favicon has changed for |icon_url|. 1695 // Notify the UI that the favicon has changed for |icon_url|.
1696 SendFaviconChangedNotificationForIconURL(icon_url); 1696 SendFaviconChangedNotificationForIconURL(icon_url);
1697 } 1697 }
1698 1698
1699 ScheduleCommit(); 1699 ScheduleCommit();
1700 } 1700 }
1701 1701
1702 void HistoryBackend::SetFavicons(const GURL& page_url, 1702 favicon_base::FaviconID HistoryBackend::SetFavicons(
1703 favicon_base::IconType icon_type, 1703 const GURL& page_url,
1704 const GURL& icon_url, 1704 favicon_base::IconType icon_type,
1705 const std::vector<SkBitmap>& bitmaps) { 1705 const GURL& icon_url,
1706 const std::vector<SkBitmap>& bitmaps) {
1706 if (!thumbnail_db_ || !db_) 1707 if (!thumbnail_db_ || !db_)
1707 return; 1708 return favicon_base::FaviconID(0);
1708 1709
1709 DCHECK_GE(kMaxFaviconBitmapsPerIconURL, bitmaps.size()); 1710 DCHECK_GE(kMaxFaviconBitmapsPerIconURL, bitmaps.size());
1710 1711
1711 favicon_base::FaviconID icon_id = 1712 favicon_base::FaviconID icon_id =
1712 thumbnail_db_->GetFaviconIDForFaviconURL(icon_url, icon_type, nullptr); 1713 thumbnail_db_->GetFaviconIDForFaviconURL(icon_url, icon_type, nullptr);
1713 1714
1714 bool favicon_created = false; 1715 bool favicon_created = false;
1715 if (!icon_id) { 1716 if (!icon_id) {
1716 icon_id = thumbnail_db_->AddFavicon(icon_url, icon_type); 1717 icon_id = thumbnail_db_->AddFavicon(icon_url, icon_type);
1717 favicon_created = true; 1718 favicon_created = true;
(...skipping 10 matching lines...) Expand all
1728 SendFaviconChangedNotificationForPageAndRedirects(page_url); 1729 SendFaviconChangedNotificationForPageAndRedirects(page_url);
1729 } 1730 }
1730 1731
1731 if (favicon_data_modified && !favicon_created) { 1732 if (favicon_data_modified && !favicon_created) {
1732 // If there was a favicon at |icon_url| prior to SetFavicons() being called, 1733 // If there was a favicon at |icon_url| prior to SetFavicons() being called,
1733 // there may be page URLs which also use the favicon at |icon_url|. Notify 1734 // there may be page URLs which also use the favicon at |icon_url|. Notify
1734 // the UI that the favicon has changed for |icon_url|. 1735 // the UI that the favicon has changed for |icon_url|.
1735 SendFaviconChangedNotificationForIconURL(icon_url); 1736 SendFaviconChangedNotificationForIconURL(icon_url);
1736 } 1737 }
1737 ScheduleCommit(); 1738 ScheduleCommit();
1739 return icon_id;
1740 }
1741
1742 void HistoryBackend::SetExpiredFaviconsIfNoneKnown(
pkotwicz 2017/03/08 05:38:16 You should add a test testing that this method doe
mastiz 2017/03/08 16:37:33 Will do, I'll add the tests once the rest looks OK
1743 const GURL& page_url,
1744 favicon_base::IconType icon_type,
1745 const GURL& icon_url,
1746 const std::vector<SkBitmap>& bitmaps) {
1747 if (!thumbnail_db_ || !db_)
1748 return;
1749
pkotwicz 2017/03/03 22:33:25 Given that |page_url| is currently a substring of
pkotwicz 2017/03/08 05:38:16 Ping on this comment
mastiz 2017/03/08 16:37:33 I think it's rather hacky to make such assumption
pkotwicz 2017/03/09 02:25:57 The sync code uses |page_url| if |icon_url| is mis
mastiz 2017/03/15 16:58:10 The server-side guys have implemented including th
pkotwicz 2017/03/16 00:50:45 In this case, this function should check that ther
mastiz 2017/03/21 12:09:17 This change has landed in the form of a dedicated
1750 if (!thumbnail_db_->GetIconMappingsForPageURL(page_url,
1751 /*mapping_data*/ nullptr)) {
1752 favicon_base::FaviconID icon_id =
1753 SetFavicons(page_url, icon_type, icon_url, bitmaps);
1754 thumbnail_db_->SetFaviconOutOfDate(icon_id);
pkotwicz 2017/03/03 22:33:25 Don't you need to run ScheduleCommit()? The Sched
mastiz 2017/03/08 16:37:33 Done, added the redundant ScheduleCommit() for cla
1755 }
1738 } 1756 }
1739 1757
1740 void HistoryBackend::SetFaviconsOutOfDateForPage(const GURL& page_url) { 1758 void HistoryBackend::SetFaviconsOutOfDateForPage(const GURL& page_url) {
1741 std::vector<IconMapping> icon_mappings; 1759 std::vector<IconMapping> icon_mappings;
1742 1760
1743 if (!thumbnail_db_ || 1761 if (!thumbnail_db_ ||
1744 !thumbnail_db_->GetIconMappingsForPageURL(page_url, &icon_mappings)) 1762 !thumbnail_db_->GetIconMappingsForPageURL(page_url, &icon_mappings))
1745 return; 1763 return;
1746 1764
1747 for (std::vector<IconMapping>::iterator m = icon_mappings.begin(); 1765 for (std::vector<IconMapping>::iterator m = icon_mappings.begin();
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after
2601 // transaction is currently open. 2619 // transaction is currently open.
2602 db_->CommitTransaction(); 2620 db_->CommitTransaction();
2603 db_->Vacuum(); 2621 db_->Vacuum();
2604 db_->BeginTransaction(); 2622 db_->BeginTransaction();
2605 db_->GetStartDate(&first_recorded_time_); 2623 db_->GetStartDate(&first_recorded_time_);
2606 2624
2607 return true; 2625 return true;
2608 } 2626 }
2609 2627
2610 } // namespace history 2628 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698