Changeset 141338 in webkit


Ignore:
Timestamp:
Jan 30, 2013 4:25:37 PM (11 years ago)
Author:
jsbell@chromium.org
Message:

IndexedDB: IDBKeyRange::isOnlyKey() does pointer equality comparison
https://bugs.webkit.org/show_bug.cgi?id=107582

Reviewed by Tony Chang.

Per the bug title, IDBKeyRange::isOnlyKey() was testing the upper/lower pointers to
determine if this was a "trivial" range, which can be used to fast-path lookups. This
is insufficient in multi-process ports where range values may be thrown across the wire.
This is addressed by using the existing key equality tests.

In addition, the bounds type check incorrectly checked m_lowerType == LowerBoundOpen, which
meant the function could never return true (since upper == lower implies closed bounds).
Therefore, the fast-path case wasn't used even in single-process ports (e.g. DRT). The
slow-path case contructed a backing store cursor over the range, and exited early if the
cursor yielded nothing. The fast-path case doesn't need to create a cursor, so needs to
deal with lookup misses. This revealed two similar (but trivial) lurking bugs in the
fast-path.

No new behavior; covered by tests such as: storage/indexeddb/get-keyrange.html

  • Modules/indexeddb/IDBBackingStore.cpp:

(WebCore::IDBBackingStore::getRecord): Handle backing store read miss case.

  • Modules/indexeddb/IDBDatabaseBackendImpl.cpp:

(WebCore::GetOperation::perform): Handle backing store read miss case.

  • Modules/indexeddb/IDBKeyRange.cpp:

(WebCore::IDBKeyRange::isOnlyKey): Compare keys by value, not pointer, correct
type checks, add assertions.

  • Modules/indexeddb/IDBKeyRange.h:

(IDBKeyRange): Move implementation to CPP file.

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r141336 r141338  
     12013-01-30  Joshua Bell  <jsbell@chromium.org>
     2
     3        IndexedDB: IDBKeyRange::isOnlyKey() does pointer equality comparison
     4        https://bugs.webkit.org/show_bug.cgi?id=107582
     5
     6        Reviewed by Tony Chang.
     7
     8        Per the bug title, IDBKeyRange::isOnlyKey() was testing the upper/lower pointers to
     9        determine if this was a "trivial" range, which can be used to fast-path lookups. This
     10        is insufficient in multi-process ports where range values may be thrown across the wire.
     11        This is addressed by using the existing key equality tests.
     12
     13        In addition, the bounds type check incorrectly checked m_lowerType == LowerBoundOpen, which
     14        meant the function could never return true (since upper == lower implies closed bounds).
     15        Therefore, the fast-path case wasn't used even in single-process ports (e.g. DRT). The
     16        slow-path case contructed a backing store cursor over the range, and exited early if the
     17        cursor yielded nothing. The fast-path case doesn't need to create a cursor, so needs to
     18        deal with lookup misses. This revealed two similar (but trivial) lurking bugs in the
     19        fast-path.
     20
     21        No new behavior; covered by tests such as: storage/indexeddb/get-keyrange.html
     22
     23        * Modules/indexeddb/IDBBackingStore.cpp:
     24        (WebCore::IDBBackingStore::getRecord): Handle backing store read miss case.
     25        * Modules/indexeddb/IDBDatabaseBackendImpl.cpp:
     26        (WebCore::GetOperation::perform): Handle backing store read miss case.
     27        * Modules/indexeddb/IDBKeyRange.cpp:
     28        (WebCore::IDBKeyRange::isOnlyKey): Compare keys by value, not pointer, correct
     29        type checks, add assertions.
     30        * Modules/indexeddb/IDBKeyRange.h:
     31        (IDBKeyRange): Move implementation to CPP file.
     32
    1332013-01-30  Joe Mason  <jmason@rim.com>
    234
  • trunk/Source/WebCore/Modules/indexeddb/IDBBackingStore.cpp

    r139289 r141338  
    791791        return false;
    792792    }
     793    if (!found)
     794        return true;
    793795
    794796    int64_t version;
  • trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp

    r141332 r141338  
    756756        return;
    757757    }
     758    if (!primaryKey) {
     759        m_callbacks->onSuccess();
     760        return;
     761    }
    758762    if (m_cursorType == IDBCursorBackendInterface::KeyOnly) {
    759763        // Index Value Retrieval Operation
  • trunk/Source/WebCore/Modules/indexeddb/IDBKeyRange.cpp

    r140457 r141338  
    131131}
    132132
     133bool IDBKeyRange::isOnlyKey() const
     134{
     135    if (m_lowerType != LowerBoundClosed || m_upperType != UpperBoundClosed)
     136        return false;
     137
     138    ASSERT(m_lower);
     139    ASSERT(m_upper);
     140    return m_lower->isEqual(m_upper.get());
     141}
     142
    133143} // namespace WebCore
    134144
  • trunk/Source/WebCore/Modules/indexeddb/IDBKeyRange.h

    r140457 r141338  
    7878    static PassRefPtr<IDBKeyRange> bound(ScriptExecutionContext*, const ScriptValue& lower, const ScriptValue& upper, bool lowerOpen, bool upperOpen, ExceptionCode&);
    7979
    80     bool isOnlyKey()
    81     {
    82         return m_lower == m_upper && m_lowerType == LowerBoundOpen && m_upperType == UpperBoundClosed;
    83     }
     80    bool isOnlyKey() const;
    8481
    8582private:
Note: See TracChangeset for help on using the changeset viewer.