mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/44845 ## Design - `NetworkIOAgent` is owned by the `HostAgent`. - `NetworkIOAgent` is passed any CDP requests not handled by the `HostAgent` itself, and before delegating to `InstanceAgent`. - It handles: - [`Network.loadNetworkResource`](https://chromedevtools.github.io/devtools-protocol/tot/Network/#method-loadNetworkResource) - [`IO.read`](https://chromedevtools.github.io/devtools-protocol/tot/IO/#method-read) - [`IO.close`](https://chromedevtools.github.io/devtools-protocol/tot/IO/#method-close) - `NetworkIOAgent.loadNetworkResource` creates a `Stream` corresponding to a single resource download/upload. A reference is held in a map `streams_` until an error, the agent is disconnected (destroyed) or it is discarded by the frontend with `IO.close`. - `delegate.loadNetworkResource` is called with a `stream`-scoped executor, which it uses to call back with headers, data and errors. - Callbacks for `IO.read` requests are held by the `Stream` until the incoming data is complete or enough data is available to fill the request (an implementation choice to optimise for fewest round trips). Any incoming data or error causes any pending requests to be rechecked. {F1719616688} ## Unimplemented platforms - Platforms may optionally implement `HostTargetDelegate.networkRequest` (as of this diff, none do). If they don't we report a CDP "not implemented" error, similar to the status quo where it was unimplemented by the C++ agent. Changelog: [General][Added] Debugging: implement common C++ layer of CDP `Network.loadNetworkResource` Reviewed By: motiz88 Differential Revision: D54309633 fbshipit-source-id: 51e416e9d537b253f72693952d5fd520b6ae11b6