| 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 | |
| 38 virtual leveldb::Status Get(const base::StringPiece& key, | 33 virtual leveldb::Status Get(const base::StringPiece& key, |
| 39 std::string* value, | 34 std::string* value, |
| 40 bool* found); | 35 bool* found); |
| 41 virtual leveldb::Status Commit(); | 36 virtual leveldb::Status Commit(); |
| 42 void Rollback(); | 37 void Rollback(); |
| 43 | 38 |
| 44 std::unique_ptr<LevelDBIterator> CreateIterator(); | 39 std::unique_ptr<LevelDBIterator> CreateIterator(); |
| 45 | 40 |
| 46 protected: | 41 protected: |
| 47 virtual ~LevelDBTransaction(); | 42 virtual ~LevelDBTransaction(); |
| 48 explicit LevelDBTransaction(LevelDBDatabase* db); | 43 explicit LevelDBTransaction(LevelDBDatabase* db); |
| 49 friend class IndexedDBClassFactory; | 44 friend class IndexedDBClassFactory; |
| 50 | 45 |
| 51 private: | 46 private: |
| 52 friend class base::RefCounted<LevelDBTransaction>; | 47 friend class base::RefCounted<LevelDBTransaction>; |
| 53 FRIEND_TEST_ALL_PREFIXES(LevelDBTransactionTest, GetAndPut); | 48 FRIEND_TEST_ALL_PREFIXES(LevelDBDatabaseTest, Transaction); |
| 54 FRIEND_TEST_ALL_PREFIXES(LevelDBTransactionTest, Commit); | 49 FRIEND_TEST_ALL_PREFIXES(LevelDBDatabaseTest, TransactionCommitTest); |
| 55 FRIEND_TEST_ALL_PREFIXES(LevelDBTransactionTest, Iterator); | 50 FRIEND_TEST_ALL_PREFIXES(LevelDBDatabaseTest, TransactionIterator); |
| 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); | |
| 62 | 51 |
| 63 struct Record { | 52 struct Record { |
| 64 Record(); | 53 Record(); |
| 65 ~Record(); | 54 ~Record(); |
| 66 std::string key; | 55 std::string key; |
| 67 std::string value; | 56 std::string value; |
| 68 bool deleted = false; | 57 bool deleted; |
| 69 }; | 58 }; |
| 70 | 59 |
| 71 class Comparator { | 60 class Comparator { |
| 72 public: | 61 public: |
| 73 explicit Comparator(const LevelDBComparator* comparator) | 62 explicit Comparator(const LevelDBComparator* comparator) |
| 74 : comparator_(comparator) {} | 63 : comparator_(comparator) {} |
| 75 bool operator()(const base::StringPiece& a, | 64 bool operator()(const base::StringPiece& a, |
| 76 const base::StringPiece& b) const { | 65 const base::StringPiece& b) const { |
| 77 return comparator_->Compare(a, b) < 0; | 66 return comparator_->Compare(a, b) < 0; |
| 78 } | 67 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 LevelDBDatabase* db_; | 170 LevelDBDatabase* db_; |
| 182 std::unique_ptr<LevelDBWriteBatch> write_batch_; | 171 std::unique_ptr<LevelDBWriteBatch> write_batch_; |
| 183 bool finished_; | 172 bool finished_; |
| 184 | 173 |
| 185 DISALLOW_COPY_AND_ASSIGN(LevelDBDirectTransaction); | 174 DISALLOW_COPY_AND_ASSIGN(LevelDBDirectTransaction); |
| 186 }; | 175 }; |
| 187 | 176 |
| 188 } // namespace content | 177 } // namespace content |
| 189 | 178 |
| 190 #endif // CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_ | 179 #endif // CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_ |
| OLD | NEW |