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

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

Issue 173363002: Move mediastream module to oilpan transition types (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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
Index: Source/bindings/v8/V8Binding.h
diff --git a/Source/bindings/v8/V8Binding.h b/Source/bindings/v8/V8Binding.h
index 166bc27d6eefbb37de8962599232342e7fbb9dc2..2556cba038378fc5a1da111b3f323f99e87c2b5b 100644
--- a/Source/bindings/v8/V8Binding.h
+++ b/Source/bindings/v8/V8Binding.h
@@ -495,6 +495,28 @@ namespace WebCore {
return result;
}
+ template <class T, class V8T>
+ HeapVector<Member<T> > toMemberNativeArrayUnchecked(v8::Local<v8::Value> v8Value, uint32_t length, v8::Isolate* isolate, bool* success = 0)
+ {
+ HeapVector<Member<T> > result;
haraken 2014/02/27 15:32:43 Ditto.
+ 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 HeapVector<Member<T> >();
+ }
+ }
+ return result;
+ }
+
v8::Handle<v8::Value> toV8Sequence(v8::Handle<v8::Value>, uint32_t& length, v8::Isolate*);
template <class T, class V8T>
@@ -516,6 +538,24 @@ namespace WebCore {
}
template <class T, class V8T>
+ HeapVector<Member<T> > toMemberNativeArray(v8::Handle<v8::Value> value, int argumentIndex, 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::notAnArrayTypeArgumentOrValue(argumentIndex), isolate);
+ return HeapVector<Member<T> >();
+ }
+
+ return toMemberNativeArrayUnchecked<T, V8T>(v8Value, length, isolate, success);
+ }
+
+ template <class T, class V8T>
Vector<RefPtr<T> > toRefPtrNativeArray(v8::Handle<v8::Value> value, const String& propertyName, v8::Isolate* isolate, bool* success = 0)
{
if (success)

Powered by Google App Engine
This is Rietveld 408576698