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 <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 void NotifyIteratorsOfTreeChange(); | 149 void NotifyIteratorsOfTreeChange(); |
150 | 150 |
151 LevelDBDatabase* db_; | 151 LevelDBDatabase* db_; |
152 const LevelDBSnapshot snapshot_; | 152 const LevelDBSnapshot snapshot_; |
153 const LevelDBComparator* comparator_; | 153 const LevelDBComparator* comparator_; |
154 TreeType tree_; | 154 TreeType tree_; |
155 bool finished_; | 155 bool finished_; |
156 std::set<TransactionIterator*> iterators_; | 156 std::set<TransactionIterator*> iterators_; |
157 }; | 157 }; |
158 | 158 |
159 // The transaction actually does allow reading, but reads go straight to the | |
jsbell
2013/09/13 00:12:21
Also note that duplicate writes are not consolidat
ericu
2013/11/20 23:05:39
Noted. Perhaps I'll call it LevelDBUncachedTransa
| |
160 // database, ignoring any writes cached in write_batch_. | |
161 // TODO(ericu): Rename to LevelDBSimpleTransaction. | |
159 class LevelDBWriteOnlyTransaction { | 162 class LevelDBWriteOnlyTransaction { |
160 public: | 163 public: |
161 static scoped_ptr<LevelDBWriteOnlyTransaction> Create(LevelDBDatabase* db); | 164 static scoped_ptr<LevelDBWriteOnlyTransaction> Create(LevelDBDatabase* db); |
162 | 165 |
163 ~LevelDBWriteOnlyTransaction(); | 166 ~LevelDBWriteOnlyTransaction(); |
167 void Put(const base::StringPiece& key, const std::string* value); | |
168 bool Get(const base::StringPiece& key, std::string* value, bool* found); | |
164 void Remove(const base::StringPiece& key); | 169 void Remove(const base::StringPiece& key); |
165 bool Commit(); | 170 bool Commit(); |
166 | 171 |
167 private: | 172 private: |
168 explicit LevelDBWriteOnlyTransaction(LevelDBDatabase* db); | 173 explicit LevelDBWriteOnlyTransaction(LevelDBDatabase* db); |
169 | 174 |
170 LevelDBDatabase* db_; | 175 LevelDBDatabase* db_; |
171 scoped_ptr<LevelDBWriteBatch> write_batch_; | 176 scoped_ptr<LevelDBWriteBatch> write_batch_; |
172 bool finished_; | 177 bool finished_; |
173 }; | 178 }; |
174 | 179 |
175 } // namespace content | 180 } // namespace content |
176 | 181 |
177 #endif // CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_ | 182 #endif // CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_ |
OLD | NEW |