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

Unified Diff: chrome/browser/history/top_sites_impl.cc

Issue 14585015: Recommit the generate profile patch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Load the browser dll manually on Windows. Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/history/top_sites_impl.h ('k') | chrome/browser/history/top_sites_likely_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/top_sites_impl.cc
diff --git a/chrome/browser/history/top_sites_impl.cc b/chrome/browser/history/top_sites_impl.cc
index a00645329db3d6652704c4d39879106d6e04b173..9915d03ca04ea7b1135c7a71442c00d77fa80130 100644
--- a/chrome/browser/history/top_sites_impl.cc
+++ b/chrome/browser/history/top_sites_impl.cc
@@ -233,6 +233,41 @@ bool TopSitesImpl::SetPageThumbnail(const GURL& url,
return SetPageThumbnailEncoded(url, thumbnail_data, score);
}
+bool TopSitesImpl::SetPageThumbnailToJPEGBytes(
+ const GURL& url,
+ const base::RefCountedMemory* memory,
+ const ThumbnailScore& score) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ if (!loaded_) {
+ // TODO(sky): I need to cache these and apply them after the load
+ // completes.
+ return false;
+ }
+
+ bool add_temp_thumbnail = false;
+ if (!IsKnownURL(url)) {
+ if (!IsFull()) {
+ add_temp_thumbnail = true;
+ } else {
+ return false; // This URL is not known to us.
+ }
+ }
+
+ if (!HistoryService::CanAddURL(url))
+ return false; // It's not a real webpage.
+
+ if (add_temp_thumbnail) {
+ // Always remove the existing entry and then add it back. That way if we end
+ // up with too many temp thumbnails we'll prune the oldest first.
+ RemoveTemporaryThumbnailByURL(url);
+ AddTemporaryThumbnail(url, memory, score);
+ return true;
+ }
+
+ return SetPageThumbnailEncoded(url, memory, score);
+}
+
// WARNING: this function may be invoked on any thread.
void TopSitesImpl::GetMostVisitedURLs(
const GetMostVisitedURLsCallback& callback) {
@@ -519,7 +554,7 @@ TopSitesImpl::~TopSitesImpl() {
bool TopSitesImpl::SetPageThumbnailNoDB(
const GURL& url,
- const base::RefCountedBytes* thumbnail_data,
+ const base::RefCountedMemory* thumbnail_data,
const ThumbnailScore& score) {
// This should only be invoked when we know about the url.
DCHECK(cache_->IsKnownURL(url));
@@ -540,7 +575,7 @@ bool TopSitesImpl::SetPageThumbnailNoDB(
image->thumbnail.get())
return false; // The one we already have is better.
- image->thumbnail = const_cast<base::RefCountedBytes*>(thumbnail_data);
+ image->thumbnail = const_cast<base::RefCountedMemory*>(thumbnail_data);
image->thumbnail_score = new_score_with_redirects;
ResetThreadSafeImageCache();
@@ -549,7 +584,7 @@ bool TopSitesImpl::SetPageThumbnailNoDB(
bool TopSitesImpl::SetPageThumbnailEncoded(
const GURL& url,
- const base::RefCountedBytes* thumbnail,
+ const base::RefCountedMemory* thumbnail,
const ThumbnailScore& score) {
if (!SetPageThumbnailNoDB(url, thumbnail, score))
return false;
@@ -593,15 +628,16 @@ void TopSitesImpl::RemoveTemporaryThumbnailByURL(const GURL& url) {
}
}
-void TopSitesImpl::AddTemporaryThumbnail(const GURL& url,
- const base::RefCountedBytes* thumbnail,
- const ThumbnailScore& score) {
+void TopSitesImpl::AddTemporaryThumbnail(
+ const GURL& url,
+ const base::RefCountedMemory* thumbnail,
+ const ThumbnailScore& score) {
if (temp_images_.size() == kMaxTempTopImages)
temp_images_.erase(temp_images_.begin());
TempImage image;
image.first = url;
- image.second.thumbnail = const_cast<base::RefCountedBytes*>(thumbnail);
+ image.second.thumbnail = const_cast<base::RefCountedMemory*>(thumbnail);
image.second.thumbnail_score = score;
temp_images_.push_back(image);
}
« no previous file with comments | « chrome/browser/history/top_sites_impl.h ('k') | chrome/browser/history/top_sites_likely_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698