mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Move workers' pipeline IDs to WorkerGlobalScope
This commit is contained in:
parent
fce0a8e7cf
commit
4ccdbccdd7
5 changed files with 11 additions and 35 deletions
|
@ -81,7 +81,6 @@ enum MixedMessage {
|
|||
#[dom_struct]
|
||||
pub struct DedicatedWorkerGlobalScope {
|
||||
workerglobalscope: WorkerGlobalScope,
|
||||
id: PipelineId,
|
||||
#[ignore_heap_size_of = "Defined in std"]
|
||||
receiver: Receiver<(TrustedWorkerAddress, WorkerScriptMsg)>,
|
||||
#[ignore_heap_size_of = "Defined in std"]
|
||||
|
@ -100,7 +99,6 @@ pub struct DedicatedWorkerGlobalScope {
|
|||
impl DedicatedWorkerGlobalScope {
|
||||
fn new_inherited(init: WorkerGlobalScopeInit,
|
||||
worker_url: Url,
|
||||
id: PipelineId,
|
||||
from_devtools_receiver: Receiver<DevtoolScriptControlMsg>,
|
||||
runtime: Runtime,
|
||||
parent_sender: Box<ScriptChan + Send>,
|
||||
|
@ -117,7 +115,6 @@ impl DedicatedWorkerGlobalScope {
|
|||
from_devtools_receiver,
|
||||
timer_event_chan,
|
||||
Some(closing)),
|
||||
id: id,
|
||||
receiver: receiver,
|
||||
own_sender: own_sender,
|
||||
timer_event_port: timer_event_port,
|
||||
|
@ -129,7 +126,6 @@ impl DedicatedWorkerGlobalScope {
|
|||
|
||||
pub fn new(init: WorkerGlobalScopeInit,
|
||||
worker_url: Url,
|
||||
id: PipelineId,
|
||||
from_devtools_receiver: Receiver<DevtoolScriptControlMsg>,
|
||||
runtime: Runtime,
|
||||
parent_sender: Box<ScriptChan + Send>,
|
||||
|
@ -142,7 +138,6 @@ impl DedicatedWorkerGlobalScope {
|
|||
let cx = runtime.cx();
|
||||
let scope = box DedicatedWorkerGlobalScope::new_inherited(init,
|
||||
worker_url,
|
||||
id,
|
||||
from_devtools_receiver,
|
||||
runtime,
|
||||
parent_sender,
|
||||
|
@ -157,7 +152,6 @@ impl DedicatedWorkerGlobalScope {
|
|||
#[allow(unsafe_code)]
|
||||
pub fn run_worker_scope(init: WorkerGlobalScopeInit,
|
||||
worker_url: Url,
|
||||
id: PipelineId,
|
||||
from_devtools_receiver: IpcReceiver<DevtoolScriptControlMsg>,
|
||||
worker_rt_for_mainthread: Arc<Mutex<Option<SharedRt>>>,
|
||||
worker: TrustedWorkerAddress,
|
||||
|
@ -170,7 +164,7 @@ impl DedicatedWorkerGlobalScope {
|
|||
let name = format!("WebWorker for {}", serialized_worker_url);
|
||||
spawn_named(name, move || {
|
||||
thread_state::initialize(thread_state::SCRIPT | thread_state::IN_WORKER);
|
||||
PipelineId::install(id);
|
||||
PipelineId::install(init.pipeline_id);
|
||||
|
||||
let roots = RootCollection::new();
|
||||
let _stack_roots_tls = StackRootTLS::new(&roots);
|
||||
|
@ -204,7 +198,7 @@ impl DedicatedWorkerGlobalScope {
|
|||
});
|
||||
|
||||
let global = DedicatedWorkerGlobalScope::new(
|
||||
init, url, id, devtools_mpsc_port, runtime,
|
||||
init, url, devtools_mpsc_port, runtime,
|
||||
parent_sender.clone(), own_sender, receiver,
|
||||
timer_ipc_chan, timer_rx, closing);
|
||||
// FIXME(njn): workers currently don't have a unique ID suitable for using in reporter
|
||||
|
@ -244,10 +238,6 @@ impl DedicatedWorkerGlobalScope {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn pipeline_id(&self) -> PipelineId {
|
||||
self.id
|
||||
}
|
||||
|
||||
pub fn new_script_pair(&self) -> (Box<ScriptChan + Send>, Box<ScriptPort + Send>) {
|
||||
let (tx, rx) = channel();
|
||||
let chan = box SendableWorkerScriptChan {
|
||||
|
|
|
@ -23,7 +23,6 @@ use ipc_channel::router::ROUTER;
|
|||
use js::jsapi::{JS_SetInterruptCallback, JSAutoCompartment, JSContext};
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::rust::Runtime;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use net_traits::{LoadContext, load_whole_resource, IpcSend, CustomResponseMediator};
|
||||
use rand::random;
|
||||
use script_runtime::{CommonScriptMsg, StackRootTLS, get_reports, new_rt_and_cx, ScriptChan};
|
||||
|
@ -72,7 +71,6 @@ impl ScriptChan for ServiceWorkerChan {
|
|||
#[dom_struct]
|
||||
pub struct ServiceWorkerGlobalScope {
|
||||
workerglobalscope: WorkerGlobalScope,
|
||||
id: PipelineId,
|
||||
#[ignore_heap_size_of = "Defined in std"]
|
||||
receiver: Receiver<ServiceWorkerScriptMsg>,
|
||||
#[ignore_heap_size_of = "Defined in std"]
|
||||
|
@ -87,7 +85,6 @@ pub struct ServiceWorkerGlobalScope {
|
|||
impl ServiceWorkerGlobalScope {
|
||||
fn new_inherited(init: WorkerGlobalScopeInit,
|
||||
worker_url: Url,
|
||||
id: PipelineId,
|
||||
from_devtools_receiver: Receiver<DevtoolScriptControlMsg>,
|
||||
runtime: Runtime,
|
||||
own_sender: Sender<ServiceWorkerScriptMsg>,
|
||||
|
@ -104,7 +101,6 @@ impl ServiceWorkerGlobalScope {
|
|||
from_devtools_receiver,
|
||||
timer_event_chan,
|
||||
None),
|
||||
id: id,
|
||||
receiver: receiver,
|
||||
timer_event_port: timer_event_port,
|
||||
own_sender: own_sender,
|
||||
|
@ -115,7 +111,6 @@ impl ServiceWorkerGlobalScope {
|
|||
|
||||
pub fn new(init: WorkerGlobalScopeInit,
|
||||
worker_url: Url,
|
||||
id: PipelineId,
|
||||
from_devtools_receiver: Receiver<DevtoolScriptControlMsg>,
|
||||
runtime: Runtime,
|
||||
own_sender: Sender<ServiceWorkerScriptMsg>,
|
||||
|
@ -128,7 +123,6 @@ impl ServiceWorkerGlobalScope {
|
|||
let cx = runtime.cx();
|
||||
let scope = box ServiceWorkerGlobalScope::new_inherited(init,
|
||||
worker_url,
|
||||
id,
|
||||
from_devtools_receiver,
|
||||
runtime,
|
||||
own_sender,
|
||||
|
@ -148,7 +142,6 @@ impl ServiceWorkerGlobalScope {
|
|||
swmanager_sender: IpcSender<ServiceWorkerMsg>,
|
||||
scope_url: Url) {
|
||||
let ScopeThings { script_url,
|
||||
pipeline_id,
|
||||
init,
|
||||
worker_load_origin,
|
||||
.. } = scope_things;
|
||||
|
@ -179,7 +172,7 @@ impl ServiceWorkerGlobalScope {
|
|||
let (timer_ipc_chan, _timer_ipc_port) = ipc::channel().unwrap();
|
||||
let (timer_chan, timer_port) = channel();
|
||||
let global = ServiceWorkerGlobalScope::new(
|
||||
init, url, pipeline_id, devtools_mpsc_port, runtime,
|
||||
init, url, devtools_mpsc_port, runtime,
|
||||
own_sender, receiver,
|
||||
timer_ipc_chan, timer_port, swmanager_sender, scope_url);
|
||||
let scope = global.upcast::<WorkerGlobalScope>();
|
||||
|
@ -298,10 +291,6 @@ impl ServiceWorkerGlobalScope {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn pipeline_id(&self) -> PipelineId {
|
||||
self.id
|
||||
}
|
||||
|
||||
pub fn process_event(&self, msg: CommonScriptMsg) {
|
||||
self.handle_script_event(ServiceWorkerScriptMsg::CommonWorker(WorkerScriptMsg::Common(msg)));
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ impl Worker {
|
|||
let init = prepare_workerscope_init(global, Some(devtools_sender));
|
||||
|
||||
DedicatedWorkerGlobalScope::run_worker_scope(
|
||||
init, worker_url, global.pipeline_id(), devtools_receiver, worker.runtime.clone(), worker_ref,
|
||||
init, worker_url, devtools_receiver, worker.runtime.clone(), worker_ref,
|
||||
global.script_chan(), sender, receiver, worker_load_origin, closing);
|
||||
|
||||
Ok(worker)
|
||||
|
|
|
@ -66,7 +66,8 @@ pub fn prepare_workerscope_init(global: GlobalRef,
|
|||
from_devtools_sender: devtools_sender,
|
||||
constellation_chan: global.constellation_chan().clone(),
|
||||
scheduler_chan: global.scheduler_chan().clone(),
|
||||
worker_id: worker_id
|
||||
worker_id: worker_id,
|
||||
pipeline_id: global.pipeline_id(),
|
||||
};
|
||||
|
||||
init
|
||||
|
@ -77,6 +78,7 @@ pub fn prepare_workerscope_init(global: GlobalRef,
|
|||
pub struct WorkerGlobalScope {
|
||||
eventtarget: EventTarget,
|
||||
worker_id: WorkerId,
|
||||
pipeline_id: PipelineId,
|
||||
worker_url: Url,
|
||||
closing: Option<Arc<AtomicBool>>,
|
||||
#[ignore_heap_size_of = "Defined in js"]
|
||||
|
@ -134,6 +136,7 @@ impl WorkerGlobalScope {
|
|||
eventtarget: EventTarget::new_inherited(),
|
||||
next_worker_id: Cell::new(WorkerId(0)),
|
||||
worker_id: init.worker_id,
|
||||
pipeline_id: init.pipeline_id,
|
||||
worker_url: worker_url,
|
||||
closing: closing,
|
||||
runtime: runtime,
|
||||
|
@ -447,15 +450,7 @@ impl WorkerGlobalScope {
|
|||
}
|
||||
|
||||
pub fn pipeline_id(&self) -> PipelineId {
|
||||
let dedicated = self.downcast::<DedicatedWorkerGlobalScope>();
|
||||
let service_worker = self.downcast::<ServiceWorkerGlobalScope>();
|
||||
if let Some(dedicated) = dedicated {
|
||||
return dedicated.pipeline_id();
|
||||
} else if let Some(service_worker) = service_worker {
|
||||
return service_worker.pipeline_id();
|
||||
} else {
|
||||
panic!("need to implement a sender for SharedWorker")
|
||||
}
|
||||
self.pipeline_id
|
||||
}
|
||||
|
||||
pub fn new_script_pair(&self) -> (Box<ScriptChan + Send>, Box<ScriptPort + Send>) {
|
||||
|
|
|
@ -663,6 +663,8 @@ pub struct WorkerGlobalScopeInit {
|
|||
pub scheduler_chan: IpcSender<TimerEventRequest>,
|
||||
/// The worker id
|
||||
pub worker_id: WorkerId,
|
||||
/// The pipeline id
|
||||
pub pipeline_id: PipelineId,
|
||||
}
|
||||
|
||||
/// Common entities representing a network load origin
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue