后台js脚本是否在Chrome操作系统应用程序中的其他线程上运行? [英] Do background js scripts run on a different thread in Chrome OS apps?

查看:66
本文介绍了后台js脚本是否在Chrome操作系统应用程序中的其他线程上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Chrome操作系统应用的清单上,必须声明后台js脚本.

On the manifest for Chrome OS apps one must declare background js scripts.

{
  "name": "Hello World!",
  "description": "My first Chrome App.",
  "version": "0.1",
  "manifest_version": 2,
  "app": {
    "background": {
      "scripts": ["background.js"]
    }
  },
  "icons": { "16": "calculator-16.png", "128": "calculator-128.png" }
}

这些工具是否都在各自的线程中运行?

Are each of these running in their own thread?

它们是互相阻塞还是在应用程序窗口上运行的JS线程?

Do they block each other or the JS threads running on the app windows?

推荐答案

Chrome应用程序窗口仅是视图",并不位于单独的进程中.这是证明.每个应用程序查看页面都可以运行chrome.runtime.getBackgroundPage来直接引用后台页面的javascript上下文(所有变量,函数等).此外,背景页面还可以使用chrome.app.window.getAll引用返回的appWindow对象上的contentWindow来获取对应用程序窗口的javascript上下文的引用.

Chrome App windows are only "views", and are not living in separate processes. Here's the proof. Each app view page can run chrome.runtime.getBackgroundPage to get a direct reference to the background page's javascript context (all variables, functions, etc). Also the background page can get references to the javascript contexts of the app windows, using chrome.app.window.getAll to reference contentWindow on the appWindow objects returned.

正如另一位评论者所指出的,Chrome扩展程序的情况有所不同,但是由于问题是关于应用程序的,因此我们只关心自己.

As another commenter points out, the situation is a bit different for chrome extensions, but since the question is about apps, we only concern ourselves with that.

这篇关于后台js脚本是否在Chrome操作系统应用程序中的其他线程上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