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

Side by Side Diff: Source/bindings/tests/results/V8TestObject.cpp

Issue 85263006: Make IDL Callbacks non-refcounted by default (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Patch for landing Created 7 years 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 3577 matching lines...) Expand 10 before | Expand all | Expand 10 after
3588 { 3588 {
3589 if (UNLIKELY(info.Length() < 1)) { 3589 if (UNLIKELY(info.Length() < 1)) {
3590 throwTypeError(ExceptionMessages::failedToExecute("methodWithCallbackArg ", "TestObject", ExceptionMessages::notEnoughArguments(1, info.Length())), info. GetIsolate()); 3590 throwTypeError(ExceptionMessages::failedToExecute("methodWithCallbackArg ", "TestObject", ExceptionMessages::notEnoughArguments(1, info.Length())), info. GetIsolate());
3591 return; 3591 return;
3592 } 3592 }
3593 TestObj* imp = V8TestObject::toNative(info.Holder()); 3593 TestObj* imp = V8TestObject::toNative(info.Holder());
3594 if (info.Length() <= 0 || !info[0]->IsFunction()) { 3594 if (info.Length() <= 0 || !info[0]->IsFunction()) {
3595 throwTypeError(ExceptionMessages::failedToExecute("methodWithCallbackArg ", "TestObject", "The callback provided as parameter 1 is not a function."), inf o.GetIsolate()); 3595 throwTypeError(ExceptionMessages::failedToExecute("methodWithCallbackArg ", "TestObject", "The callback provided as parameter 1 is not a function."), inf o.GetIsolate());
3596 return; 3596 return;
3597 } 3597 }
3598 RefPtr<TestCallback> callback = V8TestCallback::create(info[0], getExecution Context()); 3598 OwnPtr<TestCallback> callback = V8TestCallback::create(info[0], getExecution Context());
3599 imp->methodWithCallbackArg(callback.release()); 3599 imp->methodWithCallbackArg(callback.release());
3600 } 3600 }
3601 3601
3602 static void methodWithCallbackArgMethodCallback(const v8::FunctionCallbackInfo<v 8::Value>& info) 3602 static void methodWithCallbackArgMethodCallback(const v8::FunctionCallbackInfo<v 8::Value>& info)
3603 { 3603 {
3604 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 3604 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
3605 TestObjV8Internal::methodWithCallbackArgMethod(info); 3605 TestObjV8Internal::methodWithCallbackArgMethod(info);
3606 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 3606 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
3607 } 3607 }
3608 3608
3609 static void methodWithNonCallbackArgAndCallbackArgMethod(const v8::FunctionCallb ackInfo<v8::Value>& info) 3609 static void methodWithNonCallbackArgAndCallbackArgMethod(const v8::FunctionCallb ackInfo<v8::Value>& info)
3610 { 3610 {
3611 if (UNLIKELY(info.Length() < 2)) { 3611 if (UNLIKELY(info.Length() < 2)) {
3612 throwTypeError(ExceptionMessages::failedToExecute("methodWithNonCallback ArgAndCallbackArg", "TestObject", ExceptionMessages::notEnoughArguments(2, info. Length())), info.GetIsolate()); 3612 throwTypeError(ExceptionMessages::failedToExecute("methodWithNonCallback ArgAndCallbackArg", "TestObject", ExceptionMessages::notEnoughArguments(2, info. Length())), info.GetIsolate());
3613 return; 3613 return;
3614 } 3614 }
3615 TestObj* imp = V8TestObject::toNative(info.Holder()); 3615 TestObj* imp = V8TestObject::toNative(info.Holder());
3616 V8TRYCATCH_VOID(int, nonCallback, toInt32(info[0])); 3616 V8TRYCATCH_VOID(int, nonCallback, toInt32(info[0]));
3617 if (info.Length() <= 1 || !info[1]->IsFunction()) { 3617 if (info.Length() <= 1 || !info[1]->IsFunction()) {
3618 throwTypeError(ExceptionMessages::failedToExecute("methodWithNonCallback ArgAndCallbackArg", "TestObject", "The callback provided as parameter 2 is not a function."), info.GetIsolate()); 3618 throwTypeError(ExceptionMessages::failedToExecute("methodWithNonCallback ArgAndCallbackArg", "TestObject", "The callback provided as parameter 2 is not a function."), info.GetIsolate());
3619 return; 3619 return;
3620 } 3620 }
3621 RefPtr<TestCallback> callback = V8TestCallback::create(info[1], getExecution Context()); 3621 OwnPtr<TestCallback> callback = V8TestCallback::create(info[1], getExecution Context());
3622 imp->methodWithNonCallbackArgAndCallbackArg(nonCallback, callback.release()) ; 3622 imp->methodWithNonCallbackArgAndCallbackArg(nonCallback, callback.release()) ;
3623 } 3623 }
3624 3624
3625 static void methodWithNonCallbackArgAndCallbackArgMethodCallback(const v8::Funct ionCallbackInfo<v8::Value>& info) 3625 static void methodWithNonCallbackArgAndCallbackArgMethodCallback(const v8::Funct ionCallbackInfo<v8::Value>& info)
3626 { 3626 {
3627 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 3627 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
3628 TestObjV8Internal::methodWithNonCallbackArgAndCallbackArgMethod(info); 3628 TestObjV8Internal::methodWithNonCallbackArgAndCallbackArgMethod(info);
3629 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 3629 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
3630 } 3630 }
3631 3631
3632 static void methodWithCallbackAndOptionalArgMethod(const v8::FunctionCallbackInf o<v8::Value>& info) 3632 static void methodWithCallbackAndOptionalArgMethod(const v8::FunctionCallbackInf o<v8::Value>& info)
3633 { 3633 {
3634 TestObj* imp = V8TestObject::toNative(info.Holder()); 3634 TestObj* imp = V8TestObject::toNative(info.Holder());
3635 RefPtr<TestCallback> callback; 3635 OwnPtr<TestCallback> callback;
3636 if (info.Length() > 0 && !info[0]->IsNull() && !info[0]->IsUndefined()) { 3636 if (info.Length() > 0 && !info[0]->IsNull() && !info[0]->IsUndefined()) {
3637 if (!info[0]->IsFunction()) { 3637 if (!info[0]->IsFunction()) {
3638 throwTypeError(ExceptionMessages::failedToExecute("methodWithCallbac kAndOptionalArg", "TestObject", "The callback provided as parameter 1 is not a f unction."), info.GetIsolate()); 3638 throwTypeError(ExceptionMessages::failedToExecute("methodWithCallbac kAndOptionalArg", "TestObject", "The callback provided as parameter 1 is not a f unction."), info.GetIsolate());
3639 return; 3639 return;
3640 } 3640 }
3641 callback = V8TestCallback::create(info[0], getExecutionContext()); 3641 callback = V8TestCallback::create(info[0], getExecutionContext());
3642 } 3642 }
3643 imp->methodWithCallbackAndOptionalArg(callback.release()); 3643 imp->methodWithCallbackAndOptionalArg(callback.release());
3644 } 3644 }
3645 3645
3646 static void methodWithCallbackAndOptionalArgMethodCallback(const v8::FunctionCal lbackInfo<v8::Value>& info) 3646 static void methodWithCallbackAndOptionalArgMethodCallback(const v8::FunctionCal lbackInfo<v8::Value>& info)
3647 { 3647 {
3648 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 3648 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
3649 TestObjV8Internal::methodWithCallbackAndOptionalArgMethod(info); 3649 TestObjV8Internal::methodWithCallbackAndOptionalArgMethod(info);
3650 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 3650 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
3651 } 3651 }
3652 3652
3653 static void methodWithNullableCallbackArgMethod(const v8::FunctionCallbackInfo<v 8::Value>& info) 3653 static void methodWithNullableCallbackArgMethod(const v8::FunctionCallbackInfo<v 8::Value>& info)
3654 { 3654 {
3655 if (UNLIKELY(info.Length() < 1)) { 3655 if (UNLIKELY(info.Length() < 1)) {
3656 throwTypeError(ExceptionMessages::failedToExecute("methodWithNullableCal lbackArg", "TestObject", ExceptionMessages::notEnoughArguments(1, info.Length()) ), info.GetIsolate()); 3656 throwTypeError(ExceptionMessages::failedToExecute("methodWithNullableCal lbackArg", "TestObject", ExceptionMessages::notEnoughArguments(1, info.Length()) ), info.GetIsolate());
3657 return; 3657 return;
3658 } 3658 }
3659 TestObj* imp = V8TestObject::toNative(info.Holder()); 3659 TestObj* imp = V8TestObject::toNative(info.Holder());
3660 if (info.Length() <= 0 || !(info[0]->IsFunction() || info[0]->IsNull())) { 3660 if (info.Length() <= 0 || !(info[0]->IsFunction() || info[0]->IsNull())) {
3661 throwTypeError(ExceptionMessages::failedToExecute("methodWithNullableCal lbackArg", "TestObject", "The callback provided as parameter 1 is not a function ."), info.GetIsolate()); 3661 throwTypeError(ExceptionMessages::failedToExecute("methodWithNullableCal lbackArg", "TestObject", "The callback provided as parameter 1 is not a function ."), info.GetIsolate());
3662 return; 3662 return;
3663 } 3663 }
3664 RefPtr<TestCallback> callback = info[0]->IsNull() ? 0 : V8TestCallback::crea te(info[0], getExecutionContext()); 3664 OwnPtr<TestCallback> callback = info[0]->IsNull() ? nullptr : V8TestCallback ::create(info[0], getExecutionContext());
3665 imp->methodWithNullableCallbackArg(callback.release()); 3665 imp->methodWithNullableCallbackArg(callback.release());
3666 } 3666 }
3667 3667
3668 static void methodWithNullableCallbackArgMethodCallback(const v8::FunctionCallba ckInfo<v8::Value>& info) 3668 static void methodWithNullableCallbackArgMethodCallback(const v8::FunctionCallba ckInfo<v8::Value>& info)
3669 { 3669 {
3670 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 3670 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
3671 TestObjV8Internal::methodWithNullableCallbackArgMethod(info); 3671 TestObjV8Internal::methodWithNullableCallbackArgMethod(info);
3672 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 3672 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
3673 } 3673 }
3674 3674
3675 static void staticMethodWithCallbackAndOptionalArgMethod(const v8::FunctionCallb ackInfo<v8::Value>& info) 3675 static void staticMethodWithCallbackAndOptionalArgMethod(const v8::FunctionCallb ackInfo<v8::Value>& info)
3676 { 3676 {
3677 RefPtr<TestCallback> callback; 3677 OwnPtr<TestCallback> callback;
3678 if (info.Length() > 0 && !info[0]->IsNull() && !info[0]->IsUndefined()) { 3678 if (info.Length() > 0 && !info[0]->IsNull() && !info[0]->IsUndefined()) {
3679 if (!info[0]->IsFunction()) { 3679 if (!info[0]->IsFunction()) {
3680 throwTypeError(ExceptionMessages::failedToExecute("staticMethodWithC allbackAndOptionalArg", "TestObject", "The callback provided as parameter 1 is n ot a function."), info.GetIsolate()); 3680 throwTypeError(ExceptionMessages::failedToExecute("staticMethodWithC allbackAndOptionalArg", "TestObject", "The callback provided as parameter 1 is n ot a function."), info.GetIsolate());
3681 return; 3681 return;
3682 } 3682 }
3683 callback = V8TestCallback::create(info[0], getExecutionContext()); 3683 callback = V8TestCallback::create(info[0], getExecutionContext());
3684 } 3684 }
3685 TestObj::staticMethodWithCallbackAndOptionalArg(callback.release()); 3685 TestObj::staticMethodWithCallbackAndOptionalArg(callback.release());
3686 } 3686 }
3687 3687
3688 static void staticMethodWithCallbackAndOptionalArgMethodCallback(const v8::Funct ionCallbackInfo<v8::Value>& info) 3688 static void staticMethodWithCallbackAndOptionalArgMethodCallback(const v8::Funct ionCallbackInfo<v8::Value>& info)
3689 { 3689 {
3690 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 3690 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
3691 TestObjV8Internal::staticMethodWithCallbackAndOptionalArgMethod(info); 3691 TestObjV8Internal::staticMethodWithCallbackAndOptionalArgMethod(info);
3692 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 3692 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
3693 } 3693 }
3694 3694
3695 static void staticMethodWithCallbackArgMethod(const v8::FunctionCallbackInfo<v8: :Value>& info) 3695 static void staticMethodWithCallbackArgMethod(const v8::FunctionCallbackInfo<v8: :Value>& info)
3696 { 3696 {
3697 if (UNLIKELY(info.Length() < 1)) { 3697 if (UNLIKELY(info.Length() < 1)) {
3698 throwTypeError(ExceptionMessages::failedToExecute("staticMethodWithCallb ackArg", "TestObject", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsolate()); 3698 throwTypeError(ExceptionMessages::failedToExecute("staticMethodWithCallb ackArg", "TestObject", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsolate());
3699 return; 3699 return;
3700 } 3700 }
3701 if (info.Length() <= 0 || !info[0]->IsFunction()) { 3701 if (info.Length() <= 0 || !info[0]->IsFunction()) {
3702 throwTypeError(ExceptionMessages::failedToExecute("staticMethodWithCallb ackArg", "TestObject", "The callback provided as parameter 1 is not a function." ), info.GetIsolate()); 3702 throwTypeError(ExceptionMessages::failedToExecute("staticMethodWithCallb ackArg", "TestObject", "The callback provided as parameter 1 is not a function." ), info.GetIsolate());
3703 return; 3703 return;
3704 } 3704 }
3705 RefPtr<TestCallback> callback = V8TestCallback::create(info[0], getExecution Context()); 3705 OwnPtr<TestCallback> callback = V8TestCallback::create(info[0], getExecution Context());
3706 TestObj::staticMethodWithCallbackArg(callback.release()); 3706 TestObj::staticMethodWithCallbackArg(callback.release());
3707 } 3707 }
3708 3708
3709 static void staticMethodWithCallbackArgMethodCallback(const v8::FunctionCallback Info<v8::Value>& info) 3709 static void staticMethodWithCallbackArgMethodCallback(const v8::FunctionCallback Info<v8::Value>& info)
3710 { 3710 {
3711 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 3711 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
3712 TestObjV8Internal::staticMethodWithCallbackArgMethod(info); 3712 TestObjV8Internal::staticMethodWithCallbackArgMethod(info);
3713 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 3713 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
3714 } 3714 }
3715 3715
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
3954 { 3954 {
3955 if (UNLIKELY(info.Length() < 1)) { 3955 if (UNLIKELY(info.Length() < 1)) {
3956 throwTypeError(ExceptionMessages::failedToExecute("overloadedMethod", "T estObject", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIs olate()); 3956 throwTypeError(ExceptionMessages::failedToExecute("overloadedMethod", "T estObject", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIs olate());
3957 return; 3957 return;
3958 } 3958 }
3959 TestObj* imp = V8TestObject::toNative(info.Holder()); 3959 TestObj* imp = V8TestObject::toNative(info.Holder());
3960 if (info.Length() <= 0 || !info[0]->IsFunction()) { 3960 if (info.Length() <= 0 || !info[0]->IsFunction()) {
3961 throwTypeError(ExceptionMessages::failedToExecute("overloadedMethod", "T estObject", "The callback provided as parameter 1 is not a function."), info.Get Isolate()); 3961 throwTypeError(ExceptionMessages::failedToExecute("overloadedMethod", "T estObject", "The callback provided as parameter 1 is not a function."), info.Get Isolate());
3962 return; 3962 return;
3963 } 3963 }
3964 RefPtr<TestCallback> callbackArg = V8TestCallback::create(info[0], getExecut ionContext()); 3964 OwnPtr<TestCallback> callbackArg = V8TestCallback::create(info[0], getExecut ionContext());
3965 imp->overloadedMethod(callbackArg.release()); 3965 imp->overloadedMethod(callbackArg.release());
3966 } 3966 }
3967 3967
3968 static void overloadedMethod3Method(const v8::FunctionCallbackInfo<v8::Value>& i nfo) 3968 static void overloadedMethod3Method(const v8::FunctionCallbackInfo<v8::Value>& i nfo)
3969 { 3969 {
3970 if (UNLIKELY(info.Length() < 1)) { 3970 if (UNLIKELY(info.Length() < 1)) {
3971 throwTypeError(ExceptionMessages::failedToExecute("overloadedMethod", "T estObject", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIs olate()); 3971 throwTypeError(ExceptionMessages::failedToExecute("overloadedMethod", "T estObject", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIs olate());
3972 return; 3972 return;
3973 } 3973 }
3974 TestObj* imp = V8TestObject::toNative(info.Holder()); 3974 TestObj* imp = V8TestObject::toNative(info.Holder());
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
4923 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) 4923 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
4924 { 4924 {
4925 if (UNLIKELY(info.Length() < 1)) { 4925 if (UNLIKELY(info.Length() < 1)) {
4926 throwTypeError(ExceptionMessages::failedToExecute("Constructor", "TestOb ject", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsolate ()); 4926 throwTypeError(ExceptionMessages::failedToExecute("Constructor", "TestOb ject", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsolate ());
4927 return; 4927 return;
4928 } 4928 }
4929 if (info.Length() <= 0 || !info[0]->IsFunction()) { 4929 if (info.Length() <= 0 || !info[0]->IsFunction()) {
4930 throwTypeError(ExceptionMessages::failedToExecute("Constructor", "TestOb ject", "The callback provided as parameter 1 is not a function."), info.GetIsola te()); 4930 throwTypeError(ExceptionMessages::failedToExecute("Constructor", "TestOb ject", "The callback provided as parameter 1 is not a function."), info.GetIsola te());
4931 return; 4931 return;
4932 } 4932 }
4933 RefPtr<TestCallback> testCallback = V8TestCallback::create(info[0], getExecu tionContext()); 4933 OwnPtr<TestCallback> testCallback = V8TestCallback::create(info[0], getExecu tionContext());
4934 4934
4935 RefPtr<TestObj> impl = TestObj::create(testCallback); 4935 RefPtr<TestObj> impl = TestObj::create(testCallback);
4936 v8::Handle<v8::Object> wrapper = info.Holder(); 4936 v8::Handle<v8::Object> wrapper = info.Holder();
4937 4937
4938 V8DOMWrapper::associateObjectWithWrapper<V8TestObject>(impl.release(), &V8Te stObject::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dep endent); 4938 V8DOMWrapper::associateObjectWithWrapper<V8TestObject>(impl.release(), &V8Te stObject::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dep endent);
4939 info.GetReturnValue().Set(wrapper); 4939 info.GetReturnValue().Set(wrapper);
4940 } 4940 }
4941 4941
4942 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info) 4942 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info)
4943 { 4943 {
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
5407 fromInternalPointer(object)->deref(); 5407 fromInternalPointer(object)->deref();
5408 } 5408 }
5409 5409
5410 template<> 5410 template<>
5411 v8::Handle<v8::Value> toV8NoInline(TestObj* impl, v8::Handle<v8::Object> creatio nContext, v8::Isolate* isolate) 5411 v8::Handle<v8::Value> toV8NoInline(TestObj* impl, v8::Handle<v8::Object> creatio nContext, v8::Isolate* isolate)
5412 { 5412 {
5413 return toV8(impl, creationContext, isolate); 5413 return toV8(impl, creationContext, isolate);
5414 } 5414 }
5415 5415
5416 } // namespace WebCore 5416 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/tests/results/V8TestCallback.h ('k') | Source/bindings/tests/results/V8TestTypedefs.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698