nsIProcessScriptLoader 编辑

IDL file: mozilla-central/source/dom/base/nsIMessageManager.idl

Inherits from: nsISupports

This interface is used by parent process message managers to load scripts into a child process. The scripts run only once per process. The global object for process scripts is a ContentProcessMessageManager.

Methods

void loadProcessScript(in AString aURL,
                       in boolean aAllowDelayedLoad)

void removeDelayedProcessScript(in AString aURL);
jsval getDelayedProcessScripts();

loadProcessScript()

Load a script in the child process. Process scripts are loaded as soon as loadProcessScript() is called.

If this function is called on a ChromeMessageBroadcaster, :

  • it will load the process script into all child processes.
  • if aAllowDelayedLoad is true, then the script will also be loaded into any new child processes created after the loadProcessScript() call. Otherwise it will only be loaded into child processes that exist at the time of the call.

If this function is called on a ChromeMessageSender:

  • it will load the process script only into this ChromeMessageSender's child process
  • aAllowDelayedLoad should always be true. It's possible that the child process for this ChromeMessageSender is not yet available at the time of the loadProcessScript() call, and if you pass false in this situation, your process script won't be loaded.

For example:

let ppmm = Services.ppmm.getChildAt(1);
ppmm.loadProcessScript('data:,dump("foo\n");', true);

Parameters

NameTypeDescription
aURLStringURL for the script to load. aURL must be the absolute URL. data: URLs are also supported. For example data:,dump("foo\n");
aAllowDelayedLoadBoolean

If this flag is false, the process script will only be loaded into child processes that are already running at the time of the call.

If this flag is true, the process script will be loaded into any new child processes created after the loadProcessScript() call, until removeDelayedProcessScript() is called for that script.

If you are calling loadProcessScript() on a ChromeMessageSender, you should always pass true here.

removeDelayedProcessScript()

Removes aURL from the list of scripts which support delayed load.

This cancels the effect of the aAllowDelayedLoad flag, meaning that the loader will no longer load the script into new child processes. If you used aAllowDelayedLoad, you should call this as part of your cleanup (for example, when your add-on is disabled or uninstalled).

Parameters

NameTypeDescription
aURLStringURL for the script to remove.

getDelayedProcessScripts()

Returns all delayed scripts that will be loaded once a child process becomes available. The return value is a list of pairs [<URL>, false].

Returns

List of the delayed scripts. Each script is returned as a pair: [<URL>, false].

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

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

发布评论

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

词条统计

浏览:134 次

字数:4987

最后编辑:7年前

编辑次数:0 次

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