当前位置:网站首页>[Mozilla] basic concept analysis of IPDL
[Mozilla] basic concept analysis of IPDL
2022-06-12 10:03:00 【Lindo】
Mozilla IPDL
What is? IPDL
- IPDL The full name is “Inter-process-communication Protocol Definiton Language”
- It is an interprocess communication protocol definition language ( More or less like Android Of AIDL)
- It's a way to make C++ The code can be standardized 、 A language that is passed safely between processes or threads
- Equivalent to a platform independent interface language
- Mainly aimed at C++ Realization
- Mozilla private
- Firfox/FirfoxOS Use IPDL Statement Message(firFoxOS yes KaiOS The forerunner of )

IPDL agreement
- Use IPDL Language , Definition IPDL agreement . The agreement states Actors How to communicate between :
- Defines the interface for communication
- Defines the message for communication

- Actors:
- Actors finger IPDL Sender of message : such as P(Parent)/C(Child) End
- Parent And Child Corresponding relation :
- There is... On the left below Parent、 On the right Child
- Chrome Process(Browser) <-> Content Process(Render)
- Content Process(Render) <-> Plugin Process
IPDL And WebIDL
- WebIDL: w3c Standard interface definition language ( Interface Definition Languag), be used for WebAPI Design and development .
- IPDL And WebIDL The relationship between :

IPDL And IPC
- IPC:Inter-Process Communication
- IPDL And IPC The relationship between :
- IPDL It can be understood as the protocol layer : Serialized data 、 Hair / Take the message
- IPC It can be understood as the transport layer : pipe or socket wait

IPDL Main concepts
role (Actor)
- Parent end (Parent) And sub terminal (Child) Called role
- all IPDL The message passes through the parent / Sub send
- Parent-child correspondence :

agreement
- Agreement means by IPDL( Language ) Defined , be used for Actor Specification for communication between
- Protocol type :
- sync: Synchronous and asynchronous messages can be declared
- async: Declarable asynchronous messages
- rpc: It can be stated that RPC news ( Be similar to sync, Try not to use )
- example :
- Declared a name of PPlugin Of IPDL agreement
- Asynchronous messages sent from parent to child : Init()、ShuntDown
- Asynchronous messages sent from child to parent : Ready()
async protocol PPlugin
{
child:
async Init(nsCString pluginPath);
async Shutdown();
parent:
async Ready();
};
Sub protocol (Subprotocols) And protocol management (Protocol Management)
- One IPDL A protocol can have multiple sub protocols , These sub agreements are made by “ The agreement ” management .

- Agreement Management
- The agreement is responsible for the creation of its sub agreements ( All sub agreements , Created through this Agreement )
- Once the protocol instance is destroyed , Its associated sub agreements will also be destroyed

news (Message)
- Message type :
- Sync (sync): Sender blocking , Receive the reply from the receiver directly
- asynchronous (async): The sender will not block
- RPC: Be similar to sync,RPC allow “ Reentrant ” Message handler
- Sender blocking ,RPC When the answer is called , You can unblock to handle new incoming RPC call
- Return value :return Keyword representation Message Has a return value
- Sequential delivery : Pass... In order
- Advice on message types :
- Use asynchronous... Whenever possible
- Synchronization is not recommended
- Try not to use RPC
Error handling (Error Handling)
- Realization IPDL Message Of C++ Method returns bool type :
- ture: success
- false : Data corruption or data format error ( Can't recover 、 A disastrous mistake )
- once Message The implementation of returns False, It will be dealt with as follows :
- The communication channels for the child process disconnected
- Terminate Process
- Suggestions for error handling : about “ Normal error ”、“ Non lethal ” Error of , There is no need to return False
ShutDown( close )
- When the management agreement is destroyed , All sub agreements need to be notified :
- No more messages
- Through the management agreement , Destroy all its associated sub agreements
IPDL Exmaple
- Exmaple structure :JS call WebAPI,JS Engine call WebAPI Impl,WebAPI adopt IPLD Conduct IPC signal communication .

- The implementation of this part , please Mozilla Official website :
https://developer.mozilla.org/en-US/docs/Mozilla/IPDL/Extending_a_Protocol
Reference material
边栏推荐
猜你喜欢
![[cloud native] establishment of Eureka service registration](/img/da/0a700081be767db91edd5f3d49b5d0.png)
[cloud native] establishment of Eureka service registration

行业分析怎么做

True north reading notes

Ceph如何改善存储性能以及提升存储稳定性

CentOS 7 installing MySQL 8

MySQL索引常见问题

Web3.0与数字时尚,该如何落地?

Li Yang, a scientific and technological innovator and CIO of the world's top 500 group: the success of digital transformation depends on people. Decision makers should always focus on "firewood"

Strange error -- frame detected by contour detection, expansion corrosion, and reversal of opening and closing operation effect

MYSQL的最左匹配原则的原理讲解
随机推荐
004:AWS数据湖解决方案
2021-09-13
Transport layer protocol -- TCP protocol
How CEPH improves storage performance and storage stability
【clickhouse专栏】基础数据类型说明
基于 Ceph 对象存储的实战兵法
FPGA VGA display based on de2-115 platform
markdown_ Picture side by side scheme
C语言递归文件夹的代码
spark_ sql
Spark complex structure data retrieval method
Checkpoint of the four cornerstones of Flink
MySQL索引常见问题
Introduction to on-line circuit simulation and open source electronic hardware design
Research on autojs wechat: the control IP in wechat on different versions of wechat or simulators is different.
一文读懂Dfinity生态中的首个NFT平台:IMPOSSIBLE THINGS
CEPH performance optimization and enhancement
markdown_图片并排的方案
1268_FreeRTOS任务上下文切换的实现
[cloud native | kubernetes] kubernetes networkpolicy