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

Unified Diff: chrome/browser/history/android/favicon_sql_handler.cc

Issue 10917041: Cleanup FaviconSQLHandler::Update (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved changes to thumbnail_database to http://codereview.chromium.org/10911149/ Created 8 years, 3 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 | « no previous file | chrome/browser/history/thumbnail_database.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/android/favicon_sql_handler.cc
diff --git a/chrome/browser/history/android/favicon_sql_handler.cc b/chrome/browser/history/android/favicon_sql_handler.cc
index dbf6eaf1bdc169741adf2a2ea8263b70ce194314..9fc5b9b5e7d1746e7ce0b1a25233c67693d678f6 100644
--- a/chrome/browser/history/android/favicon_sql_handler.cc
+++ b/chrome/browser/history/android/favicon_sql_handler.cc
@@ -31,45 +31,40 @@ FaviconSQLHandler::~FaviconSQLHandler() {
bool FaviconSQLHandler::Update(const HistoryAndBookmarkRow& row,
const TableIDRows& ids_set) {
- FaviconID favicon_id = 0;
- if (row.favicon_valid()) {
- // If the image_data will be updated, it is not reasonable to find if the
- // icon is already in database, just create a new favicon.
- // TODO(pkotwicz): Pass in real pixel size.
- favicon_id = thumbnail_db_->AddFavicon(
- GURL(),
- history::FAVICON,
- history::GetDefaultFaviconSizes(),
- row.favicon(),
- Time::Now(),
- gfx::Size());
-
- if (!favicon_id)
- return false;
- }
+ if (!row.favicon_valid())
+ return Delete(ids_set);
+
+ // If the image_data will be updated, it is not reasonable to find if the
+ // icon is already in database, just create a new favicon.
+ // TODO(pkotwicz): Pass in real pixel size.
+ FaviconID favicon_id = thumbnail_db_->AddFavicon(
+ GURL(),
+ history::FAVICON,
+ history::GetDefaultFaviconSizes(),
+ row.favicon(),
+ Time::Now(),
+ gfx::Size());
+
+ if (!favicon_id)
+ return false;
std::vector<FaviconID> favicon_ids;
for (TableIDRows::const_iterator i = ids_set.begin();
i != ids_set.end(); ++i) {
+ // Remove all icon mappings to favicons of type FAVICON.
std::vector<IconMapping> icon_mappings;
- if (thumbnail_db_->GetIconMappingsForPageURL(i->url, FAVICON,
- &icon_mappings)) {
- if (favicon_id) {
- if (!thumbnail_db_->UpdateIconMapping(icon_mappings[0].mapping_id,
- favicon_id))
- return false;
- } else {
- // Require to delete the icon mapping.
- if (!thumbnail_db_->DeleteIconMappings(i->url))
- return false;
- }
- // Keep the old icon for deleting it later if possible.
- favicon_ids.push_back(icon_mappings[0].icon_id);
- } else if (favicon_id) {
- // The URL doesn't have icon before, add the icon mapping.
- if (!thumbnail_db_->AddIconMapping(i->url, favicon_id))
+ thumbnail_db_->GetIconMappingsForPageURL(i->url, FAVICON, &icon_mappings);
+ for (std::vector<IconMapping>::const_iterator m = icon_mappings.begin();
+ m != icon_mappings.end(); ++m) {
+ if (!thumbnail_db_->DeleteIconMapping(m->mapping_id))
return false;
+
+ // Keep the old icon for deleting it later if possible.
+ favicon_ids.push_back(m->icon_id);
}
+ // Add the icon mapping.
+ if (!thumbnail_db_->AddIconMapping(i->url, favicon_id))
+ return false;
}
// As we update the favicon, Let's remove unused favicons if any.
if (!favicon_ids.empty() && !DeleteUnusedFavicon(favicon_ids))
« no previous file with comments | « no previous file | chrome/browser/history/thumbnail_database.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698