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

Side by Side Diff: components/history/core/browser/thumbnail_database.cc

Issue 1004373002: Add last_requested field to the favicon_bitmaps table of the favicons database. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments and rebase for changes exported to other CLs Created 5 years, 8 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 unified diff | Download patch
OLDNEW
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 // the link tag. The FAVICON type is used for the default 51 // the link tag. The FAVICON type is used for the default
52 // favicon.ico favicon. 52 // favicon.ico favicon.
53 // 53 //
54 // favicon_bitmaps This table contains the PNG encoded bitmap data of the 54 // favicon_bitmaps This table contains the PNG encoded bitmap data of the
55 // favicons. There is a separate row for every size in a 55 // favicons. There is a separate row for every size in a
56 // multi resolution bitmap. The bitmap data is associated 56 // multi resolution bitmap. The bitmap data is associated
57 // to the favicon via the |icon_id| field which matches 57 // to the favicon via the |icon_id| field which matches
58 // the |id| field in the appropriate row in the |favicons| 58 // the |id| field in the appropriate row in the |favicons|
59 // table. 59 // table.
60 // 60 //
61 // id Unique ID. 61 // id Unique ID.
62 // icon_id The ID of the favicon that the bitmap is associated to. 62 // icon_id The ID of the favicon that the bitmap is associated to.
63 // last_updated The time at which this favicon was inserted into the 63 // last_updated The time at which this favicon was inserted into the
64 // table. This is used to determine if it needs to be 64 // table. This is used to determine if it needs to be
65 // redownloaded from the web. 65 // redownloaded from the web.
66 // image_data PNG encoded data of the favicon. 66 // last_requested The time at which this bitmap was last requested. This is
67 // width Pixel width of |image_data|. 67 // used to determine the priority with which the bitmap
68 // height Pixel height of |image_data|. 68 // should be retained on cleanup.
69 // image_data PNG encoded data of the favicon.
70 // width Pixel width of |image_data|.
71 // height Pixel height of |image_data|.
69 72
70 namespace { 73 namespace {
71 74
72 // For this database, schema migrations are deprecated after two 75 // For this database, schema migrations are deprecated after two
73 // years. This means that the oldest non-deprecated version should be 76 // years. This means that the oldest non-deprecated version should be
74 // two years old or greater (thus the migrations to get there are 77 // two years old or greater (thus the migrations to get there are
75 // older). Databases containing deprecated versions will be cleared 78 // older). Databases containing deprecated versions will be cleared
76 // at startup. Since this database is a cache, losing old data is not 79 // at startup. Since this database is a cache, losing old data is not
77 // fatal (in fact, very old data may be expired immediately at startup 80 // fatal (in fact, very old data may be expired immediately at startup
78 // anyhow). 81 // anyhow).
79 82
83 // Version 8: ???????? by rogerm@chromium.org on 2015-??-??
80 // Version 7: 911a634d/r209424 by qsr@chromium.org on 2013-07-01 84 // Version 7: 911a634d/r209424 by qsr@chromium.org on 2013-07-01
81 // Version 6: 610f923b/r152367 by pkotwicz@chromium.org on 2012-08-20 85 // Version 6: 610f923b/r152367 by pkotwicz@chromium.org on 2012-08-20
82 // Version 5: e2ee8ae9/r105004 by groby@chromium.org on 2011-10-12 (deprecated) 86 // Version 5: e2ee8ae9/r105004 by groby@chromium.org on 2011-10-12 (deprecated)
83 // Version 4: 5f104d76/r77288 by sky@chromium.org on 2011-03-08 (deprecated) 87 // Version 4: 5f104d76/r77288 by sky@chromium.org on 2011-03-08 (deprecated)
84 // Version 3: 09911bf3/r15 by initial.commit on 2008-07-26 (deprecated) 88 // Version 3: 09911bf3/r15 by initial.commit on 2008-07-26 (deprecated)
85 89
86 // Version number of the database. 90 // Version number of the database.
87 // NOTE(shess): When changing the version, add a new golden file for 91 // NOTE(shess): When changing the version, add a new golden file for
88 // the new version and a test to verify that Init() works with it. 92 // the new version and a test to verify that Init() works with it.
89 const int kCurrentVersionNumber = 7; 93 const int kCurrentVersionNumber = 8;
90 const int kCompatibleVersionNumber = 7; 94 const int kCompatibleVersionNumber = 8;
91 const int kDeprecatedVersionNumber = 5; // and earlier. 95 const int kDeprecatedVersionNumber = 5; // and earlier.
92 96
93 void FillIconMapping(const sql::Statement& statement, 97 void FillIconMapping(const sql::Statement& statement,
94 const GURL& page_url, 98 const GURL& page_url,
95 IconMapping* icon_mapping) { 99 IconMapping* icon_mapping) {
96 icon_mapping->mapping_id = statement.ColumnInt64(0); 100 icon_mapping->mapping_id = statement.ColumnInt64(0);
97 icon_mapping->icon_id = statement.ColumnInt64(1); 101 icon_mapping->icon_id = statement.ColumnInt64(1);
98 icon_mapping->icon_type = 102 icon_mapping->icon_type =
99 static_cast<favicon_base::IconType>(statement.ColumnInt(2)); 103 static_cast<favicon_base::IconType>(statement.ColumnInt(2));
100 icon_mapping->icon_url = GURL(statement.ColumnString(3)); 104 icon_mapping->icon_url = GURL(statement.ColumnString(3));
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 return false; 307 return false;
304 308
305 const char kFaviconBitmapsSql[] = 309 const char kFaviconBitmapsSql[] =
306 "CREATE TABLE IF NOT EXISTS favicon_bitmaps" 310 "CREATE TABLE IF NOT EXISTS favicon_bitmaps"
307 "(" 311 "("
308 "id INTEGER PRIMARY KEY," 312 "id INTEGER PRIMARY KEY,"
309 "icon_id INTEGER NOT NULL," 313 "icon_id INTEGER NOT NULL,"
310 "last_updated INTEGER DEFAULT 0," 314 "last_updated INTEGER DEFAULT 0,"
311 "image_data BLOB," 315 "image_data BLOB,"
312 "width INTEGER DEFAULT 0," 316 "width INTEGER DEFAULT 0,"
313 "height INTEGER DEFAULT 0" 317 "height INTEGER DEFAULT 0,"
318 // This field is at the end so that fresh tables and migrated tables have
319 // the same layout.
320 "last_requested INTEGER DEFAULT 0"
314 ")"; 321 ")";
315 if (!db->Execute(kFaviconBitmapsSql)) 322 if (!db->Execute(kFaviconBitmapsSql))
316 return false; 323 return false;
317 324
318 return true; 325 return true;
319 } 326 }
320 327
321 // NOTE(shess): Schema modifications must consider initial creation in 328 // NOTE(shess): Schema modifications must consider initial creation in
322 // |InitImpl()|, recovery in |RecoverDatabaseOrRaze()|, and history pruning in 329 // |InitImpl()|, recovery in |RecoverDatabaseOrRaze()|, and history pruning in
323 // |RetainDataForPageUrls()|. 330 // |RetainDataForPageUrls()|.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 // Recover the database to the extent possible, razing it if recovery 396 // Recover the database to the extent possible, razing it if recovery
390 // is not possible. 397 // is not possible.
391 // TODO(shess): This is mostly just a safe proof of concept. In the 398 // TODO(shess): This is mostly just a safe proof of concept. In the
392 // real world, this database is probably not worthwhile recovering, as 399 // real world, this database is probably not worthwhile recovering, as
393 // opposed to just razing it and starting over whenever corruption is 400 // opposed to just razing it and starting over whenever corruption is
394 // detected. So this database is a good test subject. 401 // detected. So this database is a good test subject.
395 void RecoverDatabaseOrRaze(sql::Connection* db, const base::FilePath& db_path) { 402 void RecoverDatabaseOrRaze(sql::Connection* db, const base::FilePath& db_path) {
396 // NOTE(shess): This code is currently specific to the version 403 // NOTE(shess): This code is currently specific to the version
397 // number. I am working on simplifying things to loosen the 404 // number. I am working on simplifying things to loosen the
398 // dependency, meanwhile contact me if you need to bump the version. 405 // dependency, meanwhile contact me if you need to bump the version.
399 DCHECK_EQ(7, kCurrentVersionNumber); 406 DCHECK_EQ(8, kCurrentVersionNumber);
400 407
401 // TODO(shess): Reset back after? 408 // TODO(shess): Reset back after?
402 db->reset_error_callback(); 409 db->reset_error_callback();
403 410
404 // For histogram purposes. 411 // For histogram purposes.
405 size_t favicons_rows_recovered = 0; 412 size_t favicons_rows_recovered = 0;
406 size_t favicon_bitmaps_rows_recovered = 0; 413 size_t favicon_bitmaps_rows_recovered = 0;
407 size_t icon_mapping_rows_recovered = 0; 414 size_t icon_mapping_rows_recovered = 0;
408 int64 original_size = 0; 415 int64 original_size = 0;
409 base::GetFileSize(db_path, &original_size); 416 base::GetFileSize(db_path, &original_size);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 // NOTE(shess,rogerm): v6 is not currently deprecated in the normal Init() 448 // NOTE(shess,rogerm): v6 is not currently deprecated in the normal Init()
442 // path, but is deprecated in the recovery path in the interest of keeping 449 // path, but is deprecated in the recovery path in the interest of keeping
443 // the code simple. http://crbug.com/327485 for numbers. 450 // the code simple. http://crbug.com/327485 for numbers.
444 DCHECK_LE(kDeprecatedVersionNumber, 6); 451 DCHECK_LE(kDeprecatedVersionNumber, 6);
445 if (version <= 6) { 452 if (version <= 6) {
446 sql::Recovery::Unrecoverable(recovery.Pass()); 453 sql::Recovery::Unrecoverable(recovery.Pass());
447 RecordRecoveryEvent(RECOVERY_EVENT_DEPRECATED); 454 RecordRecoveryEvent(RECOVERY_EVENT_DEPRECATED);
448 return; 455 return;
449 } 456 }
450 457
451 // Earlier versions have been handled or deprecated, later versions should be 458 // Earlier versions have been handled or deprecated.
452 // impossible. 459 if (version < 7) {
453 if (version != 7) {
454 sql::Recovery::Unrecoverable(recovery.Pass()); 460 sql::Recovery::Unrecoverable(recovery.Pass());
455 RecordRecoveryEvent(RECOVERY_EVENT_FAILED_META_WRONG_VERSION); 461 RecordRecoveryEvent(RECOVERY_EVENT_FAILED_META_WRONG_VERSION);
456 return; 462 return;
457 } 463 }
458 464
459 // Recover to current schema version. 465 // Recover to current schema version.
460 sql::MetaTable recover_meta_table; 466 sql::MetaTable recover_meta_table;
461 if (!recover_meta_table.Init(recovery->db(), kCurrentVersionNumber, 467 if (!recover_meta_table.Init(recovery->db(), kCurrentVersionNumber,
462 kCompatibleVersionNumber)) { 468 kCompatibleVersionNumber)) {
463 sql::Recovery::Rollback(recovery.Pass()); 469 sql::Recovery::Rollback(recovery.Pass());
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 *png_icon_data = data; 726 *png_icon_data = data;
721 } 727 }
722 728
723 if (pixel_size) { 729 if (pixel_size) {
724 *pixel_size = gfx::Size(statement.ColumnInt(2), 730 *pixel_size = gfx::Size(statement.ColumnInt(2),
725 statement.ColumnInt(3)); 731 statement.ColumnInt(3));
726 } 732 }
727 return true; 733 return true;
728 } 734 }
729 735
736 bool ThumbnailDatabase::GetFaviconBitmapLastRequestedTime(
737 FaviconBitmapID bitmap_id,
738 base::Time* last_requested) {
739 DCHECK(bitmap_id);
740 DCHECK(last_requested);
741 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE,
742 "SELECT last_requested FROM favicon_bitmaps WHERE id=?"));
743 statement.BindInt64(0, bitmap_id);
744
745 if (!statement.Step())
746 return false;
747
748 *last_requested = base::Time::FromInternalValue(statement.ColumnInt64(0));
749 return true;
750 }
751
730 FaviconBitmapID ThumbnailDatabase::AddFaviconBitmap( 752 FaviconBitmapID ThumbnailDatabase::AddFaviconBitmap(
731 favicon_base::FaviconID icon_id, 753 favicon_base::FaviconID icon_id,
732 const scoped_refptr<base::RefCountedMemory>& icon_data, 754 const scoped_refptr<base::RefCountedMemory>& icon_data,
733 base::Time time, 755 base::Time time,
734 const gfx::Size& pixel_size) { 756 const gfx::Size& pixel_size) {
735 DCHECK(icon_id); 757 DCHECK(icon_id);
736 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, 758 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE,
737 "INSERT INTO favicon_bitmaps (icon_id, image_data, last_updated, width, " 759 "INSERT INTO favicon_bitmaps (icon_id, image_data, last_updated, width, "
738 "height) VALUES (?, ?, ?, ?, ?)")); 760 "height) VALUES (?, ?, ?, ?, ?)"));
739 statement.BindInt64(0, icon_id); 761 statement.BindInt64(0, icon_id);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 FaviconBitmapID bitmap_id, 797 FaviconBitmapID bitmap_id,
776 base::Time time) { 798 base::Time time) {
777 DCHECK(bitmap_id); 799 DCHECK(bitmap_id);
778 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, 800 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE,
779 "UPDATE favicon_bitmaps SET last_updated=? WHERE id=?")); 801 "UPDATE favicon_bitmaps SET last_updated=? WHERE id=?"));
780 statement.BindInt64(0, time.ToInternalValue()); 802 statement.BindInt64(0, time.ToInternalValue());
781 statement.BindInt64(1, bitmap_id); 803 statement.BindInt64(1, bitmap_id);
782 return statement.Run(); 804 return statement.Run();
783 } 805 }
784 806
807 bool ThumbnailDatabase::SetFaviconBitmapLastRequestedTime(
808 FaviconBitmapID bitmap_id,
809 base::Time time) {
810 DCHECK(bitmap_id);
811 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE,
812 "UPDATE favicon_bitmaps SET last_requested=? WHERE id=?"));
813 statement.BindInt64(0, time.ToInternalValue());
814 statement.BindInt64(1, bitmap_id);
815 return statement.Run();
816 }
817
785 bool ThumbnailDatabase::DeleteFaviconBitmap(FaviconBitmapID bitmap_id) { 818 bool ThumbnailDatabase::DeleteFaviconBitmap(FaviconBitmapID bitmap_id) {
786 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, 819 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE,
787 "DELETE FROM favicon_bitmaps WHERE id=?")); 820 "DELETE FROM favicon_bitmaps WHERE id=?"));
788 statement.BindInt64(0, bitmap_id); 821 statement.BindInt64(0, bitmap_id);
789 return statement.Run(); 822 return statement.Run();
790 } 823 }
791 824
792 bool ThumbnailDatabase::SetFaviconOutOfDate(favicon_base::FaviconID icon_id) { 825 bool ThumbnailDatabase::SetFaviconOutOfDate(favicon_base::FaviconID icon_id) {
793 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, 826 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE,
794 "UPDATE favicon_bitmaps SET last_updated=? WHERE icon_id=?")); 827 "UPDATE favicon_bitmaps SET last_updated=? WHERE icon_id=?"));
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 "SELECT mapping.new_icon_id, old.url, old.icon_type " 1116 "SELECT mapping.new_icon_id, old.url, old.icon_type "
1084 "FROM old_favicons AS old " 1117 "FROM old_favicons AS old "
1085 "JOIN temp.icon_id_mapping AS mapping " 1118 "JOIN temp.icon_id_mapping AS mapping "
1086 "ON (old.id = mapping.old_icon_id)"; 1119 "ON (old.id = mapping.old_icon_id)";
1087 const char kDropOldFaviconsTable[] = "DROP TABLE old_favicons"; 1120 const char kDropOldFaviconsTable[] = "DROP TABLE old_favicons";
1088 1121
1089 const char kRenameFaviconBitmapsTable[] = 1122 const char kRenameFaviconBitmapsTable[] =
1090 "ALTER TABLE favicon_bitmaps RENAME TO old_favicon_bitmaps"; 1123 "ALTER TABLE favicon_bitmaps RENAME TO old_favicon_bitmaps";
1091 const char kCopyFaviconBitmaps[] = 1124 const char kCopyFaviconBitmaps[] =
1092 "INSERT INTO favicon_bitmaps " 1125 "INSERT INTO favicon_bitmaps "
1093 " (icon_id, last_updated, image_data, width, height) " 1126 " (icon_id, last_updated, image_data, width, height, last_requested) "
1094 "SELECT mapping.new_icon_id, old.last_updated, " 1127 "SELECT mapping.new_icon_id, old.last_updated, "
1095 " old.image_data, old.width, old.height " 1128 " old.image_data, old.width, old.height, old.last_requested "
1096 "FROM old_favicon_bitmaps AS old " 1129 "FROM old_favicon_bitmaps AS old "
1097 "JOIN temp.icon_id_mapping AS mapping " 1130 "JOIN temp.icon_id_mapping AS mapping "
1098 "ON (old.icon_id = mapping.old_icon_id)"; 1131 "ON (old.icon_id = mapping.old_icon_id)";
1099 const char kDropOldFaviconBitmapsTable[] = 1132 const char kDropOldFaviconBitmapsTable[] =
1100 "DROP TABLE old_favicon_bitmaps"; 1133 "DROP TABLE old_favicon_bitmaps";
1101 1134
1102 // Rename existing tables to new location. 1135 // Rename existing tables to new location.
1103 if (!db_.Execute(kRenameIconMappingTable) || 1136 if (!db_.Execute(kRenameIconMappingTable) ||
1104 !db_.Execute(kRenameFaviconsTable) || 1137 !db_.Execute(kRenameFaviconsTable) ||
1105 !db_.Execute(kRenameFaviconBitmapsTable)) { 1138 !db_.Execute(kRenameFaviconBitmapsTable)) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 return sql::INIT_FAILURE; 1219 return sql::INIT_FAILURE;
1187 1220
1188 // TODO(shess): Failing Begin() implies that something serious is 1221 // TODO(shess): Failing Begin() implies that something serious is
1189 // wrong with the database. Raze() may be in order. 1222 // wrong with the database. Raze() may be in order.
1190 1223
1191 #if defined(OS_MACOSX) && !defined(OS_IOS) 1224 #if defined(OS_MACOSX) && !defined(OS_IOS)
1192 // Exclude the thumbnails file from backups. 1225 // Exclude the thumbnails file from backups.
1193 base::mac::SetFileBackupExclusion(db_name); 1226 base::mac::SetFileBackupExclusion(db_name);
1194 #endif 1227 #endif
1195 1228
1196 // thumbnails table has been obsolete for a long time, remove any 1229 // thumbnails table has been obsolete for a long time, remove any detritus.
1197 // detrious.
1198 ignore_result(db_.Execute("DROP TABLE IF EXISTS thumbnails")); 1230 ignore_result(db_.Execute("DROP TABLE IF EXISTS thumbnails"));
1199 1231
1200 // At some point, operations involving temporary tables weren't done 1232 // At some point, operations involving temporary tables weren't done
1201 // atomically and users have been stranded. Drop those tables and 1233 // atomically and users have been stranded. Drop those tables and
1202 // move on. 1234 // move on.
1203 // TODO(shess): Prove it? Audit all cases and see if it's possible 1235 // TODO(shess): Prove it? Audit all cases and see if it's possible
1204 // that this implies non-atomic update, and should thus be handled 1236 // that this implies non-atomic update, and should thus be handled
1205 // via the corruption handler. 1237 // via the corruption handler.
1206 ignore_result(db_.Execute("DROP TABLE IF EXISTS temp_favicons")); 1238 ignore_result(db_.Execute("DROP TABLE IF EXISTS temp_favicons"));
1207 ignore_result(db_.Execute("DROP TABLE IF EXISTS temp_favicon_bitmaps")); 1239 ignore_result(db_.Execute("DROP TABLE IF EXISTS temp_favicon_bitmaps"));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 db_.RazeAndClose(); 1271 db_.RazeAndClose();
1240 return sql::INIT_FAILURE; 1272 return sql::INIT_FAILURE;
1241 } 1273 }
1242 1274
1243 if (cur_version == 6) { 1275 if (cur_version == 6) {
1244 ++cur_version; 1276 ++cur_version;
1245 if (!UpgradeToVersion7()) 1277 if (!UpgradeToVersion7())
1246 return CantUpgradeToVersion(cur_version); 1278 return CantUpgradeToVersion(cur_version);
1247 } 1279 }
1248 1280
1281 if (cur_version == 7) {
1282 ++cur_version;
1283 if (!UpgradeToVersion8())
1284 return CantUpgradeToVersion(cur_version);
1285 }
1286
1249 LOG_IF(WARNING, cur_version < kCurrentVersionNumber) << 1287 LOG_IF(WARNING, cur_version < kCurrentVersionNumber) <<
1250 "Thumbnail database version " << cur_version << " is too old to handle."; 1288 "Thumbnail database version " << cur_version << " is too old to handle.";
1251 1289
1252 // Initialization is complete. 1290 // Initialization is complete.
1253 if (!transaction.Commit()) 1291 if (!transaction.Commit())
1254 return sql::INIT_FAILURE; 1292 return sql::INIT_FAILURE;
1255 1293
1256 // Raze the database if the structure of the favicons database is not what 1294 // Raze the database if the structure of the favicons database is not what
1257 // it should be. This error cannot be detected via the SQL error code because 1295 // it should be. This error cannot be detected via the SQL error code because
1258 // the error code for running SQL statements against a database with missing 1296 // the error code for running SQL statements against a database with missing
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 db_.Execute("CREATE INDEX IF NOT EXISTS favicons_url ON favicons(url)"); 1331 db_.Execute("CREATE INDEX IF NOT EXISTS favicons_url ON favicons(url)");
1294 1332
1295 if (!success) 1333 if (!success)
1296 return false; 1334 return false;
1297 1335
1298 meta_table_.SetVersionNumber(7); 1336 meta_table_.SetVersionNumber(7);
1299 meta_table_.SetCompatibleVersionNumber(std::min(7, kCompatibleVersionNumber)); 1337 meta_table_.SetCompatibleVersionNumber(std::min(7, kCompatibleVersionNumber));
1300 return true; 1338 return true;
1301 } 1339 }
1302 1340
1341 bool ThumbnailDatabase::UpgradeToVersion8() {
1342 // Add the last_requested column to the favicon_bitmaps table.
1343 const char kFaviconBitmapsAddLastRequestedSql[] =
1344 "ALTER TABLE favicon_bitmaps ADD COLUMN last_requested INTEGER DEFAULT 0";
1345 if (!db_.Execute(kFaviconBitmapsAddLastRequestedSql))
1346 return false;
1347
1348 meta_table_.SetVersionNumber(8);
1349 meta_table_.SetCompatibleVersionNumber(std::min(8, kCompatibleVersionNumber));
1350 return true;
1351 }
1352
1303 bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() { 1353 bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() {
1304 return !db_.IsSQLValid("SELECT id, url, icon_type FROM favicons"); 1354 return !db_.IsSQLValid("SELECT id, url, icon_type FROM favicons");
1305 } 1355 }
1306 1356
1307 } // namespace history 1357 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698