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 #ifndef CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_ | 5 #ifndef CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_ |
6 #define CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_ | 6 #define CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <set> | 10 #include <set> |
(...skipping 12 matching lines...) Expand all Loading... |
23 class LevelDBWriteBatch; | 23 class LevelDBWriteBatch; |
24 | 24 |
25 class CONTENT_EXPORT LevelDBTransaction | 25 class CONTENT_EXPORT LevelDBTransaction |
26 : public base::RefCounted<LevelDBTransaction> { | 26 : public base::RefCounted<LevelDBTransaction> { |
27 public: | 27 public: |
28 void Put(const base::StringPiece& key, std::string* value); | 28 void Put(const base::StringPiece& key, std::string* value); |
29 | 29 |
30 // Returns true if this operation performs a change, where the value wasn't | 30 // Returns true if this operation performs a change, where the value wasn't |
31 // already deleted. | 31 // already deleted. |
32 bool Remove(const base::StringPiece& key); | 32 bool Remove(const base::StringPiece& key); |
| 33 |
| 34 leveldb::Status RemoveRange(const base::StringPiece& begin, |
| 35 const base::StringPiece& end, |
| 36 bool upper_open); |
| 37 |
33 virtual leveldb::Status Get(const base::StringPiece& key, | 38 virtual leveldb::Status Get(const base::StringPiece& key, |
34 std::string* value, | 39 std::string* value, |
35 bool* found); | 40 bool* found); |
36 virtual leveldb::Status Commit(); | 41 virtual leveldb::Status Commit(); |
37 void Rollback(); | 42 void Rollback(); |
38 | 43 |
39 std::unique_ptr<LevelDBIterator> CreateIterator(); | 44 std::unique_ptr<LevelDBIterator> CreateIterator(); |
40 | 45 |
41 protected: | 46 protected: |
42 virtual ~LevelDBTransaction(); | 47 virtual ~LevelDBTransaction(); |
43 explicit LevelDBTransaction(LevelDBDatabase* db); | 48 explicit LevelDBTransaction(LevelDBDatabase* db); |
44 friend class IndexedDBClassFactory; | 49 friend class IndexedDBClassFactory; |
45 | 50 |
46 private: | 51 private: |
47 friend class base::RefCounted<LevelDBTransaction>; | 52 friend class base::RefCounted<LevelDBTransaction>; |
48 FRIEND_TEST_ALL_PREFIXES(LevelDBDatabaseTest, Transaction); | 53 FRIEND_TEST_ALL_PREFIXES(LevelDBTransactionTest, GetAndPut); |
49 FRIEND_TEST_ALL_PREFIXES(LevelDBDatabaseTest, TransactionCommitTest); | 54 FRIEND_TEST_ALL_PREFIXES(LevelDBTransactionTest, Commit); |
50 FRIEND_TEST_ALL_PREFIXES(LevelDBDatabaseTest, TransactionIterator); | 55 FRIEND_TEST_ALL_PREFIXES(LevelDBTransactionTest, Iterator); |
| 56 FRIEND_TEST_ALL_PREFIXES(LevelDBTransactionTest, RemoveRangeBackingData); |
| 57 FRIEND_TEST_ALL_PREFIXES(LevelDBTransactionTest, |
| 58 RemoveRangeBackingDataUpperOpen); |
| 59 FRIEND_TEST_ALL_PREFIXES(LevelDBTransactionTest, RemoveRangeMemoryData); |
| 60 FRIEND_TEST_ALL_PREFIXES(LevelDBTransactionTest, |
| 61 RemoveRangeMemoryDataUpperOpen); |
51 | 62 |
52 struct Record { | 63 struct Record { |
53 Record(); | 64 Record(); |
54 ~Record(); | 65 ~Record(); |
55 std::string key; | 66 std::string key; |
56 std::string value; | 67 std::string value; |
57 bool deleted; | 68 bool deleted = false; |
58 }; | 69 }; |
59 | 70 |
60 class Comparator { | 71 class Comparator { |
61 public: | 72 public: |
62 explicit Comparator(const LevelDBComparator* comparator) | 73 explicit Comparator(const LevelDBComparator* comparator) |
63 : comparator_(comparator) {} | 74 : comparator_(comparator) {} |
64 bool operator()(const base::StringPiece& a, | 75 bool operator()(const base::StringPiece& a, |
65 const base::StringPiece& b) const { | 76 const base::StringPiece& b) const { |
66 return comparator_->Compare(a, b) < 0; | 77 return comparator_->Compare(a, b) < 0; |
67 } | 78 } |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 LevelDBDatabase* db_; | 181 LevelDBDatabase* db_; |
171 std::unique_ptr<LevelDBWriteBatch> write_batch_; | 182 std::unique_ptr<LevelDBWriteBatch> write_batch_; |
172 bool finished_; | 183 bool finished_; |
173 | 184 |
174 DISALLOW_COPY_AND_ASSIGN(LevelDBDirectTransaction); | 185 DISALLOW_COPY_AND_ASSIGN(LevelDBDirectTransaction); |
175 }; | 186 }; |
176 | 187 |
177 } // namespace content | 188 } // namespace content |
178 | 189 |
179 #endif // CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_ | 190 #endif // CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_ |
OLD | NEW |