/work/obj-fuzz/ipc/ipdl/PCacheStorageParent.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | // |
2 | | // Automatically generated by ipdlc. |
3 | | // Edit at your own risk |
4 | | // |
5 | | |
6 | | |
7 | | #include "mozilla/dom/cache/PCacheStorageParent.h" |
8 | | |
9 | | #include "mozilla/ipc/PBackgroundParent.h" |
10 | | #include "mozilla/dom/cache/PCacheParent.h" |
11 | | #include "mozilla/dom/cache/PCacheOpParent.h" |
12 | | #include "mozilla/dom/cache/PCacheStreamControlParent.h" |
13 | | #include "mozilla/ipc/PFileDescriptorSetParent.h" |
14 | | #include "mozilla/ipc/PChildToParentStreamParent.h" |
15 | | #include "mozilla/ipc/PParentToChildStreamParent.h" |
16 | | |
17 | | #include "nsIFile.h" |
18 | | #include "GeckoProfiler.h" |
19 | | |
20 | | namespace mozilla { |
21 | | namespace dom { |
22 | | namespace cache { |
23 | | |
24 | | |
25 | | auto PCacheStorageParent::RecvPCacheOpConstructor( |
26 | | PCacheOpParent* actor, |
27 | | const CacheOpArgs& aOpArgs) -> mozilla::ipc::IPCResult |
28 | 0 | { |
29 | 0 | return IPC_OK(); |
30 | 0 | } |
31 | | |
32 | | auto PCacheStorageParent::ActorDestroy(ActorDestroyReason aWhy) -> void |
33 | 0 | { |
34 | 0 | } |
35 | | |
36 | | MOZ_IMPLICIT PCacheStorageParent::PCacheStorageParent() : |
37 | | mozilla::ipc::IProtocol(mozilla::ipc::ParentSide), |
38 | | mLivenessState(mozilla::ipc::LivenessState::Dead) |
39 | 0 | { |
40 | 0 | MOZ_COUNT_CTOR(PCacheStorageParent); |
41 | 0 | } |
42 | | |
43 | | PCacheStorageParent::~PCacheStorageParent() |
44 | 0 | { |
45 | 0 | MOZ_COUNT_DTOR(PCacheStorageParent); |
46 | 0 | } |
47 | | |
48 | | auto PCacheStorageParent::Manager() const -> PBackgroundParent* |
49 | 0 | { |
50 | 0 | return static_cast<PBackgroundParent*>(IProtocol::Manager()); |
51 | 0 | } |
52 | | |
53 | | auto PCacheStorageParent::ManagedPCacheOpParent(nsTArray<PCacheOpParent*>& aArr) const -> void |
54 | 0 | { |
55 | 0 | (mManagedPCacheOpParent).ToArray(aArr); |
56 | 0 | } |
57 | | |
58 | | auto PCacheStorageParent::ManagedPCacheOpParent() const -> const ManagedContainer<PCacheOpParent>& |
59 | 0 | { |
60 | 0 | return mManagedPCacheOpParent; |
61 | 0 | } |
62 | | |
63 | | auto PCacheStorageParent::Send__delete__(PCacheStorageParent* actor) -> bool |
64 | 0 | { |
65 | 0 | if ((!(actor))) { |
66 | 0 | return false; |
67 | 0 | } |
68 | 0 | |
69 | 0 | IPC::Message* msg__ = PCacheStorage::Msg___delete__((actor)->Id()); |
70 | 0 |
|
71 | 0 | MOZ_RELEASE_ASSERT(actor, "NULL actor value passed to non-nullable param"); |
72 | 0 | WriteIPDLParam(msg__, actor, actor); |
73 | 0 | // Sentinel = 'actor' |
74 | 0 | (msg__)->WriteSentinel(875202478); |
75 | 0 |
|
76 | 0 |
|
77 | 0 |
|
78 | 0 | if (mozilla::ipc::LoggingEnabledFor("PCacheStorageParent")) { |
79 | 0 | mozilla::ipc::LogMessageForProtocol("PCacheStorageParent", (actor)->OtherPid(), "Sending ", (msg__)->type(), mozilla::ipc::MessageDirection::eSending); |
80 | 0 | } |
81 | 0 | AUTO_PROFILER_LABEL("PCacheStorage::Msg___delete__", OTHER); |
82 | 0 | if ((!(StateTransition(true, (&((actor)->mLivenessState)))))) { |
83 | 0 | mozilla::ipc::LogicError("Transition error"); |
84 | 0 | } |
85 | 0 |
|
86 | 0 | bool sendok__ = ((actor)->GetIPCChannel())->Send(msg__); |
87 | 0 |
|
88 | 0 | IProtocol* mgr = (actor)->Manager(); |
89 | 0 | (actor)->DestroySubtree(Deletion); |
90 | 0 | (actor)->DeallocSubtree(); |
91 | 0 | (mgr)->RemoveManagee(PCacheStorageMsgStart, actor); |
92 | 0 | return sendok__; |
93 | 0 | } |
94 | | |
95 | | auto PCacheStorageParent::RemoveManagee( |
96 | | int32_t aProtocolId, |
97 | | IProtocol* aListener) -> void |
98 | 0 | { |
99 | 0 | switch (aProtocolId) { |
100 | 0 | case PCacheOpMsgStart: |
101 | 0 | { |
102 | 0 | PCacheOpParent* actor = static_cast<PCacheOpParent*>(aListener); |
103 | 0 | auto& container = mManagedPCacheOpParent; |
104 | 0 | MOZ_RELEASE_ASSERT((container).Contains(actor), "actor not managed by this!"); |
105 | 0 |
|
106 | 0 | (container).RemoveEntry(actor); |
107 | 0 | DeallocPCacheOpParent(actor); |
108 | 0 | return; |
109 | 0 | } |
110 | 0 | default: |
111 | 0 | { |
112 | 0 | FatalError("unreached"); |
113 | 0 | return; |
114 | 0 | } |
115 | 0 | } |
116 | 0 | } |
117 | | |
118 | | auto PCacheStorageParent::OnMessageReceived(const Message& msg__) -> PCacheStorageParent::Result |
119 | 0 | { |
120 | 0 | switch ((msg__).type()) { |
121 | 0 | case PCacheStorage::Msg_PCacheOpConstructor__ID: |
122 | 0 | { |
123 | 0 | if (mozilla::ipc::LoggingEnabledFor("PCacheStorageParent")) { |
124 | 0 | mozilla::ipc::LogMessageForProtocol("PCacheStorageParent", OtherPid(), "Received ", ((&(msg__)))->type(), mozilla::ipc::MessageDirection::eReceiving); |
125 | 0 | } |
126 | 0 | AUTO_PROFILER_LABEL("PCacheStorage::Msg_PCacheOpConstructor", OTHER); |
127 | 0 |
|
128 | 0 | PickleIterator iter__(msg__); |
129 | 0 | ActorHandle handle__; |
130 | 0 | PCacheOpParent* actor; |
131 | 0 | CacheOpArgs aOpArgs; |
132 | 0 |
|
133 | 0 | if ((!(ReadIPDLParam((&(msg__)), (&(iter__)), this, (&(handle__)))))) { |
134 | 0 | FatalError("Error deserializing 'ActorHandle'"); |
135 | 0 | return MsgValueError; |
136 | 0 | } |
137 | 0 | // Sentinel = 'actor' |
138 | 0 | if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 875202478)))) { |
139 | 0 | mozilla::ipc::SentinelReadError("Error deserializing 'ActorHandle'"); |
140 | 0 | return MsgValueError; |
141 | 0 | } |
142 | 0 | if ((!(ReadIPDLParam((&(msg__)), (&(iter__)), this, (&(aOpArgs)))))) { |
143 | 0 | FatalError("Error deserializing 'CacheOpArgs'"); |
144 | 0 | return MsgValueError; |
145 | 0 | } |
146 | 0 | // Sentinel = 'aOpArgs' |
147 | 0 | if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 2628124652)))) { |
148 | 0 | mozilla::ipc::SentinelReadError("Error deserializing 'CacheOpArgs'"); |
149 | 0 | return MsgValueError; |
150 | 0 | } |
151 | 0 | (msg__).EndRead(iter__, (msg__).type()); |
152 | 0 | if ((!(StateTransition(false, (&(mLivenessState)))))) { |
153 | 0 | FatalError("Transition error"); |
154 | 0 | return MsgValueError; |
155 | 0 | } |
156 | 0 | actor = AllocPCacheOpParent(aOpArgs); |
157 | 0 | if ((!(actor))) { |
158 | 0 | NS_WARNING("Error constructing actor PCacheOpParent"); |
159 | 0 | return MsgValueError; |
160 | 0 | } |
161 | 0 | (actor)->SetManagerAndRegister(this, (handle__).mId); |
162 | 0 | (mManagedPCacheOpParent).PutEntry(actor); |
163 | 0 | (actor)->mLivenessState = mozilla::ipc::LivenessState::Start; |
164 | 0 |
|
165 | 0 | if ((!(RecvPCacheOpConstructor(actor, aOpArgs)))) { |
166 | 0 | mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!"); |
167 | 0 | // Error handled in mozilla::ipc::IPCResult |
168 | 0 | return MsgProcessingError; |
169 | 0 | } |
170 | 0 | |
171 | 0 | return MsgProcessed; |
172 | 0 | } |
173 | 0 | case PCacheStorage::Msg_Teardown__ID: |
174 | 0 | { |
175 | 0 | if (mozilla::ipc::LoggingEnabledFor("PCacheStorageParent")) { |
176 | 0 | mozilla::ipc::LogMessageForProtocol("PCacheStorageParent", OtherPid(), "Received ", ((&(msg__)))->type(), mozilla::ipc::MessageDirection::eReceiving); |
177 | 0 | } |
178 | 0 | AUTO_PROFILER_LABEL("PCacheStorage::Msg_Teardown", OTHER); |
179 | 0 |
|
180 | 0 | if ((!(StateTransition(false, (&(mLivenessState)))))) { |
181 | 0 | FatalError("Transition error"); |
182 | 0 | return MsgValueError; |
183 | 0 | } |
184 | 0 | if ((!(RecvTeardown()))) { |
185 | 0 | mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!"); |
186 | 0 | // Error handled in mozilla::ipc::IPCResult |
187 | 0 | return MsgProcessingError; |
188 | 0 | } |
189 | 0 | |
190 | 0 | return MsgProcessed; |
191 | 0 | } |
192 | 0 | case PCacheStorage::Reply___delete____ID: |
193 | 0 | { |
194 | 0 | return MsgProcessed; |
195 | 0 | } |
196 | 0 | default: |
197 | 0 | { |
198 | 0 | return MsgNotKnown; |
199 | 0 | } |
200 | 0 | } |
201 | 0 | } |
202 | | |
203 | | auto PCacheStorageParent::OnMessageReceived( |
204 | | const Message& msg__, |
205 | | Message*& reply__) -> PCacheStorageParent::Result |
206 | 0 | { |
207 | 0 | return MsgNotKnown; |
208 | 0 | } |
209 | | |
210 | | auto PCacheStorageParent::OnCallReceived( |
211 | | const Message& msg__, |
212 | | Message*& reply__) -> PCacheStorageParent::Result |
213 | 0 | { |
214 | 0 | MOZ_ASSERT_UNREACHABLE("message protocol not supported"); |
215 | 0 | return MsgNotKnown; |
216 | 0 | } |
217 | | |
218 | | auto PCacheStorageParent::GetProtocolTypeId() -> int32_t |
219 | 0 | { |
220 | 0 | return PCacheStorageMsgStart; |
221 | 0 | } |
222 | | |
223 | | auto PCacheStorageParent::DestroySubtree(ActorDestroyReason why) -> void |
224 | 0 | { |
225 | 0 | // Unregister from our manager. |
226 | 0 | Unregister(Id()); |
227 | 0 |
|
228 | 0 | ActorDestroyReason subtreewhy = (((why) == (Deletion)) || ((why) == (FailedConstructor)) ? AncestorDeletion : why); |
229 | 0 |
|
230 | 0 | { |
231 | 0 | // Recursively shutting down PCacheOp kids |
232 | 0 | nsTArray<PCacheOpParent*> kids; |
233 | 0 | // Accumulate kids into a stable structure to iterate over |
234 | 0 | ManagedPCacheOpParent(kids); |
235 | 0 | for (auto& kid : kids) { |
236 | 0 | // Guarding against a child removing a sibling from the list during the iteration. |
237 | 0 | if ((mManagedPCacheOpParent).Contains(kid)) { |
238 | 0 | (kid)->DestroySubtree(subtreewhy); |
239 | 0 | } |
240 | 0 | } |
241 | 0 | } |
242 | 0 |
|
243 | 0 | // Reject owning pending responses. |
244 | 0 | (GetIPCChannel())->RejectPendingResponsesForActor(this); |
245 | 0 |
|
246 | 0 | // Finally, destroy "us". |
247 | 0 | ActorDestroy(why); |
248 | 0 | } |
249 | | |
250 | | auto PCacheStorageParent::DeallocSubtree() -> void |
251 | 0 | { |
252 | 0 | { |
253 | 0 | // Recursively deleting PCacheOp kids |
254 | 0 | for (auto iter = (mManagedPCacheOpParent).Iter(); (!((iter).Done())); (iter).Next()) { |
255 | 0 | (((iter).Get())->GetKey())->DeallocSubtree(); |
256 | 0 | } |
257 | 0 |
|
258 | 0 | for (auto iter = (mManagedPCacheOpParent).Iter(); (!((iter).Done())); (iter).Next()) { |
259 | 0 | DeallocPCacheOpParent(((iter).Get())->GetKey()); |
260 | 0 | } |
261 | 0 | (mManagedPCacheOpParent).Clear(); |
262 | 0 | } |
263 | 0 | } |
264 | | |
265 | | |
266 | | |
267 | | } // namespace cache |
268 | | } // namespace dom |
269 | | } // namespace mozilla |
270 | | namespace mozilla { |
271 | | namespace ipc { |
272 | | auto IPDLParamTraits<mozilla::dom::cache::PCacheStorageParent>::Write( |
273 | | IPC::Message* aMsg, |
274 | | mozilla::ipc::IProtocol* aActor, |
275 | | const paramType& aVar) -> void |
276 | 0 | { |
277 | 0 | int32_t id; |
278 | 0 | if ((!(aVar))) { |
279 | 0 | id = 0; |
280 | 0 | } |
281 | 0 | else { |
282 | 0 | id = (aVar)->Id(); |
283 | 0 | if ((1) == (id)) { |
284 | 0 | (aActor)->FatalError("actor has been |delete|d"); |
285 | 0 | } |
286 | 0 | } |
287 | 0 | WriteIPDLParam(aMsg, aActor, id); |
288 | 0 | } |
289 | | |
290 | | auto IPDLParamTraits<mozilla::dom::cache::PCacheStorageParent>::Read( |
291 | | const IPC::Message* aMsg, |
292 | | PickleIterator* aIter, |
293 | | mozilla::ipc::IProtocol* aActor, |
294 | | paramType* aVar) -> bool |
295 | 0 | { |
296 | 0 | mozilla::Maybe<mozilla::ipc::IProtocol*> actor = (aActor)->ReadActor(aMsg, aIter, true, "PCacheStorage", PCacheStorageMsgStart); |
297 | 0 | if ((actor).isNothing()) { |
298 | 0 | return false; |
299 | 0 | } |
300 | 0 | |
301 | 0 | (*(aVar)) = static_cast<mozilla::dom::cache::PCacheStorageParent*>((actor).value()); |
302 | 0 | return true; |
303 | 0 | } |
304 | | |
305 | | } // namespace ipc |
306 | | } // namespace mozilla |