/work/obj-fuzz/dist/include/mozilla/dom/FetchObserverBinding.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM FetchObserver.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #ifndef mozilla_dom_FetchObserverBinding_h |
4 | | #define mozilla_dom_FetchObserverBinding_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/CallbackInterface.h" |
12 | | #include "mozilla/dom/Nullable.h" |
13 | | #include "mozilla/dom/PrototypeList.h" |
14 | | #include "mozilla/dom/ToJSValue.h" |
15 | | |
16 | | namespace mozilla { |
17 | | namespace dom { |
18 | | |
19 | | class FetchObserver; |
20 | | struct FetchObserverAtoms; |
21 | | struct NativePropertyHooks; |
22 | | class ObserverCallback; |
23 | | struct ObserverCallbackAtoms; |
24 | | class ProtoAndIfaceCache; |
25 | | |
26 | | } // namespace dom |
27 | | } // namespace mozilla |
28 | | |
29 | | namespace mozilla { |
30 | | namespace dom { |
31 | | |
32 | | enum class FetchState : uint8_t { |
33 | | Requesting, |
34 | | Responding, |
35 | | Aborted, |
36 | | Errored, |
37 | | Complete, |
38 | | EndGuard_ |
39 | | }; |
40 | | |
41 | | namespace FetchStateValues { |
42 | | extern const EnumEntry strings[6]; |
43 | | } // namespace FetchStateValues |
44 | | |
45 | | bool |
46 | | ToJSValue(JSContext* aCx, FetchState aArgument, JS::MutableHandle<JS::Value> aValue); |
47 | | |
48 | | |
49 | | namespace FetchObserver_Binding { |
50 | | |
51 | | typedef mozilla::dom::FetchObserver NativeType; |
52 | | |
53 | | bool |
54 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj); |
55 | | |
56 | | const JSClass* |
57 | | GetJSClass(); |
58 | | |
59 | | bool |
60 | | Wrap(JSContext* aCx, mozilla::dom::FetchObserver* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector); |
61 | | |
62 | | template <class T> |
63 | | inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto) |
64 | 0 | { |
65 | 0 | JS::Rooted<JSObject*> reflector(aCx); |
66 | 0 | return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr; |
67 | 0 | } |
68 | | |
69 | | // We declare this as an array so that retrieving a pointer to this |
70 | | // binding's property hooks only requires compile/link-time resolvable |
71 | | // address arithmetic. Declaring it as a pointer instead would require |
72 | | // doing a run-time load to fetch a pointer to this binding's property |
73 | | // hooks. And then structures which embedded a pointer to this structure |
74 | | // would require a run-time load for proper initialization, which would |
75 | | // then induce static constructors. Lots of static constructors. |
76 | | extern const NativePropertyHooks sNativePropertyHooks[]; |
77 | | |
78 | | void |
79 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal); |
80 | | |
81 | | inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx) |
82 | 0 | { |
83 | 0 | /* Get the interface prototype object for this class. This will create the |
84 | 0 | object as needed. */ |
85 | 0 | return GetPerInterfaceObjectHandle(aCx, prototypes::id::FetchObserver, |
86 | 0 | &CreateInterfaceObjects, |
87 | 0 | /* aDefineOnGlobal = */ true); |
88 | 0 |
|
89 | 0 | } |
90 | | |
91 | | inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true) |
92 | 0 | { |
93 | 0 | /* Get the interface object for this class. This will create the object as |
94 | 0 | needed. */ |
95 | 0 |
|
96 | 0 | return GetPerInterfaceObjectHandle(aCx, constructors::id::FetchObserver, |
97 | 0 | &CreateInterfaceObjects, |
98 | 0 | aDefineOnGlobal); |
99 | 0 | } |
100 | | |
101 | | JSObject* |
102 | | GetConstructorObject(JSContext* aCx); |
103 | | |
104 | | } // namespace FetchObserver_Binding |
105 | | |
106 | | |
107 | | |
108 | | class ObserverCallback : public CallbackInterface |
109 | | { |
110 | | public: |
111 | | explicit inline ObserverCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal) |
112 | | : CallbackInterface(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal) |
113 | 0 | { |
114 | 0 | } |
115 | | |
116 | | explicit inline ObserverCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& ) |
117 | | : CallbackInterface(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
118 | 0 | { |
119 | 0 | } |
120 | | |
121 | | explicit inline ObserverCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal) |
122 | | : CallbackInterface(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal) |
123 | 0 | { |
124 | 0 | } |
125 | | |
126 | | template <typename T> |
127 | | inline void |
128 | | HandleEvent(const T& thisVal, FetchObserver& observer, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
129 | | { |
130 | | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
131 | | if (!aExecutionReason) { |
132 | | aExecutionReason = "ObserverCallback.handleEvent"; |
133 | | } |
134 | | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
135 | | if (!s.GetContext()) { |
136 | | MOZ_ASSERT(aRv.Failed()); |
137 | | return; |
138 | | } |
139 | | JS::Rooted<JS::Value> thisValJS(s.GetContext()); |
140 | | if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) { |
141 | | aRv.Throw(NS_ERROR_FAILURE); |
142 | | return; |
143 | | } |
144 | | return HandleEvent(s.GetContext(), thisValJS, observer, aRv); |
145 | | } |
146 | | |
147 | | inline void |
148 | | HandleEvent(FetchObserver& observer, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
149 | 0 | { |
150 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
151 | 0 | if (!aExecutionReason) { |
152 | 0 | aExecutionReason = "ObserverCallback.handleEvent"; |
153 | 0 | } |
154 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
155 | 0 | if (!s.GetContext()) { |
156 | 0 | MOZ_ASSERT(aRv.Failed()); |
157 | 0 | return; |
158 | 0 | } |
159 | 0 | return HandleEvent(s.GetContext(), JS::UndefinedHandleValue, observer, aRv); |
160 | 0 | } |
161 | | |
162 | | template <typename T> |
163 | | inline void |
164 | | HandleEvent(const T& thisVal, FetchObserver& observer, const char* aExecutionReason = nullptr) |
165 | | { |
166 | | return HandleEvent(thisVal, observer, IgnoreErrors(), aExecutionReason); |
167 | | } |
168 | | |
169 | | inline void |
170 | | HandleEvent(FetchObserver& observer, const char* aExecutionReason = nullptr) |
171 | 0 | { |
172 | 0 | return HandleEvent(observer, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr); |
173 | 0 | } |
174 | | |
175 | | inline bool |
176 | | operator==(const ObserverCallback& aOther) const |
177 | 0 | { |
178 | 0 | return CallbackInterface::operator==(aOther); |
179 | 0 | } |
180 | | |
181 | | private: |
182 | | void HandleEvent(JSContext* cx, JS::Handle<JS::Value> aThisVal, FetchObserver& observer, ErrorResult& aRv); |
183 | | |
184 | | static bool |
185 | | InitIds(JSContext* cx, ObserverCallbackAtoms* atomsCache); |
186 | | }; |
187 | | |
188 | | |
189 | | namespace binding_detail { |
190 | | class FastObserverCallback : public ObserverCallback |
191 | | { |
192 | | public: |
193 | | explicit inline FastObserverCallback(JSObject* aCallback, JSObject* aCallbackGlobal) |
194 | | : ObserverCallback(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
195 | 0 | { |
196 | 0 | } |
197 | | |
198 | | inline void |
199 | | Trace(JSTracer* aTracer) |
200 | 0 | { |
201 | 0 | ObserverCallback::Trace(aTracer); |
202 | 0 | } |
203 | | |
204 | | inline void |
205 | | FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx) |
206 | 0 | { |
207 | 0 | ObserverCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx); |
208 | 0 | } |
209 | | }; |
210 | | } // namespace binding_detail |
211 | | |
212 | | |
213 | | } // namespace dom |
214 | | } // namespace mozilla |
215 | | |
216 | | #endif // mozilla_dom_FetchObserverBinding_h |