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

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

Issue 7397021: Re-land r93365 - add RefCountedString (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 9 years, 5 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
« no previous file with comments | « chrome/browser/favicon/favicon_handler_unittest.cc ('k') | chrome/browser/history/top_sites.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 1504
1505 history::RedirectList redirects; 1505 history::RedirectList redirects;
1506 URLID url_id; 1506 URLID url_id;
1507 bool success = false; 1507 bool success = false;
1508 1508
1509 // If there are some redirects, try to get a thumbnail from the last 1509 // If there are some redirects, try to get a thumbnail from the last
1510 // redirect destination. 1510 // redirect destination.
1511 if (GetMostRecentRedirectsFrom(page_url, &redirects) && 1511 if (GetMostRecentRedirectsFrom(page_url, &redirects) &&
1512 !redirects.empty()) { 1512 !redirects.empty()) {
1513 if ((url_id = db_->GetRowForURL(redirects.back(), NULL))) 1513 if ((url_id = db_->GetRowForURL(redirects.back(), NULL)))
1514 success = thumbnail_db_->GetPageThumbnail(url_id, &(*data)->data); 1514 success = thumbnail_db_->GetPageThumbnail(url_id, &(*data)->data());
1515 } 1515 }
1516 1516
1517 // If we don't have a thumbnail from redirects, try the URL directly. 1517 // If we don't have a thumbnail from redirects, try the URL directly.
1518 if (!success) { 1518 if (!success) {
1519 if ((url_id = db_->GetRowForURL(page_url, NULL))) 1519 if ((url_id = db_->GetRowForURL(page_url, NULL)))
1520 success = thumbnail_db_->GetPageThumbnail(url_id, &(*data)->data); 1520 success = thumbnail_db_->GetPageThumbnail(url_id, &(*data)->data());
1521 } 1521 }
1522 1522
1523 // In this rare case, we start to mine the older redirect sessions 1523 // In this rare case, we start to mine the older redirect sessions
1524 // from the visit table to try to find a thumbnail. 1524 // from the visit table to try to find a thumbnail.
1525 if (!success) { 1525 if (!success) {
1526 success = GetThumbnailFromOlderRedirect(page_url, &(*data)->data); 1526 success = GetThumbnailFromOlderRedirect(page_url, &(*data)->data());
1527 } 1527 }
1528 1528
1529 if (!success) 1529 if (!success)
1530 *data = NULL; // This will tell the callback there was an error. 1530 *data = NULL; // This will tell the callback there was an error.
1531 1531
1532 UMA_HISTOGRAM_TIMES("History.GetPageThumbnail", 1532 UMA_HISTOGRAM_TIMES("History.GetPageThumbnail",
1533 TimeTicks::Now() - beginning_time); 1533 TimeTicks::Now() - beginning_time);
1534 } 1534 }
1535 } 1535 }
1536 1536
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1686 FaviconData favicon; 1686 FaviconData favicon;
1687 1687
1688 if (thumbnail_db_.get()) { 1688 if (thumbnail_db_.get()) {
1689 const FaviconID favicon_id = 1689 const FaviconID favicon_id =
1690 thumbnail_db_->GetFaviconIDForFaviconURL( 1690 thumbnail_db_->GetFaviconIDForFaviconURL(
1691 icon_url, icon_types, &favicon.icon_type); 1691 icon_url, icon_types, &favicon.icon_type);
1692 if (favicon_id) { 1692 if (favicon_id) {
1693 scoped_refptr<RefCountedBytes> data = new RefCountedBytes(); 1693 scoped_refptr<RefCountedBytes> data = new RefCountedBytes();
1694 favicon.known_icon = true; 1694 favicon.known_icon = true;
1695 Time last_updated; 1695 Time last_updated;
1696 if (thumbnail_db_->GetFavicon(favicon_id, &last_updated, &data->data, 1696 if (thumbnail_db_->GetFavicon(favicon_id, &last_updated, &data->data(),
1697 NULL)) { 1697 NULL)) {
1698 favicon.expired = (Time::Now() - last_updated) > 1698 favicon.expired = (Time::Now() - last_updated) >
1699 TimeDelta::FromDays(kFaviconRefetchDays); 1699 TimeDelta::FromDays(kFaviconRefetchDays);
1700 favicon.image_data = data; 1700 favicon.image_data = data;
1701 } 1701 }
1702 1702
1703 if (page_url) 1703 if (page_url)
1704 SetFaviconMapping(*page_url, favicon_id, favicon.icon_type); 1704 SetFaviconMapping(*page_url, favicon_id, favicon.icon_type);
1705 } 1705 }
1706 // else case, haven't cached entry yet. Caller is responsible for 1706 // else case, haven't cached entry yet. Caller is responsible for
(...skipping 15 matching lines...) Expand all
1722 if (db_.get() && thumbnail_db_.get()) { 1722 if (db_.get() && thumbnail_db_.get()) {
1723 // Time the query. 1723 // Time the query.
1724 TimeTicks beginning_time = TimeTicks::Now(); 1724 TimeTicks beginning_time = TimeTicks::Now();
1725 1725
1726 std::vector<IconMapping> icon_mappings; 1726 std::vector<IconMapping> icon_mappings;
1727 Time last_updated; 1727 Time last_updated;
1728 scoped_refptr<RefCountedBytes> data = new RefCountedBytes(); 1728 scoped_refptr<RefCountedBytes> data = new RefCountedBytes();
1729 if (thumbnail_db_->GetIconMappingsForPageURL(page_url, &icon_mappings) && 1729 if (thumbnail_db_->GetIconMappingsForPageURL(page_url, &icon_mappings) &&
1730 (icon_mappings.front().icon_type & icon_types) && 1730 (icon_mappings.front().icon_type & icon_types) &&
1731 thumbnail_db_->GetFavicon(icon_mappings.front().icon_id, &last_updated, 1731 thumbnail_db_->GetFavicon(icon_mappings.front().icon_id, &last_updated,
1732 &data->data, &favicon.icon_url)) { 1732 &data->data(), &favicon.icon_url)) {
1733 favicon.known_icon = true; 1733 favicon.known_icon = true;
1734 favicon.expired = (Time::Now() - last_updated) > 1734 favicon.expired = (Time::Now() - last_updated) >
1735 TimeDelta::FromDays(kFaviconRefetchDays); 1735 TimeDelta::FromDays(kFaviconRefetchDays);
1736 favicon.icon_type = icon_mappings.front().icon_type; 1736 favicon.icon_type = icon_mappings.front().icon_type;
1737 favicon.image_data = data; 1737 favicon.image_data = data;
1738 } 1738 }
1739 1739
1740 UMA_HISTOGRAM_TIMES("History.GetFavIconForURL", // historical name 1740 UMA_HISTOGRAM_TIMES("History.GetFavIconForURL", // historical name
1741 TimeTicks::Now() - beginning_time); 1741 TimeTicks::Now() - beginning_time);
1742 } 1742 }
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
2229 return true; 2229 return true;
2230 } 2230 }
2231 2231
2232 BookmarkService* HistoryBackend::GetBookmarkService() { 2232 BookmarkService* HistoryBackend::GetBookmarkService() {
2233 if (bookmark_service_) 2233 if (bookmark_service_)
2234 bookmark_service_->BlockTillLoaded(); 2234 bookmark_service_->BlockTillLoaded();
2235 return bookmark_service_; 2235 return bookmark_service_;
2236 } 2236 }
2237 2237
2238 } // namespace history 2238 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/favicon/favicon_handler_unittest.cc ('k') | chrome/browser/history/top_sites.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698