Title: [134989] trunk/Source
Revision
134989
Author
commit-qu...@webkit.org
Date
2012-11-16 12:56:30 -0800 (Fri, 16 Nov 2012)

Log Message

IndexedDB: Propagate DOMRequestState to IndexedDB binding utility functions
https://bugs.webkit.org/show_bug.cgi?id=102430

Patch by Michael Pruett <mich...@68k.org> on 2012-11-16
Reviewed by Adam Barth.

DOMRequestState is currently propagated to some but not all of
the IndexedDB binding utility functions. In order to implement
these functions for JSC, this state must be propagated to all
of the utility functions.

Source/WebCore:

Tests: storage/indexeddb/*

* Modules/indexeddb/IDBCursor.cpp:
(WebCore::IDBCursor::update):
(WebCore::IDBCursor::setValueReady):
* Modules/indexeddb/IDBObjectStore.cpp:
(WebCore::generateIndexKeysForValue):
(WebCore::IDBObjectStore::put):
(WebCore):
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::onSuccess):
(WebCore::IDBRequest::dispatchEvent):
* Modules/indexeddb/IDBRequest.h:
(WebCore::IDBRequest::requestState):
(IDBRequest):
* bindings/v8/IDBBindingUtilities.cpp:
(WebCore::createIDBKeyFromScriptValueAndKeyPath):
(WebCore::serializeIDBValue):
(WebCore::injectIDBKeyIntoScriptValue):
* bindings/v8/IDBBindingUtilities.h:
(WebCore):

Source/WebKit/chromium:

* tests/IDBBindingUtilitiesTest.cpp:
(WebKit::checkKeyFromValueAndKeyPathInternal):
(WebKit::injectKey):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (134988 => 134989)


--- trunk/Source/WebCore/ChangeLog	2012-11-16 20:49:41 UTC (rev 134988)
+++ trunk/Source/WebCore/ChangeLog	2012-11-16 20:56:30 UTC (rev 134989)
@@ -1,3 +1,37 @@
+2012-11-16  Michael Pruett  <mich...@68k.org>
+
+        IndexedDB: Propagate DOMRequestState to IndexedDB binding utility functions
+        https://bugs.webkit.org/show_bug.cgi?id=102430
+
+        Reviewed by Adam Barth.
+
+        DOMRequestState is currently propagated to some but not all of
+        the IndexedDB binding utility functions. In order to implement
+        these functions for JSC, this state must be propagated to all
+        of the utility functions.
+
+        Tests: storage/indexeddb/*
+
+        * Modules/indexeddb/IDBCursor.cpp:
+        (WebCore::IDBCursor::update):
+        (WebCore::IDBCursor::setValueReady):
+        * Modules/indexeddb/IDBObjectStore.cpp:
+        (WebCore::generateIndexKeysForValue):
+        (WebCore::IDBObjectStore::put):
+        (WebCore):
+        * Modules/indexeddb/IDBRequest.cpp:
+        (WebCore::IDBRequest::onSuccess):
+        (WebCore::IDBRequest::dispatchEvent):
+        * Modules/indexeddb/IDBRequest.h:
+        (WebCore::IDBRequest::requestState):
+        (IDBRequest):
+        * bindings/v8/IDBBindingUtilities.cpp:
+        (WebCore::createIDBKeyFromScriptValueAndKeyPath):
+        (WebCore::serializeIDBValue):
+        (WebCore::injectIDBKeyIntoScriptValue):
+        * bindings/v8/IDBBindingUtilities.h:
+        (WebCore):
+
 2012-11-16  Byungwoo Lee  <bw80....@samsung.com>
 
         Rebaselined run-bindings-tests.

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBCursor.cpp (134988 => 134989)


--- trunk/Source/WebCore/Modules/indexeddb/IDBCursor.cpp	2012-11-16 20:49:41 UTC (rev 134988)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBCursor.cpp	2012-11-16 20:56:30 UTC (rev 134989)
@@ -145,7 +145,7 @@
     const IDBKeyPath& keyPath = objectStore->metadata().keyPath;
     const bool usesInLineKeys = !keyPath.isNull();
     if (usesInLineKeys) {
-        RefPtr<IDBKey> keyPathKey = createIDBKeyFromScriptValueAndKeyPath(value, keyPath);
+        RefPtr<IDBKey> keyPathKey = createIDBKeyFromScriptValueAndKeyPath(m_request->requestState(), value, keyPath);
         if (!keyPathKey || !keyPathKey->isEqual(m_currentPrimaryKey.get())) {
             ec = IDBDatabaseException::DATA_ERR;
             return 0;
@@ -270,10 +270,10 @@
         const IDBObjectStoreMetadata metadata = objectStore->metadata();
         if (metadata.autoIncrement && !metadata.keyPath.isNull()) {
 #ifndef NDEBUG
-            RefPtr<IDBKey> expectedKey = createIDBKeyFromScriptValueAndKeyPath(value, metadata.keyPath);
+            RefPtr<IDBKey> expectedKey = createIDBKeyFromScriptValueAndKeyPath(m_request->requestState(), value, metadata.keyPath);
             ASSERT(!expectedKey || expectedKey->isEqual(m_currentPrimaryKey.get()));
 #endif
-            bool injected = injectIDBKeyIntoScriptValue(m_currentPrimaryKey, value, metadata.keyPath);
+            bool injected = injectIDBKeyIntoScriptValue(m_request->requestState(), m_currentPrimaryKey, value, metadata.keyPath);
             // FIXME: There is no way to report errors here. Move this into onSuccessWithContinuation so that we can abort the transaction there. See: https://bugs.webkit.org/show_bug.cgi?id=92278
             ASSERT_UNUSED(injected, injected);
         }

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp (134988 => 134989)


--- trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp	2012-11-16 20:49:41 UTC (rev 134988)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp	2012-11-16 20:56:30 UTC (rev 134989)
@@ -101,12 +101,10 @@
     return get(context, keyRange.release(), ec);
 }
 
-static void generateIndexKeysForValue(const IDBIndexMetadata& indexMetadata,
-                                      const ScriptValue& objectValue,
-                                      IDBObjectStore::IndexKeys* indexKeys)
+static void generateIndexKeysForValue(DOMRequestState* requestState, const IDBIndexMetadata& indexMetadata, const ScriptValue& objectValue, IDBObjectStore::IndexKeys* indexKeys)
 {
     ASSERT(indexKeys);
-    RefPtr<IDBKey> indexKey = createIDBKeyFromScriptValueAndKeyPath(objectValue, indexMetadata.keyPath);
+    RefPtr<IDBKey> indexKey = createIDBKeyFromScriptValueAndKeyPath(requestState, objectValue, indexMetadata.keyPath);
 
     if (!indexKey)
         return;
@@ -171,6 +169,7 @@
     const IDBKeyPath& keyPath = m_metadata.keyPath;
     const bool usesInLineKeys = !keyPath.isNull();
     const bool hasKeyGenerator = autoIncrement();
+    DOMRequestState requestState(context);
 
     if (putMode != IDBObjectStoreBackendInterface::CursorUpdate && usesInLineKeys && key) {
         ec = IDBDatabaseException::DATA_ERR;
@@ -181,7 +180,7 @@
         return 0;
     }
     if (usesInLineKeys) {
-        RefPtr<IDBKey> keyPathKey = createIDBKeyFromScriptValueAndKeyPath(value, keyPath);
+        RefPtr<IDBKey> keyPathKey = createIDBKeyFromScriptValueAndKeyPath(&requestState, value, keyPath);
         if (keyPathKey && !keyPathKey->isValid()) {
             ec = IDBDatabaseException::DATA_ERR;
             return 0;
@@ -191,7 +190,7 @@
             return 0;
         }
         if (hasKeyGenerator && !keyPathKey) {
-            if (!canInjectIDBKeyIntoScriptValue(value, keyPath)) {
+            if (!canInjectIDBKeyIntoScriptValue(&requestState, value, keyPath)) {
                 ec = IDBDatabaseException::DATA_ERR;
                 return 0;
             }
@@ -208,7 +207,7 @@
     Vector<IndexKeys> indexKeys;
     for (IDBObjectStoreMetadata::IndexMap::const_iterator it = m_metadata.indexes.begin(); it != m_metadata.indexes.end(); ++it) {
         IndexKeys keys;
-        generateIndexKeysForValue(it->value, value, &keys);
+        generateIndexKeysForValue(&requestState, it->value, value, &keys);
         indexIds.append(it->key);
         indexKeys.append(keys);
     }
@@ -328,7 +327,7 @@
             ScriptValue value = cursor->value();
 
             IDBObjectStore::IndexKeys indexKeys;
-            generateIndexKeysForValue(m_indexMetadata, value, &indexKeys);
+            generateIndexKeysForValue(request->requestState(), m_indexMetadata, value, &indexKeys);
 
             Vector<IDBObjectStore::IndexKeys, 1> indexKeysList;
             indexKeysList.append(indexKeys);

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp (134988 => 134989)


--- trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp	2012-11-16 20:49:41 UTC (rev 134988)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp	2012-11-16 20:56:30 UTC (rev 134989)
@@ -286,7 +286,7 @@
         return;
 
     DOMRequestState::Scope scope(m_requestState);
-    ScriptValue value = deserializeIDBValue(&m_requestState, serializedValue);
+    ScriptValue value = deserializeIDBValue(requestState(), serializedValue);
     ASSERT(m_cursorType != IDBCursorBackendInterface::InvalidCursorType);
     RefPtr<IDBCursor> cursor;
     if (m_cursorType == IDBCursorBackendInterface::IndexKeyCursor)
@@ -343,7 +343,7 @@
         return;
 
     DOMRequestState::Scope scope(m_requestState);
-    ScriptValue value = deserializeIDBValue(&m_requestState, serializedScriptValue);
+    ScriptValue value = deserializeIDBValue(requestState(), serializedScriptValue);
     onSuccessInternal(value);
 }
 
@@ -370,14 +370,14 @@
     ASSERT(keyPath == effectiveObjectStore(m_source)->keyPath());
 #endif
     DOMRequestState::Scope scope(m_requestState);
-    ScriptValue value = deserializeIDBValue(&m_requestState, prpSerializedScriptValue);
+    ScriptValue value = deserializeIDBValue(requestState(), prpSerializedScriptValue);
 
     RefPtr<IDBKey> primaryKey = prpPrimaryKey;
 #ifndef NDEBUG
-    RefPtr<IDBKey> expectedKey = createIDBKeyFromScriptValueAndKeyPath(value, keyPath);
+    RefPtr<IDBKey> expectedKey = createIDBKeyFromScriptValueAndKeyPath(requestState(), value, keyPath);
     ASSERT(!expectedKey || expectedKey->isEqual(primaryKey.get()));
 #endif
-    bool injected = injectIDBKeyIntoScriptValue(primaryKey, value, keyPath);
+    bool injected = injectIDBKeyIntoScriptValue(requestState(), primaryKey, value, keyPath);
     ASSERT_UNUSED(injected, injected);
     onSuccessInternal(value);
 }
@@ -409,7 +409,7 @@
         return;
 
     DOMRequestState::Scope scope(m_requestState);
-    ScriptValue value = deserializeIDBValue(&m_requestState, serializedValue);
+    ScriptValue value = deserializeIDBValue(requestState(), serializedValue);
     ASSERT(m_pendingCursor);
     setResultCursor(m_pendingCursor.release(), key, primaryKey, value);
     enqueueEvent(createSuccessEvent());
@@ -482,7 +482,7 @@
     if (event->type() == eventNames().successEvent) {
         cursorToNotify = getResultCursor();
         if (cursorToNotify) {
-            cursorToNotify->setValueReady(&m_requestState, m_cursorKey.release(), m_cursorPrimaryKey.release(), m_cursorValue);
+            cursorToNotify->setValueReady(requestState(), m_cursorKey.release(), m_cursorPrimaryKey.release(), m_cursorValue);
             m_cursorValue.clear();
         }
     }

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBRequest.h (134988 => 134989)


--- trunk/Source/WebCore/Modules/indexeddb/IDBRequest.h	2012-11-16 20:49:41 UTC (rev 134988)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBRequest.h	2012-11-16 20:56:30 UTC (rev 134989)
@@ -117,6 +117,8 @@
 
     IDBTransactionBackendInterface::TaskType taskType() { return m_taskType; }
 
+    DOMRequestState* requestState() { return &m_requestState; }
+
 protected:
     IDBRequest(ScriptExecutionContext*, PassRefPtr<IDBAny> source, IDBTransactionBackendInterface::TaskType, IDBTransaction*);
     void enqueueEvent(PassRefPtr<Event>);

Modified: trunk/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp (134988 => 134989)


--- trunk/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp	2012-11-16 20:49:41 UTC (rev 134988)
+++ trunk/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp	2012-11-16 20:56:30 UTC (rev 134989)
@@ -188,7 +188,7 @@
     return createIDBKeyFromValue(v8Key);
 }
 
-PassRefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(const ScriptValue& value, const IDBKeyPath& keyPath)
+PassRefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(DOMRequestState*, const ScriptValue& value, const IDBKeyPath& keyPath)
 {
     IDB_TRACE("createIDBKeyFromScriptValueAndKeyPath");
     ASSERT(!keyPath.isNull());
@@ -222,7 +222,7 @@
     return ScriptValue(v8::Null());
 }
 
-bool injectIDBKeyIntoScriptValue(PassRefPtr<IDBKey> key, ScriptValue& value, const IDBKeyPath& keyPath)
+bool injectIDBKeyIntoScriptValue(DOMRequestState*, PassRefPtr<IDBKey> key, ScriptValue& value, const IDBKeyPath& keyPath)
 {
     IDB_TRACE("injectIDBKeyIntoScriptValue");
     ASSERT(v8::Context::InContext());
@@ -248,7 +248,7 @@
     return true;
 }
 
-bool canInjectIDBKeyIntoScriptValue(const ScriptValue& scriptValue, const IDBKeyPath& keyPath)
+bool canInjectIDBKeyIntoScriptValue(DOMRequestState*, const ScriptValue& scriptValue, const IDBKeyPath& keyPath)
 {
     IDB_TRACE("canInjectIDBKeyIntoScriptValue");
     ASSERT(keyPath.type() == IDBKeyPath::StringType);

Modified: trunk/Source/WebCore/bindings/v8/IDBBindingUtilities.h (134988 => 134989)


--- trunk/Source/WebCore/bindings/v8/IDBBindingUtilities.h	2012-11-16 20:49:41 UTC (rev 134988)
+++ trunk/Source/WebCore/bindings/v8/IDBBindingUtilities.h	2012-11-16 20:56:30 UTC (rev 134989)
@@ -41,9 +41,9 @@
 
 PassRefPtr<IDBKey> createIDBKeyFromValue(v8::Handle<v8::Value>);
 
-bool injectIDBKeyIntoScriptValue(PassRefPtr<IDBKey>, ScriptValue&, const IDBKeyPath&);
-PassRefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(const ScriptValue&, const IDBKeyPath&);
-bool canInjectIDBKeyIntoScriptValue(const ScriptValue&, const IDBKeyPath&);
+bool injectIDBKeyIntoScriptValue(DOMRequestState*, PassRefPtr<IDBKey>, ScriptValue&, const IDBKeyPath&);
+PassRefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(DOMRequestState*, const ScriptValue&, const IDBKeyPath&);
+bool canInjectIDBKeyIntoScriptValue(DOMRequestState*, const ScriptValue&, const IDBKeyPath&);
 ScriptValue deserializeIDBValue(DOMRequestState*, PassRefPtr<SerializedScriptValue>);
 ScriptValue idbKeyToScriptValue(DOMRequestState*, PassRefPtr<IDBKey>);
 

Modified: trunk/Source/WebKit/chromium/ChangeLog (134988 => 134989)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-11-16 20:49:41 UTC (rev 134988)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-11-16 20:56:30 UTC (rev 134989)
@@ -1,3 +1,19 @@
+2012-11-16  Michael Pruett  <mich...@68k.org>
+
+        IndexedDB: Propagate DOMRequestState to IndexedDB binding utility functions
+        https://bugs.webkit.org/show_bug.cgi?id=102430
+
+        Reviewed by Adam Barth.
+
+        DOMRequestState is currently propagated to some but not all of
+        the IndexedDB binding utility functions. In order to implement
+        these functions for JSC, this state must be propagated to all
+        of the utility functions.
+
+        * tests/IDBBindingUtilitiesTest.cpp:
+        (WebKit::checkKeyFromValueAndKeyPathInternal):
+        (WebKit::injectKey):
+
 2012-11-16  Tommy Widenflycht  <tom...@google.com>
 
         MediaStream API: Update RTCPeerConnection states to match the latest editors draft

Modified: trunk/Source/WebKit/chromium/tests/IDBBindingUtilitiesTest.cpp (134988 => 134989)


--- trunk/Source/WebKit/chromium/tests/IDBBindingUtilitiesTest.cpp	2012-11-16 20:49:41 UTC (rev 134988)
+++ trunk/Source/WebKit/chromium/tests/IDBBindingUtilitiesTest.cpp	2012-11-16 20:56:30 UTC (rev 134989)
@@ -53,7 +53,7 @@
     IDBKeyPath idbKeyPath(keyPath);
     EXPECT_TRUE(idbKeyPath.isValid());
     
-    return createIDBKeyFromScriptValueAndKeyPath(value, idbKeyPath);
+    return createIDBKeyFromScriptValueAndKeyPath(0, value, idbKeyPath);
 }
 
 void checkKeyPathNullValue(const ScriptValue& value, const String& keyPath)
@@ -66,7 +66,7 @@
 {
     IDBKeyPath idbKeyPath(keyPath);
     EXPECT_TRUE(idbKeyPath.isValid());
-    return injectIDBKeyIntoScriptValue(key, value, idbKeyPath);
+    return injectIDBKeyIntoScriptValue(0, key, value, idbKeyPath);
 }
 
 void checkInjection(PassRefPtr<IDBKey> prpKey, ScriptValue& value, const String& keyPath)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to