Skip to main content

BrowserResourceLoader

Struct BrowserResourceLoader 

Source
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):

  1. Caller requests a URL (resource:///..., data:... or http(s)://...).
  2. Network-free schemes (resource, data) are resolved locally and posted to the internal channel as BrowserNetworkMessages.
  3. For HTTP/HTTPS, loader forwards the request to NetworkCore and 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 !Send handle) around NetworkCore; it would make this type impossible to move.
  • Unit tests should validate resource:/// and data: resolution and HTTP request delegation semantics (e.g. mapping of request IDs to responses).

Implementations§

Source§

impl BrowserResourceLoader

Source

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).

Source

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.

Source

pub fn with_network(network: NetworkCore) -> Self

Constructs a loader backed by network.

Source

pub fn offline() -> Self

Constructs a loader that performs no network I/O.

resource:///, data: and file:// still resolve; anything else is dropped.

Source

pub fn set_network_config(&self, config: NetworkConfig)

Applies a new configuration to the network process, if present.

Source

pub fn clear_cache(&self)

Drops every cached response held by the network process, if present.

Source

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.

Source

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).

Source

pub fn fetch_blocking(&self, url: Url) -> Result<BrowserResponse>

Source

pub fn try_receive(&mut self) -> Vec<BrowserNetworkMessage>

Called from the UI thread: collect received network and immediate-scheme results.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

§

fn into_sample(self) -> T

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more