Title: [163245] trunk/Source
Revision
163245
Author
[email protected]
Date
2014-02-01 11:04:02 -0800 (Sat, 01 Feb 2014)

Log Message

IDB: Index cursor complete advance() and iterate() support
<rdar://problem/15941916> and https://bugs.webkit.org/show_bug.cgi?id=127870

Reviewed by Dan Bernstein.

Source/WebCore:

* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::onSuccess): Always use the value buffer for the script object.

Source/WebKit2:

* DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.cpp:
(WebKit::SQLiteIDBCursor::advanceOnce): Look up the found record value from the
  object store records based on the key we found from the index.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (163244 => 163245)


--- trunk/Source/WebCore/ChangeLog	2014-02-01 18:14:17 UTC (rev 163244)
+++ trunk/Source/WebCore/ChangeLog	2014-02-01 19:04:02 UTC (rev 163245)
@@ -1,3 +1,13 @@
+2014-02-01  Brady Eidson  <[email protected]>
+
+        IDB: Index cursor complete advance() and iterate() support
+        <rdar://problem/15941916> and https://bugs.webkit.org/show_bug.cgi?id=127870
+
+        Reviewed by Dan Bernstein.
+
+        * Modules/indexeddb/IDBRequest.cpp:
+        (WebCore::IDBRequest::onSuccess): Always use the value buffer for the script object.
+
 2014-02-01  Alexey Proskuryakov  <[email protected]>
 
         Update WebCrypto JWK mapping to use key_ops

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp (163244 => 163245)


--- trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp	2014-02-01 18:14:17 UTC (rev 163244)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp	2014-02-01 19:04:02 UTC (rev 163245)
@@ -287,13 +287,8 @@
     RefPtr<IDBKey> key = backend->key();
     RefPtr<IDBKey> primaryKey = backend->primaryKey();
 
-    Deprecated::ScriptValue value;
+    Deprecated::ScriptValue value = deserializeIDBValueBuffer(requestState(), backend->valueBuffer());
 
-    if (backend->valueKey())
-        value = idbKeyToScriptValue(requestState(), backend->valueKey());
-    else
-        value = deserializeIDBValueBuffer(requestState(), backend->valueBuffer());
-
     ASSERT(!m_pendingCursor);
     RefPtr<IDBCursor> cursor;
     switch (m_cursorType) {
@@ -409,7 +404,7 @@
     onSuccess(key, primaryKey, buffer, nullptr);
 }
 
-void IDBRequest::onSuccess(PassRefPtr<IDBKey> key, PassRefPtr<IDBKey> primaryKey, PassRefPtr<SharedBuffer> buffer, PassRefPtr<IDBKey> valueKey)
+void IDBRequest::onSuccess(PassRefPtr<IDBKey> key, PassRefPtr<IDBKey> primaryKey, PassRefPtr<SharedBuffer> buffer, PassRefPtr<IDBKey>)
 {
     LOG(StorageAPI, "IDBRequest::onSuccess(key, primaryKey, valueBuffer, valueKey)");
     if (!shouldEnqueueEvent())
@@ -417,11 +412,7 @@
 
     DOMRequestState::Scope scope(m_requestState);
 
-    Deprecated::ScriptValue value;
-    if (valueKey)
-        value = idbKeyToScriptValue(requestState(), valueKey);
-    else
-        value = deserializeIDBValueBuffer(requestState(), buffer);
+    Deprecated::ScriptValue value = deserializeIDBValueBuffer(requestState(), buffer);
 
     ASSERT(m_pendingCursor);
     setResultCursor(m_pendingCursor.release(), key, primaryKey, value);

Modified: trunk/Source/WebKit2/ChangeLog (163244 => 163245)


--- trunk/Source/WebKit2/ChangeLog	2014-02-01 18:14:17 UTC (rev 163244)
+++ trunk/Source/WebKit2/ChangeLog	2014-02-01 19:04:02 UTC (rev 163245)
@@ -1,3 +1,14 @@
+2014-02-01  Brady Eidson  <[email protected]>
+
+        IDB: Index cursor complete advance() and iterate() support
+        <rdar://problem/15941916> and https://bugs.webkit.org/show_bug.cgi?id=127870
+
+        Reviewed by Dan Bernstein.
+
+        * DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.cpp:
+        (WebKit::SQLiteIDBCursor::advanceOnce): Look up the found record value from the
+          object store records based on the key we found from the index.
+
 2014-01-31  Anders Carlsson  <[email protected]>
 
         Add webView:didFailNavigation:withError: delegate method

Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.cpp (163244 => 163245)


--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.cpp	2014-02-01 18:14:17 UTC (rev 163244)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.cpp	2014-02-01 19:04:02 UTC (rev 163245)
@@ -283,13 +283,22 @@
 
     if (m_indexID != IDBIndexMetadata::InvalidId) {
         if (!deserializeIDBKeyData(reinterpret_cast<const uint8_t*>(keyData.data()), keyData.size(), m_currentValueKey)) {
-            LOG_ERROR("Unable to deserialize value data from database while advancing cursor");
+            LOG_ERROR("Unable to deserialize value data from database while advancing index cursor");
             m_completed = true;
             return false;
         }
 
-        // Index cursors should only have a m_currentValueKey, and not m_currentValueBuffer
-        m_currentValueBuffer.clear();
+        SQLiteStatement objectStoreStatement(*m_statement->database(), "SELECT value FROM Records WHERE key = CAST(? AS TEXT) and objectStoreID = ?;");
+
+        if (objectStoreStatement.prepare() != SQLResultOk
+            || objectStoreStatement.bindBlob(1, m_currentValueBuffer.data(), m_currentValueBuffer.size()) != SQLResultOk
+            || objectStoreStatement.bindInt64(2, m_objectStoreID) != SQLResultOk
+            || objectStoreStatement.step() != SQLResultRow) {
+            LOG_ERROR("Could not create index cursor statement into object store records");
+            return false;
+        }
+
+        objectStoreStatement.getColumnBlobAsVector(0, m_currentValueBuffer);
     }
 
     return true;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to