1 : //
2 : // Automatically generated by ipdlc.
3 : // Edit at your own risk
4 : //
5 :
6 :
7 : #include "mozilla/net/PFTPChannelParent.h"
8 :
9 : #include "mozilla/net/PNeckoParent.h"
10 :
11 : typedef IPC::Message Message;
12 : typedef mozilla::ipc::RPCChannel Channel;
13 : typedef mozilla::ipc::RPCChannel::RPCListener ChannelListener;
14 : typedef base::ProcessHandle ProcessHandle;
15 : typedef mozilla::ipc::AsyncChannel AsyncChannel;
16 : typedef mozilla::ipc::SharedMemory SharedMemory;
17 : typedef mozilla::ipc::Trigger Trigger;
18 : typedef mozilla::ipc::ActorHandle ActorHandle;
19 : typedef mozilla::ipc::Shmem Shmem;
20 : typedef IPC::URI URI;
21 : typedef IPC::InputStream InputStream;
22 : using mozilla::net::PNeckoParent;
23 :
24 : namespace mozilla {
25 : namespace net {
26 :
27 :
28 : bool
29 0 : PFTPChannelParent::Recv__delete__()
30 : {
31 0 : return true;
32 : }
33 :
34 : void
35 0 : PFTPChannelParent::ActorDestroy(ActorDestroyReason why)
36 : {
37 0 : }
38 :
39 0 : PFTPChannelParent::PFTPChannelParent() :
40 : mId(0),
41 0 : mState(PFTPChannel::__Dead)
42 : {
43 0 : MOZ_COUNT_CTOR(PFTPChannelParent);
44 0 : }
45 :
46 0 : PFTPChannelParent::~PFTPChannelParent()
47 : {
48 0 : MOZ_COUNT_DTOR(PFTPChannelParent);
49 0 : }
50 :
51 : PNeckoParent*
52 0 : PFTPChannelParent::Manager()
53 : {
54 0 : return static_cast<PNeckoParent*>(mManager);
55 : }
56 :
57 : PFTPChannel::State
58 0 : PFTPChannelParent::state()
59 : {
60 0 : return mState;
61 : }
62 :
63 : bool
64 0 : PFTPChannelParent::SendOnStartRequest(
65 : const PRInt32& aContentLength,
66 : const nsCString& aContentType,
67 : const PRTime& aLastModified,
68 : const nsCString& aEntityID,
69 : const URI& aURI)
70 : {
71 0 : PFTPChannel::Msg_OnStartRequest* __msg = new PFTPChannel::Msg_OnStartRequest();
72 :
73 0 : Write(aContentLength, __msg);
74 0 : Write(aContentType, __msg);
75 0 : Write(aLastModified, __msg);
76 0 : Write(aEntityID, __msg);
77 0 : Write(aURI, __msg);
78 :
79 0 : (__msg)->set_routing_id(mId);
80 :
81 :
82 :
83 0 : if (mozilla::ipc::LoggingEnabled()) {
84 0 : (__msg)->Log("[PFTPChannelParent] Sending ", stderr);
85 : }
86 0 : if ((!(PFTPChannel::Transition(mState, Trigger(Trigger::Send, PFTPChannel::Msg_OnStartRequest__ID), (&(mState)))))) {
87 0 : NS_WARNING("bad state transition!");
88 : }
89 :
90 0 : bool __sendok = (mChannel)->Send(__msg);
91 0 : return __sendok;
92 : }
93 :
94 : bool
95 0 : PFTPChannelParent::SendOnDataAvailable(
96 : const nsCString& data,
97 : const PRUint32& offset,
98 : const PRUint32& count)
99 : {
100 0 : PFTPChannel::Msg_OnDataAvailable* __msg = new PFTPChannel::Msg_OnDataAvailable();
101 :
102 0 : Write(data, __msg);
103 0 : Write(offset, __msg);
104 0 : Write(count, __msg);
105 :
106 0 : (__msg)->set_routing_id(mId);
107 :
108 :
109 :
110 0 : if (mozilla::ipc::LoggingEnabled()) {
111 0 : (__msg)->Log("[PFTPChannelParent] Sending ", stderr);
112 : }
113 0 : if ((!(PFTPChannel::Transition(mState, Trigger(Trigger::Send, PFTPChannel::Msg_OnDataAvailable__ID), (&(mState)))))) {
114 0 : NS_WARNING("bad state transition!");
115 : }
116 :
117 0 : bool __sendok = (mChannel)->Send(__msg);
118 0 : return __sendok;
119 : }
120 :
121 : bool
122 0 : PFTPChannelParent::SendOnStopRequest(const nsresult& statusCode)
123 : {
124 0 : PFTPChannel::Msg_OnStopRequest* __msg = new PFTPChannel::Msg_OnStopRequest();
125 :
126 0 : Write(statusCode, __msg);
127 :
128 0 : (__msg)->set_routing_id(mId);
129 :
130 :
131 :
132 0 : if (mozilla::ipc::LoggingEnabled()) {
133 0 : (__msg)->Log("[PFTPChannelParent] Sending ", stderr);
134 : }
135 0 : if ((!(PFTPChannel::Transition(mState, Trigger(Trigger::Send, PFTPChannel::Msg_OnStopRequest__ID), (&(mState)))))) {
136 0 : NS_WARNING("bad state transition!");
137 : }
138 :
139 0 : bool __sendok = (mChannel)->Send(__msg);
140 0 : return __sendok;
141 : }
142 :
143 : bool
144 0 : PFTPChannelParent::SendFailedAsyncOpen(const nsresult& statusCode)
145 : {
146 0 : PFTPChannel::Msg_FailedAsyncOpen* __msg = new PFTPChannel::Msg_FailedAsyncOpen();
147 :
148 0 : Write(statusCode, __msg);
149 :
150 0 : (__msg)->set_routing_id(mId);
151 :
152 :
153 :
154 0 : if (mozilla::ipc::LoggingEnabled()) {
155 0 : (__msg)->Log("[PFTPChannelParent] Sending ", stderr);
156 : }
157 0 : if ((!(PFTPChannel::Transition(mState, Trigger(Trigger::Send, PFTPChannel::Msg_FailedAsyncOpen__ID), (&(mState)))))) {
158 0 : NS_WARNING("bad state transition!");
159 : }
160 :
161 0 : bool __sendok = (mChannel)->Send(__msg);
162 0 : return __sendok;
163 : }
164 :
165 : bool
166 0 : PFTPChannelParent::SendDeleteSelf()
167 : {
168 0 : PFTPChannel::Msg_DeleteSelf* __msg = new PFTPChannel::Msg_DeleteSelf();
169 :
170 :
171 0 : (__msg)->set_routing_id(mId);
172 :
173 :
174 :
175 0 : if (mozilla::ipc::LoggingEnabled()) {
176 0 : (__msg)->Log("[PFTPChannelParent] Sending ", stderr);
177 : }
178 0 : if ((!(PFTPChannel::Transition(mState, Trigger(Trigger::Send, PFTPChannel::Msg_DeleteSelf__ID), (&(mState)))))) {
179 0 : NS_WARNING("bad state transition!");
180 : }
181 :
182 0 : bool __sendok = (mChannel)->Send(__msg);
183 0 : return __sendok;
184 : }
185 :
186 : int32
187 0 : PFTPChannelParent::Register(ChannelListener* aRouted)
188 : {
189 0 : return (mManager)->Register(aRouted);
190 : }
191 :
192 : int32
193 0 : PFTPChannelParent::RegisterID(
194 : ChannelListener* aRouted,
195 : int32 aId)
196 : {
197 0 : return (mManager)->RegisterID(aRouted, aId);
198 : }
199 :
200 : ChannelListener*
201 0 : PFTPChannelParent::Lookup(int32 aId)
202 : {
203 0 : return (mManager)->Lookup(aId);
204 : }
205 :
206 : void
207 0 : PFTPChannelParent::Unregister(int32 aId)
208 : {
209 0 : return (mManager)->Unregister(aId);
210 : }
211 :
212 : void
213 0 : PFTPChannelParent::RemoveManagee(
214 : int32 aProtocolId,
215 : ChannelListener* aListener)
216 : {
217 0 : NS_RUNTIMEABORT("unreached");
218 : return;
219 : }
220 :
221 : Shmem::SharedMemory*
222 0 : PFTPChannelParent::CreateSharedMemory(
223 : size_t aSize,
224 : Shmem::SharedMemory::SharedMemoryType type,
225 : bool unsafe,
226 : Shmem::id_t* aId)
227 : {
228 0 : return (mManager)->CreateSharedMemory(aSize, type, unsafe, aId);
229 : }
230 :
231 : bool
232 0 : PFTPChannelParent::AdoptSharedMemory(
233 : Shmem::SharedMemory* segment,
234 : Shmem::id_t* aId)
235 : {
236 0 : return (mManager)->AdoptSharedMemory(segment, aId);
237 : }
238 :
239 : Shmem::SharedMemory*
240 0 : PFTPChannelParent::LookupSharedMemory(Shmem::id_t aId)
241 : {
242 0 : return (mManager)->LookupSharedMemory(aId);
243 : }
244 :
245 : bool
246 0 : PFTPChannelParent::IsTrackingSharedMemory(Shmem::SharedMemory* segment)
247 : {
248 0 : return (mManager)->IsTrackingSharedMemory(segment);
249 : }
250 :
251 : bool
252 0 : PFTPChannelParent::DestroySharedMemory(Shmem& aShmem)
253 : {
254 0 : return (mManager)->DestroySharedMemory(aShmem);
255 : }
256 :
257 : ProcessHandle
258 0 : PFTPChannelParent::OtherProcess() const
259 : {
260 0 : return (mManager)->OtherProcess();
261 : }
262 :
263 : AsyncChannel*
264 0 : PFTPChannelParent::GetIPCChannel()
265 : {
266 0 : return mChannel;
267 : }
268 :
269 : PFTPChannelParent::Result
270 0 : PFTPChannelParent::OnMessageReceived(const Message& __msg)
271 : {
272 0 : switch ((__msg).type()) {
273 : case PFTPChannel::Msg___delete____ID:
274 : {
275 0 : (const_cast<Message&>(__msg)).set_name("PFTPChannel::Msg___delete__");
276 0 : if (mozilla::ipc::LoggingEnabled()) {
277 0 : (static_cast<const PFTPChannel::Msg___delete__*>((&(__msg))))->Log("[PFTPChannelParent] Received ", stderr);
278 : }
279 :
280 0 : void* __iter = 0;
281 : PFTPChannelParent* actor;
282 :
283 0 : if ((!(Read((&(actor)), (&(__msg)), (&(__iter)), false)))) {
284 0 : FatalError("error deserializing (better message TODO)");
285 0 : return MsgValueError;
286 : }
287 0 : (__msg).EndRead(__iter);
288 0 : if ((!(PFTPChannel::Transition(mState, Trigger(Trigger::Recv, PFTPChannel::Msg___delete____ID), (&(mState)))))) {
289 0 : NS_WARNING("bad state transition!");
290 : }
291 0 : if ((!(Recv__delete__()))) {
292 0 : return MsgProcessingError;
293 : }
294 :
295 0 : (actor)->DestroySubtree(Deletion);
296 0 : (actor)->DeallocSubtree();
297 0 : ((actor)->mManager)->RemoveManagee(PFTPChannelMsgStart, actor);
298 :
299 :
300 0 : return MsgProcessed;
301 : }
302 : case PFTPChannel::Msg_AsyncOpen__ID:
303 : {
304 0 : (const_cast<Message&>(__msg)).set_name("PFTPChannel::Msg_AsyncOpen");
305 0 : if (mozilla::ipc::LoggingEnabled()) {
306 0 : (static_cast<const PFTPChannel::Msg_AsyncOpen*>((&(__msg))))->Log("[PFTPChannelParent] Received ", stderr);
307 : }
308 :
309 0 : void* __iter = 0;
310 0 : URI uri;
311 : PRUint64 startPos;
312 0 : nsCString entityID;
313 0 : InputStream uploadStream;
314 :
315 0 : if ((!(Read((&(uri)), (&(__msg)), (&(__iter)))))) {
316 0 : FatalError("error deserializing (better message TODO)");
317 0 : return MsgValueError;
318 : }
319 0 : if ((!(Read((&(startPos)), (&(__msg)), (&(__iter)))))) {
320 0 : FatalError("error deserializing (better message TODO)");
321 0 : return MsgValueError;
322 : }
323 0 : if ((!(Read((&(entityID)), (&(__msg)), (&(__iter)))))) {
324 0 : FatalError("error deserializing (better message TODO)");
325 0 : return MsgValueError;
326 : }
327 0 : if ((!(Read((&(uploadStream)), (&(__msg)), (&(__iter)))))) {
328 0 : FatalError("error deserializing (better message TODO)");
329 0 : return MsgValueError;
330 : }
331 0 : (__msg).EndRead(__iter);
332 0 : if ((!(PFTPChannel::Transition(mState, Trigger(Trigger::Recv, PFTPChannel::Msg_AsyncOpen__ID), (&(mState)))))) {
333 0 : NS_WARNING("bad state transition!");
334 : }
335 0 : if ((!(RecvAsyncOpen(uri, startPos, entityID, uploadStream)))) {
336 0 : return MsgProcessingError;
337 : }
338 :
339 0 : return MsgProcessed;
340 : }
341 : case PFTPChannel::Msg_ConnectChannel__ID:
342 : {
343 0 : (const_cast<Message&>(__msg)).set_name("PFTPChannel::Msg_ConnectChannel");
344 0 : if (mozilla::ipc::LoggingEnabled()) {
345 0 : (static_cast<const PFTPChannel::Msg_ConnectChannel*>((&(__msg))))->Log("[PFTPChannelParent] Received ", stderr);
346 : }
347 :
348 0 : void* __iter = 0;
349 : PRUint32 channelId;
350 :
351 0 : if ((!(Read((&(channelId)), (&(__msg)), (&(__iter)))))) {
352 0 : FatalError("error deserializing (better message TODO)");
353 0 : return MsgValueError;
354 : }
355 0 : (__msg).EndRead(__iter);
356 0 : if ((!(PFTPChannel::Transition(mState, Trigger(Trigger::Recv, PFTPChannel::Msg_ConnectChannel__ID), (&(mState)))))) {
357 0 : NS_WARNING("bad state transition!");
358 : }
359 0 : if ((!(RecvConnectChannel(channelId)))) {
360 0 : return MsgProcessingError;
361 : }
362 :
363 0 : return MsgProcessed;
364 : }
365 : case PFTPChannel::Msg_Cancel__ID:
366 : {
367 0 : (const_cast<Message&>(__msg)).set_name("PFTPChannel::Msg_Cancel");
368 0 : if (mozilla::ipc::LoggingEnabled()) {
369 0 : (static_cast<const PFTPChannel::Msg_Cancel*>((&(__msg))))->Log("[PFTPChannelParent] Received ", stderr);
370 : }
371 :
372 0 : void* __iter = 0;
373 : nsresult status;
374 :
375 0 : if ((!(Read((&(status)), (&(__msg)), (&(__iter)))))) {
376 0 : FatalError("error deserializing (better message TODO)");
377 0 : return MsgValueError;
378 : }
379 0 : (__msg).EndRead(__iter);
380 0 : if ((!(PFTPChannel::Transition(mState, Trigger(Trigger::Recv, PFTPChannel::Msg_Cancel__ID), (&(mState)))))) {
381 0 : NS_WARNING("bad state transition!");
382 : }
383 0 : if ((!(RecvCancel(status)))) {
384 0 : return MsgProcessingError;
385 : }
386 :
387 0 : return MsgProcessed;
388 : }
389 : case PFTPChannel::Msg_Suspend__ID:
390 : {
391 0 : (const_cast<Message&>(__msg)).set_name("PFTPChannel::Msg_Suspend");
392 0 : if (mozilla::ipc::LoggingEnabled()) {
393 0 : (static_cast<const PFTPChannel::Msg_Suspend*>((&(__msg))))->Log("[PFTPChannelParent] Received ", stderr);
394 : }
395 :
396 0 : if ((!(PFTPChannel::Transition(mState, Trigger(Trigger::Recv, PFTPChannel::Msg_Suspend__ID), (&(mState)))))) {
397 0 : NS_WARNING("bad state transition!");
398 : }
399 0 : if ((!(RecvSuspend()))) {
400 0 : return MsgProcessingError;
401 : }
402 :
403 0 : return MsgProcessed;
404 : }
405 : case PFTPChannel::Msg_Resume__ID:
406 : {
407 0 : (const_cast<Message&>(__msg)).set_name("PFTPChannel::Msg_Resume");
408 0 : if (mozilla::ipc::LoggingEnabled()) {
409 0 : (static_cast<const PFTPChannel::Msg_Resume*>((&(__msg))))->Log("[PFTPChannelParent] Received ", stderr);
410 : }
411 :
412 0 : if ((!(PFTPChannel::Transition(mState, Trigger(Trigger::Recv, PFTPChannel::Msg_Resume__ID), (&(mState)))))) {
413 0 : NS_WARNING("bad state transition!");
414 : }
415 0 : if ((!(RecvResume()))) {
416 0 : return MsgProcessingError;
417 : }
418 :
419 0 : return MsgProcessed;
420 : }
421 : default:
422 : {
423 0 : return MsgNotKnown;
424 : }
425 : }
426 : }
427 :
428 : PFTPChannelParent::Result
429 0 : PFTPChannelParent::OnMessageReceived(
430 : const Message& __msg,
431 : Message*& __reply)
432 : {
433 0 : return MsgNotKnown;
434 : }
435 :
436 : PFTPChannelParent::Result
437 0 : PFTPChannelParent::OnCallReceived(
438 : const Message& __msg,
439 : Message*& __reply)
440 : {
441 0 : return MsgNotKnown;
442 : }
443 :
444 : void
445 0 : PFTPChannelParent::OnProcessingError(Result code)
446 : {
447 0 : NS_RUNTIMEABORT("`OnProcessingError' called on non-toplevel actor");
448 0 : }
449 :
450 : bool
451 0 : PFTPChannelParent::OnReplyTimeout()
452 : {
453 0 : NS_RUNTIMEABORT("`OnReplyTimeout' called on non-toplevel actor");
454 0 : return false;
455 : }
456 :
457 : void
458 0 : PFTPChannelParent::OnChannelClose()
459 : {
460 0 : NS_RUNTIMEABORT("`OnClose' called on non-toplevel actor");
461 0 : }
462 :
463 : void
464 0 : PFTPChannelParent::OnChannelError()
465 : {
466 0 : NS_RUNTIMEABORT("`OnError' called on non-toplevel actor");
467 0 : }
468 :
469 : void
470 0 : PFTPChannelParent::OnChannelConnected(int32 pid)
471 : {
472 0 : NS_RUNTIMEABORT("'OnConnected' called on non-toplevel actor");
473 0 : }
474 :
475 : bool
476 0 : PFTPChannelParent::AllocShmem(
477 : size_t aSize,
478 : Shmem::SharedMemory::SharedMemoryType aType,
479 : Shmem* aMem)
480 : {
481 : Shmem::id_t aId;
482 0 : nsAutoPtr<Shmem::SharedMemory> rawmem(CreateSharedMemory(aSize, aType, false, (&(aId))));
483 0 : if ((!(rawmem))) {
484 0 : return false;
485 : }
486 :
487 0 : (*(aMem)) = Shmem(Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead(), (rawmem).forget(), aId);
488 0 : return true;
489 : }
490 :
491 : bool
492 0 : PFTPChannelParent::AllocUnsafeShmem(
493 : size_t aSize,
494 : Shmem::SharedMemory::SharedMemoryType aType,
495 : Shmem* aMem)
496 : {
497 : Shmem::id_t aId;
498 0 : nsAutoPtr<Shmem::SharedMemory> rawmem(CreateSharedMemory(aSize, aType, true, (&(aId))));
499 0 : if ((!(rawmem))) {
500 0 : return false;
501 : }
502 :
503 0 : (*(aMem)) = Shmem(Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead(), (rawmem).forget(), aId);
504 0 : return true;
505 : }
506 :
507 : bool
508 0 : PFTPChannelParent::AdoptShmem(
509 : Shmem& aMem,
510 : Shmem* aOutMem)
511 : {
512 0 : Shmem::SharedMemory* rawmem = (aMem).Segment(Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead());
513 0 : if (((!(rawmem))) || (IsTrackingSharedMemory(rawmem))) {
514 0 : NS_RUNTIMEABORT("bad Shmem");
515 : }
516 :
517 : Shmem::id_t aId;
518 0 : if ((!(AdoptSharedMemory(rawmem, (&(aId)))))) {
519 0 : return false;
520 : }
521 :
522 0 : (*(aOutMem)) = Shmem(Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead(), rawmem, aId);
523 0 : return true;
524 : }
525 :
526 : bool
527 0 : PFTPChannelParent::DeallocShmem(Shmem& aMem)
528 : {
529 0 : bool ok = DestroySharedMemory(aMem);
530 0 : (aMem).forget(Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead());
531 0 : return ok;
532 : }
533 :
534 : void
535 0 : PFTPChannelParent::FatalError(const char* const msg) const
536 : {
537 : // Virtual method to prevent inlining.
538 : // This give us better error reporting.
539 : // See bug 589371
540 :
541 0 : NS_ERROR("IPDL error:");
542 0 : NS_ERROR(msg);
543 :
544 0 : NS_ERROR("[PFTPChannelParent] killing child side as a result");
545 :
546 0 : if ((!(base::KillProcess(OtherProcess(), base::PROCESS_END_KILLED_BY_USER, false)))) {
547 0 : NS_ERROR(" may have failed to kill child!");
548 : }
549 0 : }
550 :
551 : void
552 0 : PFTPChannelParent::DestroySubtree(ActorDestroyReason why)
553 : {
554 : // Unregister from our manager.
555 0 : Unregister(mId);
556 0 : mId = 1;
557 :
558 : // Finally, destroy "us".
559 0 : ActorDestroy(why);
560 0 : }
561 :
562 : void
563 0 : PFTPChannelParent::DeallocSubtree()
564 : {
565 0 : }
566 :
567 : void
568 0 : PFTPChannelParent::Write(
569 : PFTPChannelParent* __v,
570 : Message* __msg,
571 : bool __nullable)
572 : {
573 : int32 id;
574 0 : if ((!(__v))) {
575 0 : if ((!(__nullable))) {
576 0 : NS_RUNTIMEABORT("NULL actor value passed to non-nullable param");
577 : }
578 0 : id = 0;
579 : }
580 : else {
581 0 : id = (__v)->mId;
582 0 : if ((1) == (id)) {
583 0 : NS_RUNTIMEABORT("actor has been |delete|d");
584 : }
585 : }
586 :
587 0 : Write(id, __msg);
588 0 : }
589 :
590 : bool
591 0 : PFTPChannelParent::Read(
592 : PFTPChannelParent** __v,
593 : const Message* __msg,
594 : void** __iter,
595 : bool __nullable)
596 : {
597 : int32 id;
598 0 : if ((!(Read((&(id)), __msg, __iter)))) {
599 0 : return false;
600 : }
601 0 : if (((1) == (id)) || (((0) == (id)) && ((!(__nullable))))) {
602 0 : return false;
603 : }
604 :
605 0 : if ((0) == (id)) {
606 0 : (*(__v)) = 0;
607 : }
608 : else {
609 0 : (*(__v)) = static_cast<PFTPChannelParent*>(Lookup(id));
610 0 : if ((!((*(__v))))) {
611 0 : return false;
612 : }
613 : }
614 0 : return true;
615 : }
616 :
617 :
618 :
619 : } // namespace net
620 : } // namespace mozilla
|