Hi Guys,
I'm trying to add an HTTP header to all outgoing requests that contains the URL of the main frame they're associated with. For example, if a page contains 6 images, I'd like to tag a header onto the URL requests that contains the main frame's document URL. (The header is going to be used on the proxy server side to annotate logs.)
Originally, I implemented it as a net::URLRequestInterceptor, by posting a task to the UI thread message loop in my custom URLRequestJob::Start() to grab the URL and then jumping back to the IO thread before adding it to the request and then starting the URLRequestJob. It mostly works, but there's a number of threading and null pointer issues with the approach.
It seems to me that I'd be better served just annotating the main frame URL onto the requests when they're made in the UI thread before they're submitted, rather than jumping around threads in an interceptor after the fact.
I'm struggling to find the right place to do that.
RenderFrameImpl::WillSendRequest - This looks promising but I have a hunch this is only called for the frame's document, not any sub-resources.
ChromeContentRendererClient::RenderThreadStarted - I've also looked at adding a sub-resource filter here.
I've spent a couple days spelunking in the
cs.chromium.org, so any advice from someone with more experience on the best approach would be immensely appreciated.
(The main reason I organized it as a URLRequestInterceptor initially was to keep it compartmentalized and minimize the changes to the main Chromium code base as much as possible.)
Thank you in advance for any help.
-J