Chromium Code Reviews| 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 8767c69a81c9e73336ae401a86d5ca086b4d4917..353232619b198f131cc12ea7d31c26d22ae773e0 100644 |
| --- a/chrome/browser/history/android/favicon_sql_handler.cc |
| +++ b/chrome/browser/history/android/favicon_sql_handler.cc |
| @@ -51,22 +51,20 @@ bool FaviconSQLHandler::Update(const HistoryAndBookmarkRow& row, |
| std::vector<FaviconID> favicon_ids; |
| for (TableIDRows::const_iterator i = ids_set.begin(); |
| i != ids_set.end(); ++i) { |
| - IconMapping icon_mapping; |
| - if (thumbnail_db_->GetIconMappingForPageURL(i->url, FAVICON, |
| - &icon_mapping)) { |
| - if (favicon_id) { |
| - if (!thumbnail_db_->UpdateIconMapping(icon_mapping.mapping_id, |
| - favicon_id)) |
| - return false; |
| - } else { |
| - // Require to delete the icon mapping. |
| - if (!thumbnail_db_->DeleteIconMappings(i->url)) |
| - return false; |
| + // Remove existing icon mappings. |
| + std::vector<IconMapping> icon_mappings; |
| + if (thumbnail_db_->GetIconMappingsForPageURL(i->url, FAVICON, |
| + &icon_mappings)) { |
| + for (std::vector<IconMapping>::const_iterator m = icon_mappings.begin(); |
| + m != icon_mappings.end(); ++m) { |
| + // Keep the old icon for deleting it later if possible. |
| + favicon_ids.push_back(m->icon_id); |
| } |
| - // Keep the old icon for deleting it later if possible. |
| - favicon_ids.push_back(icon_mapping.icon_id); |
| - } else if (favicon_id) { |
| - // The URL doesn't have icon before, add the icon mapping. |
| + if (!thumbnail_db_->DeleteIconMappings(i->url)) |
| + return false; |
| + } |
| + if (favicon_id) { |
| + // Add the icon mapping. |
| if (!thumbnail_db_->AddIconMapping(i->url, favicon_id)) |
| return false; |
| } |
| @@ -82,17 +80,14 @@ bool FaviconSQLHandler::Delete(const TableIDRows& ids_set) { |
| std::vector<FaviconID> favicon_ids; |
| for (TableIDRows::const_iterator i = ids_set.begin(); |
| i != ids_set.end(); ++i) { |
| - // Since the URL was delete, we delete all type of icon mapping. |
| - IconMapping icon_mapping; |
| - if (thumbnail_db_->GetIconMappingForPageURL(i->url, FAVICON, |
| - &icon_mapping)) |
| - favicon_ids.push_back(icon_mapping.icon_id); |
| - if (thumbnail_db_->GetIconMappingForPageURL(i->url, TOUCH_ICON, |
| - &icon_mapping)) |
| - favicon_ids.push_back(icon_mapping.icon_id); |
| - if (thumbnail_db_->GetIconMappingForPageURL(i->url, |
| - TOUCH_PRECOMPOSED_ICON, &icon_mapping)) |
| - favicon_ids.push_back(icon_mapping.icon_id); |
| + // Since the URL was delete, we delete all types of icon mappings. |
|
stevenjb
2012/08/15 22:59:18
nit: was deleted
|
| + std::vector<IconMapping> icon_mappings; |
| + if (thumbnail_db_->GetIconMappingsForPageURL(i->url, &icon_mappings)) { |
| + for (std::vector<IconMapping>::const_iterator m = icon_mappings.begin(); |
| + m != icon_mappings.end(); ++m) { |
| + favicon_ids.push_back(m->icon_id); |
| + } |
| + } |
| if (!thumbnail_db_->DeleteIconMappings(i->url)) |
| return false; |
| } |