(sending to chromium-mojo, platform-architecture-dev, and top level content owners. This should cover the set of folks working in this area so we can reach consensus). Apologies for the length of the email!
Recently the
question came up of where we put mojom files for interfaces that are called by the renderer process and implemented in chrome. This is going to come up more frequently as chrome IPCs are
converted to mojo, and as web platform implementations
move from content/renderer to third_party/WebKit.
<history>
Let's start by looking at the current situation today.
First, for many web platform features that require the user's permission or needs to get out of the sandbox, the feature code in Blink would talk to content via a WebFeature delegate interface declared in third_party/WebKit/public/platform/modules/. This would be implemented in content/render, and it would send an IPC to code in content/browser. That code would then talk to chrome through a delegate interface (sometimes a specific one, or often a general one like ContentBrowserClient).
Second, for browser features that interact with Blink, we have tried to keep knowledge about them outside of content where possible. An example is autofill. Blink calls WebAutofillClient that is implemented by src/components/autofill/content/renderer. It then IPCs to components/autofill/content/browser.
A distinction for the above two cases is that for the former, a chromium embedder has to look for interfaces in content/public to see their responsibility. In the second case, they also have to look at third_party/WebKit/public/web. For both of these cases though, it must be confusing for new embedders of chromium. These directories contain both interfaces that are used to call content and Blink, but also interfaces that have to be implemented by the embedder (of chromium) and the embedder of Blink (which is content).
This is a lot of layers. Note that when the content split was done years ago, we consciously chose a few design decisions:
-IPCs shouldn't span chrome/content layer. The thinking then was that we want to have a proper API that separates the two modules.
-content would not wrap interfaces from modules that sit below it in the stack. i.e. a chromium embedder would call/implement net/Blink/etc... interfaces directly where needed.
</history>
So a few questions come up now:
1) Since Mojo IPCs are still IPCs, do we want to change our policy and allow mojom interfaces to span processes?
-I believe the answer should be yes, since we are trying to cut down layers and remove busy work.
2) If the answer to 1) is yes, here do we put the mojom files?
There are a few sub questions here:
a) When Blink calls a chromium embedder, where do the mojom files live?
-it seems it would be silly for them to be in content/public, since in our (Chrome) case, this is communication between Blink and chrome and the content module isn't involved. That argues for putting them in third_party/WebKit/public/...
b) Should we enforce that all mojom interfaces that are implemented by chromium embedders have to be inside content/public/common/... and third_party/WebKit/...?
-i.e. chromium embedders need to be able to look in one or two places at most to see what their responsibility is as an embedder. They can't be expected to also hunt for mojom files in subdirectories of src/components, src/device etc... as well.
c) Should we clearly denote which mojom files are implemented by content vs chromium embedders in Blink's public directory?
-Since we will probably end up with a lot of mojoms in Blink's public directory, it would be good to have a way to make it easy for chromium embedders to look at a small directory to see what their responsibility is, and not have them also see the mojoms that are implemented by content.
Thanks