WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-94023-20120905133059.patch (text/plain), 23.54 KB, created by
Alec Flett
on 2012-09-05 13:31:17 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Alec Flett
Created:
2012-09-05 13:31:17 PDT
Size:
23.54 KB
patch
obsolete
>Subversion Revision: 127533 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 806cac41dbc40fcc871f9ddfcc832290a2e98712..832129c4a485ae1611c7664976c6ad49b02f8789 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,5 +1,46 @@ > 2012-08-29 Alec Flett <alecflett@chromium.org> > >+ IndexedDB: Use ScriptValue instead of SerializedScriptValue when possible >+ https://bugs.webkit.org/show_bug.cgi?id=94023 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Transition the put/add/update methods to accept direct ScriptValue >+ objects rather than SerializedScriptValues, to eliminate lots of >+ redundant deserialization/serialization steps while storing >+ values. >+ >+ Also see https://bugs.webkit.org/show_bug.cgi?id=95409 for >+ followup get/openCursor work, following this. >+ >+ No new tests, this is a performance refactor and existing tests cover >+ correctness. >+ >+ * Modules/indexeddb/IDBCursor.cpp: >+ (WebCore::IDBCursor::update): >+ * Modules/indexeddb/IDBCursor.h: >+ (IDBCursor): >+ * Modules/indexeddb/IDBCursor.idl: >+ * Modules/indexeddb/IDBObjectStore.cpp: >+ (WebCore::generateIndexKeysForValue): >+ (WebCore::IDBObjectStore::add): >+ (WebCore::IDBObjectStore::put): >+ (WebCore): >+ * Modules/indexeddb/IDBObjectStore.h: >+ (WebCore::IDBObjectStore::add): >+ (WebCore::IDBObjectStore::put): >+ (IDBObjectStore): >+ * Modules/indexeddb/IDBObjectStore.idl: >+ * bindings/v8/IDBBindingUtilities.cpp: >+ (WebCore): >+ (WebCore::createIDBKeyFromScriptValueAndKeyPath): >+ (WebCore::deserializeIDBValue): >+ (WebCore::canInjectIDBKeyIntoScriptValue): >+ * bindings/v8/IDBBindingUtilities.h: >+ (WebCore): >+ >+2012-08-29 Alec Flett <alecflett@chromium.org> >+ > IndexedDB: remove final createIndex backend glue > https://bugs.webkit.org/show_bug.cgi?id=95385 > >diff --git a/Source/WebCore/Modules/indexeddb/IDBCursor.cpp b/Source/WebCore/Modules/indexeddb/IDBCursor.cpp >index 903dab583c3632a766b95d979b3e25d9fb735892..96fe82f76d6d3cb712b864f2fc5e0de44c0e9fff 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBCursor.cpp >+++ b/Source/WebCore/Modules/indexeddb/IDBCursor.cpp >@@ -125,10 +125,9 @@ IDBAny* IDBCursor::source() const > return m_source.get(); > } > >-PassRefPtr<IDBRequest> IDBCursor::update(ScriptExecutionContext* context, PassRefPtr<SerializedScriptValue> prpValue, ExceptionCode& ec) >+PassRefPtr<IDBRequest> IDBCursor::update(ScriptExecutionContext* context, ScriptValue& value, ExceptionCode& ec) > { > IDB_TRACE("IDBCursor::update"); >- RefPtr<SerializedScriptValue> value = prpValue; > > if (!m_gotValue || isKeyCursor()) { > ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; >@@ -142,17 +141,12 @@ PassRefPtr<IDBRequest> IDBCursor::update(ScriptExecutionContext* context, PassRe > ec = IDBDatabaseException::READ_ONLY_ERR; > return 0; > } >- if (value->blobURLs().size() > 0) { >- // FIXME: Add Blob/File/FileList support >- ec = IDBDatabaseException::IDB_DATA_CLONE_ERR; >- return 0; >- } > > RefPtr<IDBObjectStore> objectStore = effectiveObjectStore(); > const IDBKeyPath& keyPath = objectStore->metadata().keyPath; > const bool usesInLineKeys = !keyPath.isNull(); > if (usesInLineKeys) { >- RefPtr<IDBKey> keyPathKey = createIDBKeyFromSerializedValueAndKeyPath(value, keyPath); >+ RefPtr<IDBKey> keyPathKey = createIDBKeyFromScriptValueAndKeyPath(value, keyPath); > if (!keyPathKey || !keyPathKey->isEqual(m_currentPrimaryKey.get())) { > ec = IDBDatabaseException::DATA_ERR; > return 0; >diff --git a/Source/WebCore/Modules/indexeddb/IDBCursor.h b/Source/WebCore/Modules/indexeddb/IDBCursor.h >index 590828859a7a31d8f08871f2c41df93203fa17de..1b619353fedb52bbbe1021f9bca8a9965012a7e6 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBCursor.h >+++ b/Source/WebCore/Modules/indexeddb/IDBCursor.h >@@ -75,7 +75,7 @@ public: > PassRefPtr<IDBAny> value(); > IDBAny* source() const; > >- PassRefPtr<IDBRequest> update(ScriptExecutionContext*, PassRefPtr<SerializedScriptValue>, ExceptionCode&); >+ PassRefPtr<IDBRequest> update(ScriptExecutionContext*, ScriptValue&, ExceptionCode&); > void advance(unsigned long, ExceptionCode&); > void continueFunction(PassRefPtr<IDBKey>, ExceptionCode&); > PassRefPtr<IDBRequest> deleteFunction(ScriptExecutionContext*, ExceptionCode&); >diff --git a/Source/WebCore/Modules/indexeddb/IDBCursor.idl b/Source/WebCore/Modules/indexeddb/IDBCursor.idl >index d73d146274418402742320f4f3e606ab3d202e49..eb2cdad8a761bcf460fb1f66ce7e3e9d0fe1dd0f 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBCursor.idl >+++ b/Source/WebCore/Modules/indexeddb/IDBCursor.idl >@@ -39,7 +39,7 @@ module storage { > readonly attribute IDBKey primaryKey; > readonly attribute IDBAny source; > >- [CallWith=ScriptExecutionContext] IDBRequest update(in SerializedScriptValue value) >+ [CallWith=ScriptExecutionContext] IDBRequest update(in DOMObject value) > raises (IDBDatabaseException); > void advance(in unsigned long count) > raises (IDBDatabaseException); >diff --git a/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp b/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp >index a7aa8a3eab609c692be08482d65a66f4687745d0..2e2d7ed72ece1c00da094aa38d5408b64752850b 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp >+++ b/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp >@@ -105,11 +105,11 @@ PassRefPtr<IDBRequest> IDBObjectStore::get(ScriptExecutionContext* context, Pass > } > > static void generateIndexKeysForValue(const IDBIndexMetadata& indexMetadata, >- PassRefPtr<SerializedScriptValue> objectValue, >+ ScriptValue& objectValue, > IDBObjectStore::IndexKeys* indexKeys) > { > ASSERT(indexKeys); >- RefPtr<IDBKey> indexKey = createIDBKeyFromSerializedValueAndKeyPath(objectValue, indexMetadata.keyPath); >+ RefPtr<IDBKey> indexKey = createIDBKeyFromScriptValueAndKeyPath(objectValue, indexMetadata.keyPath); > > if (!indexKey) > return; >@@ -129,22 +129,21 @@ static void generateIndexKeysForValue(const IDBIndexMetadata& indexMetadata, > } > } > >-PassRefPtr<IDBRequest> IDBObjectStore::add(ScriptExecutionContext* context, PassRefPtr<SerializedScriptValue> value, PassRefPtr<IDBKey> key, ExceptionCode& ec) >+PassRefPtr<IDBRequest> IDBObjectStore::add(ScriptExecutionContext* context, ScriptValue& value, PassRefPtr<IDBKey> key, ExceptionCode& ec) > { > IDB_TRACE("IDBObjectStore::add"); > return put(IDBObjectStoreBackendInterface::AddOnly, IDBAny::create(this), context, value, key, ec); > } > >-PassRefPtr<IDBRequest> IDBObjectStore::put(ScriptExecutionContext* context, PassRefPtr<SerializedScriptValue> value, PassRefPtr<IDBKey> key, ExceptionCode& ec) >+PassRefPtr<IDBRequest> IDBObjectStore::put(ScriptExecutionContext* context, ScriptValue& value, PassRefPtr<IDBKey> key, ExceptionCode& ec) > { > IDB_TRACE("IDBObjectStore::put"); > return put(IDBObjectStoreBackendInterface::AddOrUpdate, IDBAny::create(this), context, value, key, ec); > } > >-PassRefPtr<IDBRequest> IDBObjectStore::put(IDBObjectStoreBackendInterface::PutMode putMode, PassRefPtr<IDBAny> source, ScriptExecutionContext* context, PassRefPtr<SerializedScriptValue> prpValue, PassRefPtr<IDBKey> prpKey, ExceptionCode& ec) >+PassRefPtr<IDBRequest> IDBObjectStore::put(IDBObjectStoreBackendInterface::PutMode putMode, PassRefPtr<IDBAny> source, ScriptExecutionContext* context, ScriptValue& value, PassRefPtr<IDBKey> prpKey, ExceptionCode& ec) > { > IDB_TRACE("IDBObjectStore::put"); >- RefPtr<SerializedScriptValue> value = prpValue; > RefPtr<IDBKey> key = prpKey; > if (m_deleted) { > ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; >@@ -158,7 +157,15 @@ PassRefPtr<IDBRequest> IDBObjectStore::put(IDBObjectStoreBackendInterface::PutMo > ec = IDBDatabaseException::READ_ONLY_ERR; > return 0; > } >- if (value->blobURLs().size() > 0) { >+ >+ ScriptState* state = ScriptState::current(); >+ RefPtr<SerializedScriptValue> serializedValue = value.serialize(state); >+ if (state->hadException()) { >+ ec = IDBDatabaseException::IDB_DATA_CLONE_ERR; >+ return 0; >+ } >+ >+ if (serializedValue->blobURLs().size() > 0) { > // FIXME: Add Blob/File/FileList support > ec = IDBDatabaseException::IDB_DATA_CLONE_ERR; > return 0; >@@ -177,7 +184,7 @@ PassRefPtr<IDBRequest> IDBObjectStore::put(IDBObjectStoreBackendInterface::PutMo > return 0; > } > if (usesInLineKeys) { >- RefPtr<IDBKey> keyPathKey = createIDBKeyFromSerializedValueAndKeyPath(value, keyPath); >+ RefPtr<IDBKey> keyPathKey = createIDBKeyFromScriptValueAndKeyPath(value, keyPath); > if (keyPathKey && !keyPathKey->isValid()) { > ec = IDBDatabaseException::DATA_ERR; > return 0; >@@ -187,9 +194,7 @@ PassRefPtr<IDBRequest> IDBObjectStore::put(IDBObjectStoreBackendInterface::PutMo > return 0; > } > if (hasKeyGenerator && !keyPathKey) { >- RefPtr<IDBKey> dummyKey = IDBKey::createNumber(-1); >- RefPtr<SerializedScriptValue> valueAfterInjection = injectIDBKeyIntoSerializedValue(dummyKey, value, keyPath); >- if (!valueAfterInjection) { >+ if (!canInjectIDBKeyIntoScriptValue(value, keyPath)) { > ec = IDBDatabaseException::DATA_ERR; > return 0; > } >@@ -213,7 +218,7 @@ PassRefPtr<IDBRequest> IDBObjectStore::put(IDBObjectStoreBackendInterface::PutMo > ASSERT(indexKeys.size() == indexNames.size()); > > RefPtr<IDBRequest> request = IDBRequest::create(context, source, m_transaction.get()); >- m_backend->putWithIndexKeys(value.release(), key.release(), putMode, request, m_transaction->backend(), indexNames, indexKeys, ec); >+ m_backend->putWithIndexKeys(serializedValue.release(), key.release(), putMode, request, m_transaction->backend(), indexNames, indexKeys, ec); > if (ec) { > request->markEarlyDeath(); > return 0; >@@ -336,7 +341,8 @@ private: > RefPtr<IDBAny> valueAny = cursor->value(); > > ASSERT(valueAny->type() == IDBAny::SerializedScriptValueType); >- RefPtr<SerializedScriptValue> value = valueAny->serializedScriptValue(); >+ RefPtr<SerializedScriptValue> serializedValue = valueAny->serializedScriptValue(); >+ ScriptValue value(deserializeIDBValue(serializedValue)); > > IDBObjectStore::IndexKeys indexKeys; > generateIndexKeysForValue(m_indexMetadata, value, &indexKeys); >diff --git a/Source/WebCore/Modules/indexeddb/IDBObjectStore.h b/Source/WebCore/Modules/indexeddb/IDBObjectStore.h >index 92e0fed96a4636bfad3265bcb637934d460438a3..9a5c7752bbd8550407dda68904767b695a893646 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBObjectStore.h >+++ b/Source/WebCore/Modules/indexeddb/IDBObjectStore.h >@@ -64,8 +64,8 @@ public: > PassRefPtr<IDBTransaction> transaction() const { return m_transaction; } > bool autoIncrement() const { return m_metadata.autoIncrement; } > >- PassRefPtr<IDBRequest> add(ScriptExecutionContext* context, PassRefPtr<SerializedScriptValue> value, ExceptionCode& ec) { return add(context, value, 0, ec); } >- PassRefPtr<IDBRequest> put(ScriptExecutionContext* context, PassRefPtr<SerializedScriptValue> value, ExceptionCode& ec) { return put(context, value, 0, ec); } >+ PassRefPtr<IDBRequest> add(ScriptExecutionContext* context, ScriptValue& value, ExceptionCode& ec) { return add(context, value, 0, ec); } >+ PassRefPtr<IDBRequest> put(ScriptExecutionContext* context, ScriptValue& value, ExceptionCode& ec) { return put(context, value, 0, ec); } > PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext* context, ExceptionCode& ec) { return openCursor(context, static_cast<IDBKeyRange*>(0), ec); } > PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> keyRange, ExceptionCode& ec) { return openCursor(context, keyRange, IDBCursor::directionNext(), ec); } > PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext* context, PassRefPtr<IDBKey> key, ExceptionCode& ec) { return openCursor(context, key, IDBCursor::directionNext(), ec); } >@@ -77,8 +77,8 @@ public: > > PassRefPtr<IDBRequest> get(ScriptExecutionContext*, PassRefPtr<IDBKey>, ExceptionCode&); > PassRefPtr<IDBRequest> get(ScriptExecutionContext*, PassRefPtr<IDBKeyRange>, ExceptionCode&); >- PassRefPtr<IDBRequest> add(ScriptExecutionContext*, PassRefPtr<SerializedScriptValue>, PassRefPtr<IDBKey>, ExceptionCode&); >- PassRefPtr<IDBRequest> put(ScriptExecutionContext*, PassRefPtr<SerializedScriptValue>, PassRefPtr<IDBKey>, ExceptionCode&); >+ PassRefPtr<IDBRequest> add(ScriptExecutionContext*, ScriptValue&, PassRefPtr<IDBKey>, ExceptionCode&); >+ PassRefPtr<IDBRequest> put(ScriptExecutionContext*, ScriptValue&, PassRefPtr<IDBKey>, ExceptionCode&); > PassRefPtr<IDBRequest> deleteFunction(ScriptExecutionContext*, PassRefPtr<IDBKeyRange>, ExceptionCode&); > PassRefPtr<IDBRequest> deleteFunction(ScriptExecutionContext*, PassRefPtr<IDBKey> key, ExceptionCode&); > PassRefPtr<IDBRequest> clear(ScriptExecutionContext*, ExceptionCode&); >@@ -97,7 +97,7 @@ public: > PassRefPtr<IDBRequest> count(ScriptExecutionContext*, PassRefPtr<IDBKeyRange>, ExceptionCode&); > PassRefPtr<IDBRequest> count(ScriptExecutionContext*, PassRefPtr<IDBKey>, ExceptionCode&); > >- PassRefPtr<IDBRequest> put(IDBObjectStoreBackendInterface::PutMode, PassRefPtr<IDBAny> source, ScriptExecutionContext*, PassRefPtr<SerializedScriptValue>, PassRefPtr<IDBKey>, ExceptionCode&); >+ PassRefPtr<IDBRequest> put(IDBObjectStoreBackendInterface::PutMode, PassRefPtr<IDBAny> source, ScriptExecutionContext*, ScriptValue&, PassRefPtr<IDBKey>, ExceptionCode&); > void markDeleted() { m_deleted = true; } > void transactionFinished(); > >diff --git a/Source/WebCore/Modules/indexeddb/IDBObjectStore.idl b/Source/WebCore/Modules/indexeddb/IDBObjectStore.idl >index 99d86846b81ea91040ad38050a6448507cfbe0d6..6253223b8cb3c91c984d8e85e7375bc309c11521 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBObjectStore.idl >+++ b/Source/WebCore/Modules/indexeddb/IDBObjectStore.idl >@@ -34,9 +34,9 @@ module storage { > readonly attribute IDBTransaction transaction; > readonly attribute boolean autoIncrement; > >- [CallWith=ScriptExecutionContext] IDBRequest put(in SerializedScriptValue value, in [Optional] IDBKey key) >+ [CallWith=ScriptExecutionContext] IDBRequest put(in DOMObject value, in [Optional] IDBKey key) > raises (IDBDatabaseException); >- [CallWith=ScriptExecutionContext] IDBRequest add(in SerializedScriptValue value, in [Optional] IDBKey key) >+ [CallWith=ScriptExecutionContext] IDBRequest add(in DOMObject value, in [Optional] IDBKey key) > raises (IDBDatabaseException); > [CallWith=ScriptExecutionContext, ImplementedAs=deleteFunction] IDBRequest delete(in IDBKeyRange? keyRange) > raises (IDBDatabaseException); >diff --git a/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp b/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp >index 19fd91d900935dedbc8115dd94145a68f49e7016..81c0160372ed3d5a9cf243e6064076ae25e2f59a 100644 >--- a/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp >+++ b/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp >@@ -85,10 +85,8 @@ PassRefPtr<IDBKey> createIDBKeyFromValue(v8::Handle<v8::Value> value) > return IDBKey::createInvalid(); > } > >-namespace { >- > template<typename T> >-bool getValueFrom(T indexOrName, v8::Handle<v8::Value>& v8Value) >+static bool getValueFrom(T indexOrName, v8::Handle<v8::Value>& v8Value) > { > v8::Local<v8::Object> object = v8Value->ToObject(); > if (!object->Has(indexOrName)) >@@ -98,49 +96,72 @@ bool getValueFrom(T indexOrName, v8::Handle<v8::Value>& v8Value) > } > > template<typename T> >-bool setValue(v8::Handle<v8::Value>& v8Object, T indexOrName, const v8::Handle<v8::Value>& v8Value) >+static bool setValue(v8::Handle<v8::Value>& v8Object, T indexOrName, const v8::Handle<v8::Value>& v8Value) > { > v8::Local<v8::Object> object = v8Object->ToObject(); > return object->Set(indexOrName, v8Value); > } > >-bool get(v8::Handle<v8::Value>& object, const String& keyPathElement) >+static bool get(v8::Handle<v8::Value>& object, const String& keyPathElement, v8::Handle<v8::Value>& result) > { > if (object->IsString() && keyPathElement == "length") { > int32_t length = v8::Handle<v8::String>::Cast(object)->Length(); >- object = v8::Number::New(length); >+ result = v8::Number::New(length); > return true; > } >- return object->IsObject() && getValueFrom(v8String(keyPathElement), object); >+ return object->IsObject() && getValueFrom(v8String(keyPathElement), result); > } > >-bool set(v8::Handle<v8::Value>& object, const String& keyPathElement, const v8::Handle<v8::Value>& v8Value) >+static bool canSet(v8::Handle<v8::Value>& object, const String& keyPathElement) > { >- return object->IsObject() && setValue(object, v8String(keyPathElement), v8Value); >+ return object->IsObject(); > } > >-v8::Handle<v8::Value> getNthValueOnKeyPath(v8::Handle<v8::Value>& rootValue, const Vector<String>& keyPathElements, size_t index) >+static bool set(v8::Handle<v8::Value>& object, const String& keyPathElement, const v8::Handle<v8::Value>& v8Value) > { >- v8::Handle<v8::Value> currentValue(rootValue); >+ return canSet(object, keyPathElement) && setValue(object, v8String(keyPathElement), v8Value); >+} > >+static static v8::Handle<v8::Value> getNthValueOnKeyPath(v8::Handle<v8::Value>& rootValue, const Vector<String>& keyPathElements, size_t index) >+{ >+ v8::Handle<v8::Value> currentValue(rootValue); > ASSERT(index <= keyPathElements.size()); > for (size_t i = 0; i < index; ++i) { >- if (!get(currentValue, keyPathElements[i])) >+ v8::Handle<v8::Value> parentValue(currentValue); >+ if (!get(parentValue, keyPathElements[i], currentValue)) > return v8Undefined(); > } > > return currentValue; > } > >-v8::Handle<v8::Value> ensureNthValueOnKeyPath(v8::Handle<v8::Value>& rootValue, const Vector<String>& keyPathElements, size_t index) >+static bool canInjectNthValueOnKeyPath(v8::Handle<v8::Value>& rootValue, const Vector<String>& keyPathElements, size_t index) > { >+ if (!rootValue->IsObject()) >+ return false; >+ > v8::Handle<v8::Value> currentValue(rootValue); > > ASSERT(index <= keyPathElements.size()); > for (size_t i = 0; i < index; ++i) { > v8::Handle<v8::Value> parentValue(currentValue); > const String& keyPathElement = keyPathElements[i]; >- if (!get(currentValue, keyPathElement)) { >+ if (!get(parentValue, keyPathElement, currentValue)) >+ return canSet(parentValue, keyPathElement); >+ } >+ return true; >+} >+ >+ >+static v8::Handle<v8::Value> ensureNthValueOnKeyPath(v8::Handle<v8::Value>& rootValue, const Vector<String>& keyPathElements, size_t index) >+{ >+ v8::Handle<v8::Value> currentValue(rootValue); >+ >+ ASSERT(index <= keyPathElements.size()); >+ for (size_t i = 0; i < index; ++i) { >+ v8::Handle<v8::Value> parentValue(currentValue); >+ const String& keyPathElement = keyPathElements[i]; >+ if (!get(parentValue, keyPathElement, currentValue)) { > v8::Handle<v8::Object> object = v8::Object::New(); > if (!set(parentValue, keyPathElement, object)) > return v8Undefined(); >@@ -151,7 +172,41 @@ v8::Handle<v8::Value> ensureNthValueOnKeyPath(v8::Handle<v8::Value>& rootValue, > return currentValue; > } > >-} // anonymous namespace >+static PassRefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(ScriptValue& value, const String& keyPath) >+{ >+ Vector<String> keyPathElements; >+ IDBKeyPathParseError error; >+ IDBParseKeyPath(keyPath, keyPathElements, error); >+ ASSERT(error == IDBKeyPathParseErrorNone); >+ >+ V8AuxiliaryContext context; >+ v8::Handle<v8::Value> v8Value(value.v8Value()); >+ v8::Handle<v8::Value> v8Key(getNthValueOnKeyPath(v8Value, keyPathElements, keyPathElements.size())); >+ if (v8Key.IsEmpty()) >+ return 0; >+ return createIDBKeyFromValue(v8Key); >+} >+ >+PassRefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(ScriptValue& value, const IDBKeyPath& keyPath) >+{ >+ IDB_TRACE("createIDBKeyFromSerializedValueAndKeyPath"); >+ ASSERT(!keyPath.isNull()); >+ >+ if (keyPath.type() == IDBKeyPath::ArrayType) { >+ IDBKey::KeyArray result; >+ const Vector<String>& array = keyPath.array(); >+ for (size_t i = 0; i < array.size(); ++i) { >+ RefPtr<IDBKey> key = createIDBKeyFromScriptValueAndKeyPath(value, array[i]); >+ if (!key) >+ return 0; >+ result.append(key); >+ } >+ return IDBKey::createArray(result); >+ } >+ >+ ASSERT(keyPath.type() == IDBKeyPath::StringType); >+ return createIDBKeyFromScriptValueAndKeyPath(value, keyPath.string()); >+} > > static PassRefPtr<IDBKey> createIDBKeyFromSerializedValueAndKeyPath(PassRefPtr<SerializedScriptValue> prpValue, const String& keyPath) > { >@@ -170,6 +225,13 @@ static PassRefPtr<IDBKey> createIDBKeyFromSerializedValueAndKeyPath(PassRefPtr<S > return createIDBKeyFromValue(v8Key); > } > >+// FIXME: The only reason this exists is because we need a V8AuxiliaryContext inside a timer. Is there a better / more general way to do this? >+ScriptValue deserializeIDBValue(PassRefPtr<SerializedScriptValue> prpValue) >+{ >+ V8AuxiliaryContext context; >+ v8::Handle<v8::Value> v8Value(prpValue->deserialize()); >+ return ScriptValue(v8Value); >+} > > PassRefPtr<IDBKey> createIDBKeyFromSerializedValueAndKeyPath(PassRefPtr<SerializedScriptValue> prpValue, const IDBKeyPath& keyPath) > { >@@ -219,6 +281,22 @@ PassRefPtr<SerializedScriptValue> injectIDBKeyIntoSerializedValue(PassRefPtr<IDB > return SerializedScriptValue::create(v8Value); > } > >+bool canInjectIDBKeyIntoScriptValue(const ScriptValue& scriptValue, const IDBKeyPath& keyPath) >+{ >+ ASSERT(keyPath.type() == IDBKeyPath::StringType); >+ Vector<String> keyPathElements; >+ IDBKeyPathParseError error; >+ IDBParseKeyPath(keyPath.string(), keyPathElements, error); >+ ASSERT(error == IDBKeyPathParseErrorNone); >+ >+ if (!keyPathElements.size()) >+ return false; >+ >+ V8AuxiliaryContext context; >+ v8::Handle<v8::Value> v8Value(scriptValue.v8Value()); >+ return canInjectNthValueOnKeyPath(v8Value, keyPathElements, keyPathElements.size() - 1); >+} >+ > } // namespace WebCore > > #endif >diff --git a/Source/WebCore/bindings/v8/IDBBindingUtilities.h b/Source/WebCore/bindings/v8/IDBBindingUtilities.h >index 30eed421b45b0903011bd249bba0d74c23ba274f..79a3fda94b765aca8abc0a22f2adb18df3328207 100644 >--- a/Source/WebCore/bindings/v8/IDBBindingUtilities.h >+++ b/Source/WebCore/bindings/v8/IDBBindingUtilities.h >@@ -28,6 +28,7 @@ > > #if ENABLE(INDEXED_DATABASE) > >+#include "ScriptValue.h" > #include <v8.h> > #include <wtf/Forward.h> > >@@ -38,9 +39,15 @@ class IDBKeyPath; > class SerializedScriptValue; > > PassRefPtr<IDBKey> createIDBKeyFromValue(v8::Handle<v8::Value>); >+ >+// FIXME: remove the SerializedValue versions when their use is finally removed in https://bugs.webkit.org/show_bug.cgi?id=95409. > PassRefPtr<IDBKey> createIDBKeyFromSerializedValueAndKeyPath(PassRefPtr<SerializedScriptValue>, const IDBKeyPath&); > PassRefPtr<SerializedScriptValue> injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey>, PassRefPtr<SerializedScriptValue>, const IDBKeyPath&); > >+PassRefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(ScriptValue&, const IDBKeyPath&); >+bool canInjectIDBKeyIntoScriptValue(const ScriptValue&, const IDBKeyPath&); >+ScriptValue deserializeIDBValue(PassRefPtr<SerializedScriptValue>); >+ > } > > #endif // ENABLE(INDEXED_DATABASE)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 94023
:
161369
|
162315
|
162317
|
162372
|
162832
|
163236
|
163402
|
163681
|
163713
|
163718