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

Unified Diff: Source/bindings/v8/V8Binding.h

Issue 344833002: Oilpan: move MessagePortArray to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased Created 6 years, 6 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
« no previous file with comments | « Source/bindings/v8/SerializedScriptValue.cpp ('k') | Source/bindings/v8/custom/V8MessageEventCustom.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/V8Binding.h
diff --git a/Source/bindings/v8/V8Binding.h b/Source/bindings/v8/V8Binding.h
index 7fb8e727b57735c21b023e2b8513640cb8d9b618..eb1f11837b903f0d55d9d19094818fc5b436773d 100644
--- a/Source/bindings/v8/V8Binding.h
+++ b/Source/bindings/v8/V8Binding.h
@@ -690,6 +690,39 @@ WillBeHeapVector<RefPtrWillBeMember<T> > toRefPtrWillBeMemberNativeArray(v8::Han
return result;
}
+template <class T, class V8T>
+WillBeHeapVector<RefPtrWillBeMember<T> > toRefPtrWillBeMemberNativeArray(v8::Handle<v8::Value> value, const String& propertyName, v8::Isolate* isolate, bool* success = 0)
+{
+ if (success)
+ *success = true;
+
+ v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value));
+ uint32_t length = 0;
+ if (value->IsArray()) {
+ length = v8::Local<v8::Array>::Cast(v8Value)->Length();
+ } else if (toV8Sequence(value, length, isolate).IsEmpty()) {
+ throwTypeError(ExceptionMessages::notASequenceTypeProperty(propertyName), isolate);
+ return WillBeHeapVector<RefPtrWillBeMember<T> >();
+ }
+
+ WillBeHeapVector<RefPtrWillBeMember<T> > result;
+ result.reserveInitialCapacity(length);
+ v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value);
+ for (uint32_t i = 0; i < length; ++i) {
+ v8::Handle<v8::Value> element = object->Get(i);
+ if (V8T::hasInstance(element, isolate)) {
+ v8::Handle<v8::Object> elementObject = v8::Handle<v8::Object>::Cast(element);
+ result.uncheckedAppend(V8T::toNative(elementObject));
+ } else {
+ if (success)
+ *success = false;
+ throwTypeError("Invalid Array element type", isolate);
+ return WillBeHeapVector<RefPtrWillBeMember<T> >();
+ }
+ }
+ return result;
+}
+
// Converts a JavaScript value to an array as per the Web IDL specification:
// http://www.w3.org/TR/2012/CR-WebIDL-20120419/#es-array
template <class T>
« no previous file with comments | « Source/bindings/v8/SerializedScriptValue.cpp ('k') | Source/bindings/v8/custom/V8MessageEventCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698