MDN’s new design is in Beta! A sneak peek: https://blog.mozilla.org/opendesign/mdns-new-design-beta/

新しいプロトコルの作成

この翻訳は不完全です。英語から この記事を翻訳 してください。

これはどのように新しいIPDLプロトコルを追加してビルドする方法の詳細のクイックスタートです。もしあなたが know how IPDL works を見ていないなら最初に見るべきです!

プロトコルファイルの作成

The protocol file should live in the same directory as the code which will implement it. Protocol names start with P, and protocol files must be named PProtocolName.ipdl. IPDL protocols should be in the mozilla namespace or a sub-namespace.

To hook up the file to the build, you need to add your IPDL file to IPDL_SOURCES in the nearest moz.build file. See dom/ipc/moz.build for an example.

プロトコルのヒエラルキー

Unless you are working on some special project, your protocol will fit into the protocol hierarchy for multi-process plugins or tabs. The toplevel protocol for plugins is PPluginModule. The toplevel protocol for tabs is PContent. You should know what protocol will manage the new protocol and what lifetime issues that creates. If there is any doubt, ask on IRC in the #content channel.

新しいプロトコルのビルド

To build the new protocol declaration and generate headers, make in ipc/ipdl:

make -C objdir/ipc/ipdl

If there are any protocol-level errors, the IPDL compiler will print the relevant error messages and stop. To view the generated headers, look in objdir/ipc/ipdl/_ipdlheaders .

Creating the Implementation

The C++ implementation inherits from the abstract IPDL-generated classes PNewProtocolParent and PNewProtocolChild. It must implement abstract methods for receiving the appropriate messages on each side. The method signatures can be read from the generated PNewProtocolParent.h and PNewProtocolChild.h headers.

書き込みテスト

Protocols which are managed by PBrowser must be tested using the mochitest-chrome test framework with a <browser remote="true">. It is acceptable to use synchronous calls on JPW wrappers for testing purposes. It may be possible to test protocols unrelated to a particular window using the xpcshell testing framework, which has additional primitives in Electrolysis for launching and running JS commands in a content process.

ドキュメントのタグと貢献者

 このページの貢献者: lv7777
 最終更新者: lv7777,