pub struct ServiceWorkerGlobalScopeState {
pub scope: WorkerGlobalScopeState,
pub registration_id: ServiceWorkerRegistrationId,
pub has_fetch_handler: bool,
pub has_activate_handler: bool,
pub has_install_handler: bool,
pub has_message_handler: bool,
pub scope_url: String,
}Expand description
A ServiceWorkerGlobalScope state tracked by bao_browser.
This struct represents the bao-side view of a ServiceWorker’s global scope. The actual DOM ServiceWorkerGlobalScope lives in servo’s ScriptThread; this struct tracks the state that bao needs for lifecycle management, CDP observability, and stealth consistency verification.
@trace REQ-BRW-004 [entity:ServiceWorkerGlobalScope] DF-WK-8 / DF-WK-10
Fields§
§scope: WorkerGlobalScopeStateThe base WorkerGlobalScope state. @trace REQ-BRW-004 [entity:ServiceWorkerGlobalScope] [entity:WorkerGlobalScope]
registration_id: ServiceWorkerRegistrationIdThe ServiceWorkerRegistrationId this scope belongs to. @trace REQ-BRW-004 [entity:ServiceWorkerGlobalScope]
has_fetch_handler: boolWhether onfetch event handler is registered. When true, the ServiceWorker intercepts fetch events within its scope. @trace REQ-BRW-004 [entity:ServiceWorkerGlobalScope] [criterion:19]
has_activate_handler: boolWhether onactivate event handler is registered. @trace REQ-BRW-004 [entity:ServiceWorkerGlobalScope]
has_install_handler: boolWhether oninstall event handler is registered. @trace REQ-BRW-004 [entity:ServiceWorkerGlobalScope]
has_message_handler: boolWhether onmessage event handler is registered (for SW-to-page messages). @trace REQ-BRW-004 [entity:ServiceWorkerGlobalScope]
scope_url: StringThe registration scope URL (used for fetch interception matching). @trace REQ-BRW-004 [entity:ServiceWorkerGlobalScope] DF-WK-8
Implementations§
Source§impl ServiceWorkerGlobalScopeState
impl ServiceWorkerGlobalScopeState
Sourcepub fn new(
registration_id: ServiceWorkerRegistrationId,
config: &ServiceWorkerScopeConfig,
) -> Self
pub fn new( registration_id: ServiceWorkerRegistrationId, config: &ServiceWorkerScopeConfig, ) -> Self
Create a ServiceWorkerGlobalScopeState for the given ServiceWorker registration.
@trace REQ-BRW-004 [entity:ServiceWorkerGlobalScope] DF-WK-8 / DF-WK-10
Sourcepub fn location(&self) -> Option<&WorkerLocation>
pub fn location(&self) -> Option<&WorkerLocation>
Get the WorkerLocation for this scope.
@trace REQ-BRW-004 [entity:ServiceWorkerGlobalScope] [entity:WorkerLocation]
Get the WorkerNavigator for this scope.
@trace REQ-BRW-004 [entity:ServiceWorkerGlobalScope] [entity:WorkerNavigator]
Sourcepub fn set_fetch_handler(&mut self)
pub fn set_fetch_handler(&mut self)
Mark onfetch handler as registered. When set, the ServiceWorker will intercept fetch events within its scope.
@trace REQ-BRW-004 [entity:ServiceWorkerGlobalScope] [criterion:19]
Sourcepub fn set_activate_handler(&mut self)
pub fn set_activate_handler(&mut self)
Mark onactivate handler as registered.
@trace REQ-BRW-004 [entity:ServiceWorkerGlobalScope]
Sourcepub fn set_install_handler(&mut self)
pub fn set_install_handler(&mut self)
Mark oninstall handler as registered.
@trace REQ-BRW-004 [entity:ServiceWorkerGlobalScope]
Sourcepub fn set_message_handler(&mut self)
pub fn set_message_handler(&mut self)
Mark onmessage handler as registered.
@trace REQ-BRW-004 [entity:ServiceWorkerGlobalScope]
Sourcepub fn is_url_in_scope(&self, url: &str) -> bool
pub fn is_url_in_scope(&self, url: &str) -> bool
Returns true if the given URL falls within this ServiceWorker’s scope.
Per DF-WK-8: “scope 匹配的导航/fetch 经 SW 拦截”. A URL is within scope if it starts with the scope URL prefix.
@trace REQ-BRW-004 [entity:ServiceWorkerGlobalScope] DF-WK-8
Trait Implementations§
Source§impl Clone for ServiceWorkerGlobalScopeState
impl Clone for ServiceWorkerGlobalScopeState
Source§fn clone(&self) -> ServiceWorkerGlobalScopeState
fn clone(&self) -> ServiceWorkerGlobalScopeState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ServiceWorkerGlobalScopeState
impl RefUnwindSafe for ServiceWorkerGlobalScopeState
impl Send for ServiceWorkerGlobalScopeState
impl Sync for ServiceWorkerGlobalScopeState
impl Unpin for ServiceWorkerGlobalScopeState
impl UnsafeUnpin for ServiceWorkerGlobalScopeState
impl UnwindSafe for ServiceWorkerGlobalScopeState
Blanket Implementations§
Source§impl<T> AsCtxPtr for Twhere
T: ?Sized,
impl<T> AsCtxPtr for Twhere
T: ?Sized,
Source§fn as_ctx_ptr(&self) -> *mut Selfwhere
Self: Sized,
fn as_ctx_ptr(&self) -> *mut Selfwhere
Self: Sized,
self’s address as *mut Self for deferred-task / scopeguard /
ref_guard ctx slots. The closures/trampolines deref it as shared
(&*p) — every method they reach is &self post-R-2, so no write
provenance is required; the *mut spelling is purely to match the
existing DerefOnDrop / HasAutoFlush / RefCount ABI.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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Filterable for T
impl<T> Filterable for T
Source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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