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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 }; | 61 }; |
62 | 62 |
63 typedef std::map<base::StringPiece, Record*, Comparator> DataType; | 63 typedef std::map<base::StringPiece, Record*, Comparator> DataType; |
64 | 64 |
65 class DataIterator : public LevelDBIterator { | 65 class DataIterator : public LevelDBIterator { |
66 public: | 66 public: |
67 static scoped_ptr<DataIterator> Create(LevelDBTransaction* transaction); | 67 static scoped_ptr<DataIterator> Create(LevelDBTransaction* transaction); |
68 virtual ~DataIterator(); | 68 virtual ~DataIterator(); |
69 | 69 |
70 virtual bool IsValid() const OVERRIDE; | 70 virtual bool IsValid() const OVERRIDE; |
71 virtual void SeekToLast() OVERRIDE; | 71 virtual leveldb::Status SeekToLast() OVERRIDE; |
72 virtual void Seek(const base::StringPiece& slice) OVERRIDE; | 72 virtual leveldb::Status Seek(const base::StringPiece& slice) OVERRIDE; |
73 virtual void Next() OVERRIDE; | 73 virtual leveldb::Status Next() OVERRIDE; |
74 virtual void Prev() OVERRIDE; | 74 virtual leveldb::Status Prev() OVERRIDE; |
75 virtual base::StringPiece Key() const OVERRIDE; | 75 virtual base::StringPiece Key() const OVERRIDE; |
76 virtual base::StringPiece Value() const OVERRIDE; | 76 virtual base::StringPiece Value() const OVERRIDE; |
77 bool IsDeleted() const; | 77 bool IsDeleted() const; |
78 | 78 |
79 private: | 79 private: |
80 explicit DataIterator(LevelDBTransaction* transaction); | 80 explicit DataIterator(LevelDBTransaction* transaction); |
81 DataType* data_; | 81 DataType* data_; |
82 DataType::iterator iterator_; | 82 DataType::iterator iterator_; |
83 }; | 83 }; |
84 | 84 |
85 class TransactionIterator : public LevelDBIterator { | 85 class TransactionIterator : public LevelDBIterator { |
86 public: | 86 public: |
87 virtual ~TransactionIterator(); | 87 virtual ~TransactionIterator(); |
88 static scoped_ptr<TransactionIterator> Create( | 88 static scoped_ptr<TransactionIterator> Create( |
89 scoped_refptr<LevelDBTransaction> transaction); | 89 scoped_refptr<LevelDBTransaction> transaction); |
90 | 90 |
91 virtual bool IsValid() const OVERRIDE; | 91 virtual bool IsValid() const OVERRIDE; |
92 virtual void SeekToLast() OVERRIDE; | 92 virtual leveldb::Status SeekToLast() OVERRIDE; |
93 virtual void Seek(const base::StringPiece& target) OVERRIDE; | 93 virtual leveldb::Status Seek(const base::StringPiece& target) OVERRIDE; |
94 virtual void Next() OVERRIDE; | 94 virtual leveldb::Status Next() OVERRIDE; |
95 virtual void Prev() OVERRIDE; | 95 virtual leveldb::Status Prev() OVERRIDE; |
96 virtual base::StringPiece Key() const OVERRIDE; | 96 virtual base::StringPiece Key() const OVERRIDE; |
97 virtual base::StringPiece Value() const OVERRIDE; | 97 virtual base::StringPiece Value() const OVERRIDE; |
98 void DataChanged(); | 98 void DataChanged(); |
99 | 99 |
100 private: | 100 private: |
101 explicit TransactionIterator(scoped_refptr<LevelDBTransaction> transaction); | 101 explicit TransactionIterator(scoped_refptr<LevelDBTransaction> transaction); |
102 void HandleConflictsAndDeletes(); | 102 void HandleConflictsAndDeletes(); |
103 void SetCurrentIteratorToSmallestKey(); | 103 void SetCurrentIteratorToSmallestKey(); |
104 void SetCurrentIteratorToLargestKey(); | 104 void SetCurrentIteratorToLargestKey(); |
105 void RefreshDataIterator() const; | 105 void RefreshDataIterator() const; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 explicit LevelDBDirectTransaction(LevelDBDatabase* db); | 153 explicit LevelDBDirectTransaction(LevelDBDatabase* db); |
154 | 154 |
155 LevelDBDatabase* db_; | 155 LevelDBDatabase* db_; |
156 scoped_ptr<LevelDBWriteBatch> write_batch_; | 156 scoped_ptr<LevelDBWriteBatch> write_batch_; |
157 bool finished_; | 157 bool finished_; |
158 }; | 158 }; |
159 | 159 |
160 } // namespace content | 160 } // namespace content |
161 | 161 |
162 #endif // CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_ | 162 #endif // CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_TRANSACTION_H_ |
OLD | NEW |