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

Side by Side 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: toRefPtrWillBeMemberNativeArray Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Ericsson AB. All rights reserved. 3 * Copyright (C) 2012 Ericsson AB. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 if (value->IsArray()) { 539 if (value->IsArray()) {
540 length = v8::Local<v8::Array>::Cast(v8Value)->Length(); 540 length = v8::Local<v8::Array>::Cast(v8Value)->Length();
541 } else if (toV8Sequence(value, length, isolate).IsEmpty()) { 541 } else if (toV8Sequence(value, length, isolate).IsEmpty()) {
542 throwTypeError(ExceptionMessages::notASequenceTypeProperty(propertyName) , isolate); 542 throwTypeError(ExceptionMessages::notASequenceTypeProperty(propertyName) , isolate);
543 return Vector<RefPtr<T> >(); 543 return Vector<RefPtr<T> >();
544 } 544 }
545 return toRefPtrNativeArrayUnchecked<T, V8T>(v8Value, length, isolate, succes s); 545 return toRefPtrNativeArrayUnchecked<T, V8T>(v8Value, length, isolate, succes s);
546 } 546 }
547 547
548 template <class T, class V8T> 548 template <class T, class V8T>
549 HeapVector<Member<T> > toMemberNativeArray(v8::Handle<v8::Value> value, int argu mentIndex, v8::Isolate* isolate, bool* success = 0) 549 WillBeHeapVector<RefPtrWillBeMember<T> > toRefPtrWillBeMemberNativeArray(v8::Han dle<v8::Value> value, int argumentIndex, v8::Isolate* isolate, bool* success = 0 )
550 { 550 {
551 if (success) 551 if (success)
552 *success = true; 552 *success = true;
553 553
554 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); 554 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value));
555 uint32_t length = 0; 555 uint32_t length = 0;
556 if (value->IsArray()) { 556 if (value->IsArray()) {
557 length = v8::Local<v8::Array>::Cast(v8Value)->Length(); 557 length = v8::Local<v8::Array>::Cast(v8Value)->Length();
558 } else if (toV8Sequence(value, length, isolate).IsEmpty()) { 558 } else if (toV8Sequence(value, length, isolate).IsEmpty()) {
559 throwTypeError(ExceptionMessages::notAnArrayTypeArgumentOrValue(argument Index), isolate); 559 throwTypeError(ExceptionMessages::notAnArrayTypeArgumentOrValue(argument Index), isolate);
560 return HeapVector<Member<T> >(); 560 return WillBeHeapVector<RefPtrWillBeMember<T> >();
561 } 561 }
562 562
563 HeapVector<Member<T> > result; 563 WillBeHeapVector<RefPtrWillBeMember<T> > result;
564 result.reserveInitialCapacity(length); 564 result.reserveInitialCapacity(length);
565 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value); 565 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value);
566 for (uint32_t i = 0; i < length; ++i) { 566 for (uint32_t i = 0; i < length; ++i) {
567 v8::Handle<v8::Value> element = object->Get(i); 567 v8::Handle<v8::Value> element = object->Get(i);
568 if (V8T::hasInstance(element, isolate)) { 568 if (V8T::hasInstance(element, isolate)) {
569 v8::Handle<v8::Object> elementObject = v8::Handle<v8::Object>::Cast( element); 569 v8::Handle<v8::Object> elementObject = v8::Handle<v8::Object>::Cast( element);
570 result.uncheckedAppend(V8T::toNative(elementObject)); 570 result.uncheckedAppend(V8T::toNative(elementObject));
571 } else { 571 } else {
572 if (success) 572 if (success)
573 *success = false; 573 *success = false;
574 throwTypeError("Invalid Array element type", isolate); 574 throwTypeError("Invalid Array element type", isolate);
575 return HeapVector<Member<T> >(); 575 return WillBeHeapVector<RefPtrWillBeMember<T> >();
576 } 576 }
577 } 577 }
578 return result; 578 return result;
579 } 579 }
580 580
581 // Converts a JavaScript value to an array as per the Web IDL specification: 581 // Converts a JavaScript value to an array as per the Web IDL specification:
582 // http://www.w3.org/TR/2012/CR-WebIDL-20120419/#es-array 582 // http://www.w3.org/TR/2012/CR-WebIDL-20120419/#es-array
583 template <class T> 583 template <class T>
584 Vector<T> toNativeArray(v8::Handle<v8::Value> value, int argumentIndex, v8::Isol ate* isolate) 584 Vector<T> toNativeArray(v8::Handle<v8::Value> value, int argumentIndex, v8::Isol ate* isolate)
585 { 585 {
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 759
760 private: 760 private:
761 v8::HandleScope m_handleScope; 761 v8::HandleScope m_handleScope;
762 v8::Context::Scope m_contextScope; 762 v8::Context::Scope m_contextScope;
763 RefPtr<NewScriptState> m_scriptState; 763 RefPtr<NewScriptState> m_scriptState;
764 }; 764 };
765 765
766 } // namespace WebCore 766 } // namespace WebCore
767 767
768 #endif // V8Binding_h 768 #endif // V8Binding_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698