| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |