void IDBCursor::setValueReady(DOMRequestState* state, PassRefPtr<IDBKey> key, PassRefPtr<IDBKey> primaryKey, ScriptValue& value) { m_currentKey = key; m_currentKeyValue = idbKeyToScriptValue(state, m_currentKey); m_currentPrimaryKey = primaryKey; m_currentPrimaryKeyValue = idbKeyToScriptValue(state, m_currentPrimaryKey); if (!isKeyCursor()) { RefPtr<IDBObjectStore> objectStore = effectiveObjectStore(); const IDBObjectStoreMetadata metadata = objectStore->metadata(); if (metadata.autoIncrement && !metadata.keyPath.isNull()) { #ifndef NDEBUG RefPtr<IDBKey> expectedKey = createIDBKeyFromScriptValueAndKeyPath(m_request->requestState(), value, metadata.keyPath); ASSERT(!expectedKey || expectedKey->isEqual(m_currentPrimaryKey.get())); #endif 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); } } m_currentValue = value; m_gotValue = true; }
void IDBRequest::onSuccess(PassRefPtr<IDBKey> idbKey) { IDB_TRACE("IDBRequest::onSuccess(IDBKey)"); if (!shouldEnqueueEvent()) return; if (idbKey && idbKey->isValid()) { DOMRequestState::Scope scope(m_requestState); m_result = IDBAny::create(idbKeyToScriptValue(requestState(), idbKey)); } else m_result = IDBAny::createInvalid(); enqueueEvent(createSuccessEvent()); }
void LegacyRequest::onSuccess(PassRefPtr<IDBKey> idbKey) { LOG(StorageAPI, "LegacyRequest::onSuccess(IDBKey)"); if (!shouldEnqueueEvent()) return; if (idbKey && idbKey->isValid()) { DOMRequestState::Scope scope(m_requestState); m_result = LegacyAny::create(idbKeyToScriptValue(requestState(), idbKey)); } else m_result = LegacyAny::createInvalid(); enqueueEvent(createSuccessEvent()); }
void assertPrimaryKeyValidOrInjectable(ScriptState* scriptState, PassRefPtr<SharedBuffer> buffer, const Vector<blink::WebBlobInfo>* blobInfo, IDBKey* key, const IDBKeyPath& keyPath) { ScriptState::Scope scope(scriptState); v8::Isolate* isolate = scriptState->isolate(); ScriptValue keyValue = idbKeyToScriptValue(scriptState, key); ScriptValue scriptValue(scriptState, deserializeIDBValueBuffer(isolate, buffer.get(), blobInfo)); // This assertion is about already persisted data, so allow experimental types. const bool allowExperimentalTypes = true; IDBKey* expectedKey = createIDBKeyFromScriptValueAndKeyPathInternal(isolate, scriptValue, keyPath, allowExperimentalTypes); ASSERT(!expectedKey || expectedKey->isEqual(key)); bool injected = injectV8KeyIntoV8Value(isolate, keyValue.v8Value(), scriptValue.v8Value(), keyPath); ASSERT_UNUSED(injected, injected); }
void assertPrimaryKeyValidOrInjectable(DOMRequestState* state, PassRefPtr<SharedBuffer> buffer, PassRefPtr<IDBKey> prpKey, const IDBKeyPath& keyPath) { RefPtr<IDBKey> key(prpKey); DOMRequestState::Scope scope(*state); v8::Isolate* isolate = state ? state->context()->GetIsolate() : v8::Isolate::GetCurrent(); ScriptValue keyValue = idbKeyToScriptValue(state, key); ScriptValue scriptValue(deserializeIDBValueBuffer(buffer.get(), isolate), isolate); RefPtr<IDBKey> expectedKey = createIDBKeyFromScriptValueAndKeyPath(state, scriptValue, keyPath); ASSERT(!expectedKey || expectedKey->isEqual(key.get())); bool injected = injectV8KeyIntoV8Value(keyValue.v8Value(), scriptValue.v8Value(), keyPath, isolate); ASSERT_UNUSED(injected, injected); }
ScriptValue IDBKeyRange::upperValue(ScriptState* scriptState) const { return idbKeyToScriptValue(scriptState, m_upper); }
Deprecated::ScriptValue idbKeyDataToScriptValue(ScriptExecutionContext* context, const IDBKeyData& keyData) { RefPtr<IDBKey> key = keyData.maybeCreateIDBKey(); DOMRequestState requestState(context); return idbKeyToScriptValue(&requestState, key.get()); }
ScriptValue IDBKeyRange::upperValue(ScriptExecutionContext* context) const { DOMRequestState requestState(context); return idbKeyToScriptValue(&requestState, m_upper); }
ScriptValue IDBCursor::primaryKey(ScriptState* scriptState) { m_primaryKeyDirty = false; return idbKeyToScriptValue(scriptState, m_primaryKey); }