Changeset 87491 in webkit
- Timestamp:
- May 27, 2011 3:54:40 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r87490 r87491 1 2011-05-26 Hans Wennborg <hans@chromium.org> 2 3 Reviewed by Tony Gentilcore. 4 5 IndexedDB: Support NO_DUPLICATE cursors on LevelDB back-end 6 https://bugs.webkit.org/show_bug.cgi?id=61517 7 8 Support cursors where the direction is set to NEXT_NO_DUPLICATE, 9 or PREV_NO_DUPLICATE, as specified here: 10 http://www.w3.org/TR/IndexedDB/#widl-IDBCursor-NEXT_NO_DUPLICATE 11 12 This is tested by storage/indexeddb/mozilla/indexes.html 13 14 * storage/IDBLevelDBBackingStore.cpp: 15 (WebCore::IDBLevelDBBackingStore::openObjectStoreCursor): 16 (WebCore::IDBLevelDBBackingStore::openIndexKeyCursor): 17 (WebCore::IDBLevelDBBackingStore::openIndexCursor): 18 1 19 2011-05-26 Hans Wennborg <hans@chromium.org> 2 20 -
trunk/Source/WebCore/storage/IDBLevelDBBackingStore.cpp
r87370 r87491 837 837 838 838 protected: 839 CursorImplCommon(LevelDBTransaction* transaction, const Vector<char>& lowKey, bool lowOpen, const Vector<char>& highKey, bool highOpen, bool forward )839 CursorImplCommon(LevelDBTransaction* transaction, const Vector<char>& lowKey, bool lowOpen, const Vector<char>& highKey, bool highOpen, bool forward, bool unique) 840 840 : m_transaction(transaction) 841 841 , m_lowKey(lowKey) … … 844 844 , m_highOpen(highOpen) 845 845 , m_forward(forward) 846 , m_unique(unique) 846 847 { 847 848 } … … 855 856 bool m_highOpen; 856 857 bool m_forward; 858 bool m_unique; 857 859 RefPtr<IDBKey> m_currentKey; 858 860 }; … … 910 912 { 911 913 // FIXME: This shares a lot of code with firstSeek. 914 RefPtr<IDBKey> previousKey = m_currentKey; 912 915 913 916 for (;;) { … … 946 949 } 947 950 948 // FIXME: Obey the uniqueness constraint (and test for it!) 951 if (m_unique && m_currentKey->isEqual(previousKey.get())) 952 continue; 949 953 950 954 break; … … 956 960 class ObjectStoreCursorImpl : public CursorImplCommon { 957 961 public: 958 static PassRefPtr<ObjectStoreCursorImpl> create(LevelDBTransaction* transaction, const Vector<char>& lowKey, bool lowOpen, const Vector<char>& highKey, bool highOpen, bool forward )962 static PassRefPtr<ObjectStoreCursorImpl> create(LevelDBTransaction* transaction, const Vector<char>& lowKey, bool lowOpen, const Vector<char>& highKey, bool highOpen, bool forward, bool unique) 959 963 { 960 return adoptRef(new ObjectStoreCursorImpl(transaction, lowKey, lowOpen, highKey, highOpen, forward ));964 return adoptRef(new ObjectStoreCursorImpl(transaction, lowKey, lowOpen, highKey, highOpen, forward, unique)); 961 965 } 962 966 … … 968 972 969 973 private: 970 ObjectStoreCursorImpl(LevelDBTransaction* transaction, const Vector<char>& lowKey, bool lowOpen, const Vector<char>& highKey, bool highOpen, bool forward )971 : CursorImplCommon(transaction, lowKey, lowOpen, highKey, highOpen, forward )974 ObjectStoreCursorImpl(LevelDBTransaction* transaction, const Vector<char>& lowKey, bool lowOpen, const Vector<char>& highKey, bool highOpen, bool forward, bool unique) 975 : CursorImplCommon(transaction, lowKey, lowOpen, highKey, highOpen, forward, unique) 972 976 { 973 977 } … … 1003 1007 class IndexKeyCursorImpl : public CursorImplCommon { 1004 1008 public: 1005 static PassRefPtr<IndexKeyCursorImpl> create(LevelDBTransaction* transaction, const Vector<char>& lowKey, bool lowOpen, const Vector<char>& highKey, bool highOpen, bool forward )1009 static PassRefPtr<IndexKeyCursorImpl> create(LevelDBTransaction* transaction, const Vector<char>& lowKey, bool lowOpen, const Vector<char>& highKey, bool highOpen, bool forward, bool unique) 1006 1010 { 1007 return adoptRef(new IndexKeyCursorImpl(transaction, lowKey, lowOpen, highKey, highOpen, forward ));1011 return adoptRef(new IndexKeyCursorImpl(transaction, lowKey, lowOpen, highKey, highOpen, forward, unique)); 1008 1012 } 1009 1013 … … 1016 1020 1017 1021 private: 1018 IndexKeyCursorImpl(LevelDBTransaction* transaction, const Vector<char>& lowKey, bool lowOpen, const Vector<char>& highKey, bool highOpen, bool forward )1019 : CursorImplCommon(transaction, lowKey, lowOpen, highKey, highOpen, forward )1022 IndexKeyCursorImpl(LevelDBTransaction* transaction, const Vector<char>& lowKey, bool lowOpen, const Vector<char>& highKey, bool highOpen, bool forward, bool unique) 1023 : CursorImplCommon(transaction, lowKey, lowOpen, highKey, highOpen, forward, unique) 1020 1024 { 1021 1025 } … … 1066 1070 class IndexCursorImpl : public CursorImplCommon { 1067 1071 public: 1068 static PassRefPtr<IndexCursorImpl> create(LevelDBTransaction* transaction, const Vector<char>& lowKey, bool lowOpen, const Vector<char>& highKey, bool highOpen, bool forward )1072 static PassRefPtr<IndexCursorImpl> create(LevelDBTransaction* transaction, const Vector<char>& lowKey, bool lowOpen, const Vector<char>& highKey, bool highOpen, bool forward, bool unique) 1069 1073 { 1070 return adoptRef(new IndexCursorImpl(transaction, lowKey, lowOpen, highKey, highOpen, forward ));1074 return adoptRef(new IndexCursorImpl(transaction, lowKey, lowOpen, highKey, highOpen, forward, unique)); 1071 1075 } 1072 1076 … … 1079 1083 1080 1084 private: 1081 IndexCursorImpl(LevelDBTransaction* transaction, const Vector<char>& lowKey, bool lowOpen, const Vector<char>& highKey, bool highOpen, bool forward )1082 : CursorImplCommon(transaction, lowKey, lowOpen, highKey, highOpen, forward )1085 IndexCursorImpl(LevelDBTransaction* transaction, const Vector<char>& lowKey, bool lowOpen, const Vector<char>& highKey, bool highOpen, bool forward, bool unique) 1086 : CursorImplCommon(transaction, lowKey, lowOpen, highKey, highOpen, forward, unique) 1083 1087 { 1084 1088 } … … 1158 1162 bool upperBound = range && range->upper(); 1159 1163 bool forward = (direction == IDBCursor::NEXT_NO_DUPLICATE || direction == IDBCursor::NEXT); 1164 bool unique = (direction == IDBCursor::NEXT_NO_DUPLICATE || direction == IDBCursor::PREV_NO_DUPLICATE); 1160 1165 1161 1166 bool lowerOpen, upperOpen; … … 1184 1189 } 1185 1190 1186 RefPtr<ObjectStoreCursorImpl> cursor = ObjectStoreCursorImpl::create(m_currentTransaction.get(), startKey, lowerOpen, stopKey, upperOpen, forward );1191 RefPtr<ObjectStoreCursorImpl> cursor = ObjectStoreCursorImpl::create(m_currentTransaction.get(), startKey, lowerOpen, stopKey, upperOpen, forward, unique); 1187 1192 if (!cursor->firstSeek()) 1188 1193 return 0; … … 1197 1202 bool upperBound = range && range->upper(); 1198 1203 bool forward = (direction == IDBCursor::NEXT_NO_DUPLICATE || direction == IDBCursor::NEXT); 1204 bool unique = (direction == IDBCursor::NEXT_NO_DUPLICATE || direction == IDBCursor::PREV_NO_DUPLICATE); 1199 1205 1200 1206 bool lowerOpen, upperOpen; … … 1225 1231 } 1226 1232 1227 RefPtr<IndexKeyCursorImpl> cursor = IndexKeyCursorImpl::create(m_currentTransaction.get(), startKey, lowerOpen, stopKey, upperOpen, forward );1233 RefPtr<IndexKeyCursorImpl> cursor = IndexKeyCursorImpl::create(m_currentTransaction.get(), startKey, lowerOpen, stopKey, upperOpen, forward, unique); 1228 1234 if (!cursor->firstSeek()) 1229 1235 return 0; … … 1238 1244 bool upperBound = range && range->upper(); 1239 1245 bool forward = (direction == IDBCursor::NEXT_NO_DUPLICATE || direction == IDBCursor::NEXT); 1246 bool unique = (direction == IDBCursor::NEXT_NO_DUPLICATE || direction == IDBCursor::PREV_NO_DUPLICATE); 1240 1247 1241 1248 bool lowerOpen, upperOpen; … … 1266 1273 } 1267 1274 1268 RefPtr<IndexCursorImpl> cursor = IndexCursorImpl::create(m_currentTransaction.get(), startKey, lowerOpen, stopKey, upperOpen, forward );1275 RefPtr<IndexCursorImpl> cursor = IndexCursorImpl::create(m_currentTransaction.get(), startKey, lowerOpen, stopKey, upperOpen, forward, unique); 1269 1276 if (!cursor->firstSeek()) 1270 1277 return 0;
Note: See TracChangeset
for help on using the changeset viewer.