| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8BindingForModules_h | 5 #ifndef V8BindingForModules_h |
| 6 #define V8BindingForModules_h | 6 #define V8BindingForModules_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/V8Binding.h" | 8 #include "bindings/core/v8/V8Binding.h" |
| 9 #include "modules/webdatabase/sqlite/SQLValue.h" | 9 #include "modules/webdatabase/sqlite/SQLValue.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 class IDBAny; | 13 class IDBAny; |
| 14 class IDBKey; | 14 class IDBKey; |
| 15 class IDBKeyPath; | 15 class IDBKeyPath; |
| 16 class IDBKeyRange; | 16 class IDBKeyRange; |
| 17 class SerializedScriptValue; | 17 class SerializedScriptValue; |
| 18 class SharedBuffer; | 18 class SharedBuffer; |
| 19 class WebBlobInfo; | 19 class WebBlobInfo; |
| 20 | 20 |
| 21 // Exposed for unit testing: | 21 // Exposed for unit testing: |
| 22 bool injectV8KeyIntoV8Value(v8::Isolate*, v8::Local<v8::Value> key, v8::Local<v8
::Value>, const IDBKeyPath&); | 22 bool injectV8KeyIntoV8Value(v8::Isolate*, v8::Local<v8::Value> key, v8::Local<v8
::Value>, const IDBKeyPath&); |
| 23 | 23 |
| 24 // For use by Source/modules/indexeddb: | 24 // For use by Source/modules/indexeddb: |
| 25 IDBKey* createIDBKeyFromScriptValueAndKeyPath(v8::Isolate*, const ScriptValue&,
const IDBKeyPath&); | 25 IDBKey* createIDBKeyFromScriptValueAndKeyPath(v8::Isolate*, const ScriptValue&,
const IDBKeyPath&); |
| 26 bool canInjectIDBKeyIntoScriptValue(v8::Isolate*, const ScriptValue&, const IDBK
eyPath&); | 26 bool canInjectIDBKeyIntoScriptValue(v8::Isolate*, const ScriptValue&, const IDBK
eyPath&); |
| 27 ScriptValue idbAnyToScriptValue(ScriptState*, IDBAny*); | |
| 28 ScriptValue idbKeyToScriptValue(ScriptState*, const IDBKey*); | |
| 29 ScriptValue idbKeyPathToScriptValue(ScriptState*, const IDBKeyPath&); | |
| 30 IDBKey* scriptValueToIDBKey(v8::Isolate*, const ScriptValue&); | 27 IDBKey* scriptValueToIDBKey(v8::Isolate*, const ScriptValue&); |
| 31 IDBKeyRange* scriptValueToIDBKeyRange(v8::Isolate*, const ScriptValue&); | 28 IDBKeyRange* scriptValueToIDBKeyRange(v8::Isolate*, const ScriptValue&); |
| 32 ScriptValue deserializeScriptValue(ScriptState*, SerializedScriptValue*, const V
ector<blink::WebBlobInfo>*); | 29 ScriptValue deserializeScriptValue(ScriptState*, SerializedScriptValue*, const V
ector<blink::WebBlobInfo>*); |
| 33 | 30 |
| 34 #if ENABLE(ASSERT) | 31 #if ENABLE(ASSERT) |
| 35 void assertPrimaryKeyValidOrInjectable(ScriptState*, PassRefPtr<SharedBuffer>, c
onst Vector<blink::WebBlobInfo>*, IDBKey*, const IDBKeyPath&); | 32 void assertPrimaryKeyValidOrInjectable(ScriptState*, PassRefPtr<SharedBuffer>, c
onst Vector<blink::WebBlobInfo>*, IDBKey*, const IDBKeyPath&); |
| 36 #endif | 33 #endif |
| 37 | 34 |
| 38 template <> | 35 template <> |
| 39 struct NativeValueTraits<SQLValue> { | 36 struct NativeValueTraits<SQLValue> { |
| 40 static SQLValue nativeValue(const v8::Local<v8::Value>& value, v8::Isolate*
isolate, ExceptionState& exceptionState) | 37 static SQLValue nativeValue(const v8::Local<v8::Value>&, v8::Isolate*, Excep
tionState&); |
| 41 { | 38 }; |
| 42 if (value.IsEmpty() || value->IsNull()) | 39 |
| 43 return SQLValue(); | 40 template <> |
| 44 if (value->IsNumber()) | 41 struct NativeValueTraits<IDBKey*> { |
| 45 return SQLValue(value->NumberValue()); | 42 static IDBKey* nativeValue(const v8::Local<v8::Value>&, v8::Isolate*, Except
ionState&); |
| 46 V8StringResource<> stringValue(value); | 43 }; |
| 47 if (!stringValue.prepare(exceptionState)) | 44 |
| 48 return SQLValue(); | 45 template <> |
| 49 return SQLValue(stringValue); | 46 struct NativeValueTraits<IDBKeyRange*> { |
| 50 } | 47 static IDBKeyRange* nativeValue(const v8::Local<v8::Value>&, v8::Isolate*, E
xceptionState&); |
| 51 }; | 48 }; |
| 52 | 49 |
| 53 } // namespace blink | 50 } // namespace blink |
| 54 | 51 |
| 55 #endif // V8BindingForModules_h | 52 #endif // V8BindingForModules_h |
| OLD | NEW |