To help things proceed, I think we can do something like this:
1. First, rename DOMWindow to LocalDOMWindow, and update Window.idl to point at that instead.
2. Make DOMWindow a virtual interface for things DOMWindow::screen(), DOMWindow::location(), etc.
3. Update Window.idl to point back at DOMWindow, and update V8WindowShell to tie the two bits together.
4. When we add RemoteDOMWindow, update V8WindowShell::installDOMWindow to handle that case as well.
We're a little fuzzy on the fine points of #2. Looking at what the IDL bindings generator outputs, I think it /should/ just work as long as we tie things together correctly in V8WindowShell. There's nothing fundamental that prevents generated bindings code from calling virtual methods right?
Finally, do we need to be concerned about the performance implications of using virtual dispatch?
From the perspective of whether it works or not, I think your approach will work.However, I don't fully understand how the interaction between LocalDOMWindow, RemoteDOMWindow and DOMWindow's wrapper is going to be organized. Would you more elaborate on what happens on these objects in the out-of-process mode step by step (e.g., when RemoteDOMWindow is created, when V8WindowShell::installDOMWindow switches the C++ pointer from LocalDOMWindow to RemoteDOMWindow etc)?
To help things proceed, I think we can do something like this:
1. First, rename DOMWindow to LocalDOMWindow, and update Window.idl to point at that instead.
2. Make DOMWindow a virtual interface for things DOMWindow::screen(), DOMWindow::location(), etc.
3. Update Window.idl to point back at DOMWindow, and update V8WindowShell to tie the two bits together.
4. When we add RemoteDOMWindow, update V8WindowShell::installDOMWindow to handle that case as well.We're a little fuzzy on the fine points of #2. Looking at what the IDL bindings generator outputs, I think it /should/ just work as long as we tie things together correctly in V8WindowShell. There's nothing fundamental that prevents generated bindings code from calling virtual methods right?Right. The binding code just believes that a C++ pointer stored in a certain internal filed of V8's wrapper is a C++ pointer to the corresponding DOM object. Thus if you install a C++ pointer to LocalDOMWindow/RemoteDOMWindow into the internal field, you can make the binding code believe that it's a C++ pointer that the binding code should use. You can do that in V8WindowShell::installDOMWindow.Finally, do we need to be concerned about the performance implications of using virtual dispatch?Are you going to make all Window methods virtual? I guess most Window methods are not performance-sensitive.
I don't think we've completely figured this out ourselves. There will be two ways to create a RemoteFrame, and in both of these cases, we will need a RemoteDOMWindow.
1. If the browser process decides that a frame navigation should result in a cross-process swap, then the browser will trigger Blink to swap that frame in the FrameTree from LocalFrame to RemoteFrame. Right now, we have a minimally implemented Blink API to allow the embedder to trigger this (WebFrame::swap). We envision that this will eventually call a new method on V8WindowShell to allow us to swap the C++ pointer to point to the RemoteDOMWindow.
2. Once the process swap has been triggered, we need to mirror the frame tree in the new process, so by definition, we will need to instantiate RemoteFrames. We may adapt the logic in installDOMWindow to handle this case, or maybe factor out the common bits so it doesn't get too complicated. Either case, we will install a RemoteDOMWindow as the C++ pointer directly.
Finally, we will need a way to swap a RemoteFrame back to a LocalFrame, but we might be able to use the same swap function from #1.
We also need to figure out how to help V8WindowShell live across this swap; right now, ScriptController owns it. I don't think RemoteFrame needs a ScriptController, since you shouldn't be able to evaluate script directly in a RemoteFrame context. I don't know if we should try to factor this out (I imagine this is hard) or have some method to hand off ownership to RemoteFrame for swapping.