Index: Source/bindings/modules/v8/V8BindingForModules.cpp |
diff --git a/Source/bindings/modules/v8/IDBBindingUtilities.cpp b/Source/bindings/modules/v8/V8BindingForModules.cpp |
similarity index 90% |
rename from Source/bindings/modules/v8/IDBBindingUtilities.cpp |
rename to Source/bindings/modules/v8/V8BindingForModules.cpp |
index 6bfa0b7269a3149a2befa32957b644965ad5f5b9..4ffdead8524c3faff8ba9ee1f2b0f1d9a1b89905 100644 |
--- a/Source/bindings/modules/v8/IDBBindingUtilities.cpp |
+++ b/Source/bindings/modules/v8/V8BindingForModules.cpp |
@@ -24,7 +24,7 @@ |
*/ |
#include "config.h" |
-#include "bindings/modules/v8/IDBBindingUtilities.h" |
+#include "bindings/modules/v8/V8BindingForModules.h" |
#include "bindings/core/v8/SerializedScriptValue.h" |
#include "bindings/core/v8/SerializedScriptValueFactory.h" |
@@ -53,7 +53,7 @@ namespace blink { |
static v8::Local<v8::Value> deserializeIDBValueBuffer(v8::Isolate*, SharedBuffer*, const Vector<blink::WebBlobInfo>*); |
-static v8::Local<v8::Value> toV8(const IDBKeyPath& value, v8::Local<v8::Object> creationContext, v8::Isolate* isolate) |
+v8::Local<v8::Value> toV8(const IDBKeyPath& value, v8::Local<v8::Object> creationContext, v8::Isolate* isolate) |
{ |
switch (value.type()) { |
case IDBKeyPath::NullType: |
@@ -70,7 +70,7 @@ static v8::Local<v8::Value> toV8(const IDBKeyPath& value, v8::Local<v8::Object> |
return v8::Undefined(isolate); |
} |
-static v8::Local<v8::Value> toV8(const IDBKey* key, v8::Local<v8::Object> creationContext, v8::Isolate* isolate) |
+v8::Local<v8::Value> toV8(const IDBKey* key, v8::Local<v8::Object> creationContext, v8::Isolate* isolate) |
{ |
if (!key) { |
// This should be undefined, not null. |
@@ -104,7 +104,7 @@ static v8::Local<v8::Value> toV8(const IDBKey* key, v8::Local<v8::Object> creati |
return v8Undefined(); |
} |
-static v8::Local<v8::Value> toV8(const IDBAny* impl, v8::Local<v8::Object> creationContext, v8::Isolate* isolate) |
+v8::Local<v8::Value> toV8(const IDBAny* impl, v8::Local<v8::Object> creationContext, v8::Isolate* isolate) |
{ |
if (!impl) |
return v8::Null(isolate); |
@@ -398,45 +398,6 @@ bool canInjectIDBKeyIntoScriptValue(v8::Isolate* isolate, const ScriptValue& scr |
return canInjectNthValueOnKeyPath(isolate, v8Value, keyPathElements, keyPathElements.size() - 1); |
} |
-ScriptValue idbAnyToScriptValue(ScriptState* scriptState, IDBAny* any) |
-{ |
- v8::Isolate* isolate = scriptState->isolate(); |
- v8::HandleScope handleScope(isolate); |
- v8::Local<v8::Value> v8Value(toV8(any, scriptState->context()->Global(), isolate)); |
- return ScriptValue(scriptState, v8Value); |
-} |
- |
-ScriptValue idbKeyToScriptValue(ScriptState* scriptState, const IDBKey* key) |
-{ |
- v8::Isolate* isolate = scriptState->isolate(); |
- v8::HandleScope handleScope(isolate); |
- v8::Local<v8::Value> v8Value(toV8(key, scriptState->context()->Global(), isolate)); |
- return ScriptValue(scriptState, v8Value); |
-} |
- |
-ScriptValue idbKeyPathToScriptValue(ScriptState* scriptState, const IDBKeyPath& keyPath) |
-{ |
- v8::Isolate* isolate = scriptState->isolate(); |
- v8::HandleScope handleScope(isolate); |
- v8::Local<v8::Value> v8Value(toV8(keyPath, scriptState->context()->Global(), isolate)); |
- return ScriptValue(scriptState, v8Value); |
-} |
- |
-IDBKey* scriptValueToIDBKey(v8::Isolate* isolate, const ScriptValue& scriptValue) |
-{ |
- ASSERT(isolate->InContext()); |
- v8::HandleScope handleScope(isolate); |
- v8::Local<v8::Value> v8Value(scriptValue.v8Value()); |
- return createIDBKeyFromValue(isolate, v8Value); |
-} |
- |
-IDBKeyRange* scriptValueToIDBKeyRange(v8::Isolate* isolate, const ScriptValue& scriptValue) |
-{ |
- v8::HandleScope handleScope(isolate); |
- v8::Local<v8::Value> value(scriptValue.v8Value()); |
- return V8IDBKeyRange::toImplWithTypeCheck(isolate, value); |
-} |
- |
ScriptValue deserializeScriptValue(ScriptState* scriptState, SerializedScriptValue* serializedValue, const Vector<blink::WebBlobInfo>* blobInfo) |
{ |
v8::Isolate* isolate = scriptState->isolate(); |
@@ -451,7 +412,7 @@ void assertPrimaryKeyValidOrInjectable(ScriptState* scriptState, PassRefPtr<Shar |
{ |
ScriptState::Scope scope(scriptState); |
v8::Isolate* isolate = scriptState->isolate(); |
- ScriptValue keyValue = idbKeyToScriptValue(scriptState, key); |
+ ScriptValue keyValue = ScriptValue::from(scriptState, key); |
ScriptValue scriptValue(scriptState, deserializeIDBValueBuffer(isolate, buffer.get(), blobInfo)); |
// This assertion is about already persisted data, so allow experimental types. |
@@ -464,4 +425,26 @@ void assertPrimaryKeyValidOrInjectable(ScriptState* scriptState, PassRefPtr<Shar |
} |
#endif |
+SQLValue NativeValueTraits<SQLValue>::nativeValue(const v8::Local<v8::Value>& value, v8::Isolate* isolate, ExceptionState& exceptionState) |
+{ |
+ if (value.IsEmpty() || value->IsNull()) |
+ return SQLValue(); |
+ if (value->IsNumber()) |
+ return SQLValue(value->NumberValue()); |
+ V8StringResource<> stringValue(value); |
+ if (!stringValue.prepare(exceptionState)) |
+ return SQLValue(); |
+ return SQLValue(stringValue); |
+} |
+ |
+IDBKey* NativeValueTraits<IDBKey*>::nativeValue(const v8::Local<v8::Value>& value, v8::Isolate* isolate, ExceptionState& exceptionState) |
+{ |
+ return createIDBKeyFromValue(isolate, value); |
+} |
+ |
+IDBKeyRange* NativeValueTraits<IDBKeyRange*>::nativeValue(const v8::Local<v8::Value>& value, v8::Isolate* isolate, ExceptionState& exceptionState) |
jsbell
2015/03/12 17:00:57
It seems like we could do something generic for Sc
|
+{ |
+ return V8IDBKeyRange::toImplWithTypeCheck(isolate, value); |
+} |
+ |
} // namespace blink |