pub struct BrowserResourceLoader {
pub network: Option<Rc<NetworkCore>>,
pub immediate_pool: Vec<BrowserNetworkMessage>,
}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 pushed toimmediate_poolasBrowserNetworkMessages. - 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 std::rc::Rc;
use orinium_browser::platform::network::NetworkCore;
let network = Some(Rc::new(NetworkCore::new().unwrap()));
let loader = BrowserResourceLoader::new(network);
// Typical call (pseudocode):
// let body = loader.fetch(&url)?;
// process body...Notes for contributors:
- Keep the loader focused on scheme resolution, simple caching/pooling,
and delegation to
NetworkCore. Avoid adding heavy parsing logic here. - Unit tests should validate
resource:///anddata:resolution and HTTP request delegation semantics (e.g. mapping of request IDs to responses).
Fields§
§network: Option<Rc<NetworkCore>>Optional platform network core used for HTTP/HTTPS requests.
immediate_pool: Vec<BrowserNetworkMessage>Immediate pool / internal queue for messages produced by the loader.
The concrete type BrowserNetworkMessage represents internal network
events; see the network module for details.
Implementations§
Source§impl BrowserResourceLoader
impl BrowserResourceLoader
Sourcepub fn new(network: Option<Rc<NetworkCore>>) -> Self
pub fn new(network: Option<Rc<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 fetch_async(&mut self, url: Url, id: usize, initiator: &Origin)
pub fn fetch_async(&mut self, url: Url, id: usize, initiator: &Origin)
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. Its scheme access
is enforced here: web (network) origins can never reach internal
resource:/custom scheme content.
Sourcepub fn fetch_request_async(
&mut self,
request: NetworkRequest,
id: usize,
initiator: &Origin,
)
pub fn fetch_request_async( &mut self, request: NetworkRequest, id: usize, initiator: &Origin, )
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 !RefUnwindSafe for BrowserResourceLoader
impl !Send for BrowserResourceLoader
impl !Sync for BrowserResourceLoader
impl !UnwindSafe for BrowserResourceLoader
impl Freeze 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>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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