| 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/fileapi/file_system_origin_database.h" | 5 #include "webkit/fileapi/file_system_origin_database.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 options.create_if_missing = true; | 77 options.create_if_missing = true; |
| 78 leveldb::DB* db; | 78 leveldb::DB* db; |
| 79 leveldb::Status status = leveldb::DB::Open(options, path, &db); | 79 leveldb::Status status = leveldb::DB::Open(options, path, &db); |
| 80 ReportInitStatus(status); | 80 ReportInitStatus(status); |
| 81 if (status.ok()) { | 81 if (status.ok()) { |
| 82 db_.reset(db); | 82 db_.reset(db); |
| 83 return true; | 83 return true; |
| 84 } | 84 } |
| 85 HandleError(FROM_HERE, status); | 85 HandleError(FROM_HERE, status); |
| 86 | 86 |
| 87 if (!status.IsCorruption()) | 87 if (!status.IsCorruption() && !status.IsIOError()) |
| 88 return false; | 88 return false; |
| 89 | 89 |
| 90 switch (recovery_option) { | 90 switch (recovery_option) { |
| 91 case FAIL_ON_CORRUPTION: | 91 case FAIL_ON_CORRUPTION: |
| 92 return false; | 92 return false; |
| 93 case REPAIR_ON_CORRUPTION: | 93 case REPAIR_ON_CORRUPTION: |
| 94 LOG(WARNING) << "Attempting to repair FileSystemOriginDatabase."; | 94 LOG(WARNING) << "Attempting to repair FileSystemOriginDatabase."; |
| 95 if (RepairDatabase(path)) { | 95 if (RepairDatabase(path)) { |
| 96 LOG(WARNING) << "Repairing FileSystemOriginDatabase completed."; | 96 LOG(WARNING) << "Repairing FileSystemOriginDatabase completed."; |
| 97 return true; | 97 return true; |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 db_->Put(leveldb::WriteOptions(), LastPathKey(), std::string("-1")); | 309 db_->Put(leveldb::WriteOptions(), LastPathKey(), std::string("-1")); |
| 310 if (!status.ok()) { | 310 if (!status.ok()) { |
| 311 HandleError(FROM_HERE, status); | 311 HandleError(FROM_HERE, status); |
| 312 return false; | 312 return false; |
| 313 } | 313 } |
| 314 *number = -1; | 314 *number = -1; |
| 315 return true; | 315 return true; |
| 316 } | 316 } |
| 317 | 317 |
| 318 } // namespace fileapi | 318 } // namespace fileapi |
| OLD | NEW |