Changeset 87491 in webkit


Ignore:
Timestamp:
May 27, 2011 3:54:40 AM (13 years ago)
Author:
hans@chromium.org
Message:

2011-05-26 Hans Wennborg <hans@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):
Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r87490 r87491  
     12011-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
    1192011-05-26  Hans Wennborg  <hans@chromium.org>
    220
  • trunk/Source/WebCore/storage/IDBLevelDBBackingStore.cpp

    r87370 r87491  
    837837
    838838protected:
    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)
    840840        : m_transaction(transaction)
    841841        , m_lowKey(lowKey)
     
    844844        , m_highOpen(highOpen)
    845845        , m_forward(forward)
     846        , m_unique(unique)
    846847    {
    847848    }
     
    855856    bool m_highOpen;
    856857    bool m_forward;
     858    bool m_unique;
    857859    RefPtr<IDBKey> m_currentKey;
    858860};
     
    910912{
    911913    // FIXME: This shares a lot of code with firstSeek.
     914    RefPtr<IDBKey> previousKey = m_currentKey;
    912915
    913916    for (;;) {
     
    946949        }
    947950
    948         // FIXME: Obey the uniqueness constraint (and test for it!)
     951        if (m_unique && m_currentKey->isEqual(previousKey.get()))
     952            continue;
    949953
    950954        break;
     
    956960class ObjectStoreCursorImpl : public CursorImplCommon {
    957961public:
    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)
    959963    {
    960         return adoptRef(new ObjectStoreCursorImpl(transaction, lowKey, lowOpen, highKey, highOpen, forward));
     964        return adoptRef(new ObjectStoreCursorImpl(transaction, lowKey, lowOpen, highKey, highOpen, forward, unique));
    961965    }
    962966
     
    968972
    969973private:
    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)
    972976    {
    973977    }
     
    10031007class IndexKeyCursorImpl : public CursorImplCommon {
    10041008public:
    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)
    10061010    {
    1007         return adoptRef(new IndexKeyCursorImpl(transaction, lowKey, lowOpen, highKey, highOpen, forward));
     1011        return adoptRef(new IndexKeyCursorImpl(transaction, lowKey, lowOpen, highKey, highOpen, forward, unique));
    10081012    }
    10091013
     
    10161020
    10171021private:
    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)
    10201024    {
    10211025    }
     
    10661070class IndexCursorImpl : public CursorImplCommon {
    10671071public:
    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)
    10691073    {
    1070         return adoptRef(new IndexCursorImpl(transaction, lowKey, lowOpen, highKey, highOpen, forward));
     1074        return adoptRef(new IndexCursorImpl(transaction, lowKey, lowOpen, highKey, highOpen, forward, unique));
    10711075    }
    10721076
     
    10791083
    10801084private:
    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)
    10831087    {
    10841088    }
     
    11581162    bool upperBound = range && range->upper();
    11591163    bool forward = (direction == IDBCursor::NEXT_NO_DUPLICATE || direction == IDBCursor::NEXT);
     1164    bool unique = (direction == IDBCursor::NEXT_NO_DUPLICATE || direction == IDBCursor::PREV_NO_DUPLICATE);
    11601165
    11611166    bool lowerOpen, upperOpen;
     
    11841189    }
    11851190
    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);
    11871192    if (!cursor->firstSeek())
    11881193        return 0;
     
    11971202    bool upperBound = range && range->upper();
    11981203    bool forward = (direction == IDBCursor::NEXT_NO_DUPLICATE || direction == IDBCursor::NEXT);
     1204    bool unique = (direction == IDBCursor::NEXT_NO_DUPLICATE || direction == IDBCursor::PREV_NO_DUPLICATE);
    11991205
    12001206    bool lowerOpen, upperOpen;
     
    12251231    }
    12261232
    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);
    12281234    if (!cursor->firstSeek())
    12291235        return 0;
     
    12381244    bool upperBound = range && range->upper();
    12391245    bool forward = (direction == IDBCursor::NEXT_NO_DUPLICATE || direction == IDBCursor::NEXT);
     1246    bool unique = (direction == IDBCursor::NEXT_NO_DUPLICATE || direction == IDBCursor::PREV_NO_DUPLICATE);
    12401247
    12411248    bool lowerOpen, upperOpen;
     
    12661273    }
    12671274
    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);
    12691276    if (!cursor->firstSeek())
    12701277        return 0;
Note: See TracChangeset for help on using the changeset viewer.