| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 : comparator_(comparator) {} | 63 : comparator_(comparator) {} |
| 64 bool operator()(const base::StringPiece& a, | 64 bool operator()(const base::StringPiece& a, |
| 65 const base::StringPiece& b) const { | 65 const base::StringPiece& b) const { |
| 66 return comparator_->Compare(a, b) < 0; | 66 return comparator_->Compare(a, b) < 0; |
| 67 } | 67 } |
| 68 | 68 |
| 69 private: | 69 private: |
| 70 const LevelDBComparator* comparator_; | 70 const LevelDBComparator* comparator_; |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 typedef std::map<base::StringPiece, Record*, Comparator> DataType; | 73 typedef std::map<base::StringPiece, std::unique_ptr<Record>, Comparator> |
| 74 DataType; |
| 74 | 75 |
| 75 class DataIterator : public LevelDBIterator { | 76 class DataIterator : public LevelDBIterator { |
| 76 public: | 77 public: |
| 77 static std::unique_ptr<DataIterator> Create( | 78 static std::unique_ptr<DataIterator> Create( |
| 78 LevelDBTransaction* transaction); | 79 LevelDBTransaction* transaction); |
| 79 ~DataIterator() override; | 80 ~DataIterator() override; |
| 80 | 81 |
| 81 bool IsValid() const override; | 82 bool IsValid() const override; |
| 82 leveldb::Status SeekToLast() override; | 83 leveldb::Status SeekToLast() override; |
| 83 leveldb::Status Seek(const base::StringPiece& slice) override; | 84 leveldb::Status Seek(const base::StringPiece& slice) override; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 std::unique_ptr<LevelDBIterator> db_iterator_; | 128 std::unique_ptr<LevelDBIterator> db_iterator_; |
| 128 LevelDBIterator* current_; | 129 LevelDBIterator* current_; |
| 129 | 130 |
| 130 Direction direction_; | 131 Direction direction_; |
| 131 mutable bool data_changed_; | 132 mutable bool data_changed_; |
| 132 | 133 |
| 133 DISALLOW_COPY_AND_ASSIGN(TransactionIterator); | 134 DISALLOW_COPY_AND_ASSIGN(TransactionIterator); |
| 134 }; | 135 }; |
| 135 // Returns true if the key was originally marked deleted, false otherwise. | 136 // Returns true if the key was originally marked deleted, false otherwise. |
| 136 bool Set(const base::StringPiece& key, std::string* value, bool deleted); | 137 bool Set(const base::StringPiece& key, std::string* value, bool deleted); |
| 137 void Clear(); | |
| 138 void RegisterIterator(TransactionIterator* iterator); | 138 void RegisterIterator(TransactionIterator* iterator); |
| 139 void UnregisterIterator(TransactionIterator* iterator); | 139 void UnregisterIterator(TransactionIterator* iterator); |
| 140 void NotifyIterators(); | 140 void NotifyIterators(); |
| 141 | 141 |
| 142 LevelDBDatabase* db_; | 142 LevelDBDatabase* db_; |
| 143 const LevelDBSnapshot snapshot_; | 143 const LevelDBSnapshot snapshot_; |
| 144 const LevelDBComparator* comparator_; | 144 const LevelDBComparator* comparator_; |
| 145 Comparator data_comparator_; | 145 Comparator data_comparator_; |
| 146 DataType data_; | 146 DataType data_; |
| 147 bool finished_; | 147 bool finished_; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 170 LevelDBDatabase* db_; | 170 LevelDBDatabase* db_; |
| 171 std::unique_ptr<LevelDBWriteBatch> write_batch_; | 171 std::unique_ptr<LevelDBWriteBatch> write_batch_; |
| 172 bool finished_; | 172 bool finished_; |
| 173 | 173 |
| 174 DISALLOW_COPY_AND_ASSIGN(LevelDBDirectTransaction); | 174 DISALLOW_COPY_AND_ASSIGN(LevelDBDirectTransaction); |
| 175 }; | 175 }; |
| 176 | 176 |
| 177 } // namespace content | 177 } // namespace content |
| 178 | 178 |
| 179 #endif // CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_ | 179 #endif // CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_ |
| OLD | NEW |