/work/obj-fuzz/dist/include/mozilla/dom/PushManagerBinding.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM PushManager.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #ifndef mozilla_dom_PushManagerBinding_h |
4 | | #define mozilla_dom_PushManagerBinding_h |
5 | | |
6 | | #include "GeckoProfiler.h" |
7 | | #include "js/RootingAPI.h" |
8 | | #include "jsfriendapi.h" |
9 | | #include "jspubtd.h" |
10 | | #include "mozilla/ErrorResult.h" |
11 | | #include "mozilla/dom/BindingDeclarations.h" |
12 | | #include "mozilla/dom/CallbackInterface.h" |
13 | | #include "mozilla/dom/FakeString.h" |
14 | | #include "mozilla/dom/Nullable.h" |
15 | | #include "mozilla/dom/PrototypeList.h" |
16 | | #include "mozilla/dom/ToJSValue.h" |
17 | | #include "mozilla/dom/TypedArray.h" |
18 | | #include "mozilla/dom/UnionMember.h" |
19 | | #include "nsWeakReference.h" |
20 | | |
21 | | namespace mozilla { |
22 | | namespace dom { |
23 | | |
24 | | class ArrayBufferViewOrArrayBufferOrString; |
25 | | struct NativePropertyHooks; |
26 | | class OwningArrayBufferViewOrArrayBufferOrString; |
27 | | class Promise; |
28 | | class ProtoAndIfaceCache; |
29 | | class PushManager; |
30 | | struct PushManagerAtoms; |
31 | | class PushManagerImpl; |
32 | | struct PushManagerImplAtoms; |
33 | | struct PushSubscriptionOptionsInit; |
34 | | struct PushSubscriptionOptionsInitAtoms; |
35 | | |
36 | | } // namespace dom |
37 | | } // namespace mozilla |
38 | | |
39 | | namespace mozilla { |
40 | | namespace dom { |
41 | | |
42 | | enum class PushPermissionState : uint8_t { |
43 | | Granted, |
44 | | Denied, |
45 | | Prompt, |
46 | | EndGuard_ |
47 | | }; |
48 | | |
49 | | namespace PushPermissionStateValues { |
50 | | extern const EnumEntry strings[4]; |
51 | | } // namespace PushPermissionStateValues |
52 | | |
53 | | bool |
54 | | ToJSValue(JSContext* aCx, PushPermissionState aArgument, JS::MutableHandle<JS::Value> aValue); |
55 | | |
56 | | |
57 | | class ArrayBufferViewOrArrayBufferOrString |
58 | | { |
59 | | friend class ArrayBufferViewOrArrayBufferOrStringArgument; |
60 | | enum Type |
61 | | { |
62 | | eUninitialized, |
63 | | eArrayBufferView, |
64 | | eArrayBuffer, |
65 | | eString |
66 | | }; |
67 | | |
68 | | union Value |
69 | | { |
70 | | UnionMember<RootedSpiderMonkeyInterface<ArrayBufferView> > mArrayBufferView; |
71 | | UnionMember<RootedSpiderMonkeyInterface<ArrayBuffer> > mArrayBuffer; |
72 | | UnionMember<binding_detail::FakeString > mString; |
73 | | |
74 | | }; |
75 | | |
76 | | Type mType; |
77 | | Value mValue; |
78 | | |
79 | | ArrayBufferViewOrArrayBufferOrString(const ArrayBufferViewOrArrayBufferOrString&) = delete; |
80 | | ArrayBufferViewOrArrayBufferOrString& operator=(const ArrayBufferViewOrArrayBufferOrString&) = delete; |
81 | | public: |
82 | | explicit inline ArrayBufferViewOrArrayBufferOrString() |
83 | | : mType(eUninitialized) |
84 | 0 | { |
85 | 0 | } |
86 | | |
87 | | inline ~ArrayBufferViewOrArrayBufferOrString() |
88 | 0 | { |
89 | 0 | Uninit(); |
90 | 0 | } |
91 | | |
92 | | inline RootedSpiderMonkeyInterface<ArrayBufferView>& |
93 | | RawSetAsArrayBufferView(JSContext* cx) |
94 | 0 | { |
95 | 0 | if (mType == eArrayBufferView) { |
96 | 0 | return mValue.mArrayBufferView.Value(); |
97 | 0 | } |
98 | 0 | MOZ_ASSERT(mType == eUninitialized); |
99 | 0 | mType = eArrayBufferView; |
100 | 0 | return mValue.mArrayBufferView.SetValue(cx); |
101 | 0 | } |
102 | | |
103 | | inline RootedSpiderMonkeyInterface<ArrayBufferView>& |
104 | | SetAsArrayBufferView(JSContext* cx) |
105 | 0 | { |
106 | 0 | if (mType == eArrayBufferView) { |
107 | 0 | return mValue.mArrayBufferView.Value(); |
108 | 0 | } |
109 | 0 | Uninit(); |
110 | 0 | mType = eArrayBufferView; |
111 | 0 | return mValue.mArrayBufferView.SetValue(cx); |
112 | 0 | } |
113 | | |
114 | | inline bool |
115 | | IsArrayBufferView() const |
116 | 0 | { |
117 | 0 | return mType == eArrayBufferView; |
118 | 0 | } |
119 | | |
120 | | inline RootedSpiderMonkeyInterface<ArrayBufferView>& |
121 | | GetAsArrayBufferView() |
122 | 0 | { |
123 | 0 | MOZ_ASSERT(IsArrayBufferView(), "Wrong type!"); |
124 | 0 | return mValue.mArrayBufferView.Value(); |
125 | 0 | } |
126 | | |
127 | | inline ArrayBufferView const & |
128 | | GetAsArrayBufferView() const |
129 | 0 | { |
130 | 0 | MOZ_ASSERT(IsArrayBufferView(), "Wrong type!"); |
131 | 0 | return mValue.mArrayBufferView.Value(); |
132 | 0 | } |
133 | | |
134 | | inline RootedSpiderMonkeyInterface<ArrayBuffer>& |
135 | | RawSetAsArrayBuffer(JSContext* cx) |
136 | 0 | { |
137 | 0 | if (mType == eArrayBuffer) { |
138 | 0 | return mValue.mArrayBuffer.Value(); |
139 | 0 | } |
140 | 0 | MOZ_ASSERT(mType == eUninitialized); |
141 | 0 | mType = eArrayBuffer; |
142 | 0 | return mValue.mArrayBuffer.SetValue(cx); |
143 | 0 | } |
144 | | |
145 | | inline RootedSpiderMonkeyInterface<ArrayBuffer>& |
146 | | SetAsArrayBuffer(JSContext* cx) |
147 | 0 | { |
148 | 0 | if (mType == eArrayBuffer) { |
149 | 0 | return mValue.mArrayBuffer.Value(); |
150 | 0 | } |
151 | 0 | Uninit(); |
152 | 0 | mType = eArrayBuffer; |
153 | 0 | return mValue.mArrayBuffer.SetValue(cx); |
154 | 0 | } |
155 | | |
156 | | inline bool |
157 | | IsArrayBuffer() const |
158 | 0 | { |
159 | 0 | return mType == eArrayBuffer; |
160 | 0 | } |
161 | | |
162 | | inline RootedSpiderMonkeyInterface<ArrayBuffer>& |
163 | | GetAsArrayBuffer() |
164 | 0 | { |
165 | 0 | MOZ_ASSERT(IsArrayBuffer(), "Wrong type!"); |
166 | 0 | return mValue.mArrayBuffer.Value(); |
167 | 0 | } |
168 | | |
169 | | inline ArrayBuffer const & |
170 | | GetAsArrayBuffer() const |
171 | 0 | { |
172 | 0 | MOZ_ASSERT(IsArrayBuffer(), "Wrong type!"); |
173 | 0 | return mValue.mArrayBuffer.Value(); |
174 | 0 | } |
175 | | |
176 | | inline binding_detail::FakeString& |
177 | | RawSetAsString() |
178 | 0 | { |
179 | 0 | if (mType == eString) { |
180 | 0 | return mValue.mString.Value(); |
181 | 0 | } |
182 | 0 | MOZ_ASSERT(mType == eUninitialized); |
183 | 0 | mType = eString; |
184 | 0 | return mValue.mString.SetValue(); |
185 | 0 | } |
186 | | |
187 | | inline binding_detail::FakeString& |
188 | | SetAsString() |
189 | 0 | { |
190 | 0 | if (mType == eString) { |
191 | 0 | return mValue.mString.Value(); |
192 | 0 | } |
193 | 0 | Uninit(); |
194 | 0 | mType = eString; |
195 | 0 | return mValue.mString.SetValue(); |
196 | 0 | } |
197 | | |
198 | | inline bool |
199 | | IsString() const |
200 | 0 | { |
201 | 0 | return mType == eString; |
202 | 0 | } |
203 | | |
204 | | inline binding_detail::FakeString& |
205 | | GetAsString() |
206 | 0 | { |
207 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
208 | 0 | return mValue.mString.Value(); |
209 | 0 | } |
210 | | |
211 | | inline const nsAString& |
212 | | GetAsString() const |
213 | 0 | { |
214 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
215 | 0 | return mValue.mString.Value(); |
216 | 0 | } |
217 | | |
218 | | inline void |
219 | | Uninit() |
220 | 0 | { |
221 | 0 | switch (mType) { |
222 | 0 | case eUninitialized: { |
223 | 0 | break; |
224 | 0 | } |
225 | 0 | case eArrayBufferView: { |
226 | 0 | DestroyArrayBufferView(); |
227 | 0 | break; |
228 | 0 | } |
229 | 0 | case eArrayBuffer: { |
230 | 0 | DestroyArrayBuffer(); |
231 | 0 | break; |
232 | 0 | } |
233 | 0 | case eString: { |
234 | 0 | DestroyString(); |
235 | 0 | break; |
236 | 0 | } |
237 | 0 | } |
238 | 0 | } |
239 | | |
240 | | bool |
241 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
242 | | |
243 | | private: |
244 | | inline void |
245 | | DestroyArrayBufferView() |
246 | 0 | { |
247 | 0 | MOZ_ASSERT(IsArrayBufferView(), "Wrong type!"); |
248 | 0 | mValue.mArrayBufferView.Destroy(); |
249 | 0 | mType = eUninitialized; |
250 | 0 | } |
251 | | |
252 | | inline void |
253 | | DestroyArrayBuffer() |
254 | 0 | { |
255 | 0 | MOZ_ASSERT(IsArrayBuffer(), "Wrong type!"); |
256 | 0 | mValue.mArrayBuffer.Destroy(); |
257 | 0 | mType = eUninitialized; |
258 | 0 | } |
259 | | |
260 | | inline void |
261 | | DestroyString() |
262 | 0 | { |
263 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
264 | 0 | mValue.mString.Destroy(); |
265 | 0 | mType = eUninitialized; |
266 | 0 | } |
267 | | }; |
268 | | |
269 | | |
270 | | class OwningArrayBufferViewOrArrayBufferOrString : public AllOwningUnionBase |
271 | | { |
272 | | friend void ImplCycleCollectionUnlink(OwningArrayBufferViewOrArrayBufferOrString& aUnion); |
273 | | enum Type |
274 | | { |
275 | | eUninitialized, |
276 | | eArrayBufferView, |
277 | | eArrayBuffer, |
278 | | eString |
279 | | }; |
280 | | |
281 | | union Value |
282 | | { |
283 | | UnionMember<ArrayBufferView > mArrayBufferView; |
284 | | UnionMember<ArrayBuffer > mArrayBuffer; |
285 | | UnionMember<nsString > mString; |
286 | | |
287 | | }; |
288 | | |
289 | | Type mType; |
290 | | Value mValue; |
291 | | |
292 | | OwningArrayBufferViewOrArrayBufferOrString(const OwningArrayBufferViewOrArrayBufferOrString&) = delete; |
293 | | OwningArrayBufferViewOrArrayBufferOrString& operator=(const OwningArrayBufferViewOrArrayBufferOrString&) = delete; |
294 | | public: |
295 | | explicit inline OwningArrayBufferViewOrArrayBufferOrString() |
296 | | : mType(eUninitialized) |
297 | 0 | { |
298 | 0 | } |
299 | | |
300 | | inline ~OwningArrayBufferViewOrArrayBufferOrString() |
301 | 0 | { |
302 | 0 | Uninit(); |
303 | 0 | } |
304 | | |
305 | | ArrayBufferView& |
306 | | RawSetAsArrayBufferView(); |
307 | | |
308 | | ArrayBufferView& |
309 | | SetAsArrayBufferView(); |
310 | | |
311 | | bool |
312 | | TrySetToArrayBufferView(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
313 | | |
314 | | inline bool |
315 | | IsArrayBufferView() const |
316 | 0 | { |
317 | 0 | return mType == eArrayBufferView; |
318 | 0 | } |
319 | | |
320 | | inline ArrayBufferView& |
321 | | GetAsArrayBufferView() |
322 | 0 | { |
323 | 0 | MOZ_ASSERT(IsArrayBufferView(), "Wrong type!"); |
324 | 0 | return mValue.mArrayBufferView.Value(); |
325 | 0 | } |
326 | | |
327 | | inline ArrayBufferView const & |
328 | | GetAsArrayBufferView() const |
329 | 0 | { |
330 | 0 | MOZ_ASSERT(IsArrayBufferView(), "Wrong type!"); |
331 | 0 | return mValue.mArrayBufferView.Value(); |
332 | 0 | } |
333 | | |
334 | | ArrayBuffer& |
335 | | RawSetAsArrayBuffer(); |
336 | | |
337 | | ArrayBuffer& |
338 | | SetAsArrayBuffer(); |
339 | | |
340 | | bool |
341 | | TrySetToArrayBuffer(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
342 | | |
343 | | inline bool |
344 | | IsArrayBuffer() const |
345 | 0 | { |
346 | 0 | return mType == eArrayBuffer; |
347 | 0 | } |
348 | | |
349 | | inline ArrayBuffer& |
350 | | GetAsArrayBuffer() |
351 | 0 | { |
352 | 0 | MOZ_ASSERT(IsArrayBuffer(), "Wrong type!"); |
353 | 0 | return mValue.mArrayBuffer.Value(); |
354 | 0 | } |
355 | | |
356 | | inline ArrayBuffer const & |
357 | | GetAsArrayBuffer() const |
358 | 0 | { |
359 | 0 | MOZ_ASSERT(IsArrayBuffer(), "Wrong type!"); |
360 | 0 | return mValue.mArrayBuffer.Value(); |
361 | 0 | } |
362 | | |
363 | | nsString& |
364 | | RawSetAsString(); |
365 | | |
366 | | nsString& |
367 | | SetAsString(); |
368 | | |
369 | | bool |
370 | | TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
371 | | |
372 | | inline void |
373 | | SetStringData(const nsString::char_type* aData, nsString::size_type aLength) |
374 | 0 | { |
375 | 0 | RawSetAsString().Assign(aData, aLength); |
376 | 0 | } |
377 | | |
378 | | inline bool |
379 | | IsString() const |
380 | 0 | { |
381 | 0 | return mType == eString; |
382 | 0 | } |
383 | | |
384 | | inline nsString& |
385 | | GetAsString() |
386 | 0 | { |
387 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
388 | 0 | return mValue.mString.Value(); |
389 | 0 | } |
390 | | |
391 | | inline nsString const & |
392 | | GetAsString() const |
393 | 0 | { |
394 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
395 | 0 | return mValue.mString.Value(); |
396 | 0 | } |
397 | | |
398 | | void |
399 | | Uninit(); |
400 | | |
401 | | bool |
402 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
403 | | |
404 | | void |
405 | | TraceUnion(JSTracer* trc); |
406 | | |
407 | | private: |
408 | | void |
409 | | DestroyArrayBufferView(); |
410 | | |
411 | | void |
412 | | DestroyArrayBuffer(); |
413 | | |
414 | | void |
415 | | DestroyString(); |
416 | | }; |
417 | | |
418 | | |
419 | | struct PushSubscriptionOptionsInit : public DictionaryBase |
420 | | { |
421 | | MOZ_INIT_OUTSIDE_CTOR Nullable<OwningArrayBufferViewOrArrayBufferOrString > mApplicationServerKey; |
422 | | |
423 | | PushSubscriptionOptionsInit(); |
424 | | |
425 | | explicit inline PushSubscriptionOptionsInit(const FastDictionaryInitializer& ) |
426 | 0 | { |
427 | 0 | // Do nothing here; this is used by our "Fast" subclass |
428 | 0 | } |
429 | | |
430 | | private: |
431 | | PushSubscriptionOptionsInit(const PushSubscriptionOptionsInit&) = delete; |
432 | | PushSubscriptionOptionsInit& operator=(const PushSubscriptionOptionsInit&) = delete; |
433 | | |
434 | | static bool |
435 | | InitIds(JSContext* cx, PushSubscriptionOptionsInitAtoms* atomsCache); |
436 | | |
437 | | public: |
438 | | bool |
439 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
440 | | |
441 | | bool |
442 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
443 | | |
444 | | void |
445 | | TraceDictionary(JSTracer* trc); |
446 | | }; |
447 | | |
448 | | namespace binding_detail { |
449 | | struct FastPushSubscriptionOptionsInit : public PushSubscriptionOptionsInit |
450 | | { |
451 | | inline FastPushSubscriptionOptionsInit() |
452 | | : PushSubscriptionOptionsInit(FastDictionaryInitializer()) |
453 | 0 | { |
454 | 0 | // Doesn't matter what int we pass to the parent constructor |
455 | 0 | } |
456 | | }; |
457 | | } // namespace binding_detail |
458 | | |
459 | | |
460 | | namespace PushManager_Binding { |
461 | | |
462 | | typedef mozilla::dom::PushManager NativeType; |
463 | | |
464 | | bool |
465 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj); |
466 | | |
467 | | const JSClass* |
468 | | GetJSClass(); |
469 | | |
470 | | bool |
471 | | Wrap(JSContext* aCx, mozilla::dom::PushManager* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector); |
472 | | |
473 | | template <class T> |
474 | | inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto) |
475 | 0 | { |
476 | 0 | JS::Rooted<JSObject*> reflector(aCx); |
477 | 0 | return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr; |
478 | 0 | } |
479 | | |
480 | | // We declare this as an array so that retrieving a pointer to this |
481 | | // binding's property hooks only requires compile/link-time resolvable |
482 | | // address arithmetic. Declaring it as a pointer instead would require |
483 | | // doing a run-time load to fetch a pointer to this binding's property |
484 | | // hooks. And then structures which embedded a pointer to this structure |
485 | | // would require a run-time load for proper initialization, which would |
486 | | // then induce static constructors. Lots of static constructors. |
487 | | extern const NativePropertyHooks sNativePropertyHooks[]; |
488 | | |
489 | | void |
490 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal); |
491 | | |
492 | | inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx) |
493 | 0 | { |
494 | 0 | /* Get the interface prototype object for this class. This will create the |
495 | 0 | object as needed. */ |
496 | 0 | return GetPerInterfaceObjectHandle(aCx, prototypes::id::PushManager, |
497 | 0 | &CreateInterfaceObjects, |
498 | 0 | /* aDefineOnGlobal = */ true); |
499 | 0 |
|
500 | 0 | } |
501 | | |
502 | | inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true) |
503 | 0 | { |
504 | 0 | /* Get the interface object for this class. This will create the object as |
505 | 0 | needed. */ |
506 | 0 |
|
507 | 0 | return GetPerInterfaceObjectHandle(aCx, constructors::id::PushManager, |
508 | 0 | &CreateInterfaceObjects, |
509 | 0 | aDefineOnGlobal); |
510 | 0 | } |
511 | | |
512 | | JSObject* |
513 | | GetConstructorObject(JSContext* aCx); |
514 | | |
515 | | } // namespace PushManager_Binding |
516 | | |
517 | | |
518 | | |
519 | | namespace PushManagerImpl_Binding { |
520 | | |
521 | | typedef mozilla::dom::PushManagerImpl NativeType; |
522 | | |
523 | | bool |
524 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj); |
525 | | |
526 | | const JSClass* |
527 | | GetJSClass(); |
528 | | |
529 | | bool |
530 | | Wrap(JSContext* aCx, mozilla::dom::PushManagerImpl* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector); |
531 | | |
532 | | template <class T> |
533 | | inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto) |
534 | 0 | { |
535 | 0 | JS::Rooted<JSObject*> reflector(aCx); |
536 | 0 | return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr; |
537 | 0 | } |
538 | | |
539 | | // We declare this as an array so that retrieving a pointer to this |
540 | | // binding's property hooks only requires compile/link-time resolvable |
541 | | // address arithmetic. Declaring it as a pointer instead would require |
542 | | // doing a run-time load to fetch a pointer to this binding's property |
543 | | // hooks. And then structures which embedded a pointer to this structure |
544 | | // would require a run-time load for proper initialization, which would |
545 | | // then induce static constructors. Lots of static constructors. |
546 | | extern const NativePropertyHooks sNativePropertyHooks[]; |
547 | | |
548 | | void |
549 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal); |
550 | | |
551 | | inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx) |
552 | 0 | { |
553 | 0 | /* Get the interface prototype object for this class. This will create the |
554 | 0 | object as needed. */ |
555 | 0 | return GetPerInterfaceObjectHandle(aCx, prototypes::id::PushManagerImpl, |
556 | 0 | &CreateInterfaceObjects, |
557 | 0 | /* aDefineOnGlobal = */ true); |
558 | 0 |
|
559 | 0 | } |
560 | | |
561 | | inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true) |
562 | 0 | { |
563 | 0 | /* Get the interface object for this class. This will create the object as |
564 | 0 | needed. */ |
565 | 0 |
|
566 | 0 | return GetPerInterfaceObjectHandle(aCx, constructors::id::PushManagerImpl, |
567 | 0 | &CreateInterfaceObjects, |
568 | 0 | aDefineOnGlobal); |
569 | 0 | } |
570 | | |
571 | | JSObject* |
572 | | GetConstructorObject(JSContext* aCx); |
573 | | |
574 | | } // namespace PushManagerImpl_Binding |
575 | | |
576 | | |
577 | | |
578 | | class PushManagerImplJSImpl : public CallbackInterface |
579 | | { |
580 | | public: |
581 | | explicit inline PushManagerImplJSImpl(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal) |
582 | | : CallbackInterface(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal) |
583 | 0 | { |
584 | 0 | } |
585 | | |
586 | | explicit inline PushManagerImplJSImpl(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& ) |
587 | | : CallbackInterface(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
588 | 0 | { |
589 | 0 | } |
590 | | |
591 | | explicit inline PushManagerImplJSImpl(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal) |
592 | | : CallbackInterface(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal) |
593 | 0 | { |
594 | 0 | } |
595 | | |
596 | | already_AddRefed<Promise> Subscribe(const PushSubscriptionOptionsInit& options, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
597 | | |
598 | | already_AddRefed<Promise> GetSubscription(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
599 | | |
600 | | already_AddRefed<Promise> PermissionState(const PushSubscriptionOptionsInit& options, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
601 | | |
602 | | void __Init(const nsAString& scope, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
603 | | |
604 | | inline bool |
605 | | operator==(const PushManagerImplJSImpl& aOther) const |
606 | 0 | { |
607 | 0 | return CallbackInterface::operator==(aOther); |
608 | 0 | } |
609 | | |
610 | | private: |
611 | | static bool |
612 | | InitIds(JSContext* cx, PushManagerImplAtoms* atomsCache); |
613 | | }; |
614 | | |
615 | | |
616 | | class PushManagerImpl final : public nsSupportsWeakReference, |
617 | | public nsWrapperCache |
618 | | { |
619 | | public: |
620 | | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
621 | | NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PushManagerImpl) |
622 | | |
623 | | private: |
624 | | RefPtr<PushManagerImplJSImpl> mImpl; |
625 | | nsCOMPtr<nsIGlobalObject> mParent; |
626 | | |
627 | | public: |
628 | | PushManagerImpl(JS::Handle<JSObject*> aJSImplObject, JS::Handle<JSObject*> aJSImplGlobal, nsIGlobalObject* aParent); |
629 | | |
630 | | private: |
631 | | ~PushManagerImpl(); |
632 | | |
633 | | public: |
634 | | nsISupports* GetParentObject() const; |
635 | | |
636 | | virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; |
637 | | |
638 | | static already_AddRefed<PushManagerImpl> Constructor(const GlobalObject& global, JSContext* cx, const nsAString& scope, ErrorResult& aRv, JS::Handle<JSObject*> aGivenProto = nullptr); |
639 | | |
640 | | // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee). |
641 | | already_AddRefed<Promise> Subscribe(const PushSubscriptionOptionsInit& options, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
642 | | |
643 | | // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee). |
644 | | already_AddRefed<Promise> GetSubscription(ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
645 | | |
646 | | // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee). |
647 | | already_AddRefed<Promise> PermissionState(const PushSubscriptionOptionsInit& options, ErrorResult& aRv, JS::Realm* aRealm = nullptr); |
648 | | |
649 | | static bool |
650 | | _Create(JSContext* cx, unsigned argc, JS::Value* vp); |
651 | | }; |
652 | | |
653 | | |
654 | | } // namespace dom |
655 | | } // namespace mozilla |
656 | | |
657 | | #endif // mozilla_dom_PushManagerBinding_h |