Hi network teams,
Context:
We are implementing a new unload beacon API (
explainer): in short, developers can create and queue beacons on a page. The beacons will be sent out by browser sometimes later either after specified time or when the page is discarded/in bfcache.
One privacy requirement we'd like to address is that beacons shouldn't be sent to a different network when users think that they have left the page (either by closing the page or navigating away).
Right now, beacon requests are constructed in the browser process, and get passed into SImpleURLLoader for sending. However, even if we do our best to listen to
OnNetworkChanged() right before calling SImpleURLLoader, at worst network change can still happen within the loader, right before it sends out the request. Example scenario:
1. user is on network1
2. user navigates to
site1.com, which queues beacon1
4. the browser process observes no network change happens
5. (In browser, SimpleURLLoader is about to send out beacon1) user switches to network2.
Question:
1. Is there a way to make SimpleURLLoader (or any other loader) drop requests when the network changes? Or do we have to implement our own loader?
2. It looks like the Reporting API has similar requirements. But they seem to implement the entire //net level
stuff. Do they solve this issue?
Thanks,
Ming