Changeset 209893 in webkit
- Timestamp:
- Dec 15, 2016 5:20:24 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r209890 r209893 1 2016-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 1 28 2016-12-15 Keith Rollin <krollin@apple.com> 2 29 -
trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.cpp
r209824 r209893 108 108 } 109 109 110 result = { m_current Key, m_currentPrimaryKey, m_currentValue ? *m_currentValue : IDBValue() };110 result = { m_currentRecord.key, m_currentRecord.primaryKey, m_currentRecord.value ? *m_currentRecord.value : IDBValue() }; 111 111 } 112 112 … … 224 224 225 225 // If this cursor never fetched any records, we don't need to reset the statement. 226 if (m_current Key.isNull())226 if (m_currentRecord.key.isNull()) 227 227 return; 228 228 … … 231 231 // We might also have to change the statement from closed to open so we don't refetch the current key a second time. 232 232 if (m_cursorDirection == IndexedDB::CursorDirection::Next || m_cursorDirection == IndexedDB::CursorDirection::NextNoDuplicate) { 233 m_currentLowerKey = m_current Key;233 m_currentLowerKey = m_currentRecord.key; 234 234 if (!m_keyRange.lowerOpen) { 235 235 m_keyRange.lowerOpen = true; … … 238 238 } 239 239 } else { 240 m_currentUpperKey = m_current Key;240 m_currentUpperKey = m_currentRecord.key; 241 241 if (!m_keyRange.upperOpen) { 242 242 m_keyRange.upperOpen = true; … … 317 317 bool SQLiteIDBCursor::advanceUnique() 318 318 { 319 IDBKeyData currentKey = m_current Key;319 IDBKeyData currentKey = m_currentRecord.key; 320 320 321 321 while (!m_completed) { … … 324 324 325 325 // If the new current key is different from the old current key, we're done. 326 if (currentKey.compare(m_current Key))326 if (currentKey.compare(m_currentRecord.key)) 327 327 return true; 328 328 } … … 357 357 ASSERT(!m_completed); 358 358 359 m_current Value = nullptr;359 m_currentRecord.value = nullptr; 360 360 361 361 int result = m_statement->step(); … … 364 364 365 365 // 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 = { }; 369 367 m_currentRecordRowID = 0; 370 368 … … 384 382 m_statement->getColumnBlobAsVector(1, keyData); 385 383 386 if (!deserializeIDBKeyData(keyData.data(), keyData.size(), m_current Key)) {384 if (!deserializeIDBKeyData(keyData.data(), keyData.size(), m_currentRecord.key)) { 387 385 LOG_ERROR("Unable to deserialize key data from database while advancing cursor"); 388 386 markAsErrored(); … … 394 392 // The primaryKey of an ObjectStore cursor is the same as its key. 395 393 if (m_indexID == IDBIndexInfo::InvalidId) { 396 m_current PrimaryKey = m_currentKey;394 m_currentRecord.primaryKey = m_currentRecord.key; 397 395 398 396 Vector<String> blobURLs, blobFilePaths; … … 405 403 406 404 if (m_cursorType == IndexedDB::CursorType::KeyAndValue) 407 m_current Value = std::make_unique<IDBValue>(ThreadSafeDataBuffer::adoptVector(keyData), blobURLs, blobFilePaths);405 m_currentRecord.value = std::make_unique<IDBValue>(ThreadSafeDataBuffer::adoptVector(keyData), blobURLs, blobFilePaths); 408 406 } else { 409 if (!deserializeIDBKeyData(keyData.data(), keyData.size(), m_current PrimaryKey)) {407 if (!deserializeIDBKeyData(keyData.data(), keyData.size(), m_currentRecord.primaryKey)) { 410 408 LOG_ERROR("Unable to deserialize value data from database while advancing index cursor"); 411 409 markAsErrored(); … … 427 425 if (result == SQLITE_ROW) { 428 426 objectStoreStatement.getColumnBlobAsVector(0, keyData); 429 m_current Value = std::make_unique<IDBValue>(ThreadSafeDataBuffer::adoptVector(keyData));427 m_currentRecord.value = std::make_unique<IDBValue>(ThreadSafeDataBuffer::adoptVector(keyData)); 430 428 } else if (result == SQLITE_DONE) { 431 429 // This indicates that the record we're trying to retrieve has been removed from the object store. … … 460 458 // 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. 461 459 if (m_cursorDirection == IndexedDB::CursorDirection::Next || m_cursorDirection == IndexedDB::CursorDirection::NextNoDuplicate) { 462 if (m_current Key.compare(targetKey) >= 0)460 if (m_currentRecord.key.compare(targetKey) >= 0) 463 461 break; 464 } else if (m_current Key.compare(targetKey) <= 0)462 } else if (m_currentRecord.key.compare(targetKey) <= 0) 465 463 break; 466 464 … … 469 467 470 468 if (targetPrimaryKey.isValid()) { 471 while (!m_completed && !m_current Key.compare(targetKey)) {469 while (!m_completed && !m_currentRecord.key.compare(targetKey)) { 472 470 if (!result) 473 471 return false; … … 475 473 // 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. 476 474 if (m_cursorDirection == IndexedDB::CursorDirection::Next || m_cursorDirection == IndexedDB::CursorDirection::NextNoDuplicate) { 477 if (m_current PrimaryKey.compare(targetPrimaryKey) >= 0)475 if (m_currentRecord.primaryKey.compare(targetPrimaryKey) >= 0) 478 476 break; 479 } else if (m_current PrimaryKey.compare(targetPrimaryKey) <= 0)477 } else if (m_currentRecord.primaryKey.compare(targetPrimaryKey) <= 0) 480 478 break; 481 479 -
trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.h
r209824 r209893 28 28 #if ENABLE(INDEXED_DATABASE) 29 29 30 #include "IDBCursorRecord.h" 30 31 #include "IDBIndexInfo.h" 31 32 #include "IDBKeyData.h" … … 62 63 int64_t currentRecordRowID() const { return m_currentRecordRowID; } 63 64 64 const IDBKeyData& currentKey() const { return m_current Key; }65 const IDBKeyData& currentPrimaryKey() const { return m_current PrimaryKey; }66 IDBValue* currentValue() const { return m_current Value.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(); } 67 68 68 69 bool advance(uint64_t count); … … 106 107 IDBKeyData m_currentUpperKey; 107 108 108 IDBKeyData m_currentKey; 109 IDBKeyData m_currentPrimaryKey; 110 std::unique_ptr<IDBValue> m_currentValue; 109 IDBCursorRecord m_currentRecord; 111 110 112 111 std::unique_ptr<SQLiteStatement> m_statement; -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r209883 r209893 1993 1993 510D4A37103165EE0049EA54 /* SocketStreamHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 510D4A31103165EE0049EA54 /* SocketStreamHandle.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1994 1994 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 */; }; 1995 1996 511EC1271C50AACA0032F983 /* IDBSerialization.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 511EC1251C50AA570032F983 /* IDBSerialization.cpp */; }; 1996 1997 511EC1281C50AACA0032F983 /* IDBSerialization.h in Headers */ = {isa = PBXBuildFile; fileRef = 511EC1261C50AA570032F983 /* IDBSerialization.h */; }; … … 9185 9186 510D4A31103165EE0049EA54 /* SocketStreamHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocketStreamHandle.h; sourceTree = "<group>"; }; 9186 9187 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>"; }; 9187 9189 511EC1251C50AA570032F983 /* IDBSerialization.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBSerialization.cpp; sourceTree = "<group>"; }; 9188 9190 511EC1261C50AA570032F983 /* IDBSerialization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBSerialization.h; sourceTree = "<group>"; }; … … 17005 17007 517138F91BF3ADAC000D5F01 /* IDBCursorInfo.cpp */, 17006 17008 517138FA1BF3ADAC000D5F01 /* IDBCursorInfo.h */, 17009 5110FCFB1E0362A5006F8D0B /* IDBCursorRecord.h */, 17007 17010 51BA4AC11BBB5CBF00DF3D6D /* IDBDatabaseInfo.cpp */, 17008 17011 51BA4AC21BBB5CBF00DF3D6D /* IDBDatabaseInfo.h */, … … 27206 27209 31955A88160D199200858025 /* RenderSnapshottedPlugIn.h in Headers */, 27207 27210 BC8C8FAE0DDCD31B00B592F4 /* RenderStyle.h in Headers */, 27211 5110FCFC1E03641D006F8D0B /* IDBCursorRecord.h in Headers */, 27208 27212 BC5EB6680E81CB7100B25965 /* RenderStyleConstants.h in Headers */, 27209 27213 436708C112D9CA4B00044234 /* RenderSVGBlock.h in Headers */,
Note: See TracChangeset
for help on using the changeset viewer.