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

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: MOAR MakeUnique calls 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..156bab1f45c54195b7b0b68334ffc01a3a9145a4 100644
--- a/content/browser/indexed_db/leveldb/leveldb_transaction.cc
+++ b/content/browser/indexed_db/leveldb/leveldb_transaction.cc
@@ -29,12 +29,10 @@ LevelDBTransaction::Record::Record() : deleted(false) {}
LevelDBTransaction::Record::~Record() {}
void LevelDBTransaction::Clear() {
cmumford 2016/08/13 00:08:38 Now only used in LevelDBTransaction::Rollback(). C
jsbell 2016/08/16 03:05:28 Done.
- 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 +41,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 +105,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++);
}

Powered by Google App Engine
This is Rietveld 408576698