Shmem::SharedMemory* IToplevelProtocol::CreateSharedMemory(size_t aSize, Shmem::SharedMemory::SharedMemoryType aType, bool aUnsafe, Shmem::id_t* aId) { RefPtr<Shmem::SharedMemory> segment( Shmem::Alloc(Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead(), aSize, aType, aUnsafe)); if (!segment) { return nullptr; } int32_t id = GetSide() == ParentSide ? ++mLastShmemId : --mLastShmemId; Shmem shmem( Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead(), segment.get(), id); Message* descriptor = shmem.ShareTo( Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead(), OtherPid(), MSG_ROUTING_CONTROL); if (!descriptor) { return nullptr; } Unused << GetIPCChannel()->Send(descriptor); *aId = shmem.Id(Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead()); Shmem::SharedMemory* rawSegment = segment.get(); mShmemMap.AddWithID(segment.forget().take(), *aId); return rawSegment; }
bool IToplevelProtocol::Open(MessageChannel* aChannel, MessageLoop* aMessageLoop, mozilla::ipc::Side aSide) { SetOtherProcessId(base::GetCurrentProcId()); return GetIPCChannel()->Open(aChannel, aMessageLoop, aSide); }
bool IToplevelProtocol::Open(mozilla::ipc::Transport* aTransport, base::ProcessId aOtherPid, MessageLoop* aThread, mozilla::ipc::Side aSide) { SetOtherProcessId(aOtherPid); return GetIPCChannel()->Open(aTransport, aThread, aSide); }
bool IToplevelProtocol::DestroySharedMemory(Shmem& shmem) { Shmem::id_t aId = shmem.Id(Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead()); Shmem::SharedMemory* segment = LookupSharedMemory(aId); if (!segment) { return false; } Message* descriptor = shmem.UnshareFrom( Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead(), OtherPid(), MSG_ROUTING_CONTROL); mShmemMap.Remove(aId); Shmem::Dealloc(Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead(), segment); if (!GetIPCChannel()->CanSend()) { delete descriptor; return true; } return descriptor && GetIPCChannel()->Send(descriptor); }
bool TestUrgencyParent::RecvFinalTest_Begin() { SetReplyTimeoutMs(2000); if (CallFinalTest_Hang()) fail("should have failed due to timeout"); if (!GetIPCChannel()->Unsound_IsClosed()) fail("channel should have closed"); MessageLoop::current()->PostTask( FROM_HERE, NewRunnableMethod(this, &TestUrgencyParent::Close)); return false; }
mozilla::ipc::IPCResult TestCancelChild::RecvTest1_1() { GetIPCChannel()->CancelCurrentTransaction(); uint32_t value = 0; if (!SendCheckParent(&value)) fail("Test1 CheckParent"); if (value != 12) fail("Test1 CheckParent reply"); if (!SendDone1()) fail("Test1 CheckParent"); return IPC_OK(); }
bool TestHangsParent::ShouldContinueFromReplyTimeout() { mDetectedHang = true; // so we've detected a timeout after 2 ms ... now we cheat and // sleep for a long time, to allow the subprocess's reply to come // in PR_Sleep(5000); // reply should be here; we'll post a task to shut things down. // This must be after OnMaybeDequeueOne() in the event queue. MessageLoop::current()->PostTask( NewNonOwningRunnableMethod(this, &TestHangsParent::CleanUp)); GetIPCChannel()->CloseWithTimeout(); return false; }
mozilla::ipc::IPCResult TestCancelParent::RecvTest3_2() { GetIPCChannel()->CancelCurrentTransaction(); return IPC_OK(); }
bool IToplevelProtocol::IsOnCxxStack() const { return GetIPCChannel()->IsOnCxxStack(); }
void IToplevelProtocol::SetReplyTimeoutMs(int32_t aTimeoutMs) { GetIPCChannel()->SetReplyTimeoutMs(aTimeoutMs); }
void IToplevelProtocol::Close() { GetIPCChannel()->Close(); }