| 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 "storage/browser/fileapi/sandbox_origin_database.h" | 5 #include "storage/browser/fileapi/sandbox_origin_database.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 if (init_option == FAIL_IF_NONEXISTENT && !base::PathExists(db_path)) | 80 if (init_option == FAIL_IF_NONEXISTENT && !base::PathExists(db_path)) |
| 81 return false; | 81 return false; |
| 82 | 82 |
| 83 std::string path = FilePathToString(db_path); | 83 std::string path = FilePathToString(db_path); |
| 84 leveldb::Options options; | 84 leveldb::Options options; |
| 85 options.max_open_files = 0; // Use minimum. | 85 options.max_open_files = 0; // Use minimum. |
| 86 options.create_if_missing = true; | 86 options.create_if_missing = true; |
| 87 options.reuse_logs = leveldb_env::kDefaultLogReuseOptionValue; | 87 options.reuse_logs = leveldb_env::kDefaultLogReuseOptionValue; |
| 88 if (env_override_) | 88 if (env_override_) |
| 89 options.env = env_override_; | 89 options.env = env_override_; |
| 90 leveldb::DB* db; | 90 leveldb::Status status = leveldb_env::OpenDB(options, path, &db_); |
| 91 leveldb::Status status = leveldb::DB::Open(options, path, &db); | |
| 92 ReportInitStatus(status); | 91 ReportInitStatus(status); |
| 93 if (status.ok()) { | 92 if (status.ok()) { |
| 94 db_.reset(db); | |
| 95 return true; | 93 return true; |
| 96 } | 94 } |
| 97 HandleError(FROM_HERE, status); | 95 HandleError(FROM_HERE, status); |
| 98 | 96 |
| 99 // Corruption due to missing necessary MANIFEST-* file causes IOError instead | 97 // Corruption due to missing necessary MANIFEST-* file causes IOError instead |
| 100 // of Corruption error. | 98 // of Corruption error. |
| 101 // Try to repair database even when IOError case. | 99 // Try to repair database even when IOError case. |
| 102 if (!status.IsCorruption() && !status.IsIOError()) | 100 if (!status.IsCorruption() && !status.IsIOError()) |
| 103 return false; | 101 return false; |
| 104 | 102 |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 status = db_->Put(leveldb::WriteOptions(), LastPathKey(), std::string("-1")); | 346 status = db_->Put(leveldb::WriteOptions(), LastPathKey(), std::string("-1")); |
| 349 if (!status.ok()) { | 347 if (!status.ok()) { |
| 350 HandleError(FROM_HERE, status); | 348 HandleError(FROM_HERE, status); |
| 351 return false; | 349 return false; |
| 352 } | 350 } |
| 353 *number = -1; | 351 *number = -1; |
| 354 return true; | 352 return true; |
| 355 } | 353 } |
| 356 | 354 |
| 357 } // namespace storage | 355 } // namespace storage |
| OLD | NEW |