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

Side by Side Diff: storage/browser/fileapi/sandbox_origin_database.cc

Issue 2953473002: Use leveldb_env::OpenDB() to open leveldb databases. (Closed)
Patch Set: Rebase; add comments to CHECK() Created 3 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
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « storage/browser/fileapi/sandbox_directory_database.cc ('k') | third_party/leveldatabase/env_chromium.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698