Title: [121477] trunk/Source
Revision
121477
Author
[email protected]
Date
2012-06-28 15:57:08 -0700 (Thu, 28 Jun 2012)

Log Message

IndexedDB: Hook up render-side key ASSERTing for get()
https://bugs.webkit.org/show_bug.cgi?id=90001

Patch by Alec Flett <[email protected]> on 2012-06-28
Reviewed by Tony Chang.

Source/WebCore:

Hook up the new onSuccess and add it to the interface. For now,
simply assert that the right value is set. Add the same assertion
logic in the value-construction logic when the cursor advances.

No new tests, existing tests verify this refactor is correct.

* Modules/indexeddb/IDBCallbacks.h:
(IDBCallbacks):
* Modules/indexeddb/IDBObjectStoreBackendImpl.cpp:
(WebCore::IDBObjectStoreBackendImpl::getInternal):
* Modules/indexeddb/IDBRequest.cpp:
(WebCore):
(WebCore::IDBRequest::onSuccess):
* Modules/indexeddb/IDBRequest.h:
* bindings/v8/IDBBindingUtilities.cpp:
(WebCore::createIDBKeyFromSerializedValueAndKeyPath):
* inspector/InspectorIndexedDBAgent.cpp:
(WebCore):

Source/WebKit/chromium:

Hook up Chromium WebKit API to new onSuccess handler.

* src/WebIDBCallbacksImpl.cpp:
(WebKit::WebIDBCallbacksImpl::onSuccess):
* tests/IDBAbortOnCorruptTest.cpp:
(WebCore::MockIDBCallbacks::onSuccess):
* tests/IDBDatabaseBackendTest.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (121476 => 121477)


--- trunk/Source/WebCore/ChangeLog	2012-06-28 22:45:18 UTC (rev 121476)
+++ trunk/Source/WebCore/ChangeLog	2012-06-28 22:57:08 UTC (rev 121477)
@@ -1,3 +1,29 @@
+2012-06-28  Alec Flett  <[email protected]>
+
+        IndexedDB: Hook up render-side key ASSERTing for get()
+        https://bugs.webkit.org/show_bug.cgi?id=90001
+
+        Reviewed by Tony Chang.
+
+        Hook up the new onSuccess and add it to the interface. For now,
+        simply assert that the right value is set. Add the same assertion
+        logic in the value-construction logic when the cursor advances.
+
+        No new tests, existing tests verify this refactor is correct.
+
+        * Modules/indexeddb/IDBCallbacks.h:
+        (IDBCallbacks):
+        * Modules/indexeddb/IDBObjectStoreBackendImpl.cpp:
+        (WebCore::IDBObjectStoreBackendImpl::getInternal):
+        * Modules/indexeddb/IDBRequest.cpp:
+        (WebCore):
+        (WebCore::IDBRequest::onSuccess):
+        * Modules/indexeddb/IDBRequest.h:
+        * bindings/v8/IDBBindingUtilities.cpp:
+        (WebCore::createIDBKeyFromSerializedValueAndKeyPath):
+        * inspector/InspectorIndexedDBAgent.cpp:
+        (WebCore):
+
 2012-06-28  Gregg Tavares  <[email protected]>
 
         Add support for DEPTH_STENCIL to WEBGL_depth_texture

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBCallbacks.h (121476 => 121477)


--- trunk/Source/WebCore/Modules/indexeddb/IDBCallbacks.h	2012-06-28 22:45:18 UTC (rev 121476)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBCallbacks.h	2012-06-28 22:57:08 UTC (rev 121477)
@@ -34,6 +34,7 @@
 #include "IDBDatabaseBackendInterface.h"
 #include "IDBDatabaseError.h"
 #include "IDBKey.h"
+#include "IDBKeyPath.h"
 #include "IDBObjectStoreBackendInterface.h"
 #include "IDBTransactionBackendInterface.h"
 #include "SerializedScriptValue.h"
@@ -55,6 +56,7 @@
     virtual void onSuccess(PassRefPtr<IDBKey>) = 0;
     virtual void onSuccess(PassRefPtr<IDBTransactionBackendInterface>) = 0;
     virtual void onSuccess(PassRefPtr<SerializedScriptValue>) = 0;
