| 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; |
| 14 class IDBKey; |
| 15 class IDBKeyPath; |
| 16 class IDBKeyRange; |
| 17 class SerializedScriptValue; |
| 18 class SharedBuffer; |
| 19 class WebBlobInfo; |
| 20 |
| 21 // Exposed for unit testing: |
| 22 bool injectV8KeyIntoV8Value(v8::Isolate*, v8::Local<v8::Value> key, v8::Local<v8
::Value>, const IDBKeyPath&); |
| 23 |
| 24 // For use by Source/modules/indexeddb: |
| 25 IDBKey* createIDBKeyFromScriptValueAndKeyPath(v8::Isolate*, const ScriptValue&,
const IDBKeyPath&); |
| 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&); |
| 31 IDBKeyRange* scriptValueToIDBKeyRange(v8::Isolate*, const ScriptValue&); |
| 32 ScriptValue deserializeScriptValue(ScriptState*, SerializedScriptValue*, const V
ector<blink::WebBlobInfo>*); |
| 33 |
| 34 #if ENABLE(ASSERT) |
| 35 void assertPrimaryKeyValidOrInjectable(ScriptState*, PassRefPtr<SharedBuffer>, c
onst Vector<blink::WebBlobInfo>*, IDBKey*, const IDBKeyPath&); |
| 36 #endif |
| 37 |
| 13 template <> | 38 template <> |
| 14 struct NativeValueTraits<SQLValue> { | 39 struct NativeValueTraits<SQLValue> { |
| 15 static SQLValue nativeValue(const v8::Local<v8::Value>& value, v8::Isolate*
isolate, ExceptionState& exceptionState) | 40 static SQLValue nativeValue(const v8::Local<v8::Value>& value, v8::Isolate*
isolate, ExceptionState& exceptionState) |
| 16 { | 41 { |
| 17 if (value.IsEmpty() || value->IsNull()) | 42 if (value.IsEmpty() || value->IsNull()) |
| 18 return SQLValue(); | 43 return SQLValue(); |
| 19 if (value->IsNumber()) | 44 if (value->IsNumber()) |
| 20 return SQLValue(value->NumberValue()); | 45 return SQLValue(value->NumberValue()); |
| 21 V8StringResource<> stringValue(value); | 46 V8StringResource<> stringValue(value); |
| 22 if (!stringValue.prepare(exceptionState)) | 47 if (!stringValue.prepare(exceptionState)) |
| 23 return SQLValue(); | 48 return SQLValue(); |
| 24 return SQLValue(stringValue); | 49 return SQLValue(stringValue); |
| 25 } | 50 } |
| 26 }; | 51 }; |
| 27 | 52 |
| 28 } // namespace blink | 53 } // namespace blink |
| 29 | 54 |
| 30 #endif // V8BindingForModules_h | 55 #endif // V8BindingForModules_h |
| OLD | NEW |