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

Side by Side Diff: content/browser/appcache/appcache_database.cc

Issue 879393002: Expire appcaches that fail to update for "too long". (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 "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
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
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
401 bool AppCacheDatabase::InsertGroup(const GroupRecord* record) {
palmer 2015/06/01 21:09:02 Nit: I normally think to use a const reference, ra
michaeln 2015/06/19 21:38:19 You're right!? This is an existing method (it onl
402 if (!LazyOpen(true))
403 return false;
404
405 const char* kSql =
406 "INSERT INTO Groups"
407 " (group_id, origin, manifest_url, creation_time, last_access_time,"
408 " last_full_update_check_time, first_evictable_error_time)"
409 " VALUES(?, ?, ?, ?, ?, ?, ?)";
410 sql::Statement statement(db_->GetCachedStatement(SQL_FROM_HERE, kSql));
411 statement.BindInt64(0, record->group_id);
412 statement.BindString(1, record->origin.spec());
413 statement.BindString(2, record->manifest_url.spec());
414 statement.BindInt64(3, record->creation_time.ToInternalValue());
415 statement.BindInt64(4, record->last_access_time.ToInternalValue());
416 statement.BindInt64(5, record->last_full_update_check_time.ToInternalValue());
417 statement.BindInt64(6, record->first_evictable_error_time.ToInternalValue());
418 return statement.Run();
419 }
420
421 bool AppCacheDatabase::DeleteGroup(int64 group_id) {
422 if (!LazyOpen(false))
423 return false;
424
425 const char* kSql =
426 "DELETE FROM Groups WHERE group_id = ?";
427 sql::Statement statement(db_->GetCachedStatement(SQL_FROM_HERE, kSql));
428 statement.BindInt64(0, group_id);
429 return statement.Run();
430 }
431
396 bool AppCacheDatabase::UpdateLastAccessTime( 432 bool AppCacheDatabase::UpdateLastAccessTime(
397 int64 group_id, base::Time time) { 433 int64 group_id, base::Time time) {
398 if (!LazyOpen(true)) 434 if (!LazyUpdateLastAccessTime(group_id, time))
399 return false; 435 return false;
400 436 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 } 437 }
410 438
411 bool AppCacheDatabase::LazyUpdateLastAccessTime( 439 bool AppCacheDatabase::LazyUpdateLastAccessTime(
412 int64 group_id, base::Time time) { 440 int64 group_id, base::Time time) {
413 if (!LazyOpen(true)) 441 if (!LazyOpen(true))
414 return false; 442 return false;
415 lazy_last_access_times_[group_id] = time; 443 lazy_last_access_times_[group_id] = time;
416 return true; 444 return true;
417 } 445 }
418 446
419 bool AppCacheDatabase::CommitLazyLastAccessTimes() { 447 bool AppCacheDatabase::CommitLazyLastAccessTimes() {
420 if (lazy_last_access_times_.empty()) 448 if (lazy_last_access_times_.empty())
421 return true; 449 return true;
422 if (!LazyOpen(false)) 450 if (!LazyOpen(false))
423 return false; 451 return false;
424 452
425 sql::Transaction transaction(db_.get()); 453 sql::Transaction transaction(db_.get());
426 if (!transaction.Begin()) 454 if (!transaction.Begin())
427 return false; 455 return false;
428 for (const auto& pair : lazy_last_access_times_) 456 for (const auto& pair : lazy_last_access_times_) {
429 UpdateLastAccessTime(pair.first, pair.second); 457 const char* kSql =
458 "UPDATE Groups SET last_access_time = ? WHERE group_id = ?";
459 sql::Statement statement(db_->GetCachedStatement(SQL_FROM_HERE, kSql));
460 statement.BindInt64(0, pair.second.ToInternalValue()); // time
461 statement.BindInt64(1, pair.first); // group_id
462 statement.Run();
463 }
430 lazy_last_access_times_.clear(); 464 lazy_last_access_times_.clear();
431 return transaction.Commit(); 465 return transaction.Commit();
432 } 466 }
433 467
434 bool AppCacheDatabase::InsertGroup(const GroupRecord* record) { 468 bool AppCacheDatabase::UpdateEvictionTimes(
469 int64 group_id,
470 base::Time last_full_update_check_time,
471 base::Time first_evictable_error_time) {
435 if (!LazyOpen(true)) 472 if (!LazyOpen(true))
436 return false; 473 return false;
437 474
438 const char* kSql = 475 const char* kSql =
439 "INSERT INTO Groups" 476 "UPDATE Groups"
440 " (group_id, origin, manifest_url, creation_time, last_access_time)" 477 " SET last_full_update_check_time = ?, first_evictable_error_time = ?"
441 " VALUES(?, ?, ?, ?, ?)"; 478 " WHERE group_id = ?";
442
443 sql::Statement statement(db_->GetCachedStatement(SQL_FROM_HERE, kSql)); 479 sql::Statement statement(db_->GetCachedStatement(SQL_FROM_HERE, kSql));
444 statement.BindInt64(0, record->group_id); 480 statement.BindInt64(0, last_full_update_check_time.ToInternalValue());
445 statement.BindString(1, record->origin.spec()); 481 statement.BindInt64(1, first_evictable_error_time.ToInternalValue());
446 statement.BindString(2, record->manifest_url.spec()); 482 statement.BindInt64(2, group_id);
447 statement.BindInt64(3, record->creation_time.ToInternalValue()); 483 return statement.Run(); // Will succeed even if group_id is invalid.
448 statement.BindInt64(4, record->last_access_time.ToInternalValue());
449
450 return statement.Run();
451 }
452
453 bool AppCacheDatabase::DeleteGroup(int64 group_id) {
454 if (!LazyOpen(false))
455 return false;
456
457 const char* kSql =
458 "DELETE FROM Groups WHERE group_id = ?";
459
460 sql::Statement statement(db_->GetCachedStatement(SQL_FROM_HERE, kSql));
461 statement.BindInt64(0, group_id);
462
463 return statement.Run();
464 } 484 }
465 485
466 bool AppCacheDatabase::FindCache(int64 cache_id, CacheRecord* record) { 486 bool AppCacheDatabase::FindCache(int64 cache_id, CacheRecord* record) {
467 DCHECK(record); 487 DCHECK(record);
468 if (!LazyOpen(false)) 488 if (!LazyOpen(false))
469 return false; 489 return false;
470 490
471 const char* kSql = 491 const char* kSql =
472 "SELECT cache_id, group_id, online_wildcard, update_time, cache_size" 492 "SELECT cache_id, group_id, online_wildcard, update_time, cache_size"
473 " FROM Caches WHERE cache_id = ?"; 493 " FROM Caches WHERE cache_id = ?";
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 record->creation_time = 969 record->creation_time =
950 base::Time::FromInternalValue(statement.ColumnInt64(3)); 970 base::Time::FromInternalValue(statement.ColumnInt64(3));
951 971
952 const auto found = lazy_last_access_times_.find(record->group_id); 972 const auto found = lazy_last_access_times_.find(record->group_id);
953 if (found != lazy_last_access_times_.end()) { 973 if (found != lazy_last_access_times_.end()) {
954 record->last_access_time = found->second; 974 record->last_access_time = found->second;
955 } else { 975 } else {
956 record->last_access_time = 976 record->last_access_time =
957 base::Time::FromInternalValue(statement.ColumnInt64(4)); 977 base::Time::FromInternalValue(statement.ColumnInt64(4));
958 } 978 }
979
980 record->last_full_update_check_time =
981 base::Time::FromInternalValue(statement.ColumnInt64(5));
982 record->first_evictable_error_time =
983 base::Time::FromInternalValue(statement.ColumnInt64(6));
959 } 984 }
960 985
961 void AppCacheDatabase::ReadCacheRecord( 986 void AppCacheDatabase::ReadCacheRecord(
962 const sql::Statement& statement, CacheRecord* record) { 987 const sql::Statement& statement, CacheRecord* record) {
963 record->cache_id = statement.ColumnInt64(0); 988 record->cache_id = statement.ColumnInt64(0);
964 record->group_id = statement.ColumnInt64(1); 989 record->group_id = statement.ColumnInt64(1);
965 record->online_wildcard = statement.ColumnBool(2); 990 record->online_wildcard = statement.ColumnBool(2);
966 record->update_time = 991 record->update_time =
967 base::Time::FromInternalValue(statement.ColumnInt64(3)); 992 base::Time::FromInternalValue(statement.ColumnInt64(3));
968 record->cache_size = statement.ColumnInt64(4); 993 record->cache_size = statement.ColumnInt64(4);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 for (int i = 0; i < kIndexCount; ++i) { 1152 for (int i = 0; i < kIndexCount; ++i) {
1128 if (!CreateIndex(db_.get(), kIndexes[i])) 1153 if (!CreateIndex(db_.get(), kIndexes[i]))
1129 return false; 1154 return false;
1130 } 1155 }
1131 1156
1132 return transaction.Commit(); 1157 return transaction.Commit();
1133 } 1158 }
1134 1159
1135 bool AppCacheDatabase::UpgradeSchema() { 1160 bool AppCacheDatabase::UpgradeSchema() {
1136 #if defined(APPCACHE_USE_SIMPLE_CACHE) 1161 #if defined(APPCACHE_USE_SIMPLE_CACHE)
1137 return DeleteExistingAndCreateNewDatabase(); 1162 if (meta_table_->GetVersionNumber() < 6)
1138 #else 1163 return DeleteExistingAndCreateNewDatabase();
1164 #endif
1139 if (meta_table_->GetVersionNumber() == 3) { 1165 if (meta_table_->GetVersionNumber() == 3) {
1140 // version 3 was pre 12/17/2011 1166 // version 3 was pre 12/17/2011
1141 DCHECK_EQ(strcmp(kNamespacesTable, kTables[3].table_name), 0); 1167 DCHECK_EQ(strcmp(kNamespacesTable, kTables[3].table_name), 0);
1142 DCHECK_EQ(strcmp(kNamespacesTable, kIndexes[6].table_name), 0); 1168 DCHECK_EQ(strcmp(kNamespacesTable, kIndexes[6].table_name), 0);
1143 DCHECK_EQ(strcmp(kNamespacesTable, kIndexes[7].table_name), 0); 1169 DCHECK_EQ(strcmp(kNamespacesTable, kIndexes[7].table_name), 0);
1144 DCHECK_EQ(strcmp(kNamespacesTable, kIndexes[8].table_name), 0); 1170 DCHECK_EQ(strcmp(kNamespacesTable, kIndexes[8].table_name), 0);
1145 1171
1146 const TableInfo kNamespaceTable_v4 = { 1172 const TableInfo kNamespaceTable_v4 = {
1147 kNamespacesTable, 1173 kNamespacesTable,
1148 "(cache_id INTEGER," 1174 "(cache_id INTEGER,"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 " is_pattern INTEGER CHECK(is_pattern IN (0, 1))")) { 1226 " is_pattern INTEGER CHECK(is_pattern IN (0, 1))")) {
1201 return false; 1227 return false;
1202 } 1228 }
1203 if (!db_->Execute( 1229 if (!db_->Execute(
1204 "ALTER TABLE OnlineWhitelists ADD COLUMN" 1230 "ALTER TABLE OnlineWhitelists ADD COLUMN"
1205 " is_pattern INTEGER CHECK(is_pattern IN (0, 1))")) { 1231 " is_pattern INTEGER CHECK(is_pattern IN (0, 1))")) {
1206 return false; 1232 return false;
1207 } 1233 }
1208 meta_table_->SetVersionNumber(5); 1234 meta_table_->SetVersionNumber(5);
1209 meta_table_->SetCompatibleVersionNumber(5); 1235 meta_table_->SetCompatibleVersionNumber(5);
1236 if (!transaction.Commit())
1237 return false;
1238 }
1239
1240 #if defined(APPCACHE_USE_SIMPLE_CACHE)
1241 // The schema version number was increased to 6 when we switched to the
1242 // SimpleCache for Android, but the SQL part of the schema is identical
1243 // to v5 on desktop chrome.
1244 if (meta_table_->GetVersionNumber() == 6) {
1245 #else
1246 if (meta_table_->GetVersionNumber() == 5) {
1247 #endif
1248 // version [5,6] was pre May 2015
palmer 2015/06/01 21:09:02 Nit: Punctuation, et c. // Versions 5 and 6 were
michaeln 2015/06/19 21:38:19 Done.
1249 // v7 Adds support for expiring caches that are failing to update.
1250 sql::Transaction transaction(db_.get());
1251 if (!transaction.Begin() ||
1252 !db_->Execute(
1253 "ALTER TABLE Groups ADD COLUMN"
1254 " last_full_update_check_time INTEGER") ||
1255 !db_->Execute(
1256 "ALTER TABLE Groups ADD COLUMN"
1257 " first_evictable_error_time INTEGER") ||
1258 !db_->Execute(
1259 "UPDATE Groups"
1260 " SET last_full_update_check_time ="
1261 " (SELECT update_time FROM Caches"
1262 " WHERE Caches.group_id = Groups.group_id)")) {
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698