+    virtual void onSuccess(PassRefPtr<SerializedScriptValue>, PassRefPtr<IDBKey>, const IDBKeyPath&) = 0;
     virtual void onSuccessWithContinuation() = 0;
     virtual void onSuccessWithPrefetch(const Vector<RefPtr<IDBKey> >& keys, const Vector<RefPtr<IDBKey> >& primaryKeys, const Vector<RefPtr<SerializedScriptValue> >& values) = 0;
     virtual void onBlocked() = 0;

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBCursor.cpp (121476 => 121477)


--- trunk/Source/WebCore/Modules/indexeddb/IDBCursor.cpp	2012-06-28 22:45:18 UTC (rev 121476)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBCursor.cpp	2012-06-28 22:57:08 UTC (rev 121477)
@@ -266,7 +266,21 @@
 {
     m_currentKey = m_backend->key();
     m_currentPrimaryKey = m_backend->primaryKey();
-    m_currentValue = IDBAny::create(m_backend->value());
+
+    RefPtr<SerializedScriptValue> value = m_backend->value();
+#ifndef NDEBUG
+    if (!isKeyCursor()) {
+        // FIXME: Actually inject the primaryKey at the keyPath.
+        RefPtr<IDBObjectStore> objectStore = effectiveObjectStore();
+        if (objectStore->autoIncrement() && !objectStore->metadata().keyPath.isNull()) {
+            const IDBKeyPath& keyPath = objectStore->metadata().keyPath;
+            RefPtr<IDBKey> expectedKey = createIDBKeyFromSerializedValueAndKeyPath(value, keyPath);
+            ASSERT(expectedKey->isEqual(m_currentPrimaryKey.get()));
+        }
+    }
+#endif
+    m_currentValue = IDBAny::create(value.release());
+
     m_gotValue = true;
     m_valueIsDirty = true;
 }

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp (121476 => 121477)


--- trunk/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp	2012-06-28 22:45:18 UTC (rev 121476)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp	2012-06-28 22:57:08 UTC (rev 121477)
@@ -112,6 +112,11 @@
         return;
     }
 
+    if (objectStore->autoIncrement() && !objectStore->keyPath().isNull()) {
+        callbacks->onSuccess(SerializedScriptValue::createFromWire(wireData),
+                             key, objectStore->keyPath());
+        return;
+    }
     callbacks->onSuccess(SerializedScriptValue::createFromWire(wireData));
 }
 

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp (121476 => 121477)


--- trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp	2012-06-28 22:45:18 UTC (rev 121476)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp	2012-06-28 22:57:08 UTC (rev 121477)
@@ -35,6 +35,7 @@
 #include "EventListener.h"
 #include "EventNames.h"
 #include "EventQueue.h"
+#include "IDBBindingUtilities.h"
 #include "IDBCursorWithValue.h"
 #include "IDBDatabase.h"
 #include "IDBEventDispatcher.h"
@@ -304,6 +305,21 @@
     enqueueEvent(createSuccessEvent());
 }
 
+
+void IDBRequest::onSuccess(PassRefPtr<SerializedScriptValue> prpSerializedScriptValue, PassRefPtr<IDBKey> prpPrimaryKey, const IDBKeyPath& keyPath)
+{
+    LOG_ERROR("CHECKING: onSuccess(value, key, keypath)");
+    RefPtr<SerializedScriptValue> serializedScriptValue = prpSerializedScriptValue;
+#ifndef NDEBUG
+    // FIXME: Assert until we can actually inject the right value.
+    RefPtr<IDBKey> primaryKey = prpPrimaryKey;
+    RefPtr<IDBKey> expectedKey =
+              createIDBKeyFromSerializedValueAndKeyPath(serializedScriptValue, keyPath);
+    ASSERT(expectedKey->isEqual(primaryKey.get()));
+#endif
+    onSuccess(serializedScriptValue.release());
+}
+
 void IDBRequest::onSuccessWithContinuation()
 {
     IDB_TRACE("IDBRequest::onSuccessWithContinuation");

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBRequest.h (121476 => 121477)


--- trunk/Source/WebCore/Modules/indexeddb/IDBRequest.h	2012-06-28 22:45:18 UTC (rev 121476)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBRequest.h	2012-06-28 22:57:08 UTC (rev 121477)
@@ -87,6 +87,7 @@
     virtual void onSuccess(PassRefPtr<IDBKey>);
     virtual void onSuccess(PassRefPtr<IDBTransactionBackendInterface>);
     virtual void onSuccess(PassRefPtr<SerializedScriptValue>);
+    virtual void onSuccess(PassRefPtr<SerializedScriptValue>, PassRefPtr<IDBKey>, const IDBKeyPath&);
     virtual void onSuccessWithContinuation();
     virtual void onSuccessWithPrefetch(const Vector<RefPtr<IDBKey> >&, const Vector<RefPtr<IDBKey> >&, const Vector<RefPtr<SerializedScriptValue> >&) { ASSERT_NOT_REACHED(); } // Not implemented. Callback should not reach the renderer side.
     virtual void onBlocked();

Modified: trunk/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp (121476 => 121477)


--- trunk/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp	2012-06-28 22:45:18 UTC (rev 121476)
+++ trunk/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp	2012-06-28 22:57:08 UTC (rev 121477)
@@ -154,13 +154,15 @@
 
 } // anonymous namespace
 
