This commit is contained in:
Harrison G 2015-08-02 16:55:42 -04:00
parent f1c26c59f1
commit 49c5408e65
8 changed files with 67 additions and 40 deletions

View file

@ -46,6 +46,7 @@ pub enum WorkerGlobalScopeTypeId {
#[dom_struct]
pub struct WorkerGlobalScope {
eventtarget: EventTarget,
worker_id: Option<WorkerId>,
worker_url: Url,
runtime: Rc<Runtime>,
next_worker_id: Cell<WorkerId>,
@ -82,11 +83,13 @@ impl WorkerGlobalScope {
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
devtools_sender: Option<IpcSender<DevtoolScriptControlMsg>>,
devtools_receiver: Receiver<DevtoolScriptControlMsg>,
constellation_chan: ConstellationChan)
constellation_chan: ConstellationChan,
worker_id: Option<WorkerId>)
-> WorkerGlobalScope {
WorkerGlobalScope {
eventtarget: EventTarget::new_inherited(EventTargetTypeId::WorkerGlobalScope(type_id)),
next_worker_id: Cell::new(WorkerId(0)),
worker_id: worker_id,
worker_url: worker_url,
runtime: runtime,
resource_task: resource_task,
@ -141,6 +144,10 @@ impl WorkerGlobalScope {
&self.worker_url
}
pub fn get_worker_id(&self) -> Option<WorkerId> {
self.worker_id.clone()
}
pub fn get_next_worker_id(&self) -> WorkerId {
let worker_id = self.next_worker_id.get();
let WorkerId(id_num) = worker_id;