LCOV - code coverage report
Current view: directory - objdir/ipc/ipdl - PContextWrapperParent.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 205 0 0.0 %
Date: 2012-06-02 Functions: 41 0 0.0 %

       1                 : //
       2                 : // Automatically generated by ipdlc.
       3                 : // Edit at your own risk
       4                 : //
       5                 : 
       6                 : 
       7                 : #include "mozilla/jsipc/PContextWrapperParent.h"
       8                 : 
       9                 : #include "mozilla/ipc/PTestShellParent.h"
      10                 : #include "mozilla/jsipc/PObjectWrapperParent.h"
      11                 : 
      12                 : typedef IPC::Message Message;
      13                 : typedef mozilla::ipc::RPCChannel Channel;
      14                 : typedef mozilla::ipc::RPCChannel::RPCListener ChannelListener;
      15                 : typedef base::ProcessHandle ProcessHandle;
      16                 : typedef mozilla::ipc::AsyncChannel AsyncChannel;
      17                 : typedef mozilla::ipc::SharedMemory SharedMemory;
      18                 : typedef mozilla::ipc::Trigger Trigger;
      19                 : typedef mozilla::ipc::ActorHandle ActorHandle;
      20                 : typedef mozilla::ipc::Shmem Shmem;
      21                 : using mozilla::ipc::PTestShellParent;
      22                 : using mozilla::jsipc::PObjectWrapperParent;
      23                 : 
      24                 : namespace mozilla {
      25                 : namespace jsipc {
      26                 : 
      27                 : 
      28                 : bool
      29               0 : PContextWrapperParent::Recv__delete__()
      30                 : {
      31               0 :     return true;
      32                 : }
      33                 : 
      34                 : bool
      35               0 : PContextWrapperParent::RecvPObjectWrapperConstructor(
      36                 :         PObjectWrapperParent* actor,
      37                 :         const bool& makeGlobal)
      38                 : {
      39               0 :     return true;
      40                 : }
      41                 : 
      42                 : void
      43               0 : PContextWrapperParent::ActorDestroy(ActorDestroyReason why)
      44                 : {
      45               0 : }
      46                 : 
      47               0 : PContextWrapperParent::PContextWrapperParent() :
      48                 :     mId(0),
      49               0 :     mState(PContextWrapper::__Dead)
      50                 : {
      51               0 :     MOZ_COUNT_CTOR(PContextWrapperParent);
      52               0 : }
      53                 : 
      54               0 : PContextWrapperParent::~PContextWrapperParent()
      55                 : {
      56               0 :     MOZ_COUNT_DTOR(PContextWrapperParent);
      57               0 : }
      58                 : 
      59                 : PTestShellParent*
      60               0 : PContextWrapperParent::Manager()
      61                 : {
      62               0 :     return static_cast<PTestShellParent*>(mManager);
      63                 : }
      64                 : 
      65                 : void
      66               0 : PContextWrapperParent::ManagedPObjectWrapperParent(InfallibleTArray<PObjectWrapperParent*>& aArr) const
      67                 : {
      68               0 :     aArr = mManagedPObjectWrapperParent;
      69               0 : }
      70                 : 
      71                 : const InfallibleTArray<PObjectWrapperParent*>&
      72               0 : PContextWrapperParent::ManagedPObjectWrapperParent() const
      73                 : {
      74               0 :     return mManagedPObjectWrapperParent;
      75                 : }
      76                 : 
      77                 : PContextWrapper::State
      78               0 : PContextWrapperParent::state()
      79                 : {
      80               0 :     return mState;
      81                 : }
      82                 : 
      83                 : int32
      84               0 : PContextWrapperParent::Register(ChannelListener* aRouted)
      85                 : {
      86               0 :     return (mManager)->Register(aRouted);
      87                 : }
      88                 : 
      89                 : int32
      90               0 : PContextWrapperParent::RegisterID(
      91                 :         ChannelListener* aRouted,
      92                 :         int32 aId)
      93                 : {
      94               0 :     return (mManager)->RegisterID(aRouted, aId);
      95                 : }
      96                 : 
      97                 : ChannelListener*
      98               0 : PContextWrapperParent::Lookup(int32 aId)
      99                 : {
     100               0 :     return (mManager)->Lookup(aId);
     101                 : }
     102                 : 
     103                 : void
     104               0 : PContextWrapperParent::Unregister(int32 aId)
     105                 : {
     106               0 :     return (mManager)->Unregister(aId);
     107                 : }
     108                 : 
     109                 : void
     110               0 : PContextWrapperParent::RemoveManagee(
     111                 :         int32 aProtocolId,
     112                 :         ChannelListener* aListener)
     113                 : {
     114               0 :     switch (aProtocolId) {
     115                 :     case PObjectWrapperMsgStart:
     116                 :         {
     117               0 :             PObjectWrapperParent* actor = static_cast<PObjectWrapperParent*>(aListener);
     118               0 :             NS_ABORT_IF_FALSE(((mManagedPObjectWrapperParent).NoIndex) != ((mManagedPObjectWrapperParent).BinaryIndexOf(actor)), "actor not managed by this!");
     119                 : 
     120               0 :             (mManagedPObjectWrapperParent).RemoveElementSorted(actor);
     121               0 :             DeallocPObjectWrapper(actor);
     122               0 :             return;
     123                 :         }
     124                 :     default:
     125                 :         {
     126               0 :             NS_RUNTIMEABORT("unreached");
     127               0 :             return;
     128                 :         }
     129                 :     }
     130                 : }
     131                 : 
     132                 : Shmem::SharedMemory*
     133               0 : PContextWrapperParent::CreateSharedMemory(
     134                 :         size_t aSize,
     135                 :         Shmem::SharedMemory::SharedMemoryType type,
     136                 :         bool unsafe,
     137                 :         Shmem::id_t* aId)
     138                 : {
     139               0 :     return (mManager)->CreateSharedMemory(aSize, type, unsafe, aId);
     140                 : }
     141                 : 
     142                 : bool
     143               0 : PContextWrapperParent::AdoptSharedMemory(
     144                 :         Shmem::SharedMemory* segment,
     145                 :         Shmem::id_t* aId)
     146                 : {
     147               0 :     return (mManager)->AdoptSharedMemory(segment, aId);
     148                 : }
     149                 : 
     150                 : Shmem::SharedMemory*
     151               0 : PContextWrapperParent::LookupSharedMemory(Shmem::id_t aId)
     152                 : {
     153               0 :     return (mManager)->LookupSharedMemory(aId);
     154                 : }
     155                 : 
     156                 : bool
     157               0 : PContextWrapperParent::IsTrackingSharedMemory(Shmem::SharedMemory* segment)
     158                 : {
     159               0 :     return (mManager)->IsTrackingSharedMemory(segment);
     160                 : }
     161                 : 
     162                 : bool
     163               0 : PContextWrapperParent::DestroySharedMemory(Shmem& aShmem)
     164                 : {
     165               0 :     return (mManager)->DestroySharedMemory(aShmem);
     166                 : }
     167                 : 
     168                 : ProcessHandle
     169               0 : PContextWrapperParent::OtherProcess() const
     170                 : {
     171               0 :     return (mManager)->OtherProcess();
     172                 : }
     173                 : 
     174                 : AsyncChannel*
     175               0 : PContextWrapperParent::GetIPCChannel()
     176                 : {
     177               0 :     return mChannel;
     178                 : }
     179                 : 
     180                 : PContextWrapperParent::Result
     181               0 : PContextWrapperParent::OnMessageReceived(const Message& __msg)
     182                 : {
     183               0 :     switch ((__msg).type()) {
     184                 :     case PContextWrapper::Msg___delete____ID:
     185                 :         {
     186               0 :             (const_cast<Message&>(__msg)).set_name("PContextWrapper::Msg___delete__");
     187               0 :             if (mozilla::ipc::LoggingEnabled()) {
     188               0 :                 (static_cast<const PContextWrapper::Msg___delete__*>((&(__msg))))->Log("[PContextWrapperParent] Received ", stderr);
     189                 :             }
     190                 : 
     191               0 :             void* __iter = 0;
     192                 :             PContextWrapperParent* actor;
     193                 : 
     194               0 :             if ((!(Read((&(actor)), (&(__msg)), (&(__iter)), false)))) {
     195               0 :                 FatalError("error deserializing (better message TODO)");
     196               0 :                 return MsgValueError;
     197                 :             }
     198               0 :             (__msg).EndRead(__iter);
     199               0 :             if ((!(PContextWrapper::Transition(mState, Trigger(Trigger::Recv, PContextWrapper::Msg___delete____ID), (&(mState)))))) {
     200               0 :                 NS_WARNING("bad state transition!");
     201                 :             }
     202               0 :             if ((!(Recv__delete__()))) {
     203               0 :                 return MsgProcessingError;
     204                 :             }
     205                 : 
     206               0 :             (actor)->DestroySubtree(Deletion);
     207               0 :             (actor)->DeallocSubtree();
     208               0 :             ((actor)->mManager)->RemoveManagee(PContextWrapperMsgStart, actor);
     209                 : 
     210                 : 
     211               0 :             return MsgProcessed;
     212                 :         }
     213                 :     case PContextWrapper::Msg_PObjectWrapperConstructor__ID:
     214                 :         {
     215               0 :             (const_cast<Message&>(__msg)).set_name("PContextWrapper::Msg_PObjectWrapperConstructor");
     216               0 :             if (mozilla::ipc::LoggingEnabled()) {
     217               0 :                 (static_cast<const PContextWrapper::Msg_PObjectWrapperConstructor*>((&(__msg))))->Log("[PContextWrapperParent] Received ", stderr);
     218                 :             }
     219                 : 
     220               0 :             void* __iter = 0;
     221                 :             ActorHandle __handle;
     222                 :             PObjectWrapperParent* actor;
     223                 :             bool makeGlobal;
     224                 : 
     225               0 :             if ((!(Read((&(__handle)), (&(__msg)), (&(__iter)))))) {
     226               0 :                 FatalError("error deserializing (better message TODO)");
     227               0 :                 return MsgValueError;
     228                 :             }
     229               0 :             if ((!(Read((&(makeGlobal)), (&(__msg)), (&(__iter)))))) {
     230               0 :                 FatalError("error deserializing (better message TODO)");
     231               0 :                 return MsgValueError;
     232                 :             }
     233               0 :             (__msg).EndRead(__iter);
     234               0 :             if ((!(PContextWrapper::Transition(mState, Trigger(Trigger::Recv, PContextWrapper::Msg_PObjectWrapperConstructor__ID), (&(mState)))))) {
     235               0 :                 NS_WARNING("bad state transition!");
     236                 :             }
     237               0 :             actor = AllocPObjectWrapper(makeGlobal);
     238               0 :             if ((!(actor))) {
     239               0 :                 return MsgValueError;
     240                 :             }
     241               0 :             (actor)->mId = RegisterID(actor, (__handle).mId);
     242               0 :             (actor)->mManager = this;
     243               0 :             (actor)->mChannel = mChannel;
     244               0 :             (mManagedPObjectWrapperParent).InsertElementSorted(actor);
     245               0 :             (actor)->mState = mozilla::jsipc::PObjectWrapper::__Start;
     246                 : 
     247               0 :             if ((!(RecvPObjectWrapperConstructor(actor, makeGlobal)))) {
     248               0 :                 return MsgProcessingError;
     249                 :             }
     250                 : 
     251               0 :             return MsgProcessed;
     252                 :         }
     253                 :     default:
     254                 :         {
     255               0 :             return MsgNotKnown;
     256                 :         }
     257                 :     }
     258                 : }
     259                 : 
     260                 : PContextWrapperParent::Result
     261               0 : PContextWrapperParent::OnMessageReceived(
     262                 :         const Message& __msg,
     263                 :         Message*& __reply)
     264                 : {
     265               0 :     return MsgNotKnown;
     266                 : }
     267                 : 
     268                 : PContextWrapperParent::Result
     269               0 : PContextWrapperParent::OnCallReceived(
     270                 :         const Message& __msg,
     271                 :         Message*& __reply)
     272                 : {
     273               0 :     return MsgNotKnown;
     274                 : }
     275                 : 
     276                 : void
     277               0 : PContextWrapperParent::OnProcessingError(Result code)
     278                 : {
     279               0 :     NS_RUNTIMEABORT("`OnProcessingError' called on non-toplevel actor");
     280               0 : }
     281                 : 
     282                 : bool
     283               0 : PContextWrapperParent::OnReplyTimeout()
     284                 : {
     285               0 :     NS_RUNTIMEABORT("`OnReplyTimeout' called on non-toplevel actor");
     286               0 :     return false;
     287                 : }
     288                 : 
     289                 : void
     290               0 : PContextWrapperParent::OnChannelClose()
     291                 : {
     292               0 :     NS_RUNTIMEABORT("`OnClose' called on non-toplevel actor");
     293               0 : }
     294                 : 
     295                 : void
     296               0 : PContextWrapperParent::OnChannelError()
     297                 : {
     298               0 :     NS_RUNTIMEABORT("`OnError' called on non-toplevel actor");
     299               0 : }
     300                 : 
     301                 : void
     302               0 : PContextWrapperParent::OnChannelConnected(int32 pid)
     303                 : {
     304               0 :     NS_RUNTIMEABORT("'OnConnected' called on non-toplevel actor");
     305               0 : }
     306                 : 
     307                 : bool
     308               0 : PContextWrapperParent::AllocShmem(
     309                 :         size_t aSize,
     310                 :         Shmem::SharedMemory::SharedMemoryType aType,
     311                 :         Shmem* aMem)
     312                 : {
     313                 :     Shmem::id_t aId;
     314               0 :     nsAutoPtr<Shmem::SharedMemory> rawmem(CreateSharedMemory(aSize, aType, false, (&(aId))));
     315               0 :     if ((!(rawmem))) {
     316               0 :         return false;
     317                 :     }
     318                 : 
     319               0 :     (*(aMem)) = Shmem(Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead(), (rawmem).forget(), aId);
     320               0 :     return true;
     321                 : }
     322                 : 
     323                 : bool
     324               0 : PContextWrapperParent::AllocUnsafeShmem(
     325                 :         size_t aSize,
     326                 :         Shmem::SharedMemory::SharedMemoryType aType,
     327                 :         Shmem* aMem)
     328                 : {
     329                 :     Shmem::id_t aId;
     330               0 :     nsAutoPtr<Shmem::SharedMemory> rawmem(CreateSharedMemory(aSize, aType, true, (&(aId))));
     331               0 :     if ((!(rawmem))) {
     332               0 :         return false;
     333                 :     }
     334                 : 
     335               0 :     (*(aMem)) = Shmem(Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead(), (rawmem).forget(), aId);
     336               0 :     return true;
     337                 : }
     338                 : 
     339                 : bool
     340               0 : PContextWrapperParent::AdoptShmem(
     341                 :         Shmem& aMem,
     342                 :         Shmem* aOutMem)
     343                 : {
     344               0 :     Shmem::SharedMemory* rawmem = (aMem).Segment(Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead());
     345               0 :     if (((!(rawmem))) || (IsTrackingSharedMemory(rawmem))) {
     346               0 :         NS_RUNTIMEABORT("bad Shmem");
     347                 :     }
     348                 : 
     349                 :     Shmem::id_t aId;
     350               0 :     if ((!(AdoptSharedMemory(rawmem, (&(aId)))))) {
     351               0 :         return false;
     352                 :     }
     353                 : 
     354               0 :     (*(aOutMem)) = Shmem(Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead(), rawmem, aId);
     355               0 :     return true;
     356                 : }
     357                 : 
     358                 : bool
     359               0 : PContextWrapperParent::DeallocShmem(Shmem& aMem)
     360                 : {
     361               0 :     bool ok = DestroySharedMemory(aMem);
     362               0 :     (aMem).forget(Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead());
     363               0 :     return ok;
     364                 : }
     365                 : 
     366                 : void
     367               0 : PContextWrapperParent::FatalError(const char* const msg) const
     368                 : {
     369                 :     // Virtual method to prevent inlining.
     370                 :     // This give us better error reporting.
     371                 :     // See bug 589371
     372                 : 
     373               0 :     NS_ERROR("IPDL error:");
     374               0 :     NS_ERROR(msg);
     375                 : 
     376               0 :     NS_ERROR("[PContextWrapperParent] killing child side as a result");
     377                 : 
     378               0 :     if ((!(base::KillProcess(OtherProcess(), base::PROCESS_END_KILLED_BY_USER, false)))) {
     379               0 :         NS_ERROR("  may have failed to kill child!");
     380                 :     }
     381               0 : }
     382                 : 
     383                 : void
     384               0 : PContextWrapperParent::DestroySubtree(ActorDestroyReason why)
     385                 : {
     386                 :     // Unregister from our manager.
     387               0 :     Unregister(mId);
     388               0 :     mId = 1;
     389                 : 
     390               0 :     ActorDestroyReason subtreewhy = (((why) == (Deletion)) || ((why) == (FailedConstructor)) ? AncestorDeletion : why);
     391                 : 
     392                 :     {
     393                 :         // Recursively shutting down PObjectWrapper kids
     394               0 :         InfallibleTArray<PObjectWrapperParent*> kids = mManagedPObjectWrapperParent;
     395               0 :         for (uint32 i = 0; (i) < ((kids).Length()); (++(i))) {
     396               0 :             (kids[i])->DestroySubtree(subtreewhy);
     397                 :         }
     398                 :     }
     399                 : 
     400                 :     // Finally, destroy "us".
     401               0 :     ActorDestroy(why);
     402               0 : }
     403                 : 
     404                 : void
     405               0 : PContextWrapperParent::DeallocSubtree()
     406                 : {
     407                 :     {
     408                 :         // Recursively deleting PObjectWrapper kids
     409               0 :         InfallibleTArray<PObjectWrapperParent*>& kids = mManagedPObjectWrapperParent;
     410               0 :         for (uint32 i = 0; (i) < ((kids).Length()); (++(i))) {
     411               0 :             (kids[i])->DeallocSubtree();
     412                 :         }
     413                 : 
     414               0 :         for (uint32 i = 0; (i) < ((kids).Length()); (++(i))) {
     415               0 :             DeallocPObjectWrapper(kids[i]);
     416                 :         }
     417               0 :         (mManagedPObjectWrapperParent).Clear();
     418                 :     }
     419               0 : }
     420                 : 
     421                 : void
     422               0 : PContextWrapperParent::Write(
     423                 :         PObjectWrapperParent* __v,
     424                 :         Message* __msg,
     425                 :         bool __nullable)
     426                 : {
     427                 :     int32 id;
     428               0 :     if ((!(__v))) {
     429               0 :         if ((!(__nullable))) {
     430               0 :             NS_RUNTIMEABORT("NULL actor value passed to non-nullable param");
     431                 :         }
     432               0 :         id = 0;
     433                 :     }
     434                 :     else {
     435               0 :         id = (__v)->mId;
     436               0 :         if ((1) == (id)) {
     437               0 :             NS_RUNTIMEABORT("actor has been |delete|d");
     438                 :         }
     439                 :     }
     440                 : 
     441               0 :     Write(id, __msg);
     442               0 : }
     443                 : 
     444                 : bool
     445               0 : PContextWrapperParent::Read(
     446                 :         PObjectWrapperParent** __v,
     447                 :         const Message* __msg,
     448                 :         void** __iter,
     449                 :         bool __nullable)
     450                 : {
     451                 :     int32 id;
     452               0 :     if ((!(Read((&(id)), __msg, __iter)))) {
     453               0 :         return false;
     454                 :     }
     455               0 :     if (((1) == (id)) || (((0) == (id)) && ((!(__nullable))))) {
     456               0 :         return false;
     457                 :     }
     458                 : 
     459               0 :     if ((0) == (id)) {
     460               0 :         (*(__v)) = 0;
     461                 :     }
     462                 :     else {
     463               0 :         (*(__v)) = static_cast<PObjectWrapperParent*>(Lookup(id));
     464               0 :         if ((!((*(__v))))) {
     465               0 :             return false;
     466                 :         }
     467                 :     }
     468               0 :     return true;
     469                 : }
     470                 : 
     471                 : void
     472               0 : PContextWrapperParent::Write(
     473                 :         PContextWrapperParent* __v,
     474                 :         Message* __msg,
     475                 :         bool __nullable)
     476                 : {
     477                 :     int32 id;
     478               0 :     if ((!(__v))) {
     479               0 :         if ((!(__nullable))) {
     480               0 :             NS_RUNTIMEABORT("NULL actor value passed to non-nullable param");
     481                 :         }
     482               0 :         id = 0;
     483                 :     }
     484                 :     else {
     485               0 :         id = (__v)->mId;
     486               0 :         if ((1) == (id)) {
     487               0 :             NS_RUNTIMEABORT("actor has been |delete|d");
     488                 :         }
     489                 :     }
     490                 : 
     491               0 :     Write(id, __msg);
     492               0 : }
     493                 : 
     494                 : bool
     495               0 : PContextWrapperParent::Read(
     496                 :         PContextWrapperParent** __v,
     497                 :         const Message* __msg,
     498                 :         void** __iter,
     499                 :         bool __nullable)
     500                 : {
     501                 :     int32 id;
     502               0 :     if ((!(Read((&(id)), __msg, __iter)))) {
     503               0 :         return false;
     504                 :     }
     505               0 :     if (((1) == (id)) || (((0) == (id)) && ((!(__nullable))))) {
     506               0 :         return false;
     507                 :     }
     508                 : 
     509               0 :     if ((0) == (id)) {
     510               0 :         (*(__v)) = 0;
     511                 :     }
     512                 :     else {
     513               0 :         (*(__v)) = static_cast<PContextWrapperParent*>(Lookup(id));
     514               0 :         if ((!((*(__v))))) {
     515               0 :             return false;
     516                 :         }
     517                 :     }
     518               0 :     return true;
     519                 : }
     520                 : 
     521                 : 
     522                 : 
     523                 : } // namespace jsipc
     524                 : } // namespace mozilla

Generated by: LCOV version 1.7