Changeset 209893 in webkit


Ignore:
Timestamp:
Dec 15, 2016 5:20:24 PM (7 years ago)
Author:
beidson@apple.com
Message:

IndexedDB: Add an "IDBCursorRecord" struct.
https://bugs.webkit.org/show_bug.cgi?id=165929

Reviewed by Alex Christensen.

No new tests (Refactor, no behavior change).

  • Modules/indexeddb/server/SQLiteIDBCursor.cpp:

(WebCore::IDBServer::SQLiteIDBCursor::currentData):
(WebCore::IDBServer::SQLiteIDBCursor::resetAndRebindStatement):
(WebCore::IDBServer::SQLiteIDBCursor::advanceUnique):
(WebCore::IDBServer::SQLiteIDBCursor::internalAdvanceOnce):
(WebCore::IDBServer::SQLiteIDBCursor::iterate):

  • Modules/indexeddb/server/SQLiteIDBCursor.h:

(WebCore::IDBServer::SQLiteIDBCursor::currentKey):
(WebCore::IDBServer::SQLiteIDBCursor::currentPrimaryKey):
(WebCore::IDBServer::SQLiteIDBCursor::currentValue):

  • Modules/indexeddb/shared/IDBCursorRecord.h: Added.

(WebCore::IDBCursorRecord::encode):
(WebCore::IDBCursorRecord::decode):

  • WebCore.xcodeproj/project.pbxproj:
Location:
trunk/Source/WebCore
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r209890 r209893  
     12016-12-15  Brady Eidson  <beidson@apple.com>
     2
     3        IndexedDB: Add an "IDBCursorRecord" struct.
     4        https://bugs.webkit.org/show_bug.cgi?id=165929
     5
     6        Reviewed by Alex Christensen.
     7
     8        No new tests (Refactor, no behavior change).
     9
     10        * Modules/indexeddb/server/SQLiteIDBCursor.cpp:
     11        (WebCore::IDBServer::SQLiteIDBCursor::currentData):
     12        (WebCore::IDBServer::SQLiteIDBCursor::resetAndRebindStatement):
     13        (WebCore::IDBServer::SQLiteIDBCursor::advanceUnique):
     14        (WebCore::IDBServer::SQLiteIDBCursor::internalAdvanceOnce):
     15        (WebCore::IDBServer::SQLiteIDBCursor::iterate):
     16       
     17        * Modules/indexeddb/server/SQLiteIDBCursor.h:
     18        (WebCore::IDBServer::SQLiteIDBCursor::currentKey):
     19        (WebCore::IDBServer::SQLiteIDBCursor::currentPrimaryKey):
     20        (WebCore::IDBServer::SQLiteIDBCursor::currentValue):
     21
     22        * Modules/indexeddb/shared/IDBCursorRecord.h: Added.
     23        (WebCore::IDBCursorRecord::encode):
     24        (WebCore::IDBCursorRecord::decode):
     25       
     26        * WebCore.xcodeproj/project.pbxproj:
     27
    1282016-12-15  Keith Rollin  <krollin@apple.com>
    229
  • trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.cpp

    r209824 r209893  
    108108    }
    109109
    110     result = { m_currentKey, m_currentPrimaryKey, m_currentValue ? *m_currentValue : IDBValue() };
     110    result = { m_currentRecord.key, m_currentRecord.primaryKey, m_currentRecord.value ? *m_currentRecord.value : IDBValue() };
    111111}
    112112
     
    224224
    225225    // If this cursor never fetched any records, we don't need to reset the statement.
    226     if (m_currentKey.isNull())
     226    if (m_currentRecord.key.isNull())
    227227        return;
    228228
     
    231231    // We might also have to change the statement from closed to open so we don't refetch the current key a second time.
    232232    if (m_cursorDirection == IndexedDB::CursorDirection::Next || m_cursorDirection == IndexedDB::CursorDirection::NextNoDuplicate) {
    233         m_currentLowerKey = m_currentKey;
     233        m_currentLowerKey = m_currentRecord.key;
    234234        if (!m_keyRange.lowerOpen) {
    235235            m_keyRange.lowerOpen = true;
     
    238238        }
    239239    } else {
    240         m_currentUpperKey = m_currentKey;
     240        m_currentUpperKey = m_currentRecord.key;
    241241        if (!m_keyRange.upperOpen) {
    242242            m_keyRange.upperOpen = true;
     
    317317bool SQLiteIDBCursor::advanceUnique()
    318318{
    319     IDBKeyData currentKey = m_currentKey;
     319    IDBKeyData currentKey = m_currentRecord.key;
    320320
    321321    while (!m_completed) {
     
    324324
    325325        // If the new current key is different from the old current key, we're done.
    326         if (currentKey.compare(m_currentKey))
     326        if (currentKey.compare(m_currentRecord.key))
    327327            return true;
    328328    }
     
    357357    ASSERT(!m_completed);
    358358
    359     m_currentValue = nullptr;
     359    m_currentRecord.value = nullptr;
    360360
    361361    int result = m_statement->step();
     
    364364
    365365        // When a cursor reaches its end, that is indicated by having undefined keys/values
    366         m_currentKey = IDBKeyData();
    367         m_currentPrimaryKey = IDBKeyData();
    368         m_currentValue = nullptr;
     366        m_currentRecord = { };
    369367        m_currentRecordRowID = 0;
    370368
     
    384382    m_statement->getColumnBlobAsVector(1, keyData);
    385383
    386     if (!deserializeIDBKeyData(keyData.data(), keyData.size(), m_currentKey)) {
     384    if (!deserializeIDBKeyData(keyData.data(), keyData.size(), m_currentRecord.key)) {
    387385        LOG_ERROR("Unable to deserialize key data from database while advancing cursor");
    388386        markAsErrored();
     
    394392    // The primaryKey of an ObjectStore cursor is the same as its key.
    395393    if (m_indexID == IDBIndexInfo::InvalidId) {
    396         m_currentPrimaryKey = m_currentKey;
     394        m_currentRecord.primaryKey = m_currentRecord.key;
    397395
    398396        Vector<String> blobURLs, blobFilePaths;
     
    405403
    406404        if (m_cursorType == IndexedDB::CursorType::KeyAndValue)
    407             m_currentValue = std::make_unique<IDBValue>(ThreadSafeDataBuffer::adoptVector(keyData), blobURLs, blobFilePaths);
     405            m_currentRecord.value = std::make_unique<IDBValue>(ThreadSafeDataBuffer::adoptVector(keyData), blobURLs, blobFilePaths);
    408406    } else {
    409         if (!deserializeIDBKeyData(keyData.data(), keyData.size(), m_currentPrimaryKey)) {
     407        if (!deserializeIDBKeyData(keyData.data(), keyData.size(), m_currentRecord.primaryKey)) {
    410408            LOG_ERROR("Unable to deserialize value data from database while advancing index cursor");
    411409            markAsErrored();
     
    427425        if (result == SQLITE_ROW) {
    428426            objectStoreStatement.getColumnBlobAsVector(0, keyData);
    429             m_currentValue = std::make_unique<IDBValue>(ThreadSafeDataBuffer::adoptVector(keyData));
     427            m_currentRecord.value = std::make_unique<IDBValue>(ThreadSafeDataBuffer::adoptVector(keyData));
    430428        } else if (result == SQLITE_DONE) {
    431429            // This indicates that the record we're trying to retrieve has been removed from the object store.
     
    460458        // Search for the next key >= the target if the cursor is a Next cursor, or the next key <= if the cursor is a Previous cursor.
    461459        if (m_cursorDirection == IndexedDB::CursorDirection::Next || m_cursorDirection == IndexedDB::CursorDirection::NextNoDuplicate) {
    462             if (m_currentKey.compare(targetKey) >= 0)
     460            if (m_currentRecord.key.compare(targetKey) >= 0)
    463461                break;
    464         } else if (m_currentKey.compare(targetKey) <= 0)
     462        } else if (m_currentRecord.key.compare(targetKey) <= 0)
    465463            break;
    466464
     
    469467
    470468    if (targetPrimaryKey.isValid()) {
    471         while (!m_completed && !m_currentKey.compare(targetKey)) {
     469        while (!m_completed && !m_currentRecord.key.compare(targetKey)) {
    472470            if (!result)
    473471                return false;
     
    475473            // Search for the next primary key >= the primary target if the cursor is a Next cursor, or the next key <= if the cursor is a Previous cursor.
    476474            if (m_cursorDirection == IndexedDB::CursorDirection::Next || m_cursorDirection == IndexedDB::CursorDirection::NextNoDuplicate) {
    477                 if (m_currentPrimaryKey.compare(targetPrimaryKey) >= 0)
     475                if (m_currentRecord.primaryKey.compare(targetPrimaryKey) >= 0)
    478476                    break;
    479             } else if (m_currentPrimaryKey.compare(targetPrimaryKey) <= 0)
     477            } else if (m_currentRecord.primaryKey.compare(targetPrimaryKey) <= 0)
    480478                break;
    481479
  • trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.h

    r209824 r209893  
    2828#if ENABLE(INDEXED_DATABASE)
    2929
     30#include "IDBCursorRecord.h"
    3031#include "IDBIndexInfo.h"
    3132#include "IDBKeyData.h"
     
    6263    int64_t currentRecordRowID() const { return m_currentRecordRowID; }
    6364
    64     const IDBKeyData& currentKey() const { return m_currentKey; }
    65     const IDBKeyData& currentPrimaryKey() const { return m_currentPrimaryKey; }
    66     IDBValue* currentValue() const { return m_currentValue.get(); }
     65    const IDBKeyData& currentKey() const { return m_currentRecord.key; }
     66    const IDBKeyData& currentPrimaryKey() const { return m_currentRecord.primaryKey; }
     67    IDBValue* currentValue() const { return m_currentRecord.value.get(); }
    6768
    6869    bool advance(uint64_t count);
     
    106107    IDBKeyData m_currentUpperKey;
    107108
    108     IDBKeyData m_currentKey;
    109     IDBKeyData m_currentPrimaryKey;
    110     std::unique_ptr<IDBValue> m_currentValue;
     109    IDBCursorRecord m_currentRecord;
    111110
    112111    std::unique_ptr<SQLiteStatement> m_statement;
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r209883 r209893  
    19931993                510D4A37103165EE0049EA54 /* SocketStreamHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 510D4A31103165EE0049EA54 /* SocketStreamHandle.h */; settings = {ATTRIBUTES = (Private, ); }; };
    19941994                510D4A38103165EE0049EA54 /* SocketStreamHandleClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 510D4A32103165EE0049EA54 /* SocketStreamHandleClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1995                5110FCFC1E03641D006F8D0B /* IDBCursorRecord.h in Headers */ = {isa = PBXBuildFile; fileRef = 5110FCFB1E0362A5006F8D0B /* IDBCursorRecord.h */; };
    19951996                511EC1271C50AACA0032F983 /* IDBSerialization.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 511EC1251C50AA570032F983 /* IDBSerialization.cpp */; };
    19961997                511EC1281C50AACA0032F983 /* IDBSerialization.h in Headers */ = {isa = PBXBuildFile; fileRef = 511EC1261C50AA570032F983 /* IDBSerialization.h */; };
     
    91859186                510D4A31103165EE0049EA54 /* SocketStreamHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocketStreamHandle.h; sourceTree = "<group>"; };
    91869187                510D4A32103165EE0049EA54 /* SocketStreamHandleClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocketStreamHandleClient.h; sourceTree = "<group>"; };
     9188                5110FCFB1E0362A5006F8D0B /* IDBCursorRecord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBCursorRecord.h; sourceTree = "<group>"; };
    91879189                511EC1251C50AA570032F983 /* IDBSerialization.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBSerialization.cpp; sourceTree = "<group>"; };
    91889190                511EC1261C50AA570032F983 /* IDBSerialization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBSerialization.h; sourceTree = "<group>"; };
     
    1700517007                                517138F91BF3ADAC000D5F01 /* IDBCursorInfo.cpp */,
    1700617008                                517138FA1BF3ADAC000D5F01 /* IDBCursorInfo.h */,
     17009                                5110FCFB1E0362A5006F8D0B /* IDBCursorRecord.h */,
    1700717010                                51BA4AC11BBB5CBF00DF3D6D /* IDBDatabaseInfo.cpp */,
    1700817011                                51BA4AC21BBB5CBF00DF3D6D /* IDBDatabaseInfo.h */,
     
    2720627209                                31955A88160D199200858025 /* RenderSnapshottedPlugIn.h in Headers */,
    2720727210                                BC8C8FAE0DDCD31B00B592F4 /* RenderStyle.h in Headers */,
     27211                                5110FCFC1E03641D006F8D0B /* IDBCursorRecord.h in Headers */,
    2720827212                                BC5EB6680E81CB7100B25965 /* RenderStyleConstants.h in Headers */,
    2720927213                                436708C112D9CA4B00044234 /* RenderSVGBlock.h in Headers */,
Note: See TracChangeset for help on using the changeset viewer.