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

Side by Side Diff: storage/browser/fileapi/sandbox_directory_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_directory_database.h" 5 #include "storage/browser/fileapi/sandbox_directory_database.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 739
740 std::string path = 740 std::string path =
741 FilePathToString(filesystem_data_directory_.Append( 741 FilePathToString(filesystem_data_directory_.Append(
742 kDirectoryDatabaseName)); 742 kDirectoryDatabaseName));
743 leveldb::Options options; 743 leveldb::Options options;
744 options.max_open_files = 0; // Use minimum. 744 options.max_open_files = 0; // Use minimum.
745 options.create_if_missing = true; 745 options.create_if_missing = true;
746 options.reuse_logs = leveldb_env::kDefaultLogReuseOptionValue; 746 options.reuse_logs = leveldb_env::kDefaultLogReuseOptionValue;
747 if (env_override_) 747 if (env_override_)
748 options.env = env_override_; 748 options.env = env_override_;
749 leveldb::DB* db; 749 leveldb::Status status = leveldb_env::OpenDB(options, path, &db_);
750 leveldb::Status status = leveldb::DB::Open(options, path, &db);
751 ReportInitStatus(status); 750 ReportInitStatus(status);
752 if (status.ok()) { 751 if (status.ok()) {
753 db_.reset(db);
754 return true; 752 return true;
755 } 753 }
756 HandleError(FROM_HERE, status); 754 HandleError(FROM_HERE, status);
757 755
758 // Corruption due to missing necessary MANIFEST-* file causes IOError instead 756 // Corruption due to missing necessary MANIFEST-* file causes IOError instead
759 // of Corruption error. 757 // of Corruption error.
760 // Try to repair database even when IOError case. 758 // Try to repair database even when IOError case.
761 if (!status.IsCorruption() && !status.IsIOError()) 759 if (!status.IsCorruption() && !status.IsIOError())
762 return false; 760 return false;
763 761
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 950
953 void SandboxDirectoryDatabase::HandleError( 951 void SandboxDirectoryDatabase::HandleError(
954 const tracked_objects::Location& from_here, 952 const tracked_objects::Location& from_here,
955 const leveldb::Status& status) { 953 const leveldb::Status& status) {
956 LOG(ERROR) << "SandboxDirectoryDatabase failed at: " 954 LOG(ERROR) << "SandboxDirectoryDatabase failed at: "
957 << from_here.ToString() << " with error: " << status.ToString(); 955 << from_here.ToString() << " with error: " << status.ToString();
958 db_.reset(); 956 db_.reset();
959 } 957 }
960 958
961 } // namespace storage 959 } // namespace storage
OLDNEW
« no previous file with comments | « google_apis/gcm/engine/gcm_store_impl.cc ('k') | storage/browser/fileapi/sandbox_origin_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698