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

Side by Side Diff: Source/bindings/modules/v8/V8BindingForModules.cpp

Issue 1009503003: [bindings] Introduce ScriptValue.to<T> to convert to native values. (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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 IDBParseKeyPath(keyPath.string(), keyPathElements, error); 392 IDBParseKeyPath(keyPath.string(), keyPathElements, error);
393 ASSERT(error == IDBKeyPathParseErrorNone); 393 ASSERT(error == IDBKeyPathParseErrorNone);
394 394
395 if (!keyPathElements.size()) 395 if (!keyPathElements.size())
396 return false; 396 return false;
397 397
398 v8::Local<v8::Value> v8Value(scriptValue.v8Value()); 398 v8::Local<v8::Value> v8Value(scriptValue.v8Value());
399 return canInjectNthValueOnKeyPath(isolate, v8Value, keyPathElements, keyPath Elements.size() - 1); 399 return canInjectNthValueOnKeyPath(isolate, v8Value, keyPathElements, keyPath Elements.size() - 1);
400 } 400 }
401 401
402 IDBKey* scriptValueToIDBKey(v8::Isolate* isolate, const ScriptValue& scriptValue )
403 {
404 ASSERT(isolate->InContext());
405 v8::HandleScope handleScope(isolate);
406 v8::Local<v8::Value> v8Value(scriptValue.v8Value());
407 return createIDBKeyFromValue(isolate, v8Value);
408 }
409
410 IDBKeyRange* scriptValueToIDBKeyRange(v8::Isolate* isolate, const ScriptValue& s criptValue)
411 {
412 v8::HandleScope handleScope(isolate);
413 v8::Local<v8::Value> value(scriptValue.v8Value());
414 return V8IDBKeyRange::toImplWithTypeCheck(isolate, value);
415 }
416
417 ScriptValue deserializeScriptValue(ScriptState* scriptState, SerializedScriptVal ue* serializedValue, const Vector<blink::WebBlobInfo>* blobInfo) 402 ScriptValue deserializeScriptValue(ScriptState* scriptState, SerializedScriptVal ue* serializedValue, const Vector<blink::WebBlobInfo>* blobInfo)
418 { 403 {
419 v8::Isolate* isolate = scriptState->isolate(); 404 v8::Isolate* isolate = scriptState->isolate();
420 v8::HandleScope handleScope(isolate); 405 v8::HandleScope handleScope(isolate);
421 if (serializedValue) 406 if (serializedValue)
422 return ScriptValue(scriptState, serializedValue->deserialize(isolate, 0, blobInfo)); 407 return ScriptValue(scriptState, serializedValue->deserialize(isolate, 0, blobInfo));
423 return ScriptValue(scriptState, v8::Null(isolate)); 408 return ScriptValue(scriptState, v8::Null(isolate));
424 } 409 }
425 410
426 SQLValue NativeValueTraits<SQLValue>::nativeValue(const v8::Local<v8::Value>& va lue, v8::Isolate* isolate, ExceptionState& exceptionState) 411 SQLValue NativeValueTraits<SQLValue>::nativeValue(const v8::Local<v8::Value>& va lue, v8::Isolate* isolate, ExceptionState& exceptionState)
(...skipping 30 matching lines...) Expand all
457 const bool allowExperimentalTypes = true; 442 const bool allowExperimentalTypes = true;
458 IDBKey* expectedKey = createIDBKeyFromScriptValueAndKeyPathInternal(isolate, scriptValue, keyPath, allowExperimentalTypes); 443 IDBKey* expectedKey = createIDBKeyFromScriptValueAndKeyPathInternal(isolate, scriptValue, keyPath, allowExperimentalTypes);
459 ASSERT(!expectedKey || expectedKey->isEqual(key)); 444 ASSERT(!expectedKey || expectedKey->isEqual(key));
460 445
461 bool injected = injectV8KeyIntoV8Value(isolate, keyValue.v8Value(), scriptVa lue.v8Value(), keyPath); 446 bool injected = injectV8KeyIntoV8Value(isolate, keyValue.v8Value(), scriptVa lue.v8Value(), keyPath);
462 ASSERT_UNUSED(injected, injected); 447 ASSERT_UNUSED(injected, injected);
463 } 448 }
464 #endif 449 #endif
465 450
466 } // namespace blink 451 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698