| 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 "webkit/browser/appcache/appcache_database.h" | 5 #include "webkit/browser/appcache/appcache_database.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1012 if (use_in_memory_db) { | 1012 if (use_in_memory_db) { |
| 1013 opened = db_->OpenInMemory(); | 1013 opened = db_->OpenInMemory(); |
| 1014 } else if (!base::CreateDirectory(db_file_path_.DirName())) { | 1014 } else if (!base::CreateDirectory(db_file_path_.DirName())) { |
| 1015 LOG(ERROR) << "Failed to create appcache directory."; | 1015 LOG(ERROR) << "Failed to create appcache directory."; |
| 1016 } else { | 1016 } else { |
| 1017 opened = db_->Open(db_file_path_); | 1017 opened = db_->Open(db_file_path_); |
| 1018 if (opened) | 1018 if (opened) |
| 1019 db_->Preload(); | 1019 db_->Preload(); |
| 1020 } | 1020 } |
| 1021 | 1021 |
| 1022 if (!opened || !EnsureDatabaseVersion()) { | 1022 if (!opened || !db_->QuickIntegrityCheck() || !EnsureDatabaseVersion()) { |
| 1023 LOG(ERROR) << "Failed to open the appcache database."; | 1023 LOG(ERROR) << "Failed to open the appcache database."; |
| 1024 AppCacheHistograms::CountInitResult( | 1024 AppCacheHistograms::CountInitResult( |
| 1025 AppCacheHistograms::SQL_DATABASE_ERROR); | 1025 AppCacheHistograms::SQL_DATABASE_ERROR); |
| 1026 | 1026 |
| 1027 // We're unable to open the database. This is a fatal error | 1027 // We're unable to open the database. This is a fatal error |
| 1028 // which we can't recover from. We try to handle it by deleting | 1028 // which we can't recover from. We try to handle it by deleting |
| 1029 // the existing appcache data and starting with a clean slate in | 1029 // the existing appcache data and starting with a clean slate in |
| 1030 // this browser session. | 1030 // this browser session. |
| 1031 if (!use_in_memory_db && DeleteExistingAndCreateNewDatabase()) | 1031 if (!use_in_memory_db && DeleteExistingAndCreateNewDatabase()) |
| 1032 return true; | 1032 return true; |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1206 | 1206 |
| 1207 // So we can't go recursive. | 1207 // So we can't go recursive. |
| 1208 if (is_recreating_) | 1208 if (is_recreating_) |
| 1209 return false; | 1209 return false; |
| 1210 | 1210 |
| 1211 base::AutoReset<bool> auto_reset(&is_recreating_, true); | 1211 base::AutoReset<bool> auto_reset(&is_recreating_, true); |
| 1212 return LazyOpen(true); | 1212 return LazyOpen(true); |
| 1213 } | 1213 } |
| 1214 | 1214 |
| 1215 } // namespace appcache | 1215 } // namespace appcache |
| OLD | NEW |