Chromium Code Reviews| Index: content/browser/indexed_db/indexed_db_backing_store.cc |
| diff --git a/content/browser/indexed_db/indexed_db_backing_store.cc b/content/browser/indexed_db/indexed_db_backing_store.cc |
| index a2dccf46329d7630b4c6d14e1471ad95cfa07415..0b6769fb14703c49013dace52d31d10ac1f75fd8 100644 |
| --- a/content/browser/indexed_db/indexed_db_backing_store.cc |
| +++ b/content/browser/indexed_db/indexed_db_backing_store.cc |
| @@ -14,6 +14,7 @@ |
| #include "base/json/json_writer.h" |
| #include "base/logging.h" |
| #include "base/macros.h" |
| +#include "base/memory/ptr_util.h" |
| #include "base/metrics/histogram.h" |
| #include "base/strings/string_util.h" |
| #include "base/strings/stringprintf.h" |
| @@ -972,7 +973,7 @@ scoped_refptr<IndexedDBBackingStore> IndexedDBBackingStore::Open( |
| data_loss_info->status = blink::WebIDBDataLossNone; |
| *status = leveldb::Status::OK(); |
| - std::unique_ptr<LevelDBComparator> comparator(new Comparator()); |
| + std::unique_ptr<LevelDBComparator> comparator(base::MakeUnique<Comparator>()); |
| if (!base::IsStringASCII(path_base.AsUTF8Unsafe())) { |
| HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_ATTEMPT_NON_ASCII, |
| @@ -1117,7 +1118,7 @@ scoped_refptr<IndexedDBBackingStore> IndexedDBBackingStore::OpenInMemory( |
| leveldb::Status* status) { |
| IDB_TRACE("IndexedDBBackingStore::OpenInMemory"); |
| - std::unique_ptr<LevelDBComparator> comparator(new Comparator()); |
| + std::unique_ptr<LevelDBComparator> comparator(base::MakeUnique<Comparator>()); |
|
cmumford
2016/08/13 00:08:38
I know this is nothing new in your CL, but compara
jsbell
2016/08/16 03:05:28
The comparator is passed through (as a unique_ptr
|
| std::unique_ptr<LevelDBDatabase> db = |
| LevelDBDatabase::OpenInMemory(comparator.get()); |
| if (!db) { |
| @@ -2332,8 +2333,9 @@ class LocalWriteClosure : public FileWriterDelegate::DelegateWriteCallback, |
| storage::FileStreamWriter::CreateForLocalFile( |
| task_runner_.get(), file_path, 0, |
| storage::FileStreamWriter::CREATE_NEW_FILE)); |
| - std::unique_ptr<FileWriterDelegate> delegate(new FileWriterDelegate( |
| - std::move(writer), storage::FlushPolicy::FLUSH_ON_COMPLETION)); |
| + std::unique_ptr<FileWriterDelegate> delegate( |
| + base::MakeUnique<FileWriterDelegate>( |
| + std::move(writer), storage::FlushPolicy::FLUSH_ON_COMPLETION)); |
| DCHECK(blob_url.is_valid()); |
| std::unique_ptr<net::URLRequest> blob_request( |
| @@ -3095,7 +3097,7 @@ IndexedDBBackingStore::Cursor::Cursor( |
| transaction_(other->transaction_), |
| database_id_(other->database_id_), |
| cursor_options_(other->cursor_options_), |
| - current_key_(new IndexedDBKey(*other->current_key_)) { |
| + current_key_(base::MakeUnique<IndexedDBKey>(*other->current_key_)) { |
| if (other->iterator_) { |
| iterator_ = transaction_->transaction()->CreateIterator(); |
| @@ -3379,7 +3381,9 @@ class ObjectStoreKeyCursorImpl : public IndexedDBBackingStore::Cursor { |
| database_id, |
| cursor_options) {} |
| - Cursor* Clone() override { return new ObjectStoreKeyCursorImpl(this); } |
| + std::unique_ptr<Cursor> Clone() override { |
| + return base::WrapUnique(new ObjectStoreKeyCursorImpl(this)); |
| + } |
| // IndexedDBBackingStore::Cursor |
| IndexedDBValue* value() override { |
| @@ -3445,7 +3449,9 @@ class ObjectStoreCursorImpl : public IndexedDBBackingStore::Cursor { |
| database_id, |
| cursor_options) {} |
| - Cursor* Clone() override { return new ObjectStoreCursorImpl(this); } |
| + std::unique_ptr<Cursor> Clone() override { |
| + return base::WrapUnique(new ObjectStoreCursorImpl(this)); |
| + } |
| // IndexedDBBackingStore::Cursor |
| IndexedDBValue* value() override { return ¤t_value_; } |
| @@ -3517,7 +3523,9 @@ class IndexKeyCursorImpl : public IndexedDBBackingStore::Cursor { |
| database_id, |
| cursor_options) {} |
| - Cursor* Clone() override { return new IndexKeyCursorImpl(this); } |
| + std::unique_ptr<Cursor> Clone() override { |
| + return base::WrapUnique(new IndexKeyCursorImpl(this)); |
| + } |
| // IndexedDBBackingStore::Cursor |
| IndexedDBValue* value() override { |
| @@ -3551,7 +3559,7 @@ class IndexKeyCursorImpl : public IndexedDBBackingStore::Cursor { |
| private: |
| explicit IndexKeyCursorImpl(const IndexKeyCursorImpl* other) |
| : IndexedDBBackingStore::Cursor(other), |
| - primary_key_(new IndexedDBKey(*other->primary_key_)) {} |
| + primary_key_(base::MakeUnique<IndexedDBKey>(*other->primary_key_)) {} |
| std::unique_ptr<IndexedDBKey> primary_key_; |
| @@ -3633,7 +3641,9 @@ class IndexCursorImpl : public IndexedDBBackingStore::Cursor { |
| database_id, |
| cursor_options) {} |
| - Cursor* Clone() override { return new IndexCursorImpl(this); } |
| + std::unique_ptr<Cursor> Clone() override { |
| + return base::WrapUnique(new IndexCursorImpl(this)); |
| + } |
| // IndexedDBBackingStore::Cursor |
| IndexedDBValue* value() override { return ¤t_value_; } |
| @@ -3664,7 +3674,7 @@ class IndexCursorImpl : public IndexedDBBackingStore::Cursor { |
| private: |
| explicit IndexCursorImpl(const IndexCursorImpl* other) |
| : IndexedDBBackingStore::Cursor(other), |
| - primary_key_(new IndexedDBKey(*other->primary_key_)), |
| + primary_key_(base::MakeUnique<IndexedDBKey>(*other->primary_key_)), |
| current_value_(other->current_value_), |
| primary_leveldb_key_(other->primary_leveldb_key_) {} |
| @@ -3907,8 +3917,9 @@ IndexedDBBackingStore::OpenObjectStoreCursor( |
| direction, |
| &cursor_options)) |
| return std::unique_ptr<IndexedDBBackingStore::Cursor>(); |
| - std::unique_ptr<ObjectStoreCursorImpl> cursor(new ObjectStoreCursorImpl( |
| - this, transaction, database_id, cursor_options)); |
| + std::unique_ptr<ObjectStoreCursorImpl> cursor( |
| + base::MakeUnique<ObjectStoreCursorImpl>(this, transaction, database_id, |
| + cursor_options)); |
| if (!cursor->FirstSeek(s)) |
| return std::unique_ptr<IndexedDBBackingStore::Cursor>(); |
| @@ -3934,8 +3945,9 @@ IndexedDBBackingStore::OpenObjectStoreKeyCursor( |
| direction, |
| &cursor_options)) |
| return std::unique_ptr<IndexedDBBackingStore::Cursor>(); |
| - std::unique_ptr<ObjectStoreKeyCursorImpl> cursor(new ObjectStoreKeyCursorImpl( |
| - this, transaction, database_id, cursor_options)); |
| + std::unique_ptr<ObjectStoreKeyCursorImpl> cursor( |
| + base::MakeUnique<ObjectStoreKeyCursorImpl>(this, transaction, database_id, |
| + cursor_options)); |
| if (!cursor->FirstSeek(s)) |
| return std::unique_ptr<IndexedDBBackingStore::Cursor>(); |
| @@ -3964,7 +3976,8 @@ IndexedDBBackingStore::OpenIndexKeyCursor( |
| &cursor_options)) |
| return std::unique_ptr<IndexedDBBackingStore::Cursor>(); |
| std::unique_ptr<IndexKeyCursorImpl> cursor( |
| - new IndexKeyCursorImpl(this, transaction, database_id, cursor_options)); |
| + base::MakeUnique<IndexKeyCursorImpl>(this, transaction, database_id, |
| + cursor_options)); |
| if (!cursor->FirstSeek(s)) |
| return std::unique_ptr<IndexedDBBackingStore::Cursor>(); |