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

Side by Side Diff: storage/browser/quota/quota_database.cc

Issue 1236583002: Try to reset quota database which is suspected to be corrupted (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "storage/browser/quota/quota_database.h" 5 #include "storage/browser/quota/quota_database.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 meta_table_.reset(new sql::MetaTable); 446 meta_table_.reset(new sql::MetaTable);
447 447
448 db_->set_histogram_tag("Quota"); 448 db_->set_histogram_tag("Quota");
449 449
450 bool opened = false; 450 bool opened = false;
451 if (in_memory_only) { 451 if (in_memory_only) {
452 opened = db_->OpenInMemory(); 452 opened = db_->OpenInMemory();
453 } else if (!base::CreateDirectory(db_file_path_.DirName())) { 453 } else if (!base::CreateDirectory(db_file_path_.DirName())) {
454 LOG(ERROR) << "Failed to create quota database directory."; 454 LOG(ERROR) << "Failed to create quota database directory.";
455 } else { 455 } else {
456 opened = db_->Open(db_file_path_); 456 opened = db_->Open(db_file_path_);
michaeln 2015/07/23 19:54:18 It looks like the DLOG(FATAL) happens inside of th
457 if (opened) 457 if (opened)
458 db_->Preload(); 458 db_->Preload();
459 } 459 }
460 460
461 if (!opened || !EnsureDatabaseVersion()) { 461 if (!opened || !EnsureDatabaseVersion()) {
michaeln 2015/07/23 19:54:18 It looks like there are other ways in which a bork
462 LOG(ERROR) << "Failed to open the quota database."; 462 LOG(ERROR) << "Failed to open the quota database.";
463 is_disabled_ = true; 463 is_disabled_ = true;
464 db_.reset(); 464 db_.reset();
465 meta_table_.reset(); 465 meta_table_.reset();
466 return false; 466 return false;
467 } 467 }
468 468
469 // Start a long-running transaction. 469 // Start a long-running transaction.
470 db_->BeginTransaction(); 470 db_->BeginTransaction();
471 471
472 return true; 472 return true;
473 } 473 }
474 474
475 bool QuotaDatabase::EnsureDatabaseVersion() { 475 bool QuotaDatabase::EnsureDatabaseVersion() {
476 static const size_t kTableCount = arraysize(kTables); 476 static const size_t kTableCount = arraysize(kTables);
477 static const size_t kIndexCount = arraysize(kIndexes); 477 static const size_t kIndexCount = arraysize(kIndexes);
478 if (!sql::MetaTable::DoesTableExist(db_.get())) 478 if (!sql::MetaTable::DoesTableExist(db_.get())) {
479 return CreateSchema(db_.get(), meta_table_.get(), 479 if (CreateSchema(db_.get(), meta_table_.get(),
480 kCurrentVersion, kCompatibleVersion, 480 kCurrentVersion, kCompatibleVersion,
481 kTables, kTableCount, 481 kTables, kTableCount,
482 kIndexes, kIndexCount); 482 kIndexes, kIndexCount))
483 return true;
484
485 LOG(ERROR) << "Failed to create schema: probably database is currupted.";
486 return ResetSchema();
michaeln 2015/07/23 19:54:18 I was wondering how this fixed a crash? Its not re
487 }
483 488
484 if (!meta_table_->Init(db_.get(), kCurrentVersion, kCompatibleVersion)) 489 if (!meta_table_->Init(db_.get(), kCurrentVersion, kCompatibleVersion))
485 return false; 490 return false;
486 491
487 if (meta_table_->GetCompatibleVersionNumber() > kCurrentVersion) { 492 if (meta_table_->GetCompatibleVersionNumber() > kCurrentVersion) {
488 LOG(WARNING) << "Quota database is too new."; 493 LOG(WARNING) << "Quota database is too new.";
489 return false; 494 return false;
490 } 495 }
491 496
492 if (meta_table_->GetVersionNumber() < kCurrentVersion) { 497 if (meta_table_->GetVersionNumber() < kCurrentVersion) {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 if (lhs.origin < rhs.origin) return true; 650 if (lhs.origin < rhs.origin) return true;
646 if (rhs.origin < lhs.origin) return false; 651 if (rhs.origin < lhs.origin) return false;
647 if (lhs.type < rhs.type) return true; 652 if (lhs.type < rhs.type) return true;
648 if (rhs.type < lhs.type) return false; 653 if (rhs.type < lhs.type) return false;
649 if (lhs.used_count < rhs.used_count) return true; 654 if (lhs.used_count < rhs.used_count) return true;
650 if (rhs.used_count < lhs.used_count) return false; 655 if (rhs.used_count < lhs.used_count) return false;
651 return lhs.last_access_time < rhs.last_access_time; 656 return lhs.last_access_time < rhs.last_access_time;
652 } 657 }
653 658
654 } // namespace storage 659 } // namespace storage
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698