diff --git a/components/script/dom/dedicatedworkerglobalscope.rs b/components/script/dom/dedicatedworkerglobalscope.rs index c425c38b86b..95180513ccf 100644 --- a/components/script/dom/dedicatedworkerglobalscope.rs +++ b/components/script/dom/dedicatedworkerglobalscope.rs @@ -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, runtime: Runtime, parent_sender: Box, @@ -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, runtime: Runtime, parent_sender: Box, @@ -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, worker_rt_for_mainthread: Arc>>, 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, Box) { let (tx, rx) = channel(); let chan = box SendableWorkerScriptChan { diff --git a/components/script/dom/serviceworkerglobalscope.rs b/components/script/dom/serviceworkerglobalscope.rs index f6208b63586..6efd555c909 100644 --- a/components/script/dom/serviceworkerglobalscope.rs +++ b/components/script/dom/serviceworkerglobalscope.rs @@ -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, #[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, runtime: Runtime, own_sender: Sender, @@ -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, runtime: Runtime, own_sender: Sender, @@ -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, 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::(); @@ -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))); } diff --git a/components/script/dom/worker.rs b/components/script/dom/worker.rs index 1821b2d2dee..fb6b170ab1d 100644 --- a/components/script/dom/worker.rs +++ b/components/script/dom/worker.rs @@ -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) diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs index f2809537316..689e1888e08 100644 --- a/components/script/dom/workerglobalscope.rs +++ b/components/script/dom/workerglobalscope.rs @@ -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>, #[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::(); - let service_worker = self.downcast::(); - 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, Box) { diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index c28942688e5..65c52153a63 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -663,6 +663,8 @@ pub struct WorkerGlobalScopeInit { pub scheduler_chan: IpcSender, /// The worker id pub worker_id: WorkerId, + /// The pipeline id + pub pipeline_id: PipelineId, } /// Common entities representing a network load origin