Introduce GlobalScope::constellation_chan

This commit is contained in:
Anthony Ramine 2016-10-01 04:15:47 +02:00
parent ae3763e7b3
commit f789e73fd2
14 changed files with 79 additions and 60 deletions

View file

@ -12,6 +12,7 @@ use dom::eventtarget::EventTarget;
use ipc_channel::ipc::IpcSender;
use js::jsapi::{JS_GetContext, JS_GetObjectRuntime, JSContext};
use profile_traits::{mem, time};
use script_traits::ScriptMsg as ConstellationMsg;
use std::cell::Cell;
use std::collections::HashMap;
use std::collections::hash_map::Entry;
@ -41,13 +42,18 @@ pub struct GlobalScope {
/// For sending messages to the time profiler.
#[ignore_heap_size_of = "channels are hard"]
time_profiler_chan: time::ProfilerChan,
/// A handle for communicating messages to the constellation thread.
#[ignore_heap_size_of = "channels are hard"]
constellation_chan: IpcSender<ConstellationMsg>,
}
impl GlobalScope {
pub fn new_inherited(
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
mem_profiler_chan: mem::ProfilerChan,
time_profiler_chan: time::ProfilerChan)
time_profiler_chan: time::ProfilerChan,
constellation_chan: IpcSender<ConstellationMsg>)
-> Self {
GlobalScope {
eventtarget: EventTarget::new_inherited(),
@ -58,6 +64,7 @@ impl GlobalScope {
devtools_chan: devtools_chan,
mem_profiler_chan: mem_profiler_chan,
time_profiler_chan: time_profiler_chan,
constellation_chan: constellation_chan,
}
}
@ -128,6 +135,11 @@ impl GlobalScope {
pub fn time_profiler_chan(&self) -> &time::ProfilerChan {
&self.time_profiler_chan
}
/// Get a sender to the constellation thread.
pub fn constellation_chan(&self) -> &IpcSender<ConstellationMsg> {
&self.constellation_chan
}
}
fn timestamp_in_ms(time: Timespec) -> u64 {