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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 virtual bool IsValid() const OVERRIDE; | 99 virtual bool IsValid() const OVERRIDE; |
100 virtual leveldb::Status SeekToLast() OVERRIDE; | 100 virtual leveldb::Status SeekToLast() OVERRIDE; |
101 virtual leveldb::Status Seek(const base::StringPiece& target) OVERRIDE; | 101 virtual leveldb::Status Seek(const base::StringPiece& target) OVERRIDE; |
102 virtual leveldb::Status Next() OVERRIDE; | 102 virtual leveldb::Status Next() OVERRIDE; |
103 virtual leveldb::Status Prev() OVERRIDE; | 103 virtual leveldb::Status Prev() OVERRIDE; |
104 virtual base::StringPiece Key() const OVERRIDE; | 104 virtual base::StringPiece Key() const OVERRIDE; |
105 virtual base::StringPiece Value() const OVERRIDE; | 105 virtual base::StringPiece Value() const OVERRIDE; |
106 void DataChanged(); | 106 void DataChanged(); |
107 | 107 |
108 private: | 108 private: |
| 109 enum Direction { FORWARD, REVERSE }; |
| 110 |
109 explicit TransactionIterator(scoped_refptr<LevelDBTransaction> transaction); | 111 explicit TransactionIterator(scoped_refptr<LevelDBTransaction> transaction); |
110 void HandleConflictsAndDeletes(); | 112 void HandleConflictsAndDeletes(); |
111 void SetCurrentIteratorToSmallestKey(); | 113 void SetCurrentIteratorToSmallestKey(); |
112 void SetCurrentIteratorToLargestKey(); | 114 void SetCurrentIteratorToLargestKey(); |
113 void RefreshDataIterator() const; | 115 void RefreshDataIterator() const; |
114 bool DataIteratorIsLower() const; | 116 bool DataIteratorIsLower() const; |
115 bool DataIteratorIsHigher() const; | 117 bool DataIteratorIsHigher() const; |
116 | 118 |
117 scoped_refptr<LevelDBTransaction> transaction_; | 119 scoped_refptr<LevelDBTransaction> transaction_; |
118 const LevelDBComparator* comparator_; | 120 const LevelDBComparator* comparator_; |
119 mutable scoped_ptr<DataIterator> data_iterator_; | 121 mutable scoped_ptr<DataIterator> data_iterator_; |
120 scoped_ptr<LevelDBIterator> db_iterator_; | 122 scoped_ptr<LevelDBIterator> db_iterator_; |
121 LevelDBIterator* current_; | 123 LevelDBIterator* current_; |
122 | 124 |
123 enum Direction { | |
124 FORWARD, | |
125 REVERSE | |
126 }; | |
127 Direction direction_; | 125 Direction direction_; |
128 mutable bool data_changed_; | 126 mutable bool data_changed_; |
129 | 127 |
130 DISALLOW_COPY_AND_ASSIGN(TransactionIterator); | 128 DISALLOW_COPY_AND_ASSIGN(TransactionIterator); |
131 }; | 129 }; |
132 | 130 |
133 void Set(const base::StringPiece& key, std::string* value, bool deleted); | 131 void Set(const base::StringPiece& key, std::string* value, bool deleted); |
134 void Clear(); | 132 void Clear(); |
135 void RegisterIterator(TransactionIterator* iterator); | 133 void RegisterIterator(TransactionIterator* iterator); |
136 void UnregisterIterator(TransactionIterator* iterator); | 134 void UnregisterIterator(TransactionIterator* iterator); |
(...skipping 30 matching lines...) Expand all Loading... |
167 LevelDBDatabase* db_; | 165 LevelDBDatabase* db_; |
168 scoped_ptr<LevelDBWriteBatch> write_batch_; | 166 scoped_ptr<LevelDBWriteBatch> write_batch_; |
169 bool finished_; | 167 bool finished_; |
170 | 168 |
171 DISALLOW_COPY_AND_ASSIGN(LevelDBDirectTransaction); | 169 DISALLOW_COPY_AND_ASSIGN(LevelDBDirectTransaction); |
172 }; | 170 }; |
173 | 171 |
174 } // namespace content | 172 } // namespace content |
175 | 173 |
176 #endif // CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_ | 174 #endif // CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_ |
OLD | NEW |