firefox os 框架结构及调用机制

最近学习了一些新的比较前沿的东西,贴出来和大家分享,我想成功是留给少数人的,抓住比较前沿的东西学习也是一件有意义的事!!嘿嘿!!


 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. 


原文出处及更多详细资料

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值