How can I access chrome.history from a Web Worker?

故事扮演 提交于 2019-12-02 10:59:29

问题


Is there any way I can access the chrome.* apis (specifically chrome.history) from a Web Worker?

If I pass the chrome.history or chrome object in with postMessage, it is not working because of a conversion error to Transferable type.

I can successfully query the history from my extension and pass the results, but I would like to leave the heavy lifting to the worker instead of the main thread and then pass the results.


回答1:


Web Workers are meant to be light-weight, and do not inherit any permissions (not even host permissions) from the extension (besides, chrome is not even defined in a Web worker).

If you're doing really heavy stuff with the results of the chrome.history API, then you could pass the result of a callback to a worker for processing (with Transferables, the overhead is minimal). Before doing that, make sure that you profile whether the performance impact is really that significant to warrant implementing anything like this.



来源:https://stackoverflow.com/questions/21216481/how-can-i-access-chrome-history-from-a-web-worker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!