-static PassRefPtr<IDBKey> createIDBKeyFromSerializedValueAndKeyPath(PassRefPtr<SerializedScriptValue> value, const String& keyPath)
+static PassRefPtr<IDBKey> createIDBKeyFromSerializedValueAndKeyPath(PassRefPtr<SerializedScriptValue> prpValue, const String& keyPath)
 {
     Vector<String> keyPathElements;
     IDBKeyPathParseError error;
     IDBParseKeyPath(keyPath, keyPathElements, error);
     ASSERT(error == IDBKeyPathParseErrorNone);
 
+    RefPtr<SerializedScriptValue> value = prpValue;
+
     V8AuxiliaryContext context;
     v8::Handle<v8::Value> v8Value(value->deserialize());
     v8::Handle<v8::Value> v8Key(getNthValueOnKeyPath(v8Value, keyPathElements, keyPathElements.size()));

Modified: trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp (121476 => 121477)


--- trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp	2012-06-28 22:45:18 UTC (rev 121476)
+++ trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp	2012-06-28 22:57:08 UTC (rev 121477)
@@ -105,16 +105,17 @@
 public:
     virtual ~InspectorIDBCallback() { }
 
-    virtual void onError(PassRefPtr<IDBDatabaseError>) { }
-    virtual void onSuccess(PassRefPtr<DOMStringList>) { }
-    virtual void onSuccess(PassRefPtr<IDBCursorBackendInterface>) { }
-    virtual void onSuccess(PassRefPtr<IDBDatabaseBackendInterface>) { }
-    virtual void onSuccess(PassRefPtr<IDBKey>) { }
-    virtual void onSuccess(PassRefPtr<IDBTransactionBackendInterface>) { }
-    virtual void onSuccess(PassRefPtr<SerializedScriptValue>) { }
-    virtual void onSuccessWithContinuation() { }
-    virtual void onSuccessWithPrefetch(const Vector<RefPtr<IDBKey> >&, const Vector<RefPtr<IDBKey> >&, const Vector<RefPtr<SerializedScriptValue> >&) { }
-    virtual void onBlocked() { }
+    virtual void onError(PassRefPtr<IDBDatabaseError>) OVERRIDE { }
+    virtual void onSuccess(PassRefPtr<DOMStringList>) OVERRIDE { }
+    virtual void onSuccess(PassRefPtr<IDBCursorBackendInterface>) OVERRIDE { }
+    virtual void onSuccess(PassRefPtr<IDBDatabaseBackendInterface>) OVERRIDE { }
+    virtual void onSuccess(PassRefPtr<IDBKey>) OVERRIDE { }
+    virtual void onSuccess(PassRefPtr<IDBTransactionBackendInterface>) OVERRIDE { }
+    virtual void onSuccess(PassRefPtr<SerializedScriptValue>) OVERRIDE { }
+    virtual void onSuccess(PassRefPtr<SerializedScriptValue>, PassRefPtr<IDBKey>, const IDBKeyPath&) OVERRIDE { }
+    virtual void onSuccessWithContinuation() OVERRIDE { }
+    virtual void onSuccessWithPrefetch(const Vector<RefPtr<IDBKey> >&, const Vector<RefPtr<IDBKey> >&, const Vector<RefPtr<SerializedScriptValue> >&) OVERRIDE { }
+    virtual void onBlocked() OVERRIDE { }
 };
 
 class InspectorIDBDatabaseCallbacks : public IDBDatabaseCallbacks {

Modified: trunk/Source/WebKit/chromium/ChangeLog (121476 => 121477)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-06-28 22:45:18 UTC (rev 121476)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-06-28 22:57:08 UTC (rev 121477)
@@ -1,3 +1,18 @@
+2012-06-28  Alec Flett  <[email protected]>
+
+        IndexedDB: Hook up render-side key ASSERTing for get()
+        https://bugs.webkit.org/show_bug.cgi?id=90001
+
+        Reviewed by Tony Chang.
+
+        Hook up Chromium WebKit API to new onSuccess handler.
+
+        * src/WebIDBCallbacksImpl.cpp:
+        (WebKit::WebIDBCallbacksImpl::onSuccess):
+        * tests/IDBAbortOnCorruptTest.cpp:
+        (WebCore::MockIDBCallbacks::onSuccess):
+        * tests/IDBDatabaseBackendTest.cpp:
+
 2012-06-28  Sheriff Bot  <[email protected]>
 
         Unreviewed.  Rolled DEPS.

Modified: trunk/Source/WebKit/chromium/src/WebIDBCallbacksImpl.cpp (121476 => 121477)


--- trunk/Source/WebKit/chromium/src/WebIDBCallbacksImpl.cpp	2012-06-28 22:45:18 UTC (rev 121476)
+++ trunk/Source/WebKit/chromium/src/WebIDBCallbacksImpl.cpp	2012-06-28 22:57:08 UTC (rev 121477)
@@ -92,9 +92,7 @@
 
 void WebIDBCallbacksImpl::onSuccess(const WebSerializedScriptValue& serializedScriptValue, const WebIDBKey& key, const WebIDBKeyPath& keyPath)
 {
-    // FIXME: proxy to the 3-parameter version when interface lands:
-    // m_callbacks->onSuccess(serializedScriptValue, key, keyPath););
-    ASSERT_NOT_REACHED();
+    m_callbacks->onSuccess(serializedScriptValue, key, keyPath);
 }
 
 void WebIDBCallbacksImpl::onSuccessWithContinuation()

Modified: trunk/Source/WebKit/chromium/tests/IDBAbortOnCorruptTest.cpp (121476 => 121477)


--- trunk/Source/WebKit/chromium/tests/IDBAbortOnCorruptTest.cpp	2012-06-28 22:45:18 UTC (rev 121476)
+++ trunk/Source/WebKit/chromium/tests/IDBAbortOnCorruptTest.cpp	2012-06-28 22:57:08 UTC (rev 121477)
@@ -57,6 +57,7 @@
     virtual void onSuccess(PassRefPtr<IDBKey>) { }
     virtual void onSuccess(PassRefPtr<IDBTransactionBackendInterface>) { }
     virtual void onSuccess(PassRefPtr<SerializedScriptValue>) { }
+    virtual void onSuccess(PassRefPtr<SerializedScriptValue>, PassRefPtr<IDBKey>, const IDBKeyPath&) { }
     virtual void onSuccessWithContinuation() { }
     virtual void onSuccessWithPrefetch(const Vector<RefPtr<IDBKey> >&, const Vector<RefPtr<IDBKey> >&, const Vector<RefPtr<SerializedScriptValue> >&) { }
     virtual void onBlocked() { }

Modified: trunk/Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp (121476 => 121477)


--- trunk/Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp	2012-06-28 22:45:18 UTC (rev 121476)
+++ trunk/Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp	2012-06-28 22:57:08 UTC (rev 121477)
@@ -84,6 +84,7 @@
     virtual void onSuccess(PassRefPtr<IDBKey>) OVERRIDE { }
     virtual void onSuccess(PassRefPtr<IDBTransactionBackendInterface>) OVERRIDE { }
     virtual void onSuccess(PassRefPtr<SerializedScriptValue>) OVERRIDE { }
+    virtual void onSuccess(PassRefPtr<SerializedScriptValue>, PassRefPtr<IDBKey>, const IDBKeyPath&) OVERRIDE { };
     virtual void onSuccessWithContinuation() OVERRIDE { }
     virtual void onSuccessWithPrefetch(const Vector<RefPtr<IDBKey> >&, const Vector<RefPtr<IDBKey> >&, const Vector<RefPtr<SerializedScriptValue> >&) OVERRIDE { }
     virtual void onBlocked() OVERRIDE { }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to