I'm Mojofying ChromeViewMsg_SetIsIncognitoProcess in chrome/common/render_messages.h
AFAICT, the only use of that IPC message is from the browser to the renderer, once per renderer, near the start of the renderer process' lifetime. The message is only sent from ChromeContentBrowserClient::RenderProcessWillLaunch:
which says:
host->Send(new ChromeViewMsg_SetIsIncognitoProcess(profile->IsOffTheRecord()));
On the receiving side, all it does is set an is_incognito_process_ field:
host is a content::RenderProcessHost*, but naively replacing the host->Send with:
chrome::mojom::IncognitoProcessSetterPtr ips_service;
host->GetRemoteInterfaces()->GetInterface(&ips_service);
fails with:
InterfaceRegistry(service_manager:connector):
--> InterfaceRegistry is not yet bound to a pipe.
which makes sense, I suppose, as we're inside a function called RenderProcessWillLaunch, so the renderer isn't fully operational yet. But it does make the conversion non-trivial.
Why was the previous IPC OK but the Mojo interface unavailable? Is it because (loosely typed??) old-style IPCs can just sit in a buffer before the receiver is ready to read / dispatch / process?
What approach should I take to Mojofy this? I can think of three options.
1) make a SetIsIncognitoProcess Mojo call at some point later, when the renderer is ready to receive / dispatch / process Mojo calls. But not too late, in case the renderer needs to know that its local is_incognito_process_ field value is correct. When exactly is later but not too late?
2) reverse the flow. Rather than the browser telling the renderer, "you're in incognito mode", have the renderer ask the browser "am I in incognito mode". This could possibly be cached / lazily loaded on the renderer side. (If I'm driving codesearch correctly, I think that this bool is only used by extensions??)
3) this really shouldn't be using Mojo (or old-style IPC) at all. It's one time initialization, conceptually similar to a constructor parameter instead of a setter method. It should really be the equivalent of a command line flag to the renderer process. Chromium noob question: do we have such a mechanism?
Any suggestions?