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

Unified Diff: content/browser/indexed_db/leveldb/leveldb_transaction.cc

Issue 2233153002: IndexedDB: WrapUnique(new T(args..)) -> MakeUnique<T>(args...) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review feedback Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/indexed_db/leveldb/leveldb_transaction.cc
diff --git a/content/browser/indexed_db/leveldb/leveldb_transaction.cc b/content/browser/indexed_db/leveldb/leveldb_transaction.cc
index a42f3c3da4ff5cfeade3b9c3905a5c043a6575fd..5db5b433593c1cbf6a513b29f8df222281cab15d 100644
--- a/content/browser/indexed_db/leveldb/leveldb_transaction.cc
+++ b/content/browser/indexed_db/leveldb/leveldb_transaction.cc
@@ -28,13 +28,7 @@ LevelDBTransaction::LevelDBTransaction(LevelDBDatabase* db)
LevelDBTransaction::Record::Record() : deleted(false) {}
LevelDBTransaction::Record::~Record() {}
-void LevelDBTransaction::Clear() {
- for (const auto& it : data_)
- delete it.second;
- data_.clear();
-}
-
-LevelDBTransaction::~LevelDBTransaction() { Clear(); }
+LevelDBTransaction::~LevelDBTransaction() {}
bool LevelDBTransaction::Set(const StringPiece& key,
std::string* value,
@@ -43,11 +37,11 @@ bool LevelDBTransaction::Set(const StringPiece& key,
DataType::iterator it = data_.find(key);
if (it == data_.end()) {
- Record* record = new Record();
+ std::unique_ptr<Record> record = base::MakeUnique<Record>();
record->key.assign(key.begin(), key.end() - key.begin());
record->value.swap(*value);
record->deleted = deleted;
- data_[record->key] = record;
+ data_[record->key] = std::move(record);
NotifyIterators();
return false;
}
@@ -107,8 +101,6 @@ leveldb::Status LevelDBTransaction::Commit() {
write_batch->Put(it->first, it->second->value);
else
write_batch->Remove(it->first);
-
- delete it->second;
data_.erase(it++);
}
@@ -126,7 +118,7 @@ leveldb::Status LevelDBTransaction::Commit() {
void LevelDBTransaction::Rollback() {
DCHECK(!finished_);
finished_ = true;
- Clear();
+ data_.clear();
}
std::unique_ptr<LevelDBIterator> LevelDBTransaction::CreateIterator() {
« no previous file with comments | « content/browser/indexed_db/leveldb/leveldb_transaction.h ('k') | content/browser/indexed_db/list_set_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698