| 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 22 matching lines...) Expand all Loading... |
| 33 bool upper_open); | 33 bool upper_open); |
| 34 | 34 |
| 35 virtual leveldb::Status Get(const base::StringPiece& key, | 35 virtual leveldb::Status Get(const base::StringPiece& key, |
| 36 std::string* value, | 36 std::string* value, |
| 37 bool* found); | 37 bool* found); |
| 38 virtual leveldb::Status Commit(); | 38 virtual leveldb::Status Commit(); |
| 39 void Rollback(); | 39 void Rollback(); |
| 40 | 40 |
| 41 std::unique_ptr<LevelDBIterator> CreateIterator(); | 41 std::unique_ptr<LevelDBIterator> CreateIterator(); |
| 42 | 42 |
| 43 uint64_t GetTransactionSize() const { return size_; } |
| 44 |
| 43 protected: | 45 protected: |
| 44 virtual ~LevelDBTransaction(); | 46 virtual ~LevelDBTransaction(); |
| 45 explicit LevelDBTransaction(LevelDBDatabase* db); | 47 explicit LevelDBTransaction(LevelDBDatabase* db); |
| 46 friend class IndexedDBClassFactory; | 48 friend class IndexedDBClassFactory; |
| 47 | 49 |
| 48 private: | 50 private: |
| 49 friend class base::RefCounted<LevelDBTransaction>; | 51 friend class base::RefCounted<LevelDBTransaction>; |
| 50 friend class LevelDBTransactionRangeTest; | 52 friend class LevelDBTransactionRangeTest; |
| 51 friend class LevelDBTransactionTest; | 53 friend class LevelDBTransactionTest; |
| 52 FRIEND_TEST_ALL_PREFIXES(LevelDBTransactionTest, GetAndPut); | 54 FRIEND_TEST_ALL_PREFIXES(LevelDBTransactionTest, GetAndPut); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 void Set(const base::StringPiece& key, std::string* value, bool deleted); | 159 void Set(const base::StringPiece& key, std::string* value, bool deleted); |
| 158 void RegisterIterator(TransactionIterator* iterator); | 160 void RegisterIterator(TransactionIterator* iterator); |
| 159 void UnregisterIterator(TransactionIterator* iterator); | 161 void UnregisterIterator(TransactionIterator* iterator); |
| 160 void NotifyIterators(); | 162 void NotifyIterators(); |
| 161 | 163 |
| 162 LevelDBDatabase* db_; | 164 LevelDBDatabase* db_; |
| 163 const LevelDBSnapshot snapshot_; | 165 const LevelDBSnapshot snapshot_; |
| 164 const LevelDBComparator* comparator_; | 166 const LevelDBComparator* comparator_; |
| 165 Comparator data_comparator_; | 167 Comparator data_comparator_; |
| 166 DataType data_; | 168 DataType data_; |
| 169 uint64_t size_ = 0ull; |
| 167 bool finished_ = false; | 170 bool finished_ = false; |
| 168 std::set<TransactionIterator*> iterators_; | 171 std::set<TransactionIterator*> iterators_; |
| 169 | 172 |
| 170 DISALLOW_COPY_AND_ASSIGN(LevelDBTransaction); | 173 DISALLOW_COPY_AND_ASSIGN(LevelDBTransaction); |
| 171 }; | 174 }; |
| 172 | 175 |
| 173 // Reads go straight to the database, ignoring any writes cached in | 176 // Reads go straight to the database, ignoring any writes cached in |
| 174 // write_batch_, and writes are write-through, without consolidation. | 177 // write_batch_, and writes are write-through, without consolidation. |
| 175 class LevelDBDirectTransaction { | 178 class LevelDBDirectTransaction { |
| 176 public: | 179 public: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 190 LevelDBDatabase* db_; | 193 LevelDBDatabase* db_; |
| 191 std::unique_ptr<LevelDBWriteBatch> write_batch_; | 194 std::unique_ptr<LevelDBWriteBatch> write_batch_; |
| 192 bool finished_ = false; | 195 bool finished_ = false; |
| 193 | 196 |
| 194 DISALLOW_COPY_AND_ASSIGN(LevelDBDirectTransaction); | 197 DISALLOW_COPY_AND_ASSIGN(LevelDBDirectTransaction); |
| 195 }; | 198 }; |
| 196 | 199 |
| 197 } // namespace content | 200 } // namespace content |
| 198 | 201 |
| 199 #endif // CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_ | 202 #endif // CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_ |
| OLD | NEW |