Page load metrics wants to attribute data usage with page loads.
We currently hook into NotifyUIThreadOfRequestComplete in chrome_resource_dispatcher_host_delegate.cc, where we learn of completed URLRequests and attribute them to the currently committed load of the associated web contents.
This mostly works fine, but can be racy in cases where a request is initiated at the end of one document's lifetime, and finishes loading when a new document has been committed in the same tab. Consider the following:
1. renderer has a committed page A
2. navigation is initiated to page B
3. page A initiates URLRequests (e.g. in the unload handler)
4. page B commits
5. the URLRequests initiated by A complete
In the above example, the URLRequests initiated by A will be attributed to page load B.
Having a document identifier at the content/ layer, and annotating each URLRequest with its document id (via ResourceRequestInfo or something similar) would allow us to match up each request with its associated document.
Comment 1 by bmcquade@chromium.org
, Jun 30 2017