mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Add the TaskSourceName to CommonScriptMsg::Task
Update QueuedTaskConversion and the TaskQueue to use it
This commit is contained in:
parent
b211e45bb0
commit
e286fdcc53
18 changed files with 134 additions and 71 deletions
|
@ -27,7 +27,7 @@ use js::jsapi::{JSAutoCompartment, JSContext, JS_AddInterruptCallback};
|
|||
use js::jsval::UndefinedValue;
|
||||
use net_traits::{load_whole_resource, IpcSend, CustomResponseMediator};
|
||||
use net_traits::request::{CredentialsMode, Destination, RequestInit};
|
||||
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory, new_rt_and_cx, Runtime};
|
||||
use script_runtime::{CommonScriptMsg, ScriptChan, new_rt_and_cx, Runtime};
|
||||
use script_traits::{TimerEvent, WorkerGlobalScopeInit, ScopeThings, ServiceWorkerMsg, WorkerScriptLoadOrigin};
|
||||
use servo_config::prefs::PREFS;
|
||||
use servo_rand::random;
|
||||
|
@ -37,6 +37,7 @@ use std::thread;
|
|||
use std::time::Duration;
|
||||
use style::thread_state::{self, ThreadState};
|
||||
use task_queue::{QueuedTask, QueuedTaskConversion, TaskQueue};
|
||||
use task_source::TaskSourceName;
|
||||
|
||||
/// Messages used to control service worker event loop
|
||||
pub enum ServiceWorkerScriptMsg {
|
||||
|
@ -49,16 +50,15 @@ pub enum ServiceWorkerScriptMsg {
|
|||
}
|
||||
|
||||
impl QueuedTaskConversion for ServiceWorkerScriptMsg {
|
||||
fn task_category(&self) -> Option<&ScriptThreadEventCategory> {
|
||||
fn task_source_name(&self) -> Option<&TaskSourceName> {
|
||||
let script_msg = match self {
|
||||
ServiceWorkerScriptMsg::CommonWorker(WorkerScriptMsg::Common(script_msg)) => script_msg,
|
||||
_ => return None,
|
||||
};
|
||||
let category = match script_msg {
|
||||
CommonScriptMsg::Task(category, _boxed, _pipeline_id) => category,
|
||||
match script_msg {
|
||||
CommonScriptMsg::Task(_category, _boxed, _pipeline_id, task_source) => Some(&task_source),
|
||||
_ => return None,
|
||||
};
|
||||
Some(&category)
|
||||
}
|
||||
}
|
||||
|
||||
fn into_queued_task(self) -> Option<QueuedTask> {
|
||||
|
@ -66,17 +66,17 @@ impl QueuedTaskConversion for ServiceWorkerScriptMsg {
|
|||
ServiceWorkerScriptMsg::CommonWorker(WorkerScriptMsg::Common(script_msg)) => script_msg,
|
||||
_ => return None,
|
||||
};
|
||||
let (category, boxed, pipeline_id) = match script_msg {
|
||||
CommonScriptMsg::Task(category, boxed, pipeline_id) =>
|
||||
(category, boxed, pipeline_id),
|
||||
let (category, boxed, pipeline_id, task_source) = match script_msg {
|
||||
CommonScriptMsg::Task(category, boxed, pipeline_id, task_source) =>
|
||||
(category, boxed, pipeline_id, task_source),
|
||||
_ => return None,
|
||||
};
|
||||
Some((None, category, boxed, pipeline_id))
|
||||
Some((None, category, boxed, pipeline_id, task_source))
|
||||
}
|
||||
|
||||
fn from_queued_task(queued_task: QueuedTask) -> Self {
|
||||
let (_worker, category, boxed, pipeline_id) = queued_task;
|
||||
let script_msg = CommonScriptMsg::Task(category, boxed, pipeline_id);
|
||||
let (_worker, category, boxed, pipeline_id, task_source) = queued_task;
|
||||
let script_msg = CommonScriptMsg::Task(category, boxed, pipeline_id, task_source);
|
||||
ServiceWorkerScriptMsg::CommonWorker(WorkerScriptMsg::Common(script_msg))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue