废话就不多说了,开始。。。
近来学习了一些新的比拟前沿的东西,贴出来和大家分享,我想胜利是留给少数人的,抓住比拟前沿的东西学习也是一件有意义的事!!嘿嘿!!
http://
Gecko-js async Communicate With Gaia
1. DOM request
Once we use the refer interface, it would return a DOMRequest. Code sample:
(1) IDL file
......
nsIDOMDOMRequest get(in jsval name);
......
(2) Gecko js file
......
Cu.import('resource://gre/modules/DOMRequestHelper.jsm');
......
let request = this.createRequest();
......
return request;
......
2. Register callback
When gaia want to monitor the change about something, it can register one callback. IDL file
interface XXXX : nsISupports
{
attribute nsIDOMEventListener xxxxx;
};
......
[scriptable, function, uuid(df31c120-ded6-11d1-bd85-00805f8ae3f4)]
interface nsIDOMEventListener : nsISupports
{
void handleEvent(in nsIDOMEvent event);
};
Gecko-cpp async Communicate With Gaia
1. Callback
(1) IDL interface provide one callback parameter. Gaia deliver the callback function when use that idl interface. And gecko-c++ use "handleEvent" to execute the callback function. Example: IDL file
[scriptable, function, uuid(9cba3cdc-3a2a-44ed-a72a-4bd70b98e7d3)]
interface nsIDOMJrdFotaCommonCb : nsISupports
{
void handleEvent(in DOMString actionType,
in bool isSuccessed,
in DOMString errorType);
};
[scriptable, builtinclass, uuid(50f140da-78e8-449c-a688-d512e1df443a)]
interface nsIDOMMozJrdFotaManager:nsISupports
{
void pause(in nsIDOMJrdFotaCommonCb pauseCallback);
};
(2) CPP source / header file
nsCOMPtr<nsIDOMJrdFotaCommonCb> gOnCommonCb;
gOnCommonCb->HandleEvent(actionType, isSuccess, errorType);
2. Register callback
(1) When gaia want to the switch status, it can register one callback. Gecko can dispatch this event at any time.Example: IDL file
[scriptable, builtinclass, uuid(2bdb02e7-ec3a-47a9-885c-0ab514566801)]
interface nsIDOMMozSmsManager : nsIDOMEventTarget
{
[implicit_jscontext] attribute jsval onsending;
};
(2)Add this event into GkAtomList(<project>/gecko/content/base/src/nsGkAtomList.h)
GK_ATOM(onsending, "onsending")
3. DOM request
Sometimes Gecko-C++ has used the gecko-js DOM request interface. In this case, C++ IDL interface can provide one DOM request interface to gaia.
文章结束给大家分享下程序员的一些笑话语录:
古鸽是一种搜索隐禽,在中国快绝迹了…初步的研究表明,古鸽的离去,很可能导致另一种长着熊爪,酷似古鸽,却又习性不同的猛禽类——犤毒鸟
---------------------------------
原创文章 By
interface和框架结构
---------------------------------