mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Use task! to notify performance observers
This commit is contained in:
parent
5ed6abe22c
commit
99ff976e85
1 changed files with 7 additions and 21 deletions
|
@ -8,31 +8,12 @@
|
||||||
|
|
||||||
use dom::bindings::refcounted::Trusted;
|
use dom::bindings::refcounted::Trusted;
|
||||||
use dom::globalscope::GlobalScope;
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::performance::Performance;
|
|
||||||
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory};
|
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::result::Result;
|
use std::result::Result;
|
||||||
use task::{Task, TaskCanceller};
|
use task::{Task, TaskCanceller};
|
||||||
use task_source::TaskSource;
|
use task_source::TaskSource;
|
||||||
|
|
||||||
pub struct NotifyPerformanceObserverTask {
|
|
||||||
owner: Trusted<Performance>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl NotifyPerformanceObserverTask {
|
|
||||||
pub fn new(owner: Trusted<Performance>) -> Self {
|
|
||||||
NotifyPerformanceObserverTask {
|
|
||||||
owner,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Task for NotifyPerformanceObserverTask {
|
|
||||||
fn run(self: Box<Self>) {
|
|
||||||
self.owner.root().notify_observers();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(JSTraceable)]
|
#[derive(JSTraceable)]
|
||||||
pub struct PerformanceTimelineTaskSource(pub Box<ScriptChan + Send + 'static>);
|
pub struct PerformanceTimelineTaskSource(pub Box<ScriptChan + Send + 'static>);
|
||||||
|
|
||||||
|
@ -68,7 +49,12 @@ impl TaskSource for PerformanceTimelineTaskSource {
|
||||||
impl PerformanceTimelineTaskSource {
|
impl PerformanceTimelineTaskSource {
|
||||||
pub fn queue_notification(&self, global: &GlobalScope) {
|
pub fn queue_notification(&self, global: &GlobalScope) {
|
||||||
let owner = Trusted::new(&*global.performance());
|
let owner = Trusted::new(&*global.performance());
|
||||||
let task = box NotifyPerformanceObserverTask::new(owner);
|
// FIXME(nox): Why are errors silenced here?
|
||||||
let _ = self.queue(task, global);
|
let _ = self.queue(
|
||||||
|
box task!(notify_performance_observers: move || {
|
||||||
|
owner.root().notify_observers();
|
||||||
|
}),
|
||||||
|
global,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue