aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2016-10-01 16:02:20 +0200
committerAnthony Ramine <n.oxyde@gmail.com>2016-10-06 20:59:13 +0200
commitc6ff767625fff00e7c8f41d254c074e8e1e277be (patch)
tree7c3b2e166c74f49f9339fe64793beca6176547a6 /components/script
parentf789e73fd2cf3d88d4447978a82ac6d629a1edf4 (diff)
downloadservo-c6ff767625fff00e7c8f41d254c074e8e1e277be.tar.gz
servo-c6ff767625fff00e7c8f41d254c074e8e1e277be.zip
Introduce GlobalScope::scheduler_chan
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/bindings/global.rs11
-rw-r--r--components/script/dom/globalscope.rs13
-rw-r--r--components/script/dom/window.rs13
-rw-r--r--components/script/dom/workerglobalscope.rs18
4 files changed, 23 insertions, 32 deletions
diff --git a/components/script/dom/bindings/global.rs b/components/script/dom/bindings/global.rs
index 43eafcc2d2e..11fb22a1684 100644
--- a/components/script/dom/bindings/global.rs
+++ b/components/script/dom/bindings/global.rs
@@ -16,7 +16,6 @@ use dom::bindings::reflector::{Reflectable, Reflector};
use dom::globalscope::GlobalScope;
use dom::window;
use dom::workerglobalscope::WorkerGlobalScope;
-use ipc_channel::ipc::IpcSender;
use js::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL};
use js::glue::{IsWrapper, UnwrapObject};
use js::jsapi::{CurrentGlobalOrNull, Evaluate2, GetGlobalForObjectCrossCompartment};
@@ -30,7 +29,7 @@ use profile_traits::time;
use script_runtime::{CommonScriptMsg, EnqueuedPromiseCallback, ScriptChan};
use script_runtime::{ScriptPort, maybe_take_panic_result};
use script_thread::{MainThreadScriptChan, RunnableWrapper, ScriptThread};
-use script_traits::{MsDuration, TimerEventRequest};
+use script_traits::MsDuration;
use std::ffi::CString;
use std::panic;
use task_source::file_reading::FileReadingTaskSource;
@@ -89,14 +88,6 @@ impl<'a> GlobalRef<'a> {
}
}
- /// Get the scheduler channel to request timer events.
- pub fn scheduler_chan(&self) -> &IpcSender<TimerEventRequest> {
- match *self {
- GlobalRef::Window(window) => window.scheduler_chan(),
- GlobalRef::Worker(worker) => worker.scheduler_chan(),
- }
- }
-
/// Get the `ResourceThreads` for this global scope.
pub fn resource_threads(&self) -> ResourceThreads {
match *self {
diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs
index 9f2443b85bc..94522928b3f 100644
--- a/components/script/dom/globalscope.rs
+++ b/components/script/dom/globalscope.rs
@@ -12,7 +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 script_traits::{ScriptMsg as ConstellationMsg, TimerEventRequest};
use std::cell::Cell;
use std::collections::HashMap;
use std::collections::hash_map::Entry;
@@ -46,6 +46,9 @@ pub struct GlobalScope {
/// A handle for communicating messages to the constellation thread.
#[ignore_heap_size_of = "channels are hard"]
constellation_chan: IpcSender<ConstellationMsg>,
+
+ #[ignore_heap_size_of = "channels are hard"]
+ scheduler_chan: IpcSender<TimerEventRequest>,
}
impl GlobalScope {
@@ -53,7 +56,8 @@ impl GlobalScope {
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
mem_profiler_chan: mem::ProfilerChan,
time_profiler_chan: time::ProfilerChan,
- constellation_chan: IpcSender<ConstellationMsg>)
+ constellation_chan: IpcSender<ConstellationMsg>,
+ scheduler_chan: IpcSender<TimerEventRequest>)
-> Self {
GlobalScope {
eventtarget: EventTarget::new_inherited(),
@@ -65,6 +69,7 @@ impl GlobalScope {
mem_profiler_chan: mem_profiler_chan,
time_profiler_chan: time_profiler_chan,
constellation_chan: constellation_chan,
+ scheduler_chan: scheduler_chan,
}
}
@@ -140,6 +145,10 @@ impl GlobalScope {
pub fn constellation_chan(&self) -> &IpcSender<ConstellationMsg> {
&self.constellation_chan
}
+
+ pub fn scheduler_chan(&self) -> &IpcSender<TimerEventRequest> {
+ &self.scheduler_chan
+ }
}
fn timestamp_in_ms(time: Timespec) -> u64 {
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index 7bc64f58b1c..34c93fda495 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -170,8 +170,6 @@ pub struct Window {
session_storage: MutNullableHeap<JS<Storage>>,
local_storage: MutNullableHeap<JS<Storage>>,
status: DOMRefCell<DOMString>,
- #[ignore_heap_size_of = "channels are hard"]
- scheduler_chan: IpcSender<TimerEventRequest>,
timers: OneshotTimers,
/// For sending timeline markers. Will be ignored if
@@ -1387,10 +1385,6 @@ impl Window {
&self.layout_chan
}
- pub fn scheduler_chan(&self) -> &IpcSender<TimerEventRequest> {
- &self.scheduler_chan
- }
-
pub fn schedule_callback(&self, callback: OneshotTimerCallback, duration: MsDuration) -> OneshotTimerHandle {
self.timers.schedule_callback(callback,
duration,
@@ -1594,7 +1588,11 @@ impl Window {
let win = box Window {
globalscope:
GlobalScope::new_inherited(
- devtools_chan, mem_profiler_chan, time_profiler_chan, constellation_chan),
+ devtools_chan,
+ mem_profiler_chan,
+ time_profiler_chan,
+ constellation_chan,
+ scheduler_chan.clone()),
script_chan: script_chan,
dom_manipulation_task_source: dom_task_source,
user_interaction_task_source: user_task_source,
@@ -1613,7 +1611,6 @@ impl Window {
session_storage: Default::default(),
local_storage: Default::default(),
status: DOMRefCell::new(DOMString::new()),
- scheduler_chan: scheduler_chan.clone(),
timers: OneshotTimers::new(timer_event_chan, scheduler_chan),
id: id,
parent_info: parent_info,
diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs
index 81c43c2c5fe..9590e11409d 100644
--- a/components/script/dom/workerglobalscope.rs
+++ b/components/script/dom/workerglobalscope.rs
@@ -38,7 +38,7 @@ use net_traits::{LoadContext, ResourceThreads, load_whole_resource};
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort, maybe_take_panic_result};
use script_runtime::{ScriptThreadEventCategory, PromiseJobQueue, EnqueuedPromiseCallback};
use script_thread::{Runnable, RunnableWrapper};
-use script_traits::{MsDuration, TimerEvent, TimerEventId, TimerEventRequest, TimerSource};
+use script_traits::{MsDuration, TimerEvent, TimerEventId, TimerSource};
use script_traits::WorkerGlobalScopeInit;
use std::cell::Cell;
use std::default::Default;
@@ -59,6 +59,7 @@ pub fn prepare_workerscope_init(global: GlobalRef,
let mem_profiler_chan = global_scope.mem_profiler_chan().clone();
let time_profiler_chan = global_scope.time_profiler_chan().clone();
let constellation_chan = global_scope.constellation_chan().clone();
+ let scheduler_chan = global_scope.scheduler_chan().clone();
let init = WorkerGlobalScopeInit {
resource_threads: global.resource_threads(),
mem_profiler_chan: mem_profiler_chan,
@@ -66,7 +67,7 @@ pub fn prepare_workerscope_init(global: GlobalRef,
time_profiler_chan: time_profiler_chan,
from_devtools_sender: devtools_sender,
constellation_chan: constellation_chan,
- scheduler_chan: global.scheduler_chan().clone(),
+ scheduler_chan: scheduler_chan,
worker_id: worker_id,
pipeline_id: global.pipeline_id(),
};
@@ -102,9 +103,6 @@ pub struct WorkerGlobalScope {
/// `IpcSender` doesn't exist
from_devtools_receiver: Receiver<DevtoolScriptControlMsg>,
- #[ignore_heap_size_of = "Defined in std"]
- scheduler_chan: IpcSender<TimerEventRequest>,
-
promise_job_queue: PromiseJobQueue,
/// https://html.spec.whatwg.org/multipage/#in-error-reporting-mode
@@ -125,7 +123,8 @@ impl WorkerGlobalScope {
init.to_devtools_sender,
init.mem_profiler_chan,
init.time_profiler_chan,
- init.constellation_chan),
+ init.constellation_chan,
+ init.scheduler_chan.clone()),
worker_id: init.worker_id,
pipeline_id: init.pipeline_id,
worker_url: worker_url,
@@ -134,10 +133,9 @@ impl WorkerGlobalScope {
resource_threads: init.resource_threads,
location: Default::default(),
navigator: Default::default(),
- timers: OneshotTimers::new(timer_event_chan, init.scheduler_chan.clone()),
+ timers: OneshotTimers::new(timer_event_chan, init.scheduler_chan),
from_devtools_sender: init.from_devtools_sender,
from_devtools_receiver: from_devtools_receiver,
- scheduler_chan: init.scheduler_chan,
promise_job_queue: PromiseJobQueue::new(),
in_error_reporting_mode: Default::default(),
}
@@ -151,10 +149,6 @@ impl WorkerGlobalScope {
&self.from_devtools_receiver
}
- pub fn scheduler_chan(&self) -> &IpcSender<TimerEventRequest> {
- &self.scheduler_chan
- }
-
pub fn schedule_callback(&self, callback: OneshotTimerCallback, duration: MsDuration) -> OneshotTimerHandle {
self.timers.schedule_callback(callback,
duration,