mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
in BC event-loop, only run tasks related to fully-active documents
This commit is contained in:
parent
6b648429f5
commit
ecfb9c639a
9 changed files with 219 additions and 14 deletions
|
@ -29,6 +29,7 @@ use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
|||
use ipc_channel::router::ROUTER;
|
||||
use js::jsapi::{JSAutoCompartment, JSContext, JS_AddInterruptCallback};
|
||||
use js::jsval::UndefinedValue;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use net_traits::request::{CredentialsMode, Destination, RequestInit};
|
||||
use net_traits::{load_whole_resource, CustomResponseMediator, IpcSend};
|
||||
use script_traits::{
|
||||
|
@ -61,10 +62,16 @@ impl QueuedTaskConversion for ServiceWorkerScriptMsg {
|
|||
CommonScriptMsg::Task(_category, _boxed, _pipeline_id, task_source) => {
|
||||
Some(&task_source)
|
||||
},
|
||||
_ => return None,
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn pipeline_id(&self) -> Option<PipelineId> {
|
||||
// Workers always return None, since the pipeline_id is only used to check for document activity,
|
||||
// and this check does not apply to worker event-loops.
|
||||
None
|
||||
}
|
||||
|
||||
fn into_queued_task(self) -> Option<QueuedTask> {
|
||||
let script_msg = match self {
|
||||
ServiceWorkerScriptMsg::CommonWorker(WorkerScriptMsg::Common(script_msg)) => script_msg,
|
||||
|
@ -85,6 +92,11 @@ impl QueuedTaskConversion for ServiceWorkerScriptMsg {
|
|||
ServiceWorkerScriptMsg::CommonWorker(WorkerScriptMsg::Common(script_msg))
|
||||
}
|
||||
|
||||
fn inactive_msg() -> Self {
|
||||
// Inactive is only relevant in the context of a browsing-context event-loop.
|
||||
panic!("Workers should never receive messages marked as inactive");
|
||||
}
|
||||
|
||||
fn wake_up_msg() -> Self {
|
||||
ServiceWorkerScriptMsg::WakeUp
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue