| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/history/core/browser/thumbnail_database.h" | 5 #include "components/history/core/browser/thumbnail_database.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1136 const char kRenameFaviconsTable[] = | 1136 const char kRenameFaviconsTable[] = |
| 1137 "ALTER TABLE favicons RENAME TO old_favicons"; | 1137 "ALTER TABLE favicons RENAME TO old_favicons"; |
| 1138 const char kCopyFavicons[] = | 1138 const char kCopyFavicons[] = |
| 1139 "INSERT INTO favicons (id, url, icon_type) " | 1139 "INSERT INTO favicons (id, url, icon_type) " |
| 1140 "SELECT mapping.new_icon_id, old.url, old.icon_type " | 1140 "SELECT mapping.new_icon_id, old.url, old.icon_type " |
| 1141 "FROM old_favicons AS old " | 1141 "FROM old_favicons AS old " |
| 1142 "JOIN temp.icon_id_mapping AS mapping " | 1142 "JOIN temp.icon_id_mapping AS mapping " |
| 1143 "ON (old.id = mapping.old_icon_id)"; | 1143 "ON (old.id = mapping.old_icon_id)"; |
| 1144 const char kDropOldFaviconsTable[] = "DROP TABLE old_favicons"; | 1144 const char kDropOldFaviconsTable[] = "DROP TABLE old_favicons"; |
| 1145 | 1145 |
| 1146 // Set the retained favicon bitmaps to be expired (last_updated == 0). |
| 1147 // The user may be deleting their favicon bitmaps because the favicon bitmaps |
| 1148 // are incorrect. Expiring a favicon bitmap causes it to be redownloaded when |
| 1149 // the user visits a page associated with the favicon bitmap. See |
| 1150 // crbug.com/474421 for an example of a bug which caused favicon bitmaps to |
| 1151 // become incorrect. |
| 1146 const char kRenameFaviconBitmapsTable[] = | 1152 const char kRenameFaviconBitmapsTable[] = |
| 1147 "ALTER TABLE favicon_bitmaps RENAME TO old_favicon_bitmaps"; | 1153 "ALTER TABLE favicon_bitmaps RENAME TO old_favicon_bitmaps"; |
| 1148 const char kCopyFaviconBitmaps[] = | 1154 const char kCopyFaviconBitmaps[] = |
| 1149 "INSERT INTO favicon_bitmaps " | 1155 "INSERT INTO favicon_bitmaps " |
| 1150 " (icon_id, last_updated, image_data, width, height, last_requested) " | 1156 " (icon_id, last_updated, image_data, width, height, last_requested) " |
| 1151 "SELECT mapping.new_icon_id, old.last_updated, " | 1157 "SELECT mapping.new_icon_id, 0, old.image_data, old.width, old.height," |
| 1152 " old.image_data, old.width, old.height, old.last_requested " | 1158 " old.last_requested " |
| 1153 "FROM old_favicon_bitmaps AS old " | 1159 "FROM old_favicon_bitmaps AS old " |
| 1154 "JOIN temp.icon_id_mapping AS mapping " | 1160 "JOIN temp.icon_id_mapping AS mapping " |
| 1155 "ON (old.icon_id = mapping.old_icon_id)"; | 1161 "ON (old.icon_id = mapping.old_icon_id)"; |
| 1156 const char kDropOldFaviconBitmapsTable[] = | 1162 const char kDropOldFaviconBitmapsTable[] = |
| 1157 "DROP TABLE old_favicon_bitmaps"; | 1163 "DROP TABLE old_favicon_bitmaps"; |
| 1158 | 1164 |
| 1159 // Rename existing tables to new location. | 1165 // Rename existing tables to new location. |
| 1160 if (!db_.Execute(kRenameIconMappingTable) || | 1166 if (!db_.Execute(kRenameIconMappingTable) || |
| 1161 !db_.Execute(kRenameFaviconsTable) || | 1167 !db_.Execute(kRenameFaviconsTable) || |
| 1162 !db_.Execute(kRenameFaviconBitmapsTable)) { | 1168 !db_.Execute(kRenameFaviconBitmapsTable)) { |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1372 meta_table_.SetVersionNumber(8); | 1378 meta_table_.SetVersionNumber(8); |
| 1373 meta_table_.SetCompatibleVersionNumber(std::min(8, kCompatibleVersionNumber)); | 1379 meta_table_.SetCompatibleVersionNumber(std::min(8, kCompatibleVersionNumber)); |
| 1374 return true; | 1380 return true; |
| 1375 } | 1381 } |
| 1376 | 1382 |
| 1377 bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() { | 1383 bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() { |
| 1378 return !db_.IsSQLValid("SELECT id, url, icon_type FROM favicons"); | 1384 return !db_.IsSQLValid("SELECT id, url, icon_type FROM favicons"); |
| 1379 } | 1385 } |
| 1380 | 1386 |
| 1381 } // namespace history | 1387 } // namespace history |
| OLD | NEW |