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

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

Issue 2499003: Write thumbnail to the database on SetPageThumbnail.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 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.h ('k') | chrome/browser/history/top_sites_database.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/top_sites.cc
===================================================================
--- chrome/browser/history/top_sites.cc (revision 48639)
+++ chrome/browser/history/top_sites.cc (working copy)
@@ -47,12 +47,14 @@
MostVisitedURL url = top_sites_[i];
Images thumbnail;
if (db_->GetPageThumbnail(url, &thumbnail)) {
- SetPageThumbnail(url.url, thumbnail.thumbnail, thumbnail.thumbnail_score);
+ SetPageThumbnailNoDB(url.url, thumbnail.thumbnail,
+ thumbnail.thumbnail_score);
}
}
}
-// Public wrapper that encodes the bitmap into RefCountedBytes.
+// Public function that encodes the bitmap into RefCountedBytes and
+// updates the database.
bool TopSites::SetPageThumbnail(const GURL& url,
const SkBitmap& thumbnail,
const ThumbnailScore& score) {
@@ -66,13 +68,26 @@
&thumbnail_data->data);
if (!encoded)
return false;
- return SetPageThumbnail(url, thumbnail_data, score);
+ if (!SetPageThumbnailNoDB(url, thumbnail_data, score))
+ return false;
+
+ // Update the database.
+ if (!db_.get())
+ return true;
+ std::map<GURL, size_t>::iterator found = canonical_urls_.find(url);
+ if (found == canonical_urls_.end())
+ return false;
+ size_t index = found->second;
+
+ MostVisitedURL& most_visited = top_sites_[index];
+ db_->SetPageThumbnail(most_visited, index, top_images_[most_visited.url]);
+ return true;
}
// private
-bool TopSites::SetPageThumbnail(const GURL& url,
- const RefCountedBytes* thumbnail_data,
- const ThumbnailScore& score) {
+bool TopSites::SetPageThumbnailNoDB(const GURL& url,
+ const RefCountedBytes* thumbnail_data,
+ const ThumbnailScore& score) {
AutoLock lock(lock_);
std::map<GURL, size_t>::iterator found = canonical_urls_.find(url);
« no previous file with comments | « chrome/browser/history/top_sites.h ('k') | chrome/browser/history/top_sites_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698