b2g与nuwa相互通信的具体ipdl源码分析:
ipdl机制分析:
PProcLoader.ipdl接口定义文件:
objdir-gecko/ipc/ipdl/PProcLoader
PProcLoaderChild.cpp
PProcLoader.cpp
PProcLoaderParent.cpp
接口文件:
PProcLoader.ipdl
protocol PProcLoader //child send,parent那里有个recv parent: //这里parent send,child那边revc 故,有两对send ,recv
|
B2G loader service指的是nuwa那端吗?它会调用plugin-container的main()函数,
没错。
PProcLoaderChild.cpp 部分源码分析:
共享内存,send, recv,open
PProcLoaderChild::SendLoadComplete
PProcLoaderChild::GetIPCChannel()
if ((!(PProcLoader::Transition(mState, Trigger(Trigger::Send, PProcLoader::Msg_Load__ID), (&(mState)))))) {
NS_WARNING("bad state transition!");
}
if ((!(RecvLoad(mozilla::Move(argv), mozilla::Move(env), mozilla::Move(fdsRemap), mozilla::Move(privs), mozilla::Move(cookie))))) {
mozilla::ipc::ProtocolErrorBreakpoint("Handler for Load returned error code");
return MsgProcessingError;
}
PProcLoaderChild::Write()
PProcLoaderChild::Read()
PProcLoaderParent.cpp部分源码
PProcLoaderParent::PProcLoaderParent()
PProcLoaderParent::Open()
PProcLoaderParent::SendLoad()
PProcLoaderParent::CreateSharedMemory()
PProcLoaderParent::AdoptSharedMemory(
PProcLoaderParent::LookupSharedMemory(Shmem::id_t aId)
PProcLoaderParent::OnMessageReceived(const Message& msg__){压根没收到消息,为什么???
if ((!(PProcLoader::Transition(mState, Trigger(Trigger::Recv, PProcLoader::Msg_LoadComplete__ID), (&(mState)))))) {
NS_WARNING("bad state transition!");
}
if ((!(RecvLoadComplete(mozilla::Move(pid), mozilla::Move(cookie))))) {//一直不能complete,使一直服务???
mozilla::ipc::ProtocolErrorBreakpoint("Handler for LoadComplete returned error code");
return MsgProcessingError;
}
}
PProcLoaderParent::Write()
PProcLoaderParent::Read()
ipdl里的两个接口,
child: Load //目的在于与加载某某某
parent: LoadComplete//目的是告诉child Load 结束了,完成了
child .cpp里实现的是SendLoadComplete以及它所接收的消息是RecvLoad,
parent.cpp里实现的是SendLoad ,比较奇怪,它只发而似乎永远没收到RecvLoadComplete,OnMessageReceived都没执行,不知为何?
PProcLoader.cpp 源码分析,
//
namespace mozilla { bool } // namespace PProcLoader //----------------------------------------------------------------------------- FDRemap::~FDRemap() auto FDRemap::operator==(const FDRemap& _o) const -> bool auto FDRemap::Init() -> void auto FDRemap::Assign(//分派,调派 } // namespace ipc |
PProcLoaderChild.cpp 部分源码分析:
共享内存,send, recv,open
PProcLoaderChild::SendLoadComplete
PProcLoaderChild::GetIPCChannel()
PProcLoaderChild::OnMessageReceived(const Message& msg__){
if ((!(PProcLoader::Transition(mState, Trigger(Trigger::Send, PProcLoader::Msg_Load__ID), (&(mState)))))) {}
if ((!(RecvLoad(mozilla::Move(argv), mozilla::Move(env), mozilla::Move(fdsRemap), mozilla::Move(privs), mozilla::Move(cookie)))))
{}
}
PProcLoaderChild::Write()
PProcLoaderChild::Read()
//
/// #include "utils/Log.h" #endif ///
auto PProcLoaderChild::ProcessingError( auto PProcLoaderChild::ShouldContinueFromReplyTimeout() -> bool auto PProcLoaderChild::EnteredCxxStack() -> void auto PProcLoaderChild::ExitedCxxStack() -> void auto PProcLoaderChild::EnteredCall() -> void auto PProcLoaderChild::ExitedCall() -> void
auto PProcLoaderChild::Open( auto PProcLoaderChild::Open(//auto 返回值占位 auto PProcLoaderChild::Close() -> void auto PProcLoaderChild::state() -> PProcLoader::State auto PProcLoaderChild::SendLoadComplete( Write(pid, msg__);
bool sendok__ = (mChannel).Send(msg__); auto PProcLoaderChild::Register(ProtocolBase* aRouted) -> int32_t auto PProcLoaderChild::RegisterID( auto PProcLoaderChild::Lookup(int32_t aId) -> ProtocolBase* auto PProcLoaderChild::Unregister(int32_t aId) -> void auto PProcLoaderChild::RemoveManagee( auto PProcLoaderChild::CreateSharedMemory( auto PProcLoaderChild::AdoptSharedMemory( auto PProcLoaderChild::LookupSharedMemory(Shmem::id_t aId) -> Shmem::SharedMemory* auto PProcLoaderChild::IsTrackingSharedMemory(Shmem::SharedMemory* segment) -> bool auto PProcLoaderChild::DestroySharedMemory(Shmem& shmem) -> bool Message* descriptor = (shmem).UnshareFrom(Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead(), OtherPid(), MSG_ROUTING_CONTROL); (mShmemMap).Remove(aId); if ((!((mChannel).CanSend()))) { return (descriptor) && ((mChannel).Send(descriptor)); auto PProcLoaderChild::OtherPid() const -> base::ProcessId auto PProcLoaderChild::GetIPCChannel() -> MessageChannel* auto PProcLoaderChild::CloneManagees( auto PProcLoaderChild::CloneProtocol( auto PProcLoaderChild::OnMessageReceived(const Message& msg__) -> PProcLoaderChild::Result void* iter__ = nullptr; if ((!(Read((&(argv)), (&(msg__)), (&(iter__)))))) { return MsgProcessed; auto PProcLoaderChild::OnMessageReceived( auto PProcLoaderChild::OnCallReceived( auto PProcLoaderChild::OnProcessingError( auto PProcLoaderChild::GetProtocolTypeId() -> int32_t auto PProcLoaderChild::OnEnteredCxxStack() -> void auto PProcLoaderChild::OnExitedCxxStack() -> void auto PProcLoaderChild::OnEnteredCall() -> void auto PProcLoaderChild::OnExitedCall() -> void auto PProcLoaderChild::IsOnCxxStack() const -> bool auto PProcLoaderChild::FlushPendingInterruptQueue() -> void auto PProcLoaderChild::OnChannelClose() -> void auto PProcLoaderChild::OnChannelError() -> void auto PProcLoaderChild::OnChannelConnected(int32_t aPid) -> void auto PProcLoaderChild::AllocShmem( (*(aOutMem)) = Shmem(Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead(), rawmem, id); auto PProcLoaderChild::AllocUnsafeShmem( (*(aOutMem)) = Shmem(Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead(), rawmem, id); auto PProcLoaderChild::AdoptShmem( Shmem::id_t id; (*(aOutMem)) = Shmem(Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead(), rawmem, id); auto PProcLoaderChild::DeallocShmem(Shmem& aMem) -> bool auto PProcLoaderChild::FatalError(const char* const aMsg) const -> void auto PProcLoaderChild::DestroySubtree(ActorDestroyReason why) -> void auto PProcLoaderChild::DeallocSubtree() -> void auto PProcLoaderChild::DeallocShmems() -> void auto PProcLoaderChild::Write( for (uint32_t i = 0; (i) < (length); (++(i))) { auto PProcLoaderChild::Read( if ((!((fa).SetLength(length, mozilla::fallible)))) { auto PProcLoaderChild::Write( auto PProcLoaderChild::Read( auto PProcLoaderChild::Write( auto PProcLoaderChild::Read( FileDescriptor fd = FileDescriptor(FileDescriptor::IPDLPrivate(), pfd); (*(v__)) = fd;
} // namespace ipc
|
PProcLoaderParent.cpp部分源码
PProcLoaderParent::PProcLoaderParent()
PProcLoaderParent::Open()
PProcLoaderParent::SendLoad()
PProcLoaderParent::CreateSharedMemory()
PProcLoaderParent::AdoptSharedMemory(
PProcLoaderParent::LookupSharedMemory(Shmem::id_t aId)
PProcLoaderParent::OnMessageReceived(const Message& msg__){
if ((!(PProcLoader::Transition(mState, Trigger(Trigger::Recv, PProcLoader::Msg_LoadComplete__ID), (&(mState)))))) {
NS_WARNING("bad state transition!");
}
if ((!(RecvLoadComplete(mozilla::Move(pid), mozilla::Move(cookie))))) {
mozilla::ipc::ProtocolErrorBreakpoint("Handler for LoadComplete returned error code");
return MsgProcessingError;
}
}
//
/// #include "utils/Log.h" #endif ///
auto PProcLoaderParent::ProcessingError( auto PProcLoaderParent::ShouldContinueFromReplyTimeout() -> bool auto PProcLoaderParent::EnteredCxxStack() -> void auto PProcLoaderParent::ExitedCxxStack() -> void auto PProcLoaderParent::EnteredCall() -> void auto PProcLoaderParent::ExitedCall() -> void MOZ_IMPLICIT PProcLoaderParent::PProcLoaderParent() : PProcLoaderParent::~PProcLoaderParent() auto PProcLoaderParent::Open( auto PProcLoaderParent::Open( auto PProcLoaderParent::Close() -> void auto PProcLoaderParent::state() -> PProcLoader::State auto PProcLoaderParent::SendLoad( Write(argv, msg__);
bool sendok__ = (mChannel).Send(msg__); auto PProcLoaderParent::Register(ProtocolBase* aRouted) -> int32_t auto PProcLoaderParent::RegisterID( auto PProcLoaderParent::Lookup(int32_t aId) -> ProtocolBase* auto PProcLoaderParent::Unregister(int32_t aId) -> void auto PProcLoaderParent::RemoveManagee( auto PProcLoaderParent::CreateSharedMemory( auto PProcLoaderParent::AdoptSharedMemory( auto PProcLoaderParent::LookupSharedMemory(Shmem::id_t aId) -> Shmem::SharedMemory* auto PProcLoaderParent::IsTrackingSharedMemory(Shmem::SharedMemory* segment) -> bool auto PProcLoaderParent::DestroySharedMemory(Shmem& shmem) -> bool Message* descriptor = (shmem).UnshareFrom(Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead(), OtherPid(), MSG_ROUTING_CONTROL); (mShmemMap).Remove(aId); if ((!((mChannel).CanSend()))) { return (descriptor) && ((mChannel).Send(descriptor)); auto PProcLoaderParent::OtherPid() const -> base::ProcessId auto PProcLoaderParent::GetIPCChannel() -> MessageChannel* auto PProcLoaderParent::CloneManagees( auto PProcLoaderParent::CloneProtocol( auto PProcLoaderParent::OnMessageReceived(const Message& msg__) -> PProcLoaderParent::Result void* iter__ = nullptr; if ((!(Read((&(pid)), (&(msg__)), (&(iter__)))))) { return MsgProcessed; auto PProcLoaderParent::OnMessageReceived( auto PProcLoaderParent::OnCallReceived( auto PProcLoaderParent::OnProcessingError( auto PProcLoaderParent::GetProtocolTypeId() -> int32_t auto PProcLoaderParent::OnEnteredCxxStack() -> void auto PProcLoaderParent::OnExitedCxxStack() -> void auto PProcLoaderParent::OnEnteredCall() -> void auto PProcLoaderParent::OnExitedCall() -> void auto PProcLoaderParent::IsOnCxxStack() const -> bool auto PProcLoaderParent::FlushPendingInterruptQueue() -> void auto PProcLoaderParent::OnChannelClose() -> void auto PProcLoaderParent::OnChannelError() -> void auto PProcLoaderParent::OnChannelConnected(int32_t aPid) -> void auto PProcLoaderParent::AllocShmem( (*(aOutMem)) = Shmem(Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead(), rawmem, id); auto PProcLoaderParent::AllocUnsafeShmem( (*(aOutMem)) = Shmem(Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead(), rawmem, id); auto PProcLoaderParent::AdoptShmem( Shmem::id_t id; (*(aOutMem)) = Shmem(Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead(), rawmem, id); auto PProcLoaderParent::DeallocShmem(Shmem& aMem) -> bool auto PProcLoaderParent::SetOtherProcessId(base::ProcessId aOtherPid) -> void auto PProcLoaderParent::TakeMinidump( auto PProcLoaderParent::FatalError(const char* const aMsg) const -> void auto PProcLoaderParent::DestroySubtree(ActorDestroyReason why) -> void auto PProcLoaderParent::DeallocSubtree() -> void auto PProcLoaderParent::DeallocShmems() -> void auto PProcLoaderParent::Write( for (uint32_t i = 0; (i) < (length); (++(i))) { auto PProcLoaderParent::Read( if ((!((fa).SetLength(length, mozilla::fallible)))) { auto PProcLoaderParent::Write( auto PProcLoaderParent::Read( auto PProcLoaderParent::Write( auto PProcLoaderParent::Read( FileDescriptor fd = FileDescriptor(FileDescriptor::IPDLPrivate(), pfd); (*(v__)) = fd;
} // namespace ipc |