IndexedDB: Explicitly send null/undefined/integers to frontend IDBCallbacks
authoralecflett@chromium.org <alecflett@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Oct 2012 22:57:30 +0000 (22:57 +0000)
committeralecflett@chromium.org <alecflett@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Oct 2012 22:57:30 +0000 (22:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=99619

Reviewed by Adam Barth.

Source/WebCore:

Rather than pass SerializedScriptValue tokens from the backend,
send explicit null, (as onSuccess(static_cast<SerializedScriptValue*>(0)))
undefined, (as onSucess()), and integers (as onSuccess(long long))

This reduces backend dependency on things that might require a JS
interpreter on the backend.

No new tests, this is a refactor and existing tests cover
correctness. Tests that might fail include:

Test: storage/indexeddb/index-count.html
Test: storage/indexeddb/objectstore-count.html
Test: storage/indexeddb/database-basics.html

* Modules/indexeddb/IDBCallbacks.h:
(IDBCallbacks):
* Modules/indexeddb/IDBCursorBackendImpl.cpp:
(WebCore::IDBCursorBackendImpl::advanceInternal):
(WebCore::IDBCursorBackendImpl::continueFunctionInternal):
(WebCore::IDBCursorBackendImpl::prefetchContinueInternal):
* Modules/indexeddb/IDBCursorBackendImpl.h:
(WebCore::IDBCursorBackendImpl::value):
* Modules/indexeddb/IDBDatabaseBackendImpl.cpp:
(WebCore::IDBDatabaseBackendImpl::deleteDatabase):
* Modules/indexeddb/IDBIndex.cpp:
* Modules/indexeddb/IDBIndexBackendImpl.cpp:
(WebCore::IDBIndexBackendImpl::openCursorInternal):
(WebCore::IDBIndexBackendImpl::countInternal):
(WebCore::IDBIndexBackendImpl::getInternal):
* Modules/indexeddb/IDBObjectStore.cpp:
* Modules/indexeddb/IDBObjectStoreBackendImpl.cpp:
(WebCore::IDBObjectStoreBackendImpl::getInternal):
(WebCore::IDBObjectStoreBackendImpl::deleteInternal):
(WebCore::IDBObjectStoreBackendImpl::clearInternal):
(WebCore::IDBObjectStoreBackendImpl::openCursorInternal):
(WebCore::IDBObjectStoreBackendImpl::countInternal):
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::onSuccess):
(WebCore):
* Modules/indexeddb/IDBRequest.h:
* Modules/indexeddb/IDBTransaction.cpp:
* Modules/indexeddb/IDBTransactionBackendImpl.cpp:
* Modules/indexeddb/IDBTransactionBackendImpl.h:
* Modules/indexeddb/IDBTransactionBackendInterface.h:
* bindings/v8/IDBBindingUtilities.cpp:
(WebCore::deserializeIDBValue):
* inspector/InspectorIndexedDBAgent.cpp:
(WebCore):

Source/WebKit/chromium:

Hook up new undefined/integer-based onSuccess handlers.

* src/IDBCallbacksProxy.cpp:
(WebKit::IDBCallbacksProxy::onSuccess):
(WebKit):
* src/IDBCallbacksProxy.h:
(IDBCallbacksProxy):
* src/WebIDBCallbacksImpl.cpp:
(WebKit::WebIDBCallbacksImpl::onSuccess):
(WebKit):
* src/WebIDBCallbacksImpl.h:
(WebIDBCallbacksImpl):
* tests/IDBAbortOnCorruptTest.cpp:
* tests/IDBDatabaseBackendTest.cpp:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@131661 268f45cc-cd09-0410-ab3c-d52691b4dbfc

24 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBCallbacks.h
Source/WebCore/Modules/indexeddb/IDBCursorBackendImpl.cpp
Source/WebCore/Modules/indexeddb/IDBCursorBackendImpl.h
Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp
Source/WebCore/Modules/indexeddb/IDBIndex.cpp
Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.cpp
Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp
Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp
Source/WebCore/Modules/indexeddb/IDBRequest.cpp
Source/WebCore/Modules/indexeddb/IDBRequest.h
Source/WebCore/Modules/indexeddb/IDBTransaction.cpp
Source/WebCore/Modules/indexeddb/IDBTransactionBackendImpl.cpp
Source/WebCore/Modules/indexeddb/IDBTransactionBackendImpl.h
Source/WebCore/Modules/indexeddb/IDBTransactionBackendInterface.h
Source/WebCore/bindings/v8/IDBBindingUtilities.cpp
Source/WebCore/inspector/InspectorIndexedDBAgent.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/IDBCallbacksProxy.cpp
Source/WebKit/chromium/src/IDBCallbacksProxy.h
Source/WebKit/chromium/src/WebIDBCallbacksImpl.cpp
Source/WebKit/chromium/src/WebIDBCallbacksImpl.h
Source/WebKit/chromium/tests/IDBAbortOnCorruptTest.cpp
Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp

index ab761891930d1b5aa74a10db98d96c93fdc0d4ee..f6fe1b581dca5423e80790891b75a8579fb49bb4 100644 (file)
@@ -1,3 +1,59 @@
+2012-10-17  Alec Flett  <alecflett@chromium.org>
+
+        IndexedDB: Explicitly send null/undefined/integers to frontend IDBCallbacks
+        https://bugs.webkit.org/show_bug.cgi?id=99619
+
+        Reviewed by Adam Barth.
+
+        Rather than pass SerializedScriptValue tokens from the backend,
+        send explicit null, (as onSuccess(static_cast<SerializedScriptValue*>(0)))
+        undefined, (as onSucess()), and integers (as onSuccess(long long))
+
+        This reduces backend dependency on things that might require a JS
+        interpreter on the backend.
+
+        No new tests, this is a refactor and existing tests cover
+        correctness. Tests that might fail include:
+
+        Test: storage/indexeddb/index-count.html
+        Test: storage/indexeddb/objectstore-count.html
+        Test: storage/indexeddb/database-basics.html
+
+        * Modules/indexeddb/IDBCallbacks.h:
+        (IDBCallbacks):
+        * Modules/indexeddb/IDBCursorBackendImpl.cpp:
+        (WebCore::IDBCursorBackendImpl::advanceInternal):
+        (WebCore::IDBCursorBackendImpl::continueFunctionInternal):
+        (WebCore::IDBCursorBackendImpl::prefetchContinueInternal):
+        * Modules/indexeddb/IDBCursorBackendImpl.h:
+        (WebCore::IDBCursorBackendImpl::value):
+        * Modules/indexeddb/IDBDatabaseBackendImpl.cpp:
+        (WebCore::IDBDatabaseBackendImpl::deleteDatabase):
+        * Modules/indexeddb/IDBIndex.cpp:
+        * Modules/indexeddb/IDBIndexBackendImpl.cpp:
+        (WebCore::IDBIndexBackendImpl::openCursorInternal):
+        (WebCore::IDBIndexBackendImpl::countInternal):
+        (WebCore::IDBIndexBackendImpl::getInternal):
+        * Modules/indexeddb/IDBObjectStore.cpp:
+        * Modules/indexeddb/IDBObjectStoreBackendImpl.cpp:
+        (WebCore::IDBObjectStoreBackendImpl::getInternal):
+        (WebCore::IDBObjectStoreBackendImpl::deleteInternal):
+        (WebCore::IDBObjectStoreBackendImpl::clearInternal):
+        (WebCore::IDBObjectStoreBackendImpl::openCursorInternal):
+        (WebCore::IDBObjectStoreBackendImpl::countInternal):
+        * Modules/indexeddb/IDBRequest.cpp:
+        (WebCore::IDBRequest::onSuccess):
+        (WebCore):
+        * Modules/indexeddb/IDBRequest.h:
+        * Modules/indexeddb/IDBTransaction.cpp:
+        * Modules/indexeddb/IDBTransactionBackendImpl.cpp:
+        * Modules/indexeddb/IDBTransactionBackendImpl.h:
+        * Modules/indexeddb/IDBTransactionBackendInterface.h:
+        * bindings/v8/IDBBindingUtilities.cpp:
+        (WebCore::deserializeIDBValue):
+        * inspector/InspectorIndexedDBAgent.cpp:
+        (WebCore):
+
 2012-10-17  Nate Chapin  <japhet@chromium.org>
 
         Move ResourceRequest construction out of SubresourceLoader
index 1feb0d7011cb88a3b8a3b48020c1860fbf38aa70..c394068c527950c7000078a5cd44543dd4209b9e 100644 (file)
@@ -62,6 +62,12 @@ public:
     virtual void onSuccess(PassRefPtr<SerializedScriptValue>) = 0;
     // From IDBObjectStore/IDBIndex.get() (with key injection)
     virtual void onSuccess(PassRefPtr<SerializedScriptValue>, PassRefPtr<IDBKey>, const IDBKeyPath&) = 0;
+    // From IDBObjectStore/IDBIndex.count()
+    virtual void onSuccess(int64_t value) = 0;
+
+    // From IDBFactor.deleteDatabase(), IDBObjectStore/IDBIndex.get(), IDBObjectStore.delete(), IDBObjectStore.clear()
+    virtual void onSuccess() = 0;
+    
     // From IDBCursor.advance()/continue()
     virtual void onSuccess(PassRefPtr<IDBKey>, PassRefPtr<IDBKey> primaryKey, PassRefPtr<SerializedScriptValue>) = 0;
     // From IDBCursor.advance()/continue()
index 668466b0fc45957165438d03c308f695cd23a702..428cc0412c2b63444074032f82ce5b879de8bb22 100644 (file)
@@ -87,7 +87,7 @@ void IDBCursorBackendImpl::advanceInternal(ScriptExecutionContext*, PassRefPtr<I
     RefPtr<IDBCursorBackendImpl> cursor = prpCursor;
     if (!cursor->m_cursor || !cursor->m_cursor->advance(count)) {
         cursor->m_cursor = 0;
-        callbacks->onSuccess(SerializedScriptValue::nullValue());
+        callbacks->onSuccess(static_cast<SerializedScriptValue*>(0));
         return;
     }
 
@@ -102,7 +102,7 @@ void IDBCursorBackendImpl::continueFunctionInternal(ScriptExecutionContext*, Pas
 
     if (!cursor->m_cursor || !cursor->m_cursor->continueFunction(key.get())) {
         cursor->m_cursor = 0;
-        callbacks->onSuccess(SerializedScriptValue::nullValue());
+        callbacks->onSuccess(static_cast<SerializedScriptValue*>(0));
         return;
     }
 
@@ -169,7 +169,7 @@ void IDBCursorBackendImpl::prefetchContinueInternal(ScriptExecutionContext*, Pas
     }
 
     if (!foundKeys.size()) {
-        callbacks->onSuccess(SerializedScriptValue::nullValue());
+        callbacks->onSuccess(static_cast<SerializedScriptValue*>(0));
         return;
     }
 
index 2b76dd48c2f358c86ee985a4aa6c3718668552d5..3b92f117ef1e4e2f971e7209c8cd540387e00ede 100644 (file)
@@ -67,7 +67,7 @@ public:
 
     PassRefPtr<IDBKey> key() const { return m_cursor->key(); }
     PassRefPtr<IDBKey> primaryKey() const { return m_cursor->primaryKey(); }
-    PassRefPtr<SerializedScriptValue> value() const { return (m_cursorType == IndexKeyCursor) ? SerializedScriptValue::nullValue() : SerializedScriptValue::createFromWire(m_cursor->value()); }
+    PassRefPtr<SerializedScriptValue> value() const { return (m_cursorType == IndexKeyCursor) ? 0 : SerializedScriptValue::createFromWire(m_cursor->value()); }
     void close();
 
 private:
index d3322ca408f1fd238db90c02af3a3227d8e6a55a..4e895417d461bd68fc1180345c769196b4b1885c 100644 (file)
@@ -561,7 +561,7 @@ void IDBDatabaseBackendImpl::deleteDatabase(PassRefPtr<IDBCallbacks> prpCallback
     m_id = InvalidId;
     m_intVersion = IDBDatabaseMetadata::NoIntVersion;
     m_objectStores.clear();
-    callbacks->onSuccess(SerializedScriptValue::undefinedValue());
+    callbacks->onSuccess();
 }
 
 void IDBDatabaseBackendImpl::close(PassRefPtr<IDBDatabaseCallbacks> prpCallbacks)
index f122500587c30a4213b5dd59f84cdbe3d875cf82..ec29837a11915cbe1a461ac9c0ce4c1c6d92a52a 100644 (file)
@@ -37,6 +37,7 @@
 #include "IDBRequest.h"
 #include "IDBTracing.h"
 #include "IDBTransaction.h"
+#include "ScriptExecutionContext.h"
 
 namespace WebCore {
 
index 7f32b9cd2ffe153e7edb02e26cda4a6ac5b44bb0..7b2a475e59b55f88c9533e57a5d729b2c7511c5a 100644 (file)
@@ -84,7 +84,7 @@ void IDBIndexBackendImpl::openCursorInternal(ScriptExecutionContext*, PassRefPtr
     }
 
     if (!backingStoreCursor) {
-        callbacks->onSuccess(SerializedScriptValue::nullValue());
+        callbacks->onSuccess(static_cast<SerializedScriptValue*>(0));
         return;
     }
 
@@ -123,7 +123,7 @@ void IDBIndexBackendImpl::countInternal(ScriptExecutionContext*, PassRefPtr<IDBI
 
     RefPtr<IDBBackingStore::Cursor> backingStoreCursor = index->backingStore()->openIndexKeyCursor(transaction->backingStoreTransaction(), index->databaseId(), index->m_objectStoreBackend->id(), index->id(), range.get(), IDBCursor::NEXT);
     if (!backingStoreCursor) {
-        callbacks->onSuccess(SerializedScriptValue::numberValue(count));
+        callbacks->onSuccess(count);
         return;
     }
 
@@ -131,7 +131,7 @@ void IDBIndexBackendImpl::countInternal(ScriptExecutionContext*, PassRefPtr<IDBI
         ++count;
     } while (backingStoreCursor->continueFunction(0));
     backingStoreCursor->close();
-    callbacks->onSuccess(SerializedScriptValue::numberValue(count));
+    callbacks->onSuccess(count);
 }
 
 void IDBIndexBackendImpl::count(PassRefPtr<IDBKeyRange> range, PassRefPtr<IDBCallbacks> callbacks, IDBTransactionBackendInterface* transactionPtr, ExceptionCode&)
@@ -155,7 +155,7 @@ void IDBIndexBackendImpl::getInternal(ScriptExecutionContext*, PassRefPtr<IDBInd
         RefPtr<IDBBackingStore::Cursor> backingStoreCursor = index->backingStore()->openIndexCursor(transaction->backingStoreTransaction(), index->databaseId(), index->m_objectStoreBackend->id(), index->id(), keyRange.get(), IDBCursor::NEXT);
 
         if (!backingStoreCursor) {
-            callbacks->onSuccess(SerializedScriptValue::undefinedValue());
+            callbacks->onSuccess();
             return;
         }
         key = backingStoreCursor->key();
@@ -167,7 +167,7 @@ void IDBIndexBackendImpl::getInternal(ScriptExecutionContext*, PassRefPtr<IDBInd
     String value = index->backingStore()->getObjectStoreRecord(transaction->backingStoreTransaction(), index->databaseId(), index->m_objectStoreBackend->id(), *primaryKey);
 
     if (value.isNull()) {
-        callbacks->onSuccess(SerializedScriptValue::undefinedValue());
+        callbacks->onSuccess();
         return;
     }
     if (index->m_objectStoreBackend->autoIncrement() && !index->m_objectStoreBackend->keyPath().isNull()) {
index 1ce94925ebe9197679b0cd273e567d040bc9e500..2eacb319c658d8f859de51d6ce5e20e6f6614754 100644 (file)
@@ -41,6 +41,7 @@
 #include "IDBKeyRange.h"
 #include "IDBTracing.h"
 #include "IDBTransaction.h"
+#include "ScriptExecutionContext.h"
 #include "SerializedScriptValue.h"
 #include <wtf/UnusedParam.h>
 
index 3745b62f592f2bf2dc63e9c172279092d224414e..d06818a581ae1c4fb8f447c56ffd15e244d16cd3 100644 (file)
@@ -42,7 +42,6 @@
 #include "IDBKeyRange.h"
 #include "IDBTracing.h"
 #include "IDBTransactionBackendImpl.h"
-#include "ScriptExecutionContext.h"
 #include <wtf/MathExtras.h>
 
 namespace WebCore {
@@ -91,7 +90,7 @@ void IDBObjectStoreBackendImpl::getInternal(ScriptExecutionContext*, PassRefPtr<
     else {
         RefPtr<IDBBackingStore::Cursor> backingStoreCursor = objectStore->backingStore()->openObjectStoreCursor(transaction->backingStoreTransaction(), objectStore->databaseId(), objectStore->id(), keyRange.get(), IDBCursor::NEXT);
         if (!backingStoreCursor) {
-            callbacks->onSuccess(SerializedScriptValue::undefinedValue());
+            callbacks->onSuccess();
             return;
         }
         key = backingStoreCursor->key();
@@ -100,7 +99,7 @@ void IDBObjectStoreBackendImpl::getInternal(ScriptExecutionContext*, PassRefPtr<
 
     String wireData = objectStore->backingStore()->getObjectStoreRecord(transaction->backingStoreTransaction(), objectStore->databaseId(), objectStore->id(), *key);
     if (wireData.isNull()) {
-        callbacks->onSuccess(SerializedScriptValue::undefinedValue());
+        callbacks->onSuccess();
         return;
     }
 
@@ -404,7 +403,7 @@ void IDBObjectStoreBackendImpl::deleteInternal(ScriptExecutionContext*, PassRefP
         backingStoreCursor->close();
     }
 
-    callbacks->onSuccess(SerializedScriptValue::undefinedValue());
+    callbacks->onSuccess();
 }
 
 void IDBObjectStoreBackendImpl::clear(PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transactionPtr, ExceptionCode&)
@@ -425,7 +424,7 @@ void IDBObjectStoreBackendImpl::clear(PassRefPtr<IDBCallbacks> prpCallbacks, IDB
 void IDBObjectStoreBackendImpl::clearInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<IDBTransactionBackendImpl> transaction)
 {
     objectStore->backingStore()->clearObjectStore(transaction->backingStoreTransaction(), objectStore->databaseId(), objectStore->id());
-    callbacks->onSuccess(SerializedScriptValue::undefinedValue());
+    callbacks->onSuccess();
 }
 
 PassRefPtr<IDBIndexBackendInterface> IDBObjectStoreBackendImpl::createIndex(int64_t id, const String& name, const IDBKeyPath& keyPath, bool unique, bool multiEntry, IDBTransactionBackendInterface* transactionPtr, ExceptionCode& ec)
@@ -521,7 +520,7 @@ void IDBObjectStoreBackendImpl::openCursorInternal(ScriptExecutionContext*, Pass
     if (taskType == IDBTransactionBackendInterface::PreemptiveTask)
         transaction->addPreemptiveEvent();
     if (!backingStoreCursor) {
-        callbacks->onSuccess(SerializedScriptValue::nullValue());
+        callbacks->onSuccess(static_cast<SerializedScriptValue*>(0));
         return;
     }
 
@@ -544,7 +543,7 @@ void IDBObjectStoreBackendImpl::countInternal(ScriptExecutionContext*, PassRefPt
     uint32_t count = 0;
     RefPtr<IDBBackingStore::Cursor> backingStoreCursor = objectStore->backingStore()->openObjectStoreKeyCursor(transaction->backingStoreTransaction(), objectStore->databaseId(), objectStore->id(), range.get(), IDBCursor::NEXT);
     if (!backingStoreCursor) {
-        callbacks->onSuccess(SerializedScriptValue::numberValue(count));
+        callbacks->onSuccess(count);
         return;
     }
 
@@ -553,7 +552,7 @@ void IDBObjectStoreBackendImpl::countInternal(ScriptExecutionContext*, PassRefPt
     } while (backingStoreCursor->continueFunction(0));
 
     backingStoreCursor->close();
-    callbacks->onSuccess(SerializedScriptValue::numberValue(count));
+    callbacks->onSuccess(count);
 }
 
 void IDBObjectStoreBackendImpl::loadIndexes()
index 06ae9e235957e010c0cbd51d5f4997932383c31f..3f6f9cd84297b819d5418e5039cbd3811ae34d7f 100644 (file)
@@ -41,6 +41,7 @@
 #include "IDBEventDispatcher.h"
 #include "IDBTracing.h"
 #include "IDBTransaction.h"
+#include "ScriptExecutionContext.h"
 
 namespace WebCore {
 
@@ -376,6 +377,16 @@ void IDBRequest::onSuccess(PassRefPtr<SerializedScriptValue> prpSerializedScript
     onSuccessInternal(value);
 }
 
+void IDBRequest::onSuccess(int64_t value)
+{
+    return onSuccess(SerializedScriptValue::numberValue(value));
+}
+
+void IDBRequest::onSuccess()
+{
+    return onSuccess(SerializedScriptValue::undefinedValue());
+}
+
 void IDBRequest::onSuccessInternal(const ScriptValue& value)
 {
     m_result = IDBAny::create(value);
index d82fac7207c11eebe42f713e0e900c7fade48d79..cab0651200c45f58ac024f1cfd80c5562e9636e7 100644 (file)
@@ -88,6 +88,8 @@ public:
     virtual void onSuccess(PassRefPtr<IDBTransactionBackendInterface>);
     virtual void onSuccess(PassRefPtr<SerializedScriptValue>);
     virtual void onSuccess(PassRefPtr<SerializedScriptValue>, PassRefPtr<IDBKey>, const IDBKeyPath&);
+    virtual void onSuccess(int64_t);
+    virtual void onSuccess();
     virtual void onSuccess(PassRefPtr<IDBKey>, PassRefPtr<IDBKey> primaryKey, PassRefPtr<SerializedScriptValue>);
     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.
 
index 053e086560b09e892a090a9e27ab6eb450cab397..8ec15e5ec073dffb1fb1610ee8640321e049a42a 100644 (file)
@@ -40,6 +40,7 @@
 #include "IDBPendingTransactionMonitor.h"
 #include "IDBTracing.h"
 #include "ScriptCallStack.h"
+#include "ScriptExecutionContext.h"
 
 namespace WebCore {
 
index 6265ee919e7ee77eb1fbdc29a67db7dd7c1f833c..f16651949bad3c5b151beb4ff75f25d06b71a266 100644 (file)
@@ -35,6 +35,7 @@
 #include "IDBObjectStoreBackendImpl.h"
 #include "IDBTracing.h"
 #include "IDBTransactionCoordinator.h"
+#include "ScriptExecutionContext.h"
 
 namespace WebCore {
 
index 1ae145b6c7379c1a8090e7a1df096c1ecde4da71..34a97570f00fb7a084b8dd389347a254a2534862 100644 (file)
@@ -33,6 +33,7 @@
 #include "IDBDatabaseError.h"
 #include "IDBTransactionBackendInterface.h"
 #include "IDBTransactionCallbacks.h"
+#include "ScriptExecutionContext.h"
 #include "Timer.h"
 #include <wtf/Deque.h>
 #include <wtf/HashSet.h>
index eb7341fe076c5cab1c359542f659f51c56aaad0d..f707f34a099854f4392182394a2f1e725ce0574c 100644 (file)
@@ -27,7 +27,6 @@
 #define IDBTransactionBackendInterface_h
 
 #include "IDBCallbacks.h"
-#include "ScriptExecutionContext.h"
 #include <wtf/Threading.h>
 #include <wtf/text/WTFString.h>
 
index 1f3008e7837af95290f61059af39c2aff9441f15..83ae9b2fd8ebdae41fdf628ba5893cc49086d909 100644 (file)
@@ -214,7 +214,10 @@ ScriptValue deserializeIDBValue(ScriptExecutionContext* scriptContext, PassRefPt
 {
     v8::HandleScope handleScope;
     v8::Context::Scope contextScope(toV8Context(scriptContext, UseCurrentWorld));
-    return ScriptValue(prpValue->deserialize());
+    RefPtr<SerializedScriptValue> serializedValue = prpValue;
+    if (serializedValue)
+        return ScriptValue(serializedValue->deserialize());
+    return ScriptValue(v8::Null());
 }
 
 bool injectIDBKeyIntoScriptValue(PassRefPtr<IDBKey> key, ScriptValue& value, const IDBKeyPath& keyPath)
index d045170f50b736e202ed2b24d36375df09edd888..63401dd6ebaafcf167a539d03bbcc5a8a76ace85 100644 (file)
@@ -102,6 +102,8 @@ public:
     virtual void onSuccess(PassRefPtr<IDBTransactionBackendInterface>) OVERRIDE { }
     virtual void onSuccess(PassRefPtr<SerializedScriptValue>) OVERRIDE { }
     virtual void onSuccess(PassRefPtr<SerializedScriptValue>, PassRefPtr<IDBKey>, const IDBKeyPath&) OVERRIDE { }
+    virtual void onSuccess(int64_t value) OVERRIDE { return onSuccess(SerializedScriptValue::numberValue(value)); }
+    virtual void onSuccess() OVERRIDE { return onSuccess(SerializedScriptValue::undefinedValue()); }
     virtual void onSuccess(PassRefPtr<IDBKey>, PassRefPtr<IDBKey>, PassRefPtr<SerializedScriptValue>) OVERRIDE { }
     virtual void onSuccessWithPrefetch(const Vector<RefPtr<IDBKey> >&, const Vector<RefPtr<IDBKey> >&, const Vector<RefPtr<SerializedScriptValue> >&) OVERRIDE { }
     virtual void onUpgradeNeeded(int64_t, PassRefPtr<WebCore::IDBTransactionBackendInterface>, PassRefPtr<WebCore::IDBDatabaseBackendInterface>) OVERRIDE { }
index 3fd020e6cf6df963f3ee3363186d86fb5861402f..b0f5599cfbe6a63a85b64f9e66b164527b52e03e 100644 (file)
@@ -1,3 +1,25 @@
+2012-10-17  Alec Flett  <alecflett@chromium.org>
+
+        IndexedDB: Explicitly send null/undefined/integers to frontend IDBCallbacks
+        https://bugs.webkit.org/show_bug.cgi?id=99619
+
+        Reviewed by Adam Barth.
+
+        Hook up new undefined/integer-based onSuccess handlers.
+
+        * src/IDBCallbacksProxy.cpp:
+        (WebKit::IDBCallbacksProxy::onSuccess):
+        (WebKit):
+        * src/IDBCallbacksProxy.h:
+        (IDBCallbacksProxy):
+        * src/WebIDBCallbacksImpl.cpp:
+        (WebKit::WebIDBCallbacksImpl::onSuccess):
+        (WebKit):
+        * src/WebIDBCallbacksImpl.h:
+        (WebIDBCallbacksImpl):
+        * tests/IDBAbortOnCorruptTest.cpp:
+        * tests/IDBDatabaseBackendTest.cpp:
+
 2012-10-17  Sadrul Habib Chowdhury  <sadrul@chromium.org>
 
         plugins: Allow a plugin to dictate whether it can receive drag events or not.
index af4984a77c4b85e26e29ef88a8d283de46acc38c..42ac76ba55721dbb9c1a21943a6398b686f26550 100644 (file)
@@ -106,6 +106,16 @@ void IDBCallbacksProxy::onSuccess(PassRefPtr<SerializedScriptValue> serializedSc
     m_callbacks->onSuccess(serializedScriptValue, key, keyPath);
 }
 
+void IDBCallbacksProxy::onSuccess(int64_t value)
+{
+    m_callbacks->onSuccess(value);
+}
+
+void IDBCallbacksProxy::onSuccess()
+{
+    m_callbacks->onSuccess();
+}
+
 void IDBCallbacksProxy::onSuccess(PassRefPtr<IDBKey> key, PassRefPtr<IDBKey> primaryKey, PassRefPtr<SerializedScriptValue> value)
 {
     m_callbacks->onSuccess(key, primaryKey, value);
index f613a85c2e4ed16cb887f68a05031849cb1cef20..c940698f71015edafdb6d0278012ec7071257dbb 100644 (file)
@@ -54,6 +54,8 @@ public:
     virtual void onSuccess(PassRefPtr<WebCore::IDBTransactionBackendInterface>);
     virtual void onSuccess(PassRefPtr<WebCore::SerializedScriptValue>);
     virtual void onSuccess(PassRefPtr<WebCore::SerializedScriptValue>, PassRefPtr<WebCore::IDBKey>, const WebCore::IDBKeyPath&);
+    virtual void onSuccess(int64_t);
+    virtual void onSuccess();
     virtual void onSuccess(PassRefPtr<WebCore::IDBKey>, PassRefPtr<WebCore::IDBKey> primaryKey, PassRefPtr<WebCore::SerializedScriptValue>);
     virtual void onSuccessWithPrefetch(const Vector<RefPtr<WebCore::IDBKey> >& keys, const Vector<RefPtr<WebCore::IDBKey> >& primaryKeys, const Vector<RefPtr<WebCore::SerializedScriptValue> >& values);
     virtual void onBlocked();
index 2cb90ea46e63aaa65283965a1c4fee4c09520a86..e09c1a3fed247d2f55be7b9725d5a39253b69666 100644 (file)
@@ -100,6 +100,16 @@ void WebIDBCallbacksImpl::onSuccess(const WebSerializedScriptValue& serializedSc
     m_callbacks->onSuccess(serializedScriptValue, key, keyPath);
 }
 
+void WebIDBCallbacksImpl::onSuccess(long long value)
+{
+    m_callbacks->onSuccess(value);
+}
+
+void WebIDBCallbacksImpl::onSuccess()
+{
+    m_callbacks->onSuccess();
+}
+
 void WebIDBCallbacksImpl::onSuccess(const WebIDBKey& key, const WebIDBKey& primaryKey, const WebSerializedScriptValue& value)
 {
     m_callbacks->onSuccess(key, primaryKey, value);
index 33cd2029facfcd5295dd6644ad01cc7db7699055..ba444842833a1eb432ae530a496d1ee979e50f2a 100644 (file)
@@ -50,6 +50,8 @@ public:
     virtual void onSuccess(const WebSerializedScriptValue&);
     virtual void onSuccess(const WebSerializedScriptValue&, const WebIDBKey&, const WebIDBKeyPath&);
     virtual void onSuccess(const WebIDBKey&, const WebIDBKey& primaryKey, const WebSerializedScriptValue&);
+    virtual void onSuccess(long long);
+    virtual void onSuccess();
     virtual void onBlocked();
     virtual void onBlocked(long long oldVersion);
     virtual void onUpgradeNeeded(long long oldVersion, WebIDBTransaction*, WebIDBDatabase*);
index b080bfc4df51a298f4fdb5d9c28e7717f40daf14..cd2a0764973b5a3bee2d5ea043756af0032915c2 100644 (file)
@@ -61,6 +61,8 @@ public:
     virtual void onSuccess(PassRefPtr<IDBTransactionBackendInterface>) { }
     virtual void onSuccess(PassRefPtr<SerializedScriptValue>) { }
     virtual void onSuccess(PassRefPtr<SerializedScriptValue>, PassRefPtr<IDBKey>, const IDBKeyPath&) { }
+    virtual void onSuccess(int64_t) OVERRIDE { }
+    virtual void onSuccess() OVERRIDE { }
     virtual void onSuccess(PassRefPtr<IDBKey>, PassRefPtr<IDBKey>, PassRefPtr<SerializedScriptValue>) { };
     virtual void onSuccessWithPrefetch(const Vector<RefPtr<IDBKey> >&, const Vector<RefPtr<IDBKey> >&, const Vector<RefPtr<SerializedScriptValue> >&) { }
     virtual void onBlocked() { }
index 2cf2a1f887d776302b97bc5f8c78ebc5043fb783..cee089c85b3b8e3265b57b42525ee3ab9d6ad5c3 100644 (file)
@@ -91,6 +91,8 @@ public:
     virtual void onSuccess(PassRefPtr<IDBTransactionBackendInterface>) OVERRIDE { }
     virtual void onSuccess(PassRefPtr<SerializedScriptValue>) OVERRIDE { }
     virtual void onSuccess(PassRefPtr<SerializedScriptValue>, PassRefPtr<IDBKey>, const IDBKeyPath&) OVERRIDE { };
+    virtual void onSuccess(int64_t) OVERRIDE { }
+    virtual void onSuccess() OVERRIDE { }
     virtual void onSuccess(PassRefPtr<IDBKey>, PassRefPtr<IDBKey>, PassRefPtr<SerializedScriptValue>) OVERRIDE { };
     virtual void onSuccessWithPrefetch(const Vector<RefPtr<IDBKey> >&, const Vector<RefPtr<IDBKey> >&, const Vector<RefPtr<SerializedScriptValue> >&) OVERRIDE { }
     virtual void onBlocked() OVERRIDE { }