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 deserializeScriptValue(ScriptState*, SerializedScriptValue*, const V
ector<blink::WebBlobInfo>*); |
| 28 |
| 29 #if ENABLE(ASSERT) |
| 30 void assertPrimaryKeyValidOrInjectable(ScriptState*, PassRefPtr<SharedBuffer>, c
onst Vector<blink::WebBlobInfo>*, IDBKey*, const IDBKeyPath&); |
| 31 #endif |
| 32 |
13 template <> | 33 template <> |
14 struct NativeValueTraits<SQLValue> { | 34 struct NativeValueTraits<SQLValue> { |
15 static SQLValue nativeValue(const v8::Local<v8::Value>& value, v8::Isolate*
isolate, ExceptionState& exceptionState) | 35 static SQLValue nativeValue(const v8::Local<v8::Value>&, v8::Isolate*, Excep
tionState&); |
16 { | 36 }; |
17 if (value.IsEmpty() || value->IsNull()) | 37 |
18 return SQLValue(); | 38 template <> |
19 if (value->IsNumber()) | 39 struct NativeValueTraits<IDBKey*> { |
20 return SQLValue(value->NumberValue()); | 40 static IDBKey* nativeValue(const v8::Local<v8::Value>&, v8::Isolate*, Except
ionState&); |
21 V8StringResource<> stringValue(value); | 41 }; |
22 if (!stringValue.prepare(exceptionState)) | 42 |
23 return SQLValue(); | 43 template <> |
24 return SQLValue(stringValue); | 44 struct NativeValueTraits<IDBKeyRange*> { |
25 } | 45 static IDBKeyRange* nativeValue(const v8::Local<v8::Value>&, v8::Isolate*, E
xceptionState&); |
26 }; | 46 }; |
27 | 47 |
28 } // namespace blink | 48 } // namespace blink |
29 | 49 |
30 #endif // V8BindingForModules_h | 50 #endif // V8BindingForModules_h |
OLD | NEW |