| 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 <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 126 |
| 127 LevelDBDatabase* db_; | 127 LevelDBDatabase* db_; |
| 128 const LevelDBSnapshot snapshot_; | 128 const LevelDBSnapshot snapshot_; |
| 129 const LevelDBComparator* comparator_; | 129 const LevelDBComparator* comparator_; |
| 130 Comparator data_comparator_; | 130 Comparator data_comparator_; |
| 131 DataType data_; | 131 DataType data_; |
| 132 bool finished_; | 132 bool finished_; |
| 133 std::set<TransactionIterator*> iterators_; | 133 std::set<TransactionIterator*> iterators_; |
| 134 }; | 134 }; |
| 135 | 135 |
| 136 class LevelDBWriteOnlyTransaction { | 136 // Reads go straight to the database, ignoring any writes cached in |
| 137 // write_batch_, and writes are write-through, without consolidation. |
| 138 class LevelDBUncachedTransaction { |
| 137 public: | 139 public: |
| 138 static scoped_ptr<LevelDBWriteOnlyTransaction> Create(LevelDBDatabase* db); | 140 static scoped_ptr<LevelDBUncachedTransaction> Create(LevelDBDatabase* db); |
| 139 | 141 |
| 140 ~LevelDBWriteOnlyTransaction(); | 142 ~LevelDBUncachedTransaction(); |
| 143 void Put(const base::StringPiece& key, const std::string* value); |
| 144 bool Get(const base::StringPiece& key, std::string* value, bool* found); |
| 141 void Remove(const base::StringPiece& key); | 145 void Remove(const base::StringPiece& key); |
| 142 bool Commit(); | 146 bool Commit(); |
| 143 | 147 |
| 144 private: | 148 private: |
| 145 explicit LevelDBWriteOnlyTransaction(LevelDBDatabase* db); | 149 explicit LevelDBUncachedTransaction(LevelDBDatabase* db); |
| 146 | 150 |
| 147 LevelDBDatabase* db_; | 151 LevelDBDatabase* db_; |
| 148 scoped_ptr<LevelDBWriteBatch> write_batch_; | 152 scoped_ptr<LevelDBWriteBatch> write_batch_; |
| 149 bool finished_; | 153 bool finished_; |
| 150 }; | 154 }; |
| 151 | 155 |
| 152 } // namespace content | 156 } // namespace content |
| 153 | 157 |
| 154 #endif // CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_ | 158 #endif // CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_ |
| OLD | NEW |