firemail

标题: Creating the Component Code [打印本页]

作者: hechengjin    时间: 2016-3-27 23:41
标题: Creating the Component Code
组件是分层的.每一个XPCOM组件都有三部分.从内到外, 第一个对象是XPCOM对象. 这个对象包含了交互逻辑, 负责载入network, 执行一个监听载入过程或新content type的接口。
XPCOM的上层是 nsIFactory 对象. nsIFactory是对XPCOM的基本抽象.通过CreateInstance与XPCOM对象进行交互, 返回一个匹配给定的CID 和IID 的两个对象.如下图:


Onion Peel View of XPCOM Component Creation

最外层是nsIModule对象. 他提供了对nsIFactory 的进一步抽象, 而且可能允许多个nsIFactory对象. 关键点是这个接口的方法getClassObject返回的不一定非要是nsIFactory. nsIModule 也可以用来询问 XPCOM 对象的细节. This is very useful if the caller is required to know information about the component like its threading module, whether or not it's a singleton, its implementation language, and so forth. 这是可以使用接口nsIClassInfo.
IID 接口ID
CID  类ID






欢迎光临 firemail (http://firemail.wang:8088/) Powered by Discuz! X3