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