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 "content/browser/indexed_db/leveldb/leveldb_slice.h" | 7 #include "base/strings/string_piece.h" |
8 #include "third_party/leveldatabase/src/include/leveldb/slice.h" | 8 #include "third_party/leveldatabase/src/include/leveldb/slice.h" |
9 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" | 9 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" |
10 | 10 |
11 namespace content { | 11 namespace content { |
12 | 12 |
13 scoped_ptr<LevelDBWriteBatch> LevelDBWriteBatch::Create() { | 13 scoped_ptr<LevelDBWriteBatch> LevelDBWriteBatch::Create() { |
14 return make_scoped_ptr(new LevelDBWriteBatch); | 14 return make_scoped_ptr(new LevelDBWriteBatch); |
15 } | 15 } |
16 | 16 |
17 LevelDBWriteBatch::LevelDBWriteBatch() | 17 LevelDBWriteBatch::LevelDBWriteBatch() |
18 : write_batch_(new leveldb::WriteBatch) {} | 18 : write_batch_(new leveldb::WriteBatch) {} |
19 | 19 |
20 LevelDBWriteBatch::~LevelDBWriteBatch() {} | 20 LevelDBWriteBatch::~LevelDBWriteBatch() {} |
21 | 21 |
22 static leveldb::Slice MakeSlice(const LevelDBSlice& s) { | 22 static leveldb::Slice MakeSlice(const base::StringPiece& s) { |
23 return leveldb::Slice(s.begin(), s.end() - s.begin()); | 23 return leveldb::Slice(s.begin(), s.end() - s.begin()); |
24 } | 24 } |
25 | 25 |
26 void LevelDBWriteBatch::Put(const LevelDBSlice& key, | 26 void LevelDBWriteBatch::Put(const base::StringPiece& key, |
27 const LevelDBSlice& value) { | 27 const base::StringPiece& value) { |
28 write_batch_->Put(MakeSlice(key), MakeSlice(value)); | 28 write_batch_->Put(MakeSlice(key), MakeSlice(value)); |
29 } | 29 } |
30 | 30 |
31 void LevelDBWriteBatch::Remove(const LevelDBSlice& key) { | 31 void LevelDBWriteBatch::Remove(const base::StringPiece& key) { |
32 write_batch_->Delete(MakeSlice(key)); | 32 write_batch_->Delete(MakeSlice(key)); |
33 } | 33 } |
34 | 34 |
35 void LevelDBWriteBatch::Clear() { write_batch_->Clear(); } | 35 void LevelDBWriteBatch::Clear() { write_batch_->Clear(); } |
36 | 36 |
37 } // namespace content | 37 } // namespace content |
OLD | NEW |