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

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

Issue 11830007: Avoid sending notifications when the bitmap data in history has not changed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Split the changes to MergeFavicon() and SetFavicons() into two CLs as only the changes to MergeFavi… Created 7 years, 11 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/history_backend.h ('k') | chrome/browser/history/history_backend_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/history_backend.cc
diff --git a/chrome/browser/history/history_backend.cc b/chrome/browser/history/history_backend.cc
index 34a0a30b2e08a7561fb6e5b7d50d8312fd1cab8d..e5a7c14bbf0b07d2a05f1a75e642d5344f2a1625 100644
--- a/chrome/browser/history/history_backend.cc
+++ b/chrome/browser/history/history_backend.cc
@@ -1931,6 +1931,13 @@ void HistoryBackend::MergeFavicon(
bool replaced_bitmap = false;
for (size_t i = 0; i < bitmap_id_sizes.size(); ++i) {
if (bitmap_id_sizes[i].pixel_size == pixel_size) {
+ if (IsFaviconBitmapDataEqual(bitmap_id_sizes[i].bitmap_id, bitmap_data)) {
+ thumbnail_db_->SetFaviconBitmapLastUpdateTime(
+ bitmap_id_sizes[i].bitmap_id, base::Time::Now());
+ // Return early as merging did not alter the bitmap data.
+ ScheduleCommit();
+ return;
+ }
thumbnail_db_->SetFaviconBitmap(bitmap_id_sizes[i].bitmap_id, bitmap_data,
base::Time::Now());
replaced_bitmap = true;
@@ -2316,6 +2323,20 @@ void HistoryBackend::SetFaviconSizes(FaviconID icon_id,
thumbnail_db_->SetFaviconSizes(icon_id, favicon_sizes);
}
+bool HistoryBackend::IsFaviconBitmapDataEqual(
+ FaviconBitmapID bitmap_id,
+ const scoped_refptr<base::RefCountedMemory>& new_bitmap_data) {
+ if (!new_bitmap_data.get())
+ return false;
+
+ scoped_refptr<base::RefCountedMemory> original_bitmap_data;
+ thumbnail_db_->GetFaviconBitmap(bitmap_id,
+ NULL,
+ &original_bitmap_data,
+ NULL);
+ return new_bitmap_data->Equals(original_bitmap_data);
+}
+
bool HistoryBackend::GetFaviconsFromDB(
const GURL& page_url,
int icon_types,
« no previous file with comments | « chrome/browser/history/history_backend.h ('k') | chrome/browser/history/history_backend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698