Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/indexed_db/leveldb/leveldb_write_batch.h" | 5 #include "content/browser/indexed_db/leveldb/leveldb_write_batch.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/strings/string_piece.h" | 8 #include "base/strings/string_piece.h" |
| 9 #include "third_party/leveldatabase/src/include/leveldb/slice.h" | 9 #include "third_party/leveldatabase/src/include/leveldb/slice.h" |
| 10 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" | 10 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 | 13 |
| 14 std::unique_ptr<LevelDBWriteBatch> LevelDBWriteBatch::Create() { | 14 std::unique_ptr<LevelDBWriteBatch> LevelDBWriteBatch::Create() { |
| 15 return base::WrapUnique(new LevelDBWriteBatch); | 15 return base::WrapUnique(new LevelDBWriteBatch()); |
|
cmumford
2016/08/10 23:03:47
It's too bad MakeUnique can't handle private metho
| |
| 16 } | 16 } |
| 17 | 17 |
| 18 LevelDBWriteBatch::LevelDBWriteBatch() | 18 LevelDBWriteBatch::LevelDBWriteBatch() |
| 19 : write_batch_(new leveldb::WriteBatch) {} | 19 : write_batch_(new leveldb::WriteBatch) {} |
| 20 | 20 |
| 21 LevelDBWriteBatch::~LevelDBWriteBatch() {} | 21 LevelDBWriteBatch::~LevelDBWriteBatch() {} |
| 22 | 22 |
| 23 static leveldb::Slice MakeSlice(const base::StringPiece& s) { | 23 static leveldb::Slice MakeSlice(const base::StringPiece& s) { |
| 24 return leveldb::Slice(s.begin(), s.size()); | 24 return leveldb::Slice(s.begin(), s.size()); |
| 25 } | 25 } |
| 26 | 26 |
| 27 void LevelDBWriteBatch::Put(const base::StringPiece& key, | 27 void LevelDBWriteBatch::Put(const base::StringPiece& key, |
| 28 const base::StringPiece& value) { | 28 const base::StringPiece& value) { |
| 29 write_batch_->Put(MakeSlice(key), MakeSlice(value)); | 29 write_batch_->Put(MakeSlice(key), MakeSlice(value)); |
| 30 } | 30 } |
| 31 | 31 |
| 32 void LevelDBWriteBatch::Remove(const base::StringPiece& key) { | 32 void LevelDBWriteBatch::Remove(const base::StringPiece& key) { |
| 33 write_batch_->Delete(MakeSlice(key)); | 33 write_batch_->Delete(MakeSlice(key)); |
| 34 } | 34 } |
| 35 | 35 |
| 36 void LevelDBWriteBatch::Clear() { write_batch_->Clear(); } | 36 void LevelDBWriteBatch::Clear() { write_batch_->Clear(); } |
| 37 | 37 |
| 38 } // namespace content | 38 } // namespace content |
| OLD | NEW |