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 "content/browser/appcache/appcache_database.h" | 5 #include "content/browser/appcache/appcache_database.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "content/browser/appcache/appcache_entry.h" | 13 #include "content/browser/appcache/appcache_entry.h" |
14 #include "content/browser/appcache/appcache_histograms.h" | 14 #include "content/browser/appcache/appcache_histograms.h" |
15 #include "sql/connection.h" | 15 #include "sql/connection.h" |
16 #include "sql/error_delegate_util.h" | 16 #include "sql/error_delegate_util.h" |
17 #include "sql/meta_table.h" | 17 #include "sql/meta_table.h" |
18 #include "sql/statement.h" | 18 #include "sql/statement.h" |
19 #include "sql/transaction.h" | 19 #include "sql/transaction.h" |
20 | 20 |
21 namespace content { | 21 namespace content { |
22 | 22 |
23 // Schema ------------------------------------------------------------------- | 23 // Schema ------------------------------------------------------------------- |
24 namespace { | 24 namespace { |
25 | 25 |
26 #if defined(APPCACHE_USE_SIMPLE_CACHE) | 26 const int kCurrentVersion = 7; |
27 const int kCurrentVersion = 6; | 27 const int kCompatibleVersion = 7; |
28 const int kCompatibleVersion = 6; | |
29 #else | |
30 const int kCurrentVersion = 5; | |
31 const int kCompatibleVersion = 5; | |
32 #endif | |
33 | 28 |
34 // A mechanism to run experiments that may affect in data being persisted | 29 // A mechanism to run experiments that may affect in data being persisted |
35 // in different ways such that when the experiment is toggled on/off via | 30 // in different ways such that when the experiment is toggled on/off via |
36 // cmd line flags, the database gets reset. The active flags are stored at | 31 // cmd line flags, the database gets reset. The active flags are stored at |
37 // the time of database creation and compared when reopening. If different | 32 // the time of database creation and compared when reopening. If different |
38 // the database is reset. | 33 // the database is reset. |
39 const char kExperimentFlagsKey[] = "ExperimentFlags"; | 34 const char kExperimentFlagsKey[] = "ExperimentFlags"; |
40 | 35 |
41 const char kGroupsTable[] = "Groups"; | 36 const char kGroupsTable[] = "Groups"; |
42 const char kCachesTable[] = "Caches"; | 37 const char kCachesTable[] = "Caches"; |
(...skipping 13 matching lines...) Expand all Loading... | |
56 const char* columns; | 51 const char* columns; |
57 bool unique; | 52 bool unique; |
58 }; | 53 }; |
59 | 54 |
60 const TableInfo kTables[] = { | 55 const TableInfo kTables[] = { |
61 { kGroupsTable, | 56 { kGroupsTable, |
62 "(group_id INTEGER PRIMARY KEY," | 57 "(group_id INTEGER PRIMARY KEY," |
63 " origin TEXT," | 58 " origin TEXT," |
64 " manifest_url TEXT," | 59 " manifest_url TEXT," |
65 " creation_time INTEGER," | 60 " creation_time INTEGER," |
66 " last_access_time INTEGER)" }, | 61 " last_access_time INTEGER," |
62 " last_full_update_check_time INTEGER," | |
63 " first_evictable_error_time INTEGER)" }, | |
67 | 64 |
68 { kCachesTable, | 65 { kCachesTable, |
69 "(cache_id INTEGER PRIMARY KEY," | 66 "(cache_id INTEGER PRIMARY KEY," |
70 " group_id INTEGER," | 67 " group_id INTEGER," |
71 " online_wildcard INTEGER CHECK(online_wildcard IN (0, 1))," | 68 " online_wildcard INTEGER CHECK(online_wildcard IN (0, 1))," |
72 " update_time INTEGER," | 69 " update_time INTEGER," |
73 " cache_size INTEGER)" }, // intentionally not normalized | 70 " cache_size INTEGER)" }, // intentionally not normalized |
74 | 71 |
75 { kEntriesTable, | 72 { kEntriesTable, |
76 "(cache_id INTEGER," | 73 "(cache_id INTEGER," |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
306 return true; | 303 return true; |
307 } | 304 } |
308 | 305 |
309 bool AppCacheDatabase::FindGroup(int64 group_id, GroupRecord* record) { | 306 bool AppCacheDatabase::FindGroup(int64 group_id, GroupRecord* record) { |
310 DCHECK(record); | 307 DCHECK(record); |
311 if (!LazyOpen(false)) | 308 if (!LazyOpen(false)) |
312 return false; | 309 return false; |
313 | 310 |
314 const char* kSql = | 311 const char* kSql = |
315 "SELECT group_id, origin, manifest_url," | 312 "SELECT group_id, origin, manifest_url," |
316 " creation_time, last_access_time" | 313 " creation_time, last_access_time," |
314 " last_full_update_check_time," | |
315 " first_evictable_error_time" | |
317 " FROM Groups WHERE group_id = ?"; | 316 " FROM Groups WHERE group_id = ?"; |
318 | 317 |
319 sql::Statement statement(db_->GetCachedStatement(SQL_FROM_HERE, kSql)); | 318 sql::Statement statement(db_->GetCachedStatement(SQL_FROM_HERE, kSql)); |
320 | 319 |
321 statement.BindInt64(0, group_id); | 320 statement.BindInt64(0, group_id); |
322 if (!statement.Step()) | 321 if (!statement.Step()) |
323 return false; | 322 return false; |
324 | 323 |
325 ReadGroupRecord(statement, record); | 324 ReadGroupRecord(statement, record); |
326 DCHECK(record->group_id == group_id); | 325 DCHECK(record->group_id == group_id); |
327 return true; | 326 return true; |
328 } | 327 } |
329 | 328 |
330 bool AppCacheDatabase::FindGroupForManifestUrl( | 329 bool AppCacheDatabase::FindGroupForManifestUrl( |
331 const GURL& manifest_url, GroupRecord* record) { | 330 const GURL& manifest_url, GroupRecord* record) { |
332 DCHECK(record); | 331 DCHECK(record); |
333 if (!LazyOpen(false)) | 332 if (!LazyOpen(false)) |
334 return false; | 333 return false; |
335 | 334 |
336 const char* kSql = | 335 const char* kSql = |
337 "SELECT group_id, origin, manifest_url," | 336 "SELECT group_id, origin, manifest_url," |
338 " creation_time, last_access_time" | 337 " creation_time, last_access_time," |
338 " last_full_update_check_time," | |
339 " first_evictable_error_time" | |
339 " FROM Groups WHERE manifest_url = ?"; | 340 " FROM Groups WHERE manifest_url = ?"; |
340 | 341 |
341 sql::Statement statement(db_->GetCachedStatement(SQL_FROM_HERE, kSql)); | 342 sql::Statement statement(db_->GetCachedStatement(SQL_FROM_HERE, kSql)); |
342 statement.BindString(0, manifest_url.spec()); | 343 statement.BindString(0, manifest_url.spec()); |
343 | 344 |
344 if (!statement.Step()) | 345 if (!statement.Step()) |
345 return false; | 346 return false; |
346 | 347 |
347 ReadGroupRecord(statement, record); | 348 ReadGroupRecord(statement, record); |
348 DCHECK(record->manifest_url == manifest_url); | 349 DCHECK(record->manifest_url == manifest_url); |
349 return true; | 350 return true; |
350 } | 351 } |
351 | 352 |
352 bool AppCacheDatabase::FindGroupsForOrigin( | 353 bool AppCacheDatabase::FindGroupsForOrigin( |
353 const GURL& origin, std::vector<GroupRecord>* records) { | 354 const GURL& origin, std::vector<GroupRecord>* records) { |
354 DCHECK(records && records->empty()); | 355 DCHECK(records && records->empty()); |
355 if (!LazyOpen(false)) | 356 if (!LazyOpen(false)) |
356 return false; | 357 return false; |
357 | 358 |
358 const char* kSql = | 359 const char* kSql = |
359 "SELECT group_id, origin, manifest_url," | 360 "SELECT group_id, origin, manifest_url," |
360 " creation_time, last_access_time" | 361 " creation_time, last_access_time," |
362 " last_full_update_check_time," | |
363 " first_evictable_error_time" | |
361 " FROM Groups WHERE origin = ?"; | 364 " FROM Groups WHERE origin = ?"; |
362 | 365 |
363 sql::Statement statement(db_->GetCachedStatement(SQL_FROM_HERE, kSql)); | 366 sql::Statement statement(db_->GetCachedStatement(SQL_FROM_HERE, kSql)); |
364 statement.BindString(0, origin.spec()); | 367 statement.BindString(0, origin.spec()); |
365 | 368 |
366 while (statement.Step()) { | 369 while (statement.Step()) { |
367 records->push_back(GroupRecord()); | 370 records->push_back(GroupRecord()); |
368 ReadGroupRecord(statement, &records->back()); | 371 ReadGroupRecord(statement, &records->back()); |
369 DCHECK(records->back().origin == origin); | 372 DCHECK(records->back().origin == origin); |
370 } | 373 } |
371 | 374 |
372 return statement.Succeeded(); | 375 return statement.Succeeded(); |
373 } | 376 } |
374 | 377 |
375 bool AppCacheDatabase::FindGroupForCache(int64 cache_id, GroupRecord* record) { | 378 bool AppCacheDatabase::FindGroupForCache(int64 cache_id, GroupRecord* record) { |
376 DCHECK(record); | 379 DCHECK(record); |
377 if (!LazyOpen(false)) | 380 if (!LazyOpen(false)) |
378 return false; | 381 return false; |
379 | 382 |
380 const char* kSql = | 383 const char* kSql = |
381 "SELECT g.group_id, g.origin, g.manifest_url," | 384 "SELECT g.group_id, g.origin, g.manifest_url," |
382 " g.creation_time, g.last_access_time" | 385 " g.creation_time, g.last_access_time," |
386 " g.last_full_update_check_time," | |
387 " g.first_evictable_error_time" | |
383 " FROM Groups g, Caches c" | 388 " FROM Groups g, Caches c" |
384 " WHERE c.cache_id = ? AND c.group_id = g.group_id"; | 389 " WHERE c.cache_id = ? AND c.group_id = g.group_id"; |
385 | 390 |
386 sql::Statement statement(db_->GetCachedStatement(SQL_FROM_HERE, kSql)); | 391 sql::Statement statement(db_->GetCachedStatement(SQL_FROM_HERE, kSql)); |
387 statement.BindInt64(0, cache_id); | 392 statement.BindInt64(0, cache_id); |
388 | 393 |
389 if (!statement.Step()) | 394 if (!statement.Step()) |
390 return false; | 395 return false; |
391 | 396 |
392 ReadGroupRecord(statement, record); | 397 ReadGroupRecord(statement, record); |
393 return true; | 398 return true; |
394 } | 399 } |
395 | 400 |
396 bool AppCacheDatabase::UpdateLastAccessTime( | 401 bool AppCacheDatabase::UpdateLastAccessTime( |
397 int64 group_id, base::Time time) { | 402 int64 group_id, base::Time time) { |
398 if (!LazyOpen(true)) | 403 if (!LazyUpdateLastAccessTime(group_id, time)) |
399 return false; | 404 return false; |
400 | 405 return CommitLazyLastAccessTimes(); |
401 const char* kSql = | |
402 "UPDATE Groups SET last_access_time = ? WHERE group_id = ?"; | |
403 | |
404 sql::Statement statement(db_->GetCachedStatement(SQL_FROM_HERE, kSql)); | |
405 statement.BindInt64(0, time.ToInternalValue()); | |
406 statement.BindInt64(1, group_id); | |
407 | |
408 return statement.Run(); | |
409 } | 406 } |
410 | 407 |
411 bool AppCacheDatabase::LazyUpdateLastAccessTime( | 408 bool AppCacheDatabase::LazyUpdateLastAccessTime( |
412 int64 group_id, base::Time time) { | 409 int64 group_id, base::Time time) { |
413 if (!LazyOpen(true)) | 410 if (!LazyOpen(true)) |
414 return false; | 411 return false; |
415 lazy_last_access_times_[group_id] = time; | 412 lazy_last_access_times_[group_id] = time; |
416 return true; | 413 return true; |
417 } | 414 } |
418 | 415 |
419 bool AppCacheDatabase::CommitLazyLastAccessTimes() { | 416 bool AppCacheDatabase::CommitLazyLastAccessTimes() { |
420 if (lazy_last_access_times_.empty()) | 417 if (lazy_last_access_times_.empty()) |
421 return true; | 418 return true; |
422 if (!LazyOpen(false)) | 419 if (!LazyOpen(false)) |
423 return false; | 420 return false; |
424 | 421 |
425 sql::Transaction transaction(db_.get()); | 422 sql::Transaction transaction(db_.get()); |
426 if (!transaction.Begin()) | 423 if (!transaction.Begin()) |
427 return false; | 424 return false; |
428 for (const auto& pair : lazy_last_access_times_) | 425 for (const auto& pair : lazy_last_access_times_) { |
429 UpdateLastAccessTime(pair.first, pair.second); | 426 const char* kSql = |
427 "UPDATE Groups SET last_access_time = ? WHERE group_id = ?"; | |
428 sql::Statement statement(db_->GetCachedStatement(SQL_FROM_HERE, kSql)); | |
jsbell
2015/05/27 22:38:18
Does this Statement need to be explicitly Run()?
michaeln
2015/05/27 23:21:51
Ooops, sure does need a call to Run.
| |
429 statement.BindInt64(0, pair.second.ToInternalValue()); // time | |
430 statement.BindInt64(1, pair.first); // group_id | |
431 } | |
430 lazy_last_access_times_.clear(); | 432 lazy_last_access_times_.clear(); |
431 return transaction.Commit(); | 433 return transaction.Commit(); |
432 } | 434 } |
433 | 435 |
436 bool AppCacheDatabase::UpdateEvictionTimes( | |
437 int64 group_id, | |
438 base::Time last_full_update_check_time, | |
439 base::Time first_evictable_error_time) { | |
440 if (!LazyOpen(true)) | |
441 return false; | |
442 | |
443 const char* kSql = | |
444 "UPDATE Groups" | |
445 " SET last_full_update_check_time = ?, first_evictable_error_time = ?" | |
446 " WHERE group_id = ?"; | |
447 | |
448 sql::Statement statement(db_->GetCachedStatement(SQL_FROM_HERE, kSql)); | |
449 statement.BindInt64(0, last_full_update_check_time.ToInternalValue()); | |
450 statement.BindInt64(1, first_evictable_error_time.ToInternalValue()); | |
451 statement.BindInt64(3, group_id); | |
452 | |
453 return statement.Run(); | |
454 } | |
455 | |
434 bool AppCacheDatabase::InsertGroup(const GroupRecord* record) { | 456 bool AppCacheDatabase::InsertGroup(const GroupRecord* record) { |
435 if (!LazyOpen(true)) | 457 if (!LazyOpen(true)) |
436 return false; | 458 return false; |
437 | 459 |
438 const char* kSql = | 460 const char* kSql = |
439 "INSERT INTO Groups" | 461 "INSERT INTO Groups" |
440 " (group_id, origin, manifest_url, creation_time, last_access_time)" | 462 " (group_id, origin, manifest_url, creation_time, last_access_time," |
441 " VALUES(?, ?, ?, ?, ?)"; | 463 " last_full_update_check_time, first_evictable_error_time)" |
464 " VALUES(?, ?, ?, ?, ?, ?, ?)"; | |
442 | 465 |
443 sql::Statement statement(db_->GetCachedStatement(SQL_FROM_HERE, kSql)); | 466 sql::Statement statement(db_->GetCachedStatement(SQL_FROM_HERE, kSql)); |
444 statement.BindInt64(0, record->group_id); | 467 statement.BindInt64(0, record->group_id); |
445 statement.BindString(1, record->origin.spec()); | 468 statement.BindString(1, record->origin.spec()); |
446 statement.BindString(2, record->manifest_url.spec()); | 469 statement.BindString(2, record->manifest_url.spec()); |
447 statement.BindInt64(3, record->creation_time.ToInternalValue()); | 470 statement.BindInt64(3, record->creation_time.ToInternalValue()); |
448 statement.BindInt64(4, record->last_access_time.ToInternalValue()); | 471 statement.BindInt64(4, record->last_access_time.ToInternalValue()); |
472 statement.BindInt64(5, record->last_full_update_check_time.ToInternalValue()); | |
473 statement.BindInt64(6, record->first_evictable_error_time.ToInternalValue()); | |
449 | 474 |
450 return statement.Run(); | 475 return statement.Run(); |
451 } | 476 } |
452 | 477 |
453 bool AppCacheDatabase::DeleteGroup(int64 group_id) { | 478 bool AppCacheDatabase::DeleteGroup(int64 group_id) { |
454 if (!LazyOpen(false)) | 479 if (!LazyOpen(false)) |
455 return false; | 480 return false; |
456 | 481 |
457 const char* kSql = | 482 const char* kSql = |
458 "DELETE FROM Groups WHERE group_id = ?"; | 483 "DELETE FROM Groups WHERE group_id = ?"; |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
949 record->creation_time = | 974 record->creation_time = |
950 base::Time::FromInternalValue(statement.ColumnInt64(3)); | 975 base::Time::FromInternalValue(statement.ColumnInt64(3)); |
951 | 976 |
952 const auto found = lazy_last_access_times_.find(record->group_id); | 977 const auto found = lazy_last_access_times_.find(record->group_id); |
953 if (found != lazy_last_access_times_.end()) { | 978 if (found != lazy_last_access_times_.end()) { |
954 record->last_access_time = found->second; | 979 record->last_access_time = found->second; |
955 } else { | 980 } else { |
956 record->last_access_time = | 981 record->last_access_time = |
957 base::Time::FromInternalValue(statement.ColumnInt64(4)); | 982 base::Time::FromInternalValue(statement.ColumnInt64(4)); |
958 } | 983 } |
984 | |
985 record->last_full_update_check_time = | |
986 base::Time::FromInternalValue(statement.ColumnInt64(5)); | |
987 record->first_evictable_error_time = | |
988 base::Time::FromInternalValue(statement.ColumnInt64(6)); | |
959 } | 989 } |
960 | 990 |
961 void AppCacheDatabase::ReadCacheRecord( | 991 void AppCacheDatabase::ReadCacheRecord( |
962 const sql::Statement& statement, CacheRecord* record) { | 992 const sql::Statement& statement, CacheRecord* record) { |
963 record->cache_id = statement.ColumnInt64(0); | 993 record->cache_id = statement.ColumnInt64(0); |
964 record->group_id = statement.ColumnInt64(1); | 994 record->group_id = statement.ColumnInt64(1); |
965 record->online_wildcard = statement.ColumnBool(2); | 995 record->online_wildcard = statement.ColumnBool(2); |
966 record->update_time = | 996 record->update_time = |
967 base::Time::FromInternalValue(statement.ColumnInt64(3)); | 997 base::Time::FromInternalValue(statement.ColumnInt64(3)); |
968 record->cache_size = statement.ColumnInt64(4); | 998 record->cache_size = statement.ColumnInt64(4); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1127 for (int i = 0; i < kIndexCount; ++i) { | 1157 for (int i = 0; i < kIndexCount; ++i) { |
1128 if (!CreateIndex(db_.get(), kIndexes[i])) | 1158 if (!CreateIndex(db_.get(), kIndexes[i])) |
1129 return false; | 1159 return false; |
1130 } | 1160 } |
1131 | 1161 |
1132 return transaction.Commit(); | 1162 return transaction.Commit(); |
1133 } | 1163 } |
1134 | 1164 |
1135 bool AppCacheDatabase::UpgradeSchema() { | 1165 bool AppCacheDatabase::UpgradeSchema() { |
1136 #if defined(APPCACHE_USE_SIMPLE_CACHE) | 1166 #if defined(APPCACHE_USE_SIMPLE_CACHE) |
1137 return DeleteExistingAndCreateNewDatabase(); | 1167 if (meta_table_->GetVersionNumber() < 6) |
1138 #else | 1168 return DeleteExistingAndCreateNewDatabase(); |
1169 #endif | |
1139 if (meta_table_->GetVersionNumber() == 3) { | 1170 if (meta_table_->GetVersionNumber() == 3) { |
1140 // version 3 was pre 12/17/2011 | 1171 // version 3 was pre 12/17/2011 |
1141 DCHECK_EQ(strcmp(kNamespacesTable, kTables[3].table_name), 0); | 1172 DCHECK_EQ(strcmp(kNamespacesTable, kTables[3].table_name), 0); |
1142 DCHECK_EQ(strcmp(kNamespacesTable, kIndexes[6].table_name), 0); | 1173 DCHECK_EQ(strcmp(kNamespacesTable, kIndexes[6].table_name), 0); |
1143 DCHECK_EQ(strcmp(kNamespacesTable, kIndexes[7].table_name), 0); | 1174 DCHECK_EQ(strcmp(kNamespacesTable, kIndexes[7].table_name), 0); |
1144 DCHECK_EQ(strcmp(kNamespacesTable, kIndexes[8].table_name), 0); | 1175 DCHECK_EQ(strcmp(kNamespacesTable, kIndexes[8].table_name), 0); |
1145 | 1176 |
1146 const TableInfo kNamespaceTable_v4 = { | 1177 const TableInfo kNamespaceTable_v4 = { |
1147 kNamespacesTable, | 1178 kNamespacesTable, |
1148 "(cache_id INTEGER," | 1179 "(cache_id INTEGER," |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1200 " is_pattern INTEGER CHECK(is_pattern IN (0, 1))")) { | 1231 " is_pattern INTEGER CHECK(is_pattern IN (0, 1))")) { |
1201 return false; | 1232 return false; |
1202 } | 1233 } |
1203 if (!db_->Execute( | 1234 if (!db_->Execute( |
1204 "ALTER TABLE OnlineWhitelists ADD COLUMN" | 1235 "ALTER TABLE OnlineWhitelists ADD COLUMN" |
1205 " is_pattern INTEGER CHECK(is_pattern IN (0, 1))")) { | 1236 " is_pattern INTEGER CHECK(is_pattern IN (0, 1))")) { |
1206 return false; | 1237 return false; |
1207 } | 1238 } |
1208 meta_table_->SetVersionNumber(5); | 1239 meta_table_->SetVersionNumber(5); |
1209 meta_table_->SetCompatibleVersionNumber(5); | 1240 meta_table_->SetCompatibleVersionNumber(5); |
1241 if (!transaction.Commit()) | |
1242 return false; | |
1243 } | |
1244 | |
1245 #if defined(APPCACHE_USE_SIMPLE_CACHE) | |
1246 // The schema version number was increased to 6 when we switched to the | |
1247 // SimpleCache for Android, but the SQL part of the schema is identical | |
1248 // to v5 on desktop chrome. | |
1249 if (meta_table_->GetVersionNumber() == 6) { | |
jsbell
2015/05/27 22:38:18
Could this just be < 7 in both SimpleCache and oth
michaeln
2015/05/27 23:21:51
That could work with an early return up top for <
| |
1250 #else | |
1251 if (meta_table_->GetVersionNumber() == 5) { | |
1252 #endif | |
1253 // version [5,6] was pre May 2015 | |
1254 // v7 Adds support for expiring caches that are failing to update. | |
1255 sql::Transaction transaction(db_.get()); | |
1256 if (!transaction.Begin() || | |
1257 !db_->Execute( | |
1258 "ALTER TABLE Groups ADD COLUMN" | |
1259 " last_full_update_check_time INTEGER") || | |
1260 !db_->Execute( | |
1261 "ALTER TABLE Groups ADD COLUMN" | |
1262 " first_evictable_error_time INTEGER")) { | |
1263 return false; | |
1264 } | |
1265 meta_table_->SetVersionNumber(7); | |
1266 meta_table_->SetCompatibleVersionNumber(7); | |
1210 return transaction.Commit(); | 1267 return transaction.Commit(); |
1211 } | 1268 } |
1212 | 1269 |
1213 // If there is no upgrade path for the version on disk to the current | 1270 // If there is no upgrade path for the version on disk to the current |
1214 // version, nuke everything and start over. | 1271 // version, nuke everything and start over. |
1215 return DeleteExistingAndCreateNewDatabase(); | 1272 return DeleteExistingAndCreateNewDatabase(); |
1216 #endif | |
1217 } | 1273 } |
1218 | 1274 |
1219 void AppCacheDatabase::ResetConnectionAndTables() { | 1275 void AppCacheDatabase::ResetConnectionAndTables() { |
1220 meta_table_.reset(); | 1276 meta_table_.reset(); |
1221 db_.reset(); | 1277 db_.reset(); |
1222 } | 1278 } |
1223 | 1279 |
1224 bool AppCacheDatabase::DeleteExistingAndCreateNewDatabase() { | 1280 bool AppCacheDatabase::DeleteExistingAndCreateNewDatabase() { |
1225 DCHECK(!db_file_path_.empty()); | 1281 DCHECK(!db_file_path_.empty()); |
1226 DCHECK(base::PathExists(db_file_path_)); | 1282 DCHECK(base::PathExists(db_file_path_)); |
(...skipping 22 matching lines...) Expand all Loading... | |
1249 } | 1305 } |
1250 | 1306 |
1251 void AppCacheDatabase::OnDatabaseError(int err, sql::Statement* stmt) { | 1307 void AppCacheDatabase::OnDatabaseError(int err, sql::Statement* stmt) { |
1252 was_corruption_detected_ |= sql::IsErrorCatastrophic(err); | 1308 was_corruption_detected_ |= sql::IsErrorCatastrophic(err); |
1253 if (!db_->ShouldIgnoreSqliteError(err)) | 1309 if (!db_->ShouldIgnoreSqliteError(err)) |
1254 DLOG(ERROR) << db_->GetErrorMessage(); | 1310 DLOG(ERROR) << db_->GetErrorMessage(); |
1255 // TODO: Maybe use non-catostrophic errors to trigger a full integrity check? | 1311 // TODO: Maybe use non-catostrophic errors to trigger a full integrity check? |
1256 } | 1312 } |
1257 | 1313 |
1258 } // namespace content | 1314 } // namespace content |
OLD | NEW |