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

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

Issue 1007703003: [bindings] Utilize ScriptValue::from and remove IDB* => ScriptValue conversion methods (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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 9020f9e2e067665024d0ac6a5efe12794bfa3e31..8ed2e087afe6efc8d54a7e8efd68bd3327f31aff 100644
--- a/Source/bindings/modules/v8/V8BindingForModules.cpp
+++ b/Source/bindings/modules/v8/V8BindingForModules.cpp
@@ -33,6 +33,7 @@
#include "bindings/core/v8/V8DOMStringList.h"
#include "bindings/core/v8/V8HiddenValue.h"
#include "bindings/core/v8/V8Uint8Array.h"
+#include "bindings/modules/v8/ToV8ForModules.h"
#include "bindings/modules/v8/V8IDBCursor.h"
#include "bindings/modules/v8/V8IDBCursorWithValue.h"
#include "bindings/modules/v8/V8IDBDatabase.h"
@@ -53,7 +54,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 +71,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 +105,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,30 +399,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);
haraken 2015/03/13 12:48:10 The previous code was creating a HandleScope befor
- 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)
haraken 2015/03/13 12:48:10 Can we now remove this?
{
ASSERT(isolate->InContext());
@@ -446,12 +423,34 @@ ScriptValue deserializeScriptValue(ScriptState* scriptState, SerializedScriptVal
return ScriptValue(scriptState, v8::Null(isolate));
}
+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)
+{
+ return V8IDBKeyRange::toImplWithTypeCheck(isolate, value);
+}
+
#if ENABLE(ASSERT)
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 keyValue = ScriptValue::from(scriptState, key);
ScriptValue scriptValue(scriptState, deserializeIDBValueBuffer(isolate, buffer.get(), blobInfo));
// This assertion is about already persisted data, so allow experimental types.
« no previous file with comments | « Source/bindings/modules/v8/V8BindingForModules.h ('k') | Source/bindings/modules/v8/V8BindingForModulesTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698