Coverage Report

Created: 2018-09-25 14:53

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