Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM RTCPeerConnectionStatic.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #ifndef mozilla_dom_RTCPeerConnectionStaticBinding_h
4 : #define mozilla_dom_RTCPeerConnectionStaticBinding_h
5 :
6 : #include "js/RootingAPI.h"
7 : #include "jspubtd.h"
8 : #include "mozilla/ErrorResult.h"
9 : #include "mozilla/dom/BindingDeclarations.h"
10 : #include "mozilla/dom/CallbackFunction.h"
11 : #include "mozilla/dom/CallbackInterface.h"
12 : #include "mozilla/dom/Nullable.h"
13 : #include "mozilla/dom/ToJSValue.h"
14 : #include "nsWeakReference.h"
15 :
16 : namespace mozilla {
17 : namespace dom {
18 :
19 : struct NativePropertyHooks;
20 : class PeerConnectionLifecycleCallback;
21 : class ProtoAndIfaceCache;
22 : class RTCPeerConnection;
23 : class RTCPeerConnectionStatic;
24 : struct RTCPeerConnectionStaticAtoms;
25 :
26 : } // namespace dom
27 : } // namespace mozilla
28 :
29 : namespace mozilla {
30 : namespace dom {
31 :
32 : enum class RTCLifecycleEvent : uint8_t {
33 : Initialized,
34 : Icegatheringstatechange,
35 : Iceconnectionstatechange,
36 : EndGuard_
37 : };
38 :
39 : namespace RTCLifecycleEventValues {
40 : extern const EnumEntry strings[4];
41 : } // namespace RTCLifecycleEventValues
42 :
43 : bool
44 : ToJSValue(JSContext* aCx, RTCLifecycleEvent aArgument, JS::MutableHandle<JS::Value> aValue);
45 :
46 :
47 0 : class PeerConnectionLifecycleCallback : public CallbackFunction
48 : {
49 : public:
50 : explicit inline PeerConnectionLifecycleCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, nsIGlobalObject* aIncumbentGlobal)
51 : : CallbackFunction(aCx, aCallback, aIncumbentGlobal)
52 : {
53 : MOZ_ASSERT(JS::IsCallable(mCallback));
54 : }
55 :
56 0 : explicit inline PeerConnectionLifecycleCallback(JS::Handle<JSObject*> aCallback, const FastCallbackConstructor& )
57 0 : : CallbackFunction(aCallback, FastCallbackConstructor())
58 : {
59 0 : MOZ_ASSERT(JS::IsCallable(mCallback));
60 0 : }
61 :
62 : explicit inline PeerConnectionLifecycleCallback(JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
63 : : CallbackFunction(aCallback, aAsyncStack, aIncumbentGlobal)
64 : {
65 : MOZ_ASSERT(JS::IsCallable(mCallback));
66 : }
67 :
68 : explicit inline PeerConnectionLifecycleCallback(CallbackFunction* aOther)
69 : : CallbackFunction(aOther)
70 : {
71 : }
72 :
73 : template <typename T>
74 : inline void
75 : Call(const T& thisVal, RTCPeerConnection& pc, uint64_t windowId, RTCLifecycleEvent eventType, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
76 : {
77 : MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
78 : if (!aExecutionReason) {
79 : aExecutionReason = "PeerConnectionLifecycleCallback";
80 : }
81 : CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
82 : if (!s.GetContext()) {
83 : MOZ_ASSERT(aRv.Failed());
84 : return;
85 : }
86 : JS::Rooted<JS::Value> thisValJS(s.GetContext());
87 : if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) {
88 : aRv.Throw(NS_ERROR_FAILURE);
89 : return;
90 : }
91 : return Call(s.GetContext(), thisValJS, pc, windowId, eventType, aRv);
92 : }
93 :
94 : inline void
95 : Call(RTCPeerConnection& pc, uint64_t windowId, RTCLifecycleEvent eventType, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
96 : {
97 : MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
98 : if (!aExecutionReason) {
99 : aExecutionReason = "PeerConnectionLifecycleCallback";
100 : }
101 : CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
102 : if (!s.GetContext()) {
103 : MOZ_ASSERT(aRv.Failed());
104 : return;
105 : }
106 : return Call(s.GetContext(), JS::UndefinedHandleValue, pc, windowId, eventType, aRv);
107 : }
108 :
109 : template <typename T>
110 : inline void
111 : Call(const T& thisVal, RTCPeerConnection& pc, uint64_t windowId, RTCLifecycleEvent eventType, const char* aExecutionReason = nullptr)
112 : {
113 : IgnoredErrorResult rv;
114 : return Call(thisVal, pc, windowId, eventType, rv, aExecutionReason);
115 : }
116 :
117 : inline void
118 : Call(RTCPeerConnection& pc, uint64_t windowId, RTCLifecycleEvent eventType, const char* aExecutionReason = nullptr)
119 : {
120 : IgnoredErrorResult rv;
121 : return Call(pc, windowId, eventType, rv, aExecutionReason, eReportExceptions, nullptr);
122 : }
123 :
124 : inline bool
125 : operator==(const PeerConnectionLifecycleCallback& aOther) const
126 : {
127 : return CallbackFunction::operator==(aOther);
128 : }
129 :
130 : private:
131 : void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, RTCPeerConnection& pc, uint64_t windowId, RTCLifecycleEvent eventType, ErrorResult& aRv);
132 : };
133 :
134 :
135 : namespace binding_detail {
136 0 : class FastPeerConnectionLifecycleCallback : public PeerConnectionLifecycleCallback
137 : {
138 : public:
139 0 : explicit inline FastPeerConnectionLifecycleCallback(JS::Handle<JSObject*> aCallback)
140 0 : : PeerConnectionLifecycleCallback(aCallback, FastCallbackConstructor())
141 : {
142 0 : }
143 :
144 : inline void
145 0 : Trace(JSTracer* aTracer)
146 : {
147 0 : PeerConnectionLifecycleCallback::Trace(aTracer);
148 0 : }
149 :
150 : inline void
151 0 : FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
152 : {
153 0 : PeerConnectionLifecycleCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx);
154 0 : }
155 : };
156 : } // namespace binding_detail
157 :
158 :
159 : namespace RTCPeerConnectionStaticBinding {
160 :
161 : typedef mozilla::dom::RTCPeerConnectionStatic NativeType;
162 :
163 : bool
164 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
165 :
166 : JSObject*
167 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);
168 :
169 : const JSClass*
170 : GetJSClass();
171 :
172 : bool
173 : Wrap(JSContext* aCx, mozilla::dom::RTCPeerConnectionStatic* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
174 :
175 : template <class T>
176 0 : inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
177 : {
178 0 : JS::Rooted<JSObject*> reflector(aCx);
179 0 : return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
180 : }
181 :
182 : // We declare this as an array so that retrieving a pointer to this
183 : // binding's property hooks only requires compile/link-time resolvable
184 : // address arithmetic. Declaring it as a pointer instead would require
185 : // doing a run-time load to fetch a pointer to this binding's property
186 : // hooks. And then structures which embedded a pointer to this structure
187 : // would require a run-time load for proper initialization, which would
188 : // then induce static constructors. Lots of static constructors.
189 : extern const NativePropertyHooks sNativePropertyHooks[];
190 :
191 : void
192 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
193 :
194 : JS::Handle<JSObject*>
195 : GetProtoObjectHandle(JSContext* aCx);
196 :
197 : JS::Handle<JSObject*>
198 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true);
199 :
200 : JSObject*
201 : GetConstructorObject(JSContext* aCx);
202 :
203 : } // namespace RTCPeerConnectionStaticBinding
204 :
205 :
206 :
207 0 : class RTCPeerConnectionStaticJSImpl : public CallbackInterface
208 : {
209 : public:
210 0 : explicit inline RTCPeerConnectionStaticJSImpl(JSContext* aCx, JS::Handle<JSObject*> aCallback, nsIGlobalObject* aIncumbentGlobal)
211 0 : : CallbackInterface(aCx, aCallback, aIncumbentGlobal)
212 : {
213 0 : }
214 :
215 : explicit inline RTCPeerConnectionStaticJSImpl(JS::Handle<JSObject*> aCallback, const FastCallbackConstructor& )
216 : : CallbackInterface(aCallback, FastCallbackConstructor())
217 : {
218 : }
219 :
220 : explicit inline RTCPeerConnectionStaticJSImpl(JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
221 : : CallbackInterface(aCallback, aAsyncStack, aIncumbentGlobal)
222 : {
223 : }
224 :
225 : void RegisterPeerConnectionLifecycleCallback(PeerConnectionLifecycleCallback& cb, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
226 :
227 : void __Init(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
228 :
229 : inline bool
230 : operator==(const RTCPeerConnectionStaticJSImpl& aOther) const
231 : {
232 : return CallbackInterface::operator==(aOther);
233 : }
234 :
235 : private:
236 : static bool
237 : InitIds(JSContext* cx, RTCPeerConnectionStaticAtoms* atomsCache);
238 : };
239 :
240 :
241 : class RTCPeerConnectionStatic final : public nsSupportsWeakReference,
242 : public nsWrapperCache
243 : {
244 : public:
245 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
246 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(RTCPeerConnectionStatic)
247 :
248 : private:
249 : RefPtr<RTCPeerConnectionStaticJSImpl> mImpl;
250 : nsCOMPtr<nsISupports> mParent;
251 :
252 : public:
253 : RTCPeerConnectionStatic(JS::Handle<JSObject*> aJSImplObject, nsIGlobalObject* aParent);
254 :
255 : private:
256 : ~RTCPeerConnectionStatic();
257 :
258 : public:
259 : nsISupports* GetParentObject() const;
260 :
261 : virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
262 :
263 : static already_AddRefed<RTCPeerConnectionStatic> Constructor(const GlobalObject& global, JSContext* cx, ErrorResult& aRv);
264 :
265 : void RegisterPeerConnectionLifecycleCallback(PeerConnectionLifecycleCallback& cb, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
266 :
267 : static bool
268 : _Create(JSContext* cx, unsigned argc, JS::Value* vp);
269 : };
270 :
271 :
272 : } // namespace dom
273 : } // namespace mozilla
274 :
275 : #endif // mozilla_dom_RTCPeerConnectionStaticBinding_h
|