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 b52aef421d29f906d1d53f17511928bf7506d07d..ce0b509031fac296ae60fd61311d8c4e92393926 100644 |
| --- a/chrome/browser/history/android/favicon_sql_handler.cc |
| +++ b/chrome/browser/history/android/favicon_sql_handler.cc |
| @@ -8,6 +8,7 @@ |
| #include "base/memory/ref_counted.h" |
| #include "base/memory/ref_counted_memory.h" |
| #include "chrome/browser/history/thumbnail_database.h" |
| +#include "ui/gfx/favicon_size.h" |
| using base::Time; |
| @@ -19,6 +20,11 @@ namespace { |
| const HistoryAndBookmarkRow::ColumnID kInterestingColumns[] = { |
| HistoryAndBookmarkRow::FAVICON}; |
| +// This size is used by FaviconSQLHandler as the favicon's "requested size". |
| +// See the comment in History::SetFavicon for a definition of "requested size". |
| +const gfx::Size kDefaultFaviconSize = |
|
stevenjb
2012/07/30 23:58:16
We should define this with gfx::kFaviconSize, i.e.
|
| + gfx::Size(gfx::kFaviconSize, gfx::kFaviconSize); |
| + |
| } // namespace |
| FaviconSQLHandler::FaviconSQLHandler(ThumbnailDatabase* thumbnail_db) |
| @@ -35,7 +41,8 @@ bool FaviconSQLHandler::Update(const HistoryAndBookmarkRow& row, |
| if (!row.favicon().empty()) { |
| // 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. |
| - favicon_id = thumbnail_db_->AddFavicon(GURL(), history::FAVICON); |
| + favicon_id = thumbnail_db_->AddFavicon(GURL(), kDefaultFaviconSize, |
| + history::FAVICON); |
| if (!favicon_id) |
| return false; |
| @@ -48,20 +55,22 @@ 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; |
| + 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) { |
| + if (favicon_id) { |
| + if (!thumbnail_db_->UpdateIconMapping(m->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(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_->AddIconMapping(i->url, favicon_id)) |
| @@ -79,17 +88,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/07/30 23:58:16
s/was delete/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; |
| } |
| @@ -111,7 +117,8 @@ bool FaviconSQLHandler::Insert(HistoryAndBookmarkRow* row) { |
| DCHECK(row->is_value_set_explicitly(HistoryAndBookmarkRow::URL)); |
| // Is it a problem to give a empty URL? |
| - FaviconID id = thumbnail_db_->AddFavicon(GURL(), history::FAVICON); |
| + FaviconID id = thumbnail_db_->AddFavicon(GURL(), kDefaultFaviconSize, |
| + history::FAVICON); |
| if (!id) |
| return false; |