Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Unified Diff: Source/bindings/modules/v8/V8BindingForModules.cpp

Issue 1021713003: [bindings] Let NativeValueTraits<T>::nativeValue be variadic function and merge various convers… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed the compiler error behind ASSERT flag Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/bindings/modules/v8/V8BindingForModules.cpp
diff --git a/Source/bindings/modules/v8/V8BindingForModules.cpp b/Source/bindings/modules/v8/V8BindingForModules.cpp
index f18e70460f20f307c9dfce08fe9e9f7cff7e2ec9..2ceb11b65f5e7b24ef4395902250910ba6b520fd 100644
--- a/Source/bindings/modules/v8/V8BindingForModules.cpp
+++ b/Source/bindings/modules/v8/V8BindingForModules.cpp
@@ -303,7 +303,7 @@ static v8::Local<v8::Value> ensureNthValueOnKeyPath(v8::Isolate* isolate, v8::Lo
return currentValue;
}
-static IDBKey* createIDBKeyFromScriptValueAndKeyPathInternal(v8::Isolate* isolate, const ScriptValue& value, const String& keyPath, bool allowExperimentalTypes)
+static IDBKey* createIDBKeyFromScriptValueAndKeyPathInternal(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, const String& keyPath, bool allowExperimentalTypes)
{
Vector<String> keyPathElements;
IDBKeyPathParseError error;
@@ -312,14 +312,13 @@ static IDBKey* createIDBKeyFromScriptValueAndKeyPathInternal(v8::Isolate* isolat
ASSERT(isolate->InContext());
v8::HandleScope handleScope(isolate);
- v8::Local<v8::Value> v8Value(value.v8Value());
v8::Local<v8::Value> v8Key(getNthValueOnKeyPath(isolate, v8Value, keyPathElements, keyPathElements.size()));
if (v8Key.IsEmpty())
return 0;
return createIDBKeyFromValue(isolate, v8Key, allowExperimentalTypes);
}
-static IDBKey* createIDBKeyFromScriptValueAndKeyPathInternal(v8::Isolate* isolate, const ScriptValue& value, const IDBKeyPath& keyPath, bool allowExperimentalTypes = false)
+static IDBKey* createIDBKeyFromScriptValueAndKeyPathInternal(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, const IDBKeyPath& keyPath, bool allowExperimentalTypes = false)
{
ASSERT(!keyPath.isNull());
v8::HandleScope handleScope(isolate);
@@ -327,7 +326,7 @@ static IDBKey* createIDBKeyFromScriptValueAndKeyPathInternal(v8::Isolate* isolat
IDBKey::KeyArray result;
const Vector<String>& array = keyPath.array();
for (size_t i = 0; i < array.size(); ++i) {
- IDBKey* key = createIDBKeyFromScriptValueAndKeyPathInternal(isolate, value, array[i], allowExperimentalTypes);
+ IDBKey* key = createIDBKeyFromScriptValueAndKeyPathInternal(isolate, v8Value, array[i], allowExperimentalTypes);
if (!key)
return 0;
result.append(key);
@@ -336,13 +335,7 @@ static IDBKey* createIDBKeyFromScriptValueAndKeyPathInternal(v8::Isolate* isolat
}
ASSERT(keyPath.type() == IDBKeyPath::StringType);
- return createIDBKeyFromScriptValueAndKeyPathInternal(isolate, value, keyPath.string(), allowExperimentalTypes);
-}
-
-IDBKey* createIDBKeyFromScriptValueAndKeyPath(v8::Isolate* isolate, const ScriptValue& value, const IDBKeyPath& keyPath)
-{
- IDB_TRACE("createIDBKeyFromScriptValueAndKeyPath");
- return createIDBKeyFromScriptValueAndKeyPathInternal(isolate, value, keyPath);
+ return createIDBKeyFromScriptValueAndKeyPathInternal(isolate, v8Value, keyPath.string(), allowExperimentalTypes);
}
static v8::Local<v8::Value> deserializeIDBValueBuffer(v8::Isolate* isolate, SharedBuffer* buffer, const Vector<blink::WebBlobInfo>* blobInfo)
@@ -435,9 +428,12 @@ SQLValue NativeValueTraits<SQLValue>::nativeValue(v8::Local<v8::Value> value, v8
return SQLValue(stringValue);
}
-IDBKey* NativeValueTraits<IDBKey*>::nativeValue(v8::Local<v8::Value> value, v8::Isolate* isolate, ExceptionState& exceptionState)
+IDBKey* NativeValueTraits<IDBKey*>::nativeValue(v8::Local<v8::Value> value, v8::Isolate* isolate, ExceptionState& exceptionState, const IDBKeyPath& keyPath)
{
- return createIDBKeyFromValue(isolate, value);
+ if (keyPath.isNull())
+ return createIDBKeyFromValue(isolate, value);
+ IDB_TRACE("createIDBKeyFromScriptValueAndKeyPath)");
+ return createIDBKeyFromScriptValueAndKeyPathInternal(isolate, value, keyPath);
}
IDBKeyRange* NativeValueTraits<IDBKeyRange*>::nativeValue(v8::Local<v8::Value> value, v8::Isolate* isolate, ExceptionState& exceptionState)
@@ -455,7 +451,7 @@ void assertPrimaryKeyValidOrInjectable(ScriptState* scriptState, PassRefPtr<Shar
// This assertion is about already persisted data, so allow experimental types.
const bool allowExperimentalTypes = true;
- IDBKey* expectedKey = createIDBKeyFromScriptValueAndKeyPathInternal(isolate, scriptValue, keyPath, allowExperimentalTypes);
+ IDBKey* expectedKey = createIDBKeyFromScriptValueAndKeyPathInternal(isolate, scriptValue.v8Value(), keyPath, allowExperimentalTypes);
ASSERT(!expectedKey || expectedKey->isEqual(key));
bool injected = injectV8KeyIntoV8Value(isolate, keyValue.v8Value(), scriptValue.v8Value(), keyPath);

Powered by Google App Engine
This is Rietveld 408576698