/work/obj-fuzz/dist/include/mozilla/dom/RequestBinding.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM Request.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #ifndef mozilla_dom_RequestBinding_h |
4 | | #define mozilla_dom_RequestBinding_h |
5 | | |
6 | | #include "FetchBinding.h" |
7 | | #include "FetchObserverBinding.h" |
8 | | #include "GeckoProfiler.h" |
9 | | #include "HeadersBinding.h" |
10 | | #include "js/RootingAPI.h" |
11 | | #include "jspubtd.h" |
12 | | #include "mozilla/ErrorResult.h" |
13 | | #include "mozilla/dom/AbortSignal.h" |
14 | | #include "mozilla/dom/BindingDeclarations.h" |
15 | | #include "mozilla/dom/FakeString.h" |
16 | | #include "mozilla/dom/Nullable.h" |
17 | | #include "mozilla/dom/PrototypeList.h" |
18 | | #include "mozilla/dom/UnionMember.h" |
19 | | |
20 | | namespace mozilla { |
21 | | namespace dom { |
22 | | |
23 | | class AbortSignal; |
24 | | class BlobOrArrayBufferViewOrArrayBufferOrFormDataOrURLSearchParamsOrUSVString; |
25 | | class HeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord; |
26 | | struct NativePropertyHooks; |
27 | | class ObserverCallback; |
28 | | class OwningBlobOrArrayBufferViewOrArrayBufferOrFormDataOrURLSearchParamsOrUSVString; |
29 | | class OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord; |
30 | | class OwningRequestOrUSVString; |
31 | | class ProtoAndIfaceCache; |
32 | | class Request; |
33 | | struct RequestAtoms; |
34 | | struct RequestInitAtoms; |
35 | | |
36 | | } // namespace dom |
37 | | } // namespace mozilla |
38 | | |
39 | | namespace mozilla { |
40 | | namespace dom { |
41 | | |
42 | | enum class RequestDestination : uint8_t { |
43 | | _empty, |
44 | | Audio, |
45 | | Audioworklet, |
46 | | Document, |
47 | | Embed, |
48 | | Font, |
49 | | Image, |
50 | | Manifest, |
51 | | Object, |
52 | | Paintworklet, |
53 | | Report, |
54 | | Script, |
55 | | Sharedworker, |
56 | | Style, |
57 | | Track, |
58 | | Video, |
59 | | Worker, |
60 | | Xslt, |
61 | | EndGuard_ |
62 | | }; |
63 | | |
64 | | namespace RequestDestinationValues { |
65 | | extern const EnumEntry strings[19]; |
66 | | } // namespace RequestDestinationValues |
67 | | |
68 | | bool |
69 | | ToJSValue(JSContext* aCx, RequestDestination aArgument, JS::MutableHandle<JS::Value> aValue); |
70 | | |
71 | | |
72 | | enum class RequestMode : uint8_t { |
73 | | Same_origin, |
74 | | No_cors, |
75 | | Cors, |
76 | | Navigate, |
77 | | EndGuard_ |
78 | | }; |
79 | | |
80 | | namespace RequestModeValues { |
81 | | extern const EnumEntry strings[5]; |
82 | | } // namespace RequestModeValues |
83 | | |
84 | | bool |
85 | | ToJSValue(JSContext* aCx, RequestMode aArgument, JS::MutableHandle<JS::Value> aValue); |
86 | | |
87 | | |
88 | | enum class RequestCredentials : uint8_t { |
89 | | Omit, |
90 | | Same_origin, |
91 | | Include, |
92 | | EndGuard_ |
93 | | }; |
94 | | |
95 | | namespace RequestCredentialsValues { |
96 | | extern const EnumEntry strings[4]; |
97 | | } // namespace RequestCredentialsValues |
98 | | |
99 | | bool |
100 | | ToJSValue(JSContext* aCx, RequestCredentials aArgument, JS::MutableHandle<JS::Value> aValue); |
101 | | |
102 | | |
103 | | enum class RequestCache : uint8_t { |
104 | | Default, |
105 | | No_store, |
106 | | Reload, |
107 | | No_cache, |
108 | | Force_cache, |
109 | | Only_if_cached, |
110 | | EndGuard_ |
111 | | }; |
112 | | |
113 | | namespace RequestCacheValues { |
114 | | extern const EnumEntry strings[7]; |
115 | | } // namespace RequestCacheValues |
116 | | |
117 | | bool |
118 | | ToJSValue(JSContext* aCx, RequestCache aArgument, JS::MutableHandle<JS::Value> aValue); |
119 | | |
120 | | |
121 | | enum class RequestRedirect : uint8_t { |
122 | | Follow, |
123 | | Error, |
124 | | Manual, |
125 | | EndGuard_ |
126 | | }; |
127 | | |
128 | | namespace RequestRedirectValues { |
129 | | extern const EnumEntry strings[4]; |
130 | | } // namespace RequestRedirectValues |
131 | | |
132 | | bool |
133 | | ToJSValue(JSContext* aCx, RequestRedirect aArgument, JS::MutableHandle<JS::Value> aValue); |
134 | | |
135 | | |
136 | | enum class ReferrerPolicy : uint8_t { |
137 | | _empty, |
138 | | No_referrer, |
139 | | No_referrer_when_downgrade, |
140 | | Origin, |
141 | | Origin_when_cross_origin, |
142 | | Unsafe_url, |
143 | | Same_origin, |
144 | | Strict_origin, |
145 | | Strict_origin_when_cross_origin, |
146 | | EndGuard_ |
147 | | }; |
148 | | |
149 | | namespace ReferrerPolicyValues { |
150 | | extern const EnumEntry strings[10]; |
151 | | } // namespace ReferrerPolicyValues |
152 | | |
153 | | bool |
154 | | ToJSValue(JSContext* aCx, ReferrerPolicy aArgument, JS::MutableHandle<JS::Value> aValue); |
155 | | |
156 | | |
157 | | void |
158 | | ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningRequestOrUSVString& aUnion, const char* aName, uint32_t aFlags = 0); |
159 | | |
160 | | |
161 | | void |
162 | | ImplCycleCollectionUnlink(OwningRequestOrUSVString& aUnion); |
163 | | |
164 | | |
165 | | struct RequestInit : public DictionaryBase |
166 | | { |
167 | | MOZ_INIT_OUTSIDE_CTOR Optional<Nullable<OwningBlobOrArrayBufferViewOrArrayBufferOrFormDataOrURLSearchParamsOrUSVString >> mBody; |
168 | | MOZ_INIT_OUTSIDE_CTOR Optional<RequestCache> mCache; |
169 | | MOZ_INIT_OUTSIDE_CTOR Optional<RequestCredentials> mCredentials; |
170 | | MOZ_INIT_OUTSIDE_CTOR Optional<OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord> mHeaders; |
171 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mIntegrity; |
172 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsCString> mMethod; |
173 | | MOZ_INIT_OUTSIDE_CTOR Optional<RequestMode> mMode; |
174 | | MOZ_INIT_OUTSIDE_CTOR Optional<bool> mMozErrors; |
175 | | MOZ_INIT_OUTSIDE_CTOR Optional<OwningNonNull<ObserverCallback>> mObserve; |
176 | | MOZ_INIT_OUTSIDE_CTOR Optional<RequestRedirect> mRedirect; |
177 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mReferrer; |
178 | | MOZ_INIT_OUTSIDE_CTOR Optional<ReferrerPolicy> mReferrerPolicy; |
179 | | MOZ_INIT_OUTSIDE_CTOR Optional<RefPtr<mozilla::dom::AbortSignal>> mSignal; |
180 | | |
181 | | RequestInit(); |
182 | | |
183 | | explicit inline RequestInit(const FastDictionaryInitializer& ) |
184 | 0 | { |
185 | 0 | // Do nothing here; this is used by our "Fast" subclass |
186 | 0 | } |
187 | | |
188 | | private: |
189 | | RequestInit(const RequestInit&) = delete; |
190 | | RequestInit& operator=(const RequestInit&) = delete; |
191 | | |
192 | | static bool |
193 | | InitIds(JSContext* cx, RequestInitAtoms* atomsCache); |
194 | | |
195 | | public: |
196 | | bool |
197 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
198 | | |
199 | | bool |
200 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
201 | | |
202 | | void |
203 | | TraceDictionary(JSTracer* trc); |
204 | | |
205 | | inline void |
206 | | TraverseForCC(nsCycleCollectionTraversalCallback& aCallback, uint32_t aFlags) |
207 | 0 | { |
208 | 0 | ImplCycleCollectionTraverse(aCallback, mBody, "mBody", aFlags); |
209 | 0 | ImplCycleCollectionTraverse(aCallback, mHeaders, "mHeaders", aFlags); |
210 | 0 | ImplCycleCollectionTraverse(aCallback, mObserve, "mObserve", aFlags); |
211 | 0 | ImplCycleCollectionTraverse(aCallback, mSignal, "mSignal", aFlags); |
212 | 0 | } |
213 | | |
214 | | inline void |
215 | | UnlinkForCC() |
216 | 0 | { |
217 | 0 | ImplCycleCollectionUnlink(mBody); |
218 | 0 | ImplCycleCollectionUnlink(mHeaders); |
219 | 0 | ImplCycleCollectionUnlink(mObserve); |
220 | 0 | ImplCycleCollectionUnlink(mSignal); |
221 | 0 | } |
222 | | }; |
223 | | |
224 | | namespace binding_detail { |
225 | | struct FastRequestInit : public RequestInit |
226 | | { |
227 | | inline FastRequestInit() |
228 | | : RequestInit(FastDictionaryInitializer()) |
229 | 0 | { |
230 | 0 | // Doesn't matter what int we pass to the parent constructor |
231 | 0 | } |
232 | | }; |
233 | | } // namespace binding_detail |
234 | | |
235 | | |
236 | | class RequestOrUSVString |
237 | | { |
238 | | friend class RequestOrUSVStringArgument; |
239 | | enum Type |
240 | | { |
241 | | eUninitialized, |
242 | | eRequest, |
243 | | eUSVString |
244 | | }; |
245 | | |
246 | | union Value |
247 | | { |
248 | | UnionMember<NonNull<mozilla::dom::Request> > mRequest; |
249 | | UnionMember<binding_detail::FakeString > mUSVString; |
250 | | |
251 | | }; |
252 | | |
253 | | Type mType; |
254 | | Value mValue; |
255 | | |
256 | | RequestOrUSVString(const RequestOrUSVString&) = delete; |
257 | | RequestOrUSVString& operator=(const RequestOrUSVString&) = delete; |
258 | | public: |
259 | | explicit inline RequestOrUSVString() |
260 | | : mType(eUninitialized) |
261 | 0 | { |
262 | 0 | } |
263 | | |
264 | | inline ~RequestOrUSVString() |
265 | 0 | { |
266 | 0 | Uninit(); |
267 | 0 | } |
268 | | |
269 | | inline NonNull<mozilla::dom::Request>& |
270 | | RawSetAsRequest() |
271 | 0 | { |
272 | 0 | if (mType == eRequest) { |
273 | 0 | return mValue.mRequest.Value(); |
274 | 0 | } |
275 | 0 | MOZ_ASSERT(mType == eUninitialized); |
276 | 0 | mType = eRequest; |
277 | 0 | return mValue.mRequest.SetValue(); |
278 | 0 | } |
279 | | |
280 | | inline NonNull<mozilla::dom::Request>& |
281 | | SetAsRequest() |
282 | 0 | { |
283 | 0 | if (mType == eRequest) { |
284 | 0 | return mValue.mRequest.Value(); |
285 | 0 | } |
286 | 0 | Uninit(); |
287 | 0 | mType = eRequest; |
288 | 0 | return mValue.mRequest.SetValue(); |
289 | 0 | } |
290 | | |
291 | | inline bool |
292 | | IsRequest() const |
293 | 0 | { |
294 | 0 | return mType == eRequest; |
295 | 0 | } |
296 | | |
297 | | inline NonNull<mozilla::dom::Request>& |
298 | | GetAsRequest() |
299 | 0 | { |
300 | 0 | MOZ_ASSERT(IsRequest(), "Wrong type!"); |
301 | 0 | return mValue.mRequest.Value(); |
302 | 0 | } |
303 | | |
304 | | inline mozilla::dom::Request& |
305 | | GetAsRequest() const |
306 | 0 | { |
307 | 0 | MOZ_ASSERT(IsRequest(), "Wrong type!"); |
308 | 0 | return mValue.mRequest.Value(); |
309 | 0 | } |
310 | | |
311 | | inline binding_detail::FakeString& |
312 | | RawSetAsUSVString() |
313 | 0 | { |
314 | 0 | if (mType == eUSVString) { |
315 | 0 | return mValue.mUSVString.Value(); |
316 | 0 | } |
317 | 0 | MOZ_ASSERT(mType == eUninitialized); |
318 | 0 | mType = eUSVString; |
319 | 0 | return mValue.mUSVString.SetValue(); |
320 | 0 | } |
321 | | |
322 | | inline binding_detail::FakeString& |
323 | | SetAsUSVString() |
324 | 0 | { |
325 | 0 | if (mType == eUSVString) { |
326 | 0 | return mValue.mUSVString.Value(); |
327 | 0 | } |
328 | 0 | Uninit(); |
329 | 0 | mType = eUSVString; |
330 | 0 | return mValue.mUSVString.SetValue(); |
331 | 0 | } |
332 | | |
333 | | inline bool |
334 | | IsUSVString() const |
335 | 0 | { |
336 | 0 | return mType == eUSVString; |
337 | 0 | } |
338 | | |
339 | | inline binding_detail::FakeString& |
340 | | GetAsUSVString() |
341 | 0 | { |
342 | 0 | MOZ_ASSERT(IsUSVString(), "Wrong type!"); |
343 | 0 | return mValue.mUSVString.Value(); |
344 | 0 | } |
345 | | |
346 | | inline const nsAString& |
347 | | GetAsUSVString() const |
348 | 0 | { |
349 | 0 | MOZ_ASSERT(IsUSVString(), "Wrong type!"); |
350 | 0 | return mValue.mUSVString.Value(); |
351 | 0 | } |
352 | | |
353 | | inline void |
354 | | Uninit() |
355 | | { |
356 | | switch (mType) { |
357 | | case eUninitialized: { |
358 | | break; |
359 | | } |
360 | | case eRequest: { |
361 | | DestroyRequest(); |
362 | | break; |
363 | | } |
364 | | case eUSVString: { |
365 | | DestroyUSVString(); |
366 | | break; |
367 | | } |
368 | | } |
369 | | } |
370 | | |
371 | | bool |
372 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
373 | | |
374 | | private: |
375 | | inline void |
376 | | DestroyRequest() |
377 | 0 | { |
378 | 0 | MOZ_ASSERT(IsRequest(), "Wrong type!"); |
379 | 0 | mValue.mRequest.Destroy(); |
380 | 0 | mType = eUninitialized; |
381 | 0 | } |
382 | | |
383 | | inline void |
384 | | DestroyUSVString() |
385 | 0 | { |
386 | 0 | MOZ_ASSERT(IsUSVString(), "Wrong type!"); |
387 | 0 | mValue.mUSVString.Destroy(); |
388 | 0 | mType = eUninitialized; |
389 | 0 | } |
390 | | }; |
391 | | |
392 | | |
393 | | class OwningRequestOrUSVString : public AllOwningUnionBase |
394 | | { |
395 | | friend void ImplCycleCollectionUnlink(OwningRequestOrUSVString& aUnion); |
396 | | enum Type |
397 | | { |
398 | | eUninitialized, |
399 | | eRequest, |
400 | | eUSVString |
401 | | }; |
402 | | |
403 | | union Value |
404 | | { |
405 | | UnionMember<OwningNonNull<mozilla::dom::Request> > mRequest; |
406 | | UnionMember<nsString > mUSVString; |
407 | | |
408 | | }; |
409 | | |
410 | | Type mType; |
411 | | Value mValue; |
412 | | |
413 | | public: |
414 | | explicit inline OwningRequestOrUSVString() |
415 | | : mType(eUninitialized) |
416 | 0 | { |
417 | 0 | } |
418 | | |
419 | | explicit inline OwningRequestOrUSVString(const OwningRequestOrUSVString& aOther) |
420 | | : mType(eUninitialized) |
421 | 0 | { |
422 | 0 | *this = aOther; |
423 | 0 | } |
424 | | |
425 | | inline ~OwningRequestOrUSVString() |
426 | 0 | { |
427 | 0 | Uninit(); |
428 | 0 | } |
429 | | |
430 | | OwningNonNull<mozilla::dom::Request>& |
431 | | RawSetAsRequest(); |
432 | | |
433 | | OwningNonNull<mozilla::dom::Request>& |
434 | | SetAsRequest(); |
435 | | |
436 | | bool |
437 | | TrySetToRequest(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
438 | | |
439 | | inline bool |
440 | | IsRequest() const |
441 | 0 | { |
442 | 0 | return mType == eRequest; |
443 | 0 | } |
444 | | |
445 | | inline OwningNonNull<mozilla::dom::Request>& |
446 | | GetAsRequest() |
447 | 0 | { |
448 | 0 | MOZ_ASSERT(IsRequest(), "Wrong type!"); |
449 | 0 | return mValue.mRequest.Value(); |
450 | 0 | } |
451 | | |
452 | | inline OwningNonNull<mozilla::dom::Request> const & |
453 | | GetAsRequest() const |
454 | 0 | { |
455 | 0 | MOZ_ASSERT(IsRequest(), "Wrong type!"); |
456 | 0 | return mValue.mRequest.Value(); |
457 | 0 | } |
458 | | |
459 | | nsString& |
460 | | RawSetAsUSVString(); |
461 | | |
462 | | nsString& |
463 | | SetAsUSVString(); |
464 | | |
465 | | bool |
466 | | TrySetToUSVString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
467 | | |
468 | | inline void |
469 | | SetStringData(const nsString::char_type* aData, nsString::size_type aLength) |
470 | 0 | { |
471 | 0 | RawSetAsUSVString().Assign(aData, aLength); |
472 | 0 | } |
473 | | |
474 | | inline bool |
475 | | IsUSVString() const |
476 | 0 | { |
477 | 0 | return mType == eUSVString; |
478 | 0 | } |
479 | | |
480 | | inline nsString& |
481 | | GetAsUSVString() |
482 | 0 | { |
483 | 0 | MOZ_ASSERT(IsUSVString(), "Wrong type!"); |
484 | 0 | return mValue.mUSVString.Value(); |
485 | 0 | } |
486 | | |
487 | | inline nsString const & |
488 | | GetAsUSVString() const |
489 | 0 | { |
490 | 0 | MOZ_ASSERT(IsUSVString(), "Wrong type!"); |
491 | 0 | return mValue.mUSVString.Value(); |
492 | 0 | } |
493 | | |
494 | | void |
495 | | Uninit(); |
496 | | |
497 | | bool |
498 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
499 | | |
500 | | void |
501 | | TraceUnion(JSTracer* trc); |
502 | | |
503 | | OwningRequestOrUSVString& |
504 | | operator=(const OwningRequestOrUSVString& aOther); |
505 | | |
506 | | private: |
507 | | void |
508 | | DestroyRequest(); |
509 | | |
510 | | void |
511 | | DestroyUSVString(); |
512 | | }; |
513 | | |
514 | | |
515 | | namespace Request_Binding { |
516 | | |
517 | | typedef mozilla::dom::Request NativeType; |
518 | | |
519 | | const JSClass* |
520 | | GetJSClass(); |
521 | | |
522 | | bool |
523 | | Wrap(JSContext* aCx, mozilla::dom::Request* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector); |
524 | | |
525 | | template <class T> |
526 | | inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto) |
527 | 0 | { |
528 | 0 | JS::Rooted<JSObject*> reflector(aCx); |
529 | 0 | return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr; |
530 | 0 | } |
531 | | |
532 | | // We declare this as an array so that retrieving a pointer to this |
533 | | // binding's property hooks only requires compile/link-time resolvable |
534 | | // address arithmetic. Declaring it as a pointer instead would require |
535 | | // doing a run-time load to fetch a pointer to this binding's property |
536 | | // hooks. And then structures which embedded a pointer to this structure |
537 | | // would require a run-time load for proper initialization, which would |
538 | | // then induce static constructors. Lots of static constructors. |
539 | | extern const NativePropertyHooks sNativePropertyHooks[]; |
540 | | |
541 | | void |
542 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal); |
543 | | |
544 | | inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx) |
545 | 0 | { |
546 | 0 | /* Get the interface prototype object for this class. This will create the |
547 | 0 | object as needed. */ |
548 | 0 | return GetPerInterfaceObjectHandle(aCx, prototypes::id::Request, |
549 | 0 | &CreateInterfaceObjects, |
550 | 0 | /* aDefineOnGlobal = */ true); |
551 | 0 |
|
552 | 0 | } |
553 | | |
554 | | inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true) |
555 | 0 | { |
556 | 0 | /* Get the interface object for this class. This will create the object as |
557 | 0 | needed. */ |
558 | 0 |
|
559 | 0 | return GetPerInterfaceObjectHandle(aCx, constructors::id::Request, |
560 | 0 | &CreateInterfaceObjects, |
561 | 0 | aDefineOnGlobal); |
562 | 0 | } |
563 | | |
564 | | JSObject* |
565 | | GetConstructorObject(JSContext* aCx); |
566 | | |
567 | | } // namespace Request_Binding |
568 | | |
569 | | |
570 | | |
571 | | } // namespace dom |
572 | | } // namespace mozilla |
573 | | |
574 | | #endif // mozilla_dom_RequestBinding_h |