mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Add devtools_chan method to GlobalRef and make new globals notifications work with nested workers
fixup! Add devtools_chan method to GlobalRef and make new globals notifications work with nested workers fixup! Add devtools_chan method to GlobalRef and make new globals notifications work with nested workers
This commit is contained in:
parent
f22d920b4d
commit
ea5c702f4a
4 changed files with 73 additions and 23 deletions
|
@ -19,7 +19,9 @@ use dom::window::{base64_atob, base64_btoa};
|
|||
use script_task::{ScriptChan, TimerSource};
|
||||
use timers::{IsInterval, TimerId, TimerManager, TimerCallback};
|
||||
|
||||
use msg::constellation_msg::WorkerId;
|
||||
use devtools_traits::DevtoolsControlChan;
|
||||
|
||||
use msg::constellation_msg::{PipelineId, WorkerId};
|
||||
use net_traits::{load_whole_resource, ResourceTask};
|
||||
use util::str::DOMString;
|
||||
|
||||
|
@ -50,13 +52,15 @@ pub struct WorkerGlobalScope {
|
|||
navigator: MutNullableJS<WorkerNavigator>,
|
||||
console: MutNullableJS<Console>,
|
||||
timers: TimerManager,
|
||||
devtools_chan: Option<DevtoolsControlChan>,
|
||||
}
|
||||
|
||||
impl WorkerGlobalScope {
|
||||
pub fn new_inherited(type_id: WorkerGlobalScopeTypeId,
|
||||
worker_url: Url,
|
||||
cx: Rc<Cx>,
|
||||
resource_task: ResourceTask) -> WorkerGlobalScope {
|
||||
resource_task: ResourceTask,
|
||||
devtools_chan: Option<DevtoolsControlChan>) -> WorkerGlobalScope {
|
||||
WorkerGlobalScope {
|
||||
eventtarget: EventTarget::new_inherited(EventTargetTypeId::WorkerGlobalScope(type_id)),
|
||||
next_worker_id: Cell::new(WorkerId(0)),
|
||||
|
@ -67,9 +71,14 @@ impl WorkerGlobalScope {
|
|||
navigator: Default::default(),
|
||||
console: Default::default(),
|
||||
timers: TimerManager::new(),
|
||||
devtools_chan: devtools_chan,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn devtools_chan(&self) -> Option<DevtoolsControlChan> {
|
||||
self.devtools_chan.clone()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn eventtarget<'a>(&'a self) -> &'a EventTarget {
|
||||
&self.eventtarget
|
||||
|
@ -206,6 +215,7 @@ impl<'a> WorkerGlobalScopeMethods for JSRef<'a, WorkerGlobalScope> {
|
|||
pub trait WorkerGlobalScopeHelpers {
|
||||
fn handle_fire_timer(self, timer_id: TimerId);
|
||||
fn script_chan(self) -> Box<ScriptChan+Send>;
|
||||
fn pipeline(self) -> PipelineId;
|
||||
fn get_cx(self) -> *mut JSContext;
|
||||
}
|
||||
|
||||
|
@ -219,6 +229,15 @@ impl<'a> WorkerGlobalScopeHelpers for JSRef<'a, WorkerGlobalScope> {
|
|||
}
|
||||
}
|
||||
|
||||
fn pipeline(self) -> PipelineId {
|
||||
let dedicated: Option<JSRef<DedicatedWorkerGlobalScope>> =
|
||||
DedicatedWorkerGlobalScopeCast::to_ref(self);
|
||||
match dedicated {
|
||||
Some(dedicated) => dedicated.pipeline(),
|
||||
None => panic!("need to add a pipeline for SharedWorker"),
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_fire_timer(self, timer_id: TimerId) {
|
||||
self.timers.fire_timer(timer_id, self);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue