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

Side by Side Diff: content/browser/notifications/notification_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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/browser/notifications/notification_database.h" 5 #include "content/browser/notifications/notification_database.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 leveldb::Options options; 125 leveldb::Options options;
126 options.create_if_missing = create_if_missing; 126 options.create_if_missing = create_if_missing;
127 options.paranoid_checks = true; 127 options.paranoid_checks = true;
128 options.reuse_logs = leveldb_env::kDefaultLogReuseOptionValue; 128 options.reuse_logs = leveldb_env::kDefaultLogReuseOptionValue;
129 options.filter_policy = filter_policy_.get(); 129 options.filter_policy = filter_policy_.get();
130 if (IsInMemoryDatabase()) { 130 if (IsInMemoryDatabase()) {
131 env_.reset(leveldb::NewMemEnv(leveldb::Env::Default())); 131 env_.reset(leveldb::NewMemEnv(leveldb::Env::Default()));
132 options.env = env_.get(); 132 options.env = env_.get();
133 } 133 }
134 134
135 leveldb::DB* db = nullptr;
136 Status status = LevelDBStatusToStatus( 135 Status status = LevelDBStatusToStatus(
137 leveldb::DB::Open(options, path_.AsUTF8Unsafe(), &db)); 136 leveldb_env::OpenDB(options, path_.AsUTF8Unsafe(), &db_));
138 if (status != STATUS_OK) 137 if (status != STATUS_OK)
139 return status; 138 return status;
140 139
141 state_ = STATE_INITIALIZED; 140 state_ = STATE_INITIALIZED;
142 db_.reset(db);
143 141
144 return ReadNextPersistentNotificationId(); 142 return ReadNextPersistentNotificationId();
145 } 143 }
146 144
147 int64_t NotificationDatabase::GetNextPersistentNotificationId() { 145 int64_t NotificationDatabase::GetNextPersistentNotificationId() {
148 return next_persistent_notification_id_++; 146 return next_persistent_notification_id_++;
149 } 147 }
150 148
151 NotificationDatabase::Status NotificationDatabase::ReadNotificationData( 149 NotificationDatabase::Status NotificationDatabase::ReadNotificationData(
152 const std::string& notification_id, 150 const std::string& notification_id,
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 notification_database_data.notification_id); 381 notification_database_data.notification_id);
384 } 382 }
385 383
386 if (deleted_notification_ids->empty()) 384 if (deleted_notification_ids->empty())
387 return STATUS_OK; 385 return STATUS_OK;
388 386
389 return LevelDBStatusToStatus(db_->Write(leveldb::WriteOptions(), &batch)); 387 return LevelDBStatusToStatus(db_->Write(leveldb::WriteOptions(), &batch));
390 } 388 }
391 389
392 } // namespace content 390 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/leveldb/leveldb_database.cc ('k') | content/browser/service_worker/service_worker_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698