pub struct BrowserResourceLoader { /* private fields */ }Expand description
BrowserResourceLoader
High-level resource loading abstraction used by the browser core to obtain content for tabs and internal resources.
Responsibilities:
- Resolve and fetch resources from
resource:///scheme (bundled/local) and from standard HTTP/HTTPS URLs. - Decode
data:URLs (base64 or percent-encoded payloads) without touching the network stack. - Provide a small synchronous/queuing abstraction over the platform network core so callers in the engine/browser can request resources without dealing with the network implementation details.
Processing flow (overview):
- Caller requests a URL (
resource:///...,data:...orhttp(s)://...). - Network-free schemes (
resource,data) are resolved locally and posted to the internal channel asBrowserNetworkMessages. - For HTTP/HTTPS, loader forwards the request to
NetworkCoreand manages request ids / pending responses. When the network reply is ready, the loader hands the response back to the browser/tab via the expected callback or message path.
Example usage:
use orinium_browser::browser::core::resource_loader::BrowserResourceLoader;
use orinium_browser::platform::network::NetworkCore;
let loader = BrowserResourceLoader::new(NetworkCore::new().ok());The loader is Send: it owns its NetworkCore outright rather than
sharing it through a single-threaded handle. BrowserApp is not Send
yet, because it still holds per-window BrowserUi state; the loader is
free of that so it can move once the page boundary does.
Notes for contributors:
- Keep the loader focused on scheme resolution, simple caching/pooling,
and delegation to
NetworkCore. Avoid adding heavy parsing logic here. - Do not reintroduce
Rc(or any other!Sendhandle) aroundNetworkCore; it would make this type impossible to move. - Unit tests should validate
resource:///anddata:resolution and HTTP request delegation semantics (e.g. mapping of request IDs to responses).
Implementations§
Source§impl BrowserResourceLoader
impl BrowserResourceLoader
Sourcepub fn new(network: Option<NetworkCore>) -> Self
pub fn new(network: Option<NetworkCore>) -> Self
Construct a new resource loader.
network is optional to allow operating in environments where the
network stack is not available (tests, limited examples, or when only
resource:/// is needed).
Sourcepub fn with_transport<T: Transport>(
network: Option<NetworkCore>,
transport: &T,
) -> Self
pub fn with_transport<T: Transport>( network: Option<NetworkCore>, transport: &T, ) -> Self
Constructs a loader whose internal channel is carried by transport.
The default InProcess hands messages over directly. Generic rather
than &dyn Transport because pairing the ends is generic over the
message type, which costs object safety — and the transport is only
needed here, so it does not have to be stored either.
Sourcepub fn with_network(network: NetworkCore) -> Self
pub fn with_network(network: NetworkCore) -> Self
Constructs a loader backed by network.
Sourcepub fn offline() -> Self
pub fn offline() -> Self
Constructs a loader that performs no network I/O.
resource:///, data: and file:// still resolve; anything else is
dropped.
Sourcepub fn set_network_config(&self, config: NetworkConfig)
pub fn set_network_config(&self, config: NetworkConfig)
Applies a new configuration to the network process, if present.
Sourcepub fn clear_cache(&self)
pub fn clear_cache(&self)
Drops every cached response held by the network process, if present.
Sourcepub fn fetch_async(
&mut self,
url: Url,
id: usize,
initiator: &Origin,
permissions: Permissions,
)
pub fn fetch_async( &mut self, url: Url, id: usize, initiator: &Origin, permissions: Permissions, )
Async fetch: resolve immediate schemes (resource / data) in place and
push the result to immediate_pool; delegate all other schemes to NetworkCore.
initiator is the origin of the requesting document and permissions its
effective capabilities. Scheme access is enforced here: a document can
never reach a scheme its permissions do not allow.
Sourcepub fn fetch_request_async(
&mut self,
request: NetworkRequest,
id: usize,
initiator: &Origin,
permissions: Permissions,
)
pub fn fetch_request_async( &mut self, request: NetworkRequest, id: usize, initiator: &Origin, permissions: Permissions, )
Fetches a request while preserving method, headers, and body for HTTP(S).
pub fn fetch_blocking(&self, url: Url) -> Result<BrowserResponse>
Sourcepub fn try_receive(&mut self) -> Vec<BrowserNetworkMessage>
pub fn try_receive(&mut self) -> Vec<BrowserNetworkMessage>
Called from the UI thread: collect received network and immediate-scheme results.
Auto Trait Implementations§
impl !Freeze for BrowserResourceLoader
impl !RefUnwindSafe for BrowserResourceLoader
impl !Sync for BrowserResourceLoader
impl !UnwindSafe for BrowserResourceLoader
impl Send for BrowserResourceLoader
impl Unpin for BrowserResourceLoader
impl UnsafeUnpin for BrowserResourceLoader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more