| OLD | NEW |
| 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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_); |
| 457 if (opened) | 457 if (opened) |
| 458 db_->Preload(); | 458 db_->Preload(); |
| 459 } | 459 } |
| 460 | 460 |
| 461 if (!opened || !EnsureDatabaseVersion()) { | 461 if (!opened || !EnsureDatabaseVersion()) { |
| 462 LOG(ERROR) << "Could not open the quota database: " | 462 LOG(ERROR) << "Failed to open the quota database."; |
| 463 << "probably database is currupted. " | 463 is_disabled_ = true; |
| 464 << "Trying to reset..."; | 464 db_.reset(); |
| 465 if (!ResetSchema()) { | 465 meta_table_.reset(); |
| 466 LOG(ERROR) << "Failed to reset the quota database."; | 466 return false; |
| 467 is_disabled_ = true; | |
| 468 db_.reset(); | |
| 469 meta_table_.reset(); | |
| 470 return false; | |
| 471 } | |
| 472 } | 467 } |
| 473 | 468 |
| 474 // Start a long-running transaction. | 469 // Start a long-running transaction. |
| 475 db_->BeginTransaction(); | 470 db_->BeginTransaction(); |
| 476 | 471 |
| 477 return true; | 472 return true; |
| 478 } | 473 } |
| 479 | 474 |
| 480 bool QuotaDatabase::EnsureDatabaseVersion() { | 475 bool QuotaDatabase::EnsureDatabaseVersion() { |
| 481 static const size_t kTableCount = arraysize(kTables); | 476 static const size_t kTableCount = arraysize(kTables); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 if (lhs.origin < rhs.origin) return true; | 645 if (lhs.origin < rhs.origin) return true; |
| 651 if (rhs.origin < lhs.origin) return false; | 646 if (rhs.origin < lhs.origin) return false; |
| 652 if (lhs.type < rhs.type) return true; | 647 if (lhs.type < rhs.type) return true; |
| 653 if (rhs.type < lhs.type) return false; | 648 if (rhs.type < lhs.type) return false; |
| 654 if (lhs.used_count < rhs.used_count) return true; | 649 if (lhs.used_count < rhs.used_count) return true; |
| 655 if (rhs.used_count < lhs.used_count) return false; | 650 if (rhs.used_count < lhs.used_count) return false; |
| 656 return lhs.last_access_time < rhs.last_access_time; | 651 return lhs.last_access_time < rhs.last_access_time; |
| 657 } | 652 } |
| 658 | 653 |
| 659 } // namespace storage | 654 } // namespace storage |
| OLD | NEW |