Title: [87491] trunk/Source/WebCore
Revision
87491
Author
h...@chromium.org
Date
2011-05-27 03:54:40 -0700 (Fri, 27 May 2011)

Log Message

2011-05-26  Hans Wennborg  <h...@chromium.org>

        Reviewed by Tony Gentilcore.

        IndexedDB: Support NO_DUPLICATE cursors on LevelDB back-end
        https://bugs.webkit.org/show_bug.cgi?id=61517

        Support cursors where the direction is set to NEXT_NO_DUPLICATE,
        or PREV_NO_DUPLICATE, as specified here:
        http://www.w3.org/TR/IndexedDB/#widl-IDBCursor-NEXT_NO_DUPLICATE

        This is tested by storage/indexeddb/mozilla/indexes.html

        * storage/IDBLevelDBBackingStore.cpp:
        (WebCore::IDBLevelDBBackingStore::openObjectStoreCursor):
        (WebCore::IDBLevelDBBackingStore::openIndexKeyCursor):
        (WebCore::IDBLevelDBBackingStore::openIndexCursor):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (87490 => 87491)


--- trunk/Source/WebCore/ChangeLog	2011-05-27 10:37:23 UTC (rev 87490)
+++ trunk/Source/WebCore/ChangeLog	2011-05-27 10:54:40 UTC (rev 87491)
@@ -2,6 +2,24 @@
 
         Reviewed by Tony Gentilcore.
 
+        IndexedDB: Support NO_DUPLICATE cursors on LevelDB back-end
+        https://bugs.webkit.org/show_bug.cgi?id=61517
+
+        Support cursors where the direction is set to NEXT_NO_DUPLICATE,
+        or PREV_NO_DUPLICATE, as specified here:
+        http://www.w3.org/TR/IndexedDB/#widl-IDBCursor-NEXT_NO_DUPLICATE
+
+        This is tested by storage/indexeddb/mozilla/indexes.html
+
+        * storage/IDBLevelDBBackingStore.cpp:
+        (WebCore::IDBLevelDBBackingStore::openObjectStoreCursor):
+        (WebCore::IDBLevelDBBackingStore::openIndexKeyCursor):
+        (WebCore::IDBLevelDBBackingStore::openIndexCursor):
+
+2011-05-26  Hans Wennborg  <h...@chromium.org>
+
+        Reviewed by Tony Gentilcore.
+
         LevelDB: turn on paranoid checks and verify checksums, log errors
         https://bugs.webkit.org/show_bug.cgi?id=61516
 

Modified: trunk/Source/WebCore/storage/IDBLevelDBBackingStore.cpp (87490 => 87491)


--- trunk/Source/WebCore/storage/IDBLevelDBBackingStore.cpp	2011-05-27 10:37:23 UTC (rev 87490)
+++ trunk/Source/WebCore/storage/IDBLevelDBBackingStore.cpp	2011-05-27 10:54:40 UTC (rev 87491)
@@ -836,13 +836,14 @@
     bool firstSeek();
 
 protected:
-    CursorImplCommon(LevelDBTransaction* transaction, const Vector<char>& lowKey, bool lowOpen, const Vector<char>& highKey, bool highOpen, bool forward)
+    CursorImplCommon(LevelDBTransaction* transaction, const Vector<char>& lowKey, bool lowOpen, const Vector<char>& highKey, bool highOpen, bool forward, bool unique)
         : m_transaction(transaction)
         , m_lowKey(lowKey)
         , m_lowOpen(lowOpen)
         , m_highKey(highKey)
         , m_highOpen(highOpen)
         , m_forward(forward)
+        , m_unique(unique)
     {
     }
     virtual ~CursorImplCommon() {}
@@ -854,6 +855,7 @@
     Vector<char> m_highKey;
     bool m_highOpen;
     bool m_forward;
+    bool m_unique;
     RefPtr<IDBKey> m_currentKey;
 };
 
@@ -909,6 +911,7 @@
 bool CursorImplCommon::continueFunction(const IDBKey* key)
 {
     // FIXME: This shares a lot of code with firstSeek.
+    RefPtr<IDBKey> previousKey = m_currentKey;
 
     for (;;) {
         if (m_forward)
@@ -945,7 +948,8 @@
             }
         }
 
-        // FIXME: Obey the uniqueness constraint (and test for it!)
+        if (m_unique && m_currentKey->isEqual(previousKey.get()))
+            continue;
 
         break;
     }
@@ -955,9 +959,9 @@
 
 class ObjectStoreCursorImpl : public CursorImplCommon {
 public:
-    static PassRefPtr<ObjectStoreCursorImpl> create(LevelDBTransaction* transaction, const Vector<char>& lowKey, bool lowOpen, const Vector<char>& highKey, bool highOpen, bool forward)
+    static PassRefPtr<ObjectStoreCursorImpl> create(LevelDBTransaction* transaction, const Vector<char>& lowKey, bool lowOpen, const Vector<char>& highKey, bool highOpen, bool forward, bool unique)
     {
-        return adoptRef(new ObjectStoreCursorImpl(transaction, lowKey, lowOpen, highKey, highOpen, forward));
+        return adoptRef(new ObjectStoreCursorImpl(transaction, lowKey, lowOpen, highKey, highOpen, forward, unique));
     }
 
     // CursorImplCommon
@@ -967,8 +971,8 @@
     virtual bool loadCurrentRow();
 
 private:
-    ObjectStoreCursorImpl(LevelDBTransaction* transaction, const Vector<char>& lowKey, bool lowOpen, const Vector<char>& highKey, bool highOpen, bool forward)
-        : CursorImplCommon(transaction, lowKey, lowOpen, highKey, highOpen, forward)
+    ObjectStoreCursorImpl(LevelDBTransaction* transaction, const Vector<char>& lowKey, bool lowOpen, const Vector<char>& highKey, bool highOpen, bool forward, bool unique)
+        : CursorImplCommon(transaction, lowKey, lowOpen, highKey, highOpen, forward, unique)
     {
     }
 
@@ -1002,9 +1006,9 @@
 
 class IndexKeyCursorImpl : public CursorImplCommon {
 public:
-    static PassRefPtr<IndexKeyCursorImpl> create(LevelDBTransaction* transaction, const Vector<char>& lowKey, bool lowOpen, const Vector<char>& highKey, bool highOpen, bool forward)
+    static PassRefPtr<IndexKeyCursorImpl> create(LevelDBTransaction* transaction, const Vector<char>& lowKey, bool lowOpen, const Vector<char>& highKey, bool highOpen, bool forward, bool unique)
     {
-        return adoptRef(new IndexKeyCursorImpl(transaction, lowKey, lowOpen, highKey, highOpen, forward));
+        return adoptRef(new IndexKeyCursorImpl(transaction, lowKey, lowOpen, highKey, highOpen, forward, unique));
     }
 
     // CursorImplCommon
@@ -1015,8 +1019,8 @@
     virtual bool loadCurrentRow();
 
 private:
-    IndexKeyCursorImpl(LevelDBTransaction* transaction, const Vector<char>& lowKey, bool lowOpen, const Vector<char>& highKey, bool highOpen, bool forward)
-        : CursorImplCommon(transaction, lowKey, lowOpen, highKey, highOpen, forward)
+    IndexKeyCursorImpl(LevelDBTransaction* transaction, const Vector<char>& lowKey, bool lowOpen, const Vector<char>& highKey, bool highOpen, bool forward, bool unique)
+        : CursorImplCommon(transaction, lowKey, lowOpen, highKey, highOpen, forward, unique)
     {
     }
 
@@ -1065,9 +1069,9 @@
 
 class IndexCursorImpl : public CursorImplCommon {
 public:
-    static PassRefPtr<IndexCursorImpl> create(LevelDBTransaction* transaction, const Vector<char>& lowKey, bool lowOpen, const Vector<char>& highKey, bool highOpen, bool forward)
+    static PassRefPtr<IndexCursorImpl> create(LevelDBTransaction* transaction, const Vector<char>& lowKey, bool lowOpen, const Vector<char>& highKey, bool highOpen, bool forward, bool unique)
     {
-        return adoptRef(new IndexCursorImpl(transaction, lowKey, lowOpen, highKey, highOpen, forward));
+        return adoptRef(new IndexCursorImpl(transaction, lowKey, lowOpen, highKey, highOpen, forward, unique));
     }
 
     // CursorImplCommon
@@ -1078,8 +1082,8 @@
     bool loadCurrentRow();
 
 private:
-    IndexCursorImpl(LevelDBTransaction* transaction, const Vector<char>& lowKey, bool lowOpen, const Vector<char>& highKey, bool highOpen, bool forward)
-        : CursorImplCommon(transaction, lowKey, lowOpen, highKey, highOpen, forward)
+    IndexCursorImpl(LevelDBTransaction* transaction, const Vector<char>& lowKey, bool lowOpen, const Vector<char>& highKey, bool highOpen, bool forward, bool unique)
+        : CursorImplCommon(transaction, lowKey, lowOpen, highKey, highOpen, forward, unique)
     {
     }
 
@@ -1157,6 +1161,7 @@
     bool lowerBound = range && range->lower();
     bool upperBound = range && range->upper();
     bool forward = (direction == IDBCursor::NEXT_NO_DUPLICATE || direction == IDBCursor::NEXT);
+    bool unique = (direction == IDBCursor::NEXT_NO_DUPLICATE || direction == IDBCursor::PREV_NO_DUPLICATE);
 
     bool lowerOpen, upperOpen;
     Vector<char> startKey, stopKey;
@@ -1183,7 +1188,7 @@
         upperOpen = range->upperOpen();
     }
 
-    RefPtr<ObjectStoreCursorImpl> cursor = ObjectStoreCursorImpl::create(m_currentTransaction.get(), startKey, lowerOpen, stopKey, upperOpen, forward);
+    RefPtr<ObjectStoreCursorImpl> cursor = ObjectStoreCursorImpl::create(m_currentTransaction.get(), startKey, lowerOpen, stopKey, upperOpen, forward, unique);
     if (!cursor->firstSeek())
         return 0;
 
@@ -1196,6 +1201,7 @@
     bool lowerBound = range && range->lower();
     bool upperBound = range && range->upper();
     bool forward = (direction == IDBCursor::NEXT_NO_DUPLICATE || direction == IDBCursor::NEXT);
+    bool unique = (direction == IDBCursor::NEXT_NO_DUPLICATE || direction == IDBCursor::PREV_NO_DUPLICATE);
 
     bool lowerOpen, upperOpen;
     Vector<char> startKey, stopKey;
@@ -1224,7 +1230,7 @@
         upperOpen = range->upperOpen();
     }
 
-    RefPtr<IndexKeyCursorImpl> cursor = IndexKeyCursorImpl::create(m_currentTransaction.get(), startKey, lowerOpen, stopKey, upperOpen, forward);
+    RefPtr<IndexKeyCursorImpl> cursor = IndexKeyCursorImpl::create(m_currentTransaction.get(), startKey, lowerOpen, stopKey, upperOpen, forward, unique);
     if (!cursor->firstSeek())
         return 0;
 
@@ -1237,6 +1243,7 @@
     bool lowerBound = range && range->lower();
     bool upperBound = range && range->upper();
     bool forward = (direction == IDBCursor::NEXT_NO_DUPLICATE || direction == IDBCursor::NEXT);
+    bool unique = (direction == IDBCursor::NEXT_NO_DUPLICATE || direction == IDBCursor::PREV_NO_DUPLICATE);
 
     bool lowerOpen, upperOpen;
     Vector<char> startKey, stopKey;
@@ -1265,7 +1272,7 @@
         upperOpen = range->upperOpen();
     }
 
-    RefPtr<IndexCursorImpl> cursor = IndexCursorImpl::create(m_currentTransaction.get(), startKey, lowerOpen, stopKey, upperOpen, forward);
+    RefPtr<IndexCursorImpl> cursor = IndexCursorImpl::create(m_currentTransaction.get(), startKey, lowerOpen, stopKey, upperOpen, forward, unique);
     if (!cursor->firstSeek())
         return 0;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to