observing network state in a renderer?

18 views
Skip to first unread message

Chris Mumford

unread,
Jun 18, 2018, 1:55:44 PM6/18/18
to Chromium-dev
Is it possible to observe the network state in a renderer? I'm moving some code that's currently using net::NetworkChangeNotifier::NetworkChangeObserver into the renderer and am looking for an equivalent.

Ryan Sleevi

unread,
Jun 18, 2018, 2:15:51 PM6/18/18
to Chris Mumford, net-dev
bcc: chromium-dev
+cc: net-dev

"It depends" - but to do so reliably directly would require either poking more holes in the sandbox or proactively notifying the (potentially hostile) renderer, both of which can serve as information leaks.

The former should not be possible today, and the latter is only practiced in a few limited cases, specific to the feature, and not in a generalized way. For example, the socket APIs dispatch an event of network interfaces changing, rather than when the user changes network, such as for WebRTC, and only when the renderer is using WebRTC. And this is before getting into things like S13N and whether the browser will even be monitoring for these events going forward.

Since it sounds like you're going to be crossing a privilege/security boundary, could you explain a bit more about what code you're moving?

On Mon, Jun 18, 2018 at 1:55 PM, Chris Mumford <cmum...@chromium.org> wrote:
Is it possible to observe the network state in a renderer? I'm moving some code that's currently using net::NetworkChangeNotifier::NetworkChangeObserver into the renderer and am looking for an equivalent.

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/bbf69e57-5546-419f-9c10-9bd335776962%40chromium.org.

Chris Mumford

unread,
Jun 18, 2018, 3:28:59 PM6/18/18
to Chromium-dev, cmum...@chromium.org, net...@chromium.org, rsl...@chromium.org
Sure, and thanks for the response Ryan. I'm implementing the extensions throttle for the network service (crbug.com/784576). Today that throttle (ExtensionRequestLimitingThrottle) lives in the browser process. For S13N I'm moving it into the renderer, and along with it the ExtensionThrottleManager which relies on //net fairly heavily.

Tarun Bansal

unread,
Jun 18, 2018, 3:58:41 PM6/18/18
to Chromium-dev, cmum...@chromium.org, net...@chromium.org, rsl...@chromium.org
If you only want to know the network state (if it's connected or not) and get callbacks onn change events, it's possible using NetworkStateNotifier in blink:

The network state is passed from browser to renderer through https://cs.chromium.org/chromium/src/content/browser/net/browser_online_state_observer.h

The information from net::NetworkChangeNotifier to blink passes via renderer. e.g., https://cs.chromium.org/chromium/src/content/renderer/render_thread_impl.h?rcl=56a6262f1826f71e8426642a498bc0bca92cebbb&l=566

The network information in Blink path is eventually used by Chrome to expose network state via NetInfo JavaScript APIs:
Reply all
Reply to author
Forward
0 new messages