Hi.
I have a question about Mojo.
Is there any way to prohibit calling some Mojo method from different processes?
We are currently implementing the Subresource Web Bundles feature (
explainer). With this feature, multiple subresources can be loaded from one web bundle file. For example, Chrome will fetch bundle.wbn from the server and load style.css and script.js from bundle.wbn.
<link rel="webbundle"
href="
https://example.com/bundle.wbn"
resources="
https://example.com/style.css https://example.com/script.js">
<link href="
https://example.com/style.css" rel="stylesheet">
<script src="
https://example.com/script.js"></script>
In the current implementation design (
design doc), the web bundle data is held in the network process. The renderer process generates an unguessable token and uses the token both in the request for the web bundle (bundle.wbn) and in the requests for the other subresources (style.css, script.js). So the network process can return the subresources from the web bundle. This is done in
WebBundleManager::GetWebBundleURLLoaderFactory().
But I think we can use a Mojo handle of mojom::URLLoaderFactory instead of the token.
The renderer process sends a pending_receiver<URLLoaderFactory> to the network process in the web bundle request (bundle.wbn). The network process fetches the web bundle from the server and generates a WebBundleURLLoaderFactory for the subresource loading from the web bundle. And the renderer process sends a cloned URLLoaderFactory handle to the network process for the subresources (style.css, script.js).
I’m not 100% sure yet whether using a Mojo handle is a better design than using an unguessable token or not. But if we use the Mojo handle, we want to make WebBundleURLLoaderFactory::CreateLoaderAndStart() callable only from the same process (network process). Is there any way to check whether the method is called from another process?
Thank you.