Necko integration with NavigationController

Josh Matthews <[email protected]> Thu, 19 Sep 2013 15:42:20 -0400
Newsgroups gmane.comp.mozilla.devel.netlib
Message-ID <[email protected]>
I'm working on an experimental NavigationController 
(https://github.com/slightlyoff/EventWorker/blob/master/explainer.md) 
implementation for Gecko. Part of this work requires me to intercept 
navigation requests before they turn into network requests and allow 
content code to provide a synthesized response. I'm going to document my 
current thinking and experiments for implementing this in Necko, and 
then I'm hoping for feedback and/or suggestions for alternatives.

Focusing on nsHttpChannel for now, my avenue of attack is the following:
* split the code that runs in AsyncOpen into AsyncOpenSetup (everything 
that sets headers on the channel) and FinishAsyncOpen (everything that 
initiates an actual network request)
* create a new wrapper channel implementation that QIs to nsIChannel, 
and contains the ability to inject an nsIInputStream which will be 
passed to the wrapped channel's streamlistener callbacks.
* I am contemplating making this wrapper channel also QI to every 
interface that nsHttpChannel implements and forward the calls that 
should modify the underlying channel

This is incomplete, because fields like mResponseHead need to be 
initialized, but I'm hoping for feedback as to whether this sounds 
workable or not. Note that we also need the ability to continue the 
original request (or perhaps a clone of it somehow) if the web content 
decides not to intercept it.  Any thoughts?

Cheers,
Josh