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. - 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 (either
resource:///...orhttp(s)://...). - If the URL scheme is
resource, loader resolves it to a local path or embedded asset and returns the bytes immediately when available. - 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()));
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:///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)
pub fn fetch_async(&mut self, url: Url, id: usize)
非同期 fetch: URL と ID を送信するだけ
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>
UIスレッドから呼ぶ: 受信済みネットワーク結果を取り込む
Auto Trait Implementations§
impl Freeze for BrowserResourceLoader
impl RefUnwindSafe for BrowserResourceLoader
impl !Send for BrowserResourceLoader
impl !Sync for BrowserResourceLoader
impl Unpin for BrowserResourceLoader
impl UnwindSafe 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
Mutably borrows from an owned value. Read more
§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>
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 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>
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