nsIMessageWakeupService 编辑

content/base/public/nsIMessageWakeupService.idlScriptable Implements the Message Manager wakeup service; this lets other components be woken up when specific Message Manager messages arrive. By using this service, you can avoid starting those components until they're needed. 1.0 66 Introduced Gecko 2.0 Inherits from: nsISupports Last changed in Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)

Note: This service was introduced in Gecko 5.0 on Firefox for Android, but was not provided on desktop until Gecko 13.0 (Firefox 13). There is no IDL for this interface.

The parentprocessmessagemanager is used for this, so messages send from childprocessmessagemanagers will be heard.

Requesting wakeups

To request a wakeup, a wakeup condition must be registered with the category manager in the "wakeup-request" category. The easiest way to do this is to add the appropriate entry to the chrome manifest that registers your component (see category in "Chrome registration").

To indicate a wakeup request in a manifest file, add a line that looks something like this:

category wakeup-request nsComponent @mozilla.org/myservice;1,nsIMyInterface,getService,myMessage1,myMessage2[,..]

The category entry value consists of a comma separate string that contains:

  1. The contract ID for your component (e.g. "@mozilla.org/myservice;1").
  2. The string name of interface to instantiate the component as (e.g. "nsIMyInterface").
  3. The method to call to instantiate the component (either "getService" or "createInstance").
  4. A comma-separated list of messages for which your component should be instantiated.

Alternatively, it is possible to register a wakeup entry programmatically via the nsICategoryManager interface.

Currently, services must expose a wrappedJSObject in order to support this; however, once bug 593407 is fixed,  the service to be woken up must implement nsIFrameMessageListener.

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:107 次

字数:3612

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文