added pipelines to all task sources

changed task sources to accept pipeline ids
This commit is contained in:
ddh 2017-10-24 02:45:55 +01:00
parent 2ffbe53989
commit 52b63def44
20 changed files with 194 additions and 230 deletions

View file

@ -359,7 +359,7 @@ impl DedicatedWorkerGlobalScope {
#[allow(unsafe_code)]
pub fn forward_error_to_worker_object(&self, error_info: ErrorInfo) {
let worker = self.worker.borrow().as_ref().unwrap().clone();
let pipeline_id = worker.clone().root().global().pipeline_id();
let pipeline_id = self.upcast::<GlobalScope>().pipeline_id();
let task = Box::new(task!(forward_error_to_worker_object: move || {
let worker = worker.root();
let global = worker.global();
@ -406,7 +406,7 @@ impl DedicatedWorkerGlobalScopeMethods for DedicatedWorkerGlobalScope {
unsafe fn PostMessage(&self, cx: *mut JSContext, message: HandleValue) -> ErrorResult {
let data = StructuredCloneData::write(cx, message)?;
let worker = self.worker.borrow().as_ref().unwrap().clone();
let pipeline_id = worker.clone().root().global().pipeline_id();
let pipeline_id = self.upcast::<GlobalScope>().pipeline_id();
let task = Box::new(task!(post_worker_message: move || {
Worker::handle_message(worker, data);
}));

View file

@ -99,7 +99,7 @@ use hyper_serde::Serde;
use ipc_channel::ipc::{self, IpcSender};
use js::jsapi::{JSContext, JSRuntime};
use js::jsapi::JS_GetRuntime;
use metrics::{InteractiveFlag, InteractiveMetrics, InteractiveWindow, ProfilerMetadataFactory, ProgressiveWebMetric};
use metrics::{InteractiveFlag, InteractiveMetrics, InteractiveWindow, ProfilerMetadataFactory};
use msg::constellation_msg::{ALT, CONTROL, SHIFT, SUPER};
use msg::constellation_msg::{BrowsingContextId, Key, KeyModifiers, KeyState, TopLevelBrowsingContextId};
use net_traits::{FetchResponseMsg, IpcSend, ReferrerPolicy};
@ -1839,7 +1839,7 @@ impl Document {
update_with_current_time_ms(&self.dom_content_loaded_event_end);
// html parsing has finished - set dom content loaded
self.interactive_time.borrow().maybe_set_tti(self, None, InteractiveFlag::DCL);
self.interactive_time.borrow().maybe_set_tti(self, InteractiveFlag::DOMContentLoaded);
// Step 4.2.
// TODO: client message queue.
@ -1927,7 +1927,7 @@ impl Document {
self.interactive_time.borrow()
}
pub fn is_interactive(&self) -> bool {
pub fn has_recorded_tti_metric(&self) -> bool {
self.get_interactive_metrics().get_tti().is_some()
}
@ -1958,13 +1958,12 @@ impl Document {
/// check tti for this document
/// if it's been 10s since this doc encountered a task over 50ms, then we consider the
/// main thread available and try to set tti
pub fn check_tti(&self) {
if self.is_interactive() { return; }
pub fn record_tti_if_necessary(&self) {
if self.has_recorded_tti_metric() { return; }
if self.tti_window.borrow().needs_check() {
self.get_interactive_metrics().maybe_set_tti(self,
Some(self.tti_window.borrow().get_start() as f64),
InteractiveFlag::TTI);
InteractiveFlag::TimeToInteractive(self.tti_window.borrow().get_start() as f64));
}
}
@ -2177,8 +2176,7 @@ impl Document {
(DocumentReadyState::Complete, true)
};
let mut interactive_time = InteractiveMetrics::new(window.time_profiler_chan().clone());
interactive_time.set_navigation_start(window.get_navigation_start());
let interactive_time = InteractiveMetrics::new(window.time_profiler_chan().clone());
Document {
node: Node::new_document_node(),

View file

@ -9,7 +9,7 @@ use dom::bindings::str::DOMString;
use dom::globalscope::GlobalScope;
use dom::performanceentry::PerformanceEntry;
use dom_struct::dom_struct;
use script_traits::PWMType;
use script_traits::ProgressiveWebMetricType;
#[dom_struct]
pub struct PerformancePaintTiming {
@ -17,10 +17,10 @@ pub struct PerformancePaintTiming {
}
impl PerformancePaintTiming {
fn new_inherited(metric_type: PWMType, start_time: f64) -> PerformancePaintTiming {
fn new_inherited(metric_type: ProgressiveWebMetricType, start_time: f64) -> PerformancePaintTiming {
let name = match metric_type {
PWMType::FirstPaint => DOMString::from("first-paint"),
PWMType::FirstContentfulPaint => DOMString::from("first-contentful-paint"),
ProgressiveWebMetricType::FirstPaint => DOMString::from("first-paint"),
ProgressiveWebMetricType::FirstContentfulPaint => DOMString::from("first-contentful-paint"),
_ => DOMString::from(""),
};
PerformancePaintTiming {
@ -33,7 +33,7 @@ impl PerformancePaintTiming {
#[allow(unrooted_must_root)]
pub fn new(global: &GlobalScope,
metric_type: PWMType,
metric_type: ProgressiveWebMetricType,
start_time: f64) -> DomRoot<PerformancePaintTiming> {
let entry = PerformancePaintTiming::new_inherited(metric_type, start_time);
reflect_dom_object(Box::new(entry), global, PerformancePaintTimingBinding::Wrap)

View file

@ -494,6 +494,7 @@ impl VRDisplay {
let address = Trusted::new(&*self);
let near_init = self.depth_near.get();
let far_init = self.depth_far.get();
let pipeline_id = self.global().pipeline_id();
// The render loop at native headset frame rate is implemented using a dedicated thread.
// Every loop iteration syncs pose data with the HMD, submits the pixels to the display and waits for Vsync.
@ -505,7 +506,6 @@ impl VRDisplay {
let (raf_sender, raf_receiver) = mpsc::channel();
let mut near = near_init;
let mut far = far_init;
// let pipeline_id = self.global().pipeline_id().clone(); TODO
// Initialize compositor
api_sender.send_vr(WebVRCommand::Create(display_id)).unwrap();
@ -516,7 +516,7 @@ impl VRDisplay {
let task = Box::new(task!(handle_vrdisplay_raf: move || {
this.root().handle_raf(&sender);
}));
js_sender.send(CommonScriptMsg::Task(WebVREvent, task, None)).unwrap();
js_sender.send(CommonScriptMsg::Task(WebVREvent, task, Some(pipeline_id))).unwrap();
// Run Sync Poses in parallell on Render thread
let msg = WebVRCommand::SyncPoses(display_id, near, far, sync_sender.clone());

View file

@ -29,6 +29,7 @@ use ipc_channel::ipc::IpcSender;
use js::jsapi::{HandleValue, JSAutoCompartment, JSContext, JSRuntime};
use js::jsval::UndefinedValue;
use js::panic::maybe_resume_unwind;
use msg::constellation_msg::PipelineId;
use net_traits::{IpcSend, load_whole_resource};
use net_traits::request::{CredentialsMode, Destination, RequestInit as NetRequestInit, Type as RequestType};
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort, get_reports, Runtime};
@ -165,6 +166,10 @@ impl WorkerGlobalScope {
cancelled: self.closing.clone(),
}
}
pub fn pipeline_id(&self) -> PipelineId {
self.globalscope.pipeline_id()
}
}
impl WorkerGlobalScopeMethods for WorkerGlobalScope {
@ -364,15 +369,15 @@ impl WorkerGlobalScope {
}
pub fn file_reading_task_source(&self) -> FileReadingTaskSource {
FileReadingTaskSource(self.script_chan())
FileReadingTaskSource(self.script_chan(), self.pipeline_id())
}
pub fn networking_task_source(&self) -> NetworkingTaskSource {
NetworkingTaskSource(self.script_chan())
NetworkingTaskSource(self.script_chan(), self.pipeline_id())
}
pub fn performance_timeline_task_source(&self) -> PerformanceTimelineTaskSource {
PerformanceTimelineTaskSource(self.script_chan())
PerformanceTimelineTaskSource(self.script_chan(), self.pipeline_id())
}
pub fn new_script_pair(&self) -> (Box<ScriptChan + Send>, Box<ScriptPort + Send>) {

View file

@ -1285,7 +1285,7 @@ impl XMLHttpRequest {
let (task_source, script_port) = if self.sync.get() {
let (tx, rx) = global.new_script_pair();
(NetworkingTaskSource(tx), Some(rx))
(NetworkingTaskSource(tx, global.pipeline_id()), Some(rx))
} else {
(global.networking_task_source(), None)
};

View file

@ -16,7 +16,6 @@
//! takes over the response body. Once parsing is complete, the document lifecycle for loading
//! a page runs its course and the script thread returns to processing events in the main event
//! loop.
#![feature(box_syntax)]
use bluetooth_traits::BluetoothRequest;
use canvas_traits::webgl::WebGLPipeline;
@ -75,7 +74,7 @@ use js::jsapi::{JSTracer, SetWindowProxyClass};
use js::jsval::UndefinedValue;
use malloc_size_of::MallocSizeOfOps;
use mem::malloc_size_of_including_self;
use metrics::{InteractiveWindow, PaintTimeMetrics};
use metrics::{MAX_TASK_NS, PaintTimeMetrics};
use microtask::{MicrotaskQueue, Microtask};
use msg::constellation_msg::{BrowsingContextId, FrameType, PipelineId, PipelineNamespace, TopLevelBrowsingContextId};
use net_traits::{FetchMetadata, FetchResponseListener, FetchResponseMsg};
@ -92,7 +91,7 @@ use script_traits::{CompositorEvent, ConstellationControlMsg};
use script_traits::{DiscardBrowsingContext, DocumentActivity, EventResult};
use script_traits::{InitialScriptState, JsEvalResult, LayoutMsg, LoadData};
use script_traits::{MouseButton, MouseEventType, MozBrowserEvent, NewLayoutInfo};
use script_traits::{PWMType, Painter, ScriptMsg, ScriptThreadFactory};
use script_traits::{ProgressiveWebMetricType, Painter, ScriptMsg, ScriptThreadFactory};
use script_traits::{ScriptToConstellationChan, TimerEvent, TimerSchedulerMsg};
use script_traits::{TimerSource, TouchEventType, TouchId, UntrustedNodeAddress};
use script_traits::{UpdatePipelineIdReason, WindowSizeData, WindowSizeType};
@ -415,17 +414,17 @@ pub struct ScriptThread {
/// events in the event queue.
chan: MainThreadScriptChan,
dom_manipulation_task_source: DOMManipulationTaskSource,
dom_manipulation_task_sender: Sender<MainThreadScriptMsg>,
user_interaction_task_source: UserInteractionTaskSource,
user_interaction_task_sender: Sender<MainThreadScriptMsg>,
networking_task_source: NetworkingTaskSource,
networking_task_sender: Box<ScriptChan>,
history_traversal_task_source: HistoryTraversalTaskSource,
file_reading_task_source: FileReadingTaskSource,
file_reading_task_sender: Box<ScriptChan>,
performance_timeline_task_source: PerformanceTimelineTaskSource,
performance_timeline_task_sender: Box<ScriptChan>,
/// A channel to hand out to threads that need to respond to a message from the script thread.
control_chan: IpcSender<ConstellationControlMsg>,
@ -686,8 +685,8 @@ impl ScriptThread {
SCRIPT_THREAD_ROOT.with(|root| {
if let Some(script_thread) = root.get() {
let script_thread = unsafe { &*script_thread };
let p_id = Some(new_layout_info.new_pipeline_id);
script_thread.profile_event(ScriptThreadEventCategory::AttachLayout, p_id, || {
let pipeline_id = Some(new_layout_info.new_pipeline_id);
script_thread.profile_event(ScriptThreadEventCategory::AttachLayout, pipeline_id, || {
script_thread.handle_new_layout(new_layout_info, origin);
})
}
@ -836,12 +835,13 @@ impl ScriptThread {
port: port,
chan: MainThreadScriptChan(chan.clone()),
dom_manipulation_task_source: DOMManipulationTaskSource(chan.clone()),
user_interaction_task_source: UserInteractionTaskSource(chan.clone()),
networking_task_source: NetworkingTaskSource(boxed_script_sender.clone()),
dom_manipulation_task_sender: chan.clone(),
user_interaction_task_sender: chan.clone(),
networking_task_sender: boxed_script_sender.clone(),
file_reading_task_sender: boxed_script_sender.clone(),
performance_timeline_task_sender: boxed_script_sender.clone(),
history_traversal_task_source: HistoryTraversalTaskSource(chan),
file_reading_task_source: FileReadingTaskSource(boxed_script_sender.clone()),
performance_timeline_task_source: PerformanceTimelineTaskSource(boxed_script_sender),
control_chan: state.control_chan,
control_port: control_port,
@ -970,8 +970,8 @@ impl ScriptThread {
// child list yet, causing the find() to fail.
FromConstellation(ConstellationControlMsg::AttachLayout(
new_layout_info)) => {
//FIXME there should be a pipeline id
self.profile_event(ScriptThreadEventCategory::AttachLayout, None, || {
let pipeline_id = new_layout_info.new_pipeline_id;
self.profile_event(ScriptThreadEventCategory::AttachLayout, Some(pipeline_id), || {
// If this is an about:blank load, it must share the creator's origin.
// This must match the logic in the constellation when creating a new pipeline
let origin = if new_layout_info.load_data.url.as_str() != "about:blank" {
@ -1060,9 +1060,9 @@ impl ScriptThread {
debug!("Processing event {:?}.", msg);
let category = self.categorize_msg(&msg);
let p_id = self.message_to_pipeline(&msg);
let pipeline_id = self.message_to_pipeline(&msg);
let result = self.profile_event(category, p_id, move || {
let result = self.profile_event(category, pipeline_id, move || {
match msg {
FromConstellation(ConstellationControlMsg::ExitScriptThread) => {
self.handle_exit_script_thread_msg();
@ -1127,6 +1127,7 @@ impl ScriptThread {
_ => ScriptThreadEventCategory::ConstellationMsg
}
},
// TODO https://github.com/servo/servo/issues/18998
MixedMessage::FromDevtools(_) => ScriptThreadEventCategory::DevtoolsMsg,
MixedMessage::FromImageCache(_) => ScriptThreadEventCategory::ImageCacheMsg,
MixedMessage::FromScript(ref inner_msg) => {
@ -1169,15 +1170,15 @@ impl ScriptThread {
FocusIFrame(id, ..) => Some(id),
WebDriverScriptCommand(id, ..) => Some(id),
TickAllAnimations(id) => Some(id),
// FIXME https://github.com/servo/servo/issues/15079
TransitionEnd(..) => None,
WebFontLoaded(id) => Some(id),
DispatchIFrameLoadEvent { .. } => None,
DispatchIFrameLoadEvent { target: _, parent: id, child: _ } => Some(id),
DispatchStorageEvent(id, ..) => Some(id),
ReportCSSError(id, ..) => Some(id),
Reload(id, ..) => Some(id),
WebVREvents(id, ..) => Some(id),
PaintMetric(..) => None,
InteractiveMetric(..) => None,
}
},
MixedMessage::FromDevtools(_) => None,
@ -1185,7 +1186,7 @@ impl ScriptThread {
match *inner_msg {
MainThreadScriptMsg::Common(CommonScriptMsg::Task(_, _, pipeline_id)) =>
pipeline_id,
MainThreadScriptMsg::Common(_) => None, //TODO double check
MainThreadScriptMsg::Common(CommonScriptMsg::CollectReports(_)) => None,
MainThreadScriptMsg::ExitWindow(pipeline_id) => Some(pipeline_id),
MainThreadScriptMsg::Navigate(pipeline_id, ..) => Some(pipeline_id),
MainThreadScriptMsg::WorkletLoaded(pipeline_id) => Some(pipeline_id),
@ -1204,9 +1205,10 @@ impl ScriptThread {
}
}
fn profile_event<F, R>(&self, category: ScriptThreadEventCategory, p_id: Option<PipelineId>, f: F) -> R
fn profile_event<F, R>(&self, category: ScriptThreadEventCategory, pipeline_id: Option<PipelineId>, f: F) -> R
where F: FnOnce() -> R {
if opts::get().profile_script_events {
let start = precise_time_ns();
let value = if opts::get().profile_script_events {
let profiler_cat = match category {
ScriptThreadEventCategory::AttachLayout => ProfilerCategory::ScriptAttachLayout,
ScriptThreadEventCategory::ConstellationMsg => ProfilerCategory::ScriptConstellationMsg,
@ -1238,27 +1240,20 @@ impl ScriptThread {
ScriptThreadEventCategory::ExitFullscreen => ProfilerCategory::ScriptExitFullscreen,
ScriptThreadEventCategory::PerformanceTimelineTask => ProfilerCategory::ScriptPerformanceEvent,
};
let start = precise_time_ns();
let t = profile(profiler_cat, None, self.time_profiler_chan.clone(), f);
let end = precise_time_ns();
debug!("Task {:?} took {}", category, end - start); // TODO do we want to do anything with this?
for (doc_id, doc) in self.documents.borrow().iter() {
match p_id {
Some(p_id) => {
if p_id == doc_id && end - start > InteractiveWindow::max_task_time() {
doc.start_tti()
}
},
_ => ()
}
doc.check_tti();
}
t
profile(profiler_cat, None, self.time_profiler_chan.clone(), f)
} else {
f()
};
let end = precise_time_ns();
for (doc_id, doc) in self.documents.borrow().iter() {
if let Some(pipeline_id) = pipeline_id {
if pipeline_id == doc_id && end - start > MAX_TASK_NS {
doc.start_tti();
}
}
doc.record_tti_if_necessary();
}
value
}
fn handle_msg_from_constellation(&self, msg: ConstellationControlMsg) {
@ -1326,7 +1321,6 @@ impl ScriptThread {
self.handle_webvr_events(pipeline_id, events),
ConstellationControlMsg::PaintMetric(pipeline_id, metric_type, metric_value) =>
self.handle_paint_metric(pipeline_id, metric_type, metric_value),
ConstellationControlMsg::InteractiveMetric(pipeline_id, metric_value) => (), //TODO
msg @ ConstellationControlMsg::AttachLayout(..) |
msg @ ConstellationControlMsg::Viewport(..) |
msg @ ConstellationControlMsg::SetScrollState(..) |
@ -1812,12 +1806,24 @@ impl ScriptThread {
let _ = self.chan.0.send(MainThreadScriptMsg::DispatchJobQueue { scope_url });
}
pub fn dom_manipulation_task_source(&self) -> &DOMManipulationTaskSource {
&self.dom_manipulation_task_source
pub fn dom_manipulation_task_source(&self, pipeline_id: PipelineId) -> DOMManipulationTaskSource {
DOMManipulationTaskSource(self.dom_manipulation_task_sender.clone(), pipeline_id)
}
pub fn performance_timeline_task_source(&self) -> &PerformanceTimelineTaskSource {
&self.performance_timeline_task_source
pub fn performance_timeline_task_source(&self, pipeline_id: PipelineId) -> PerformanceTimelineTaskSource {
PerformanceTimelineTaskSource(self.performance_timeline_task_sender.clone(), pipeline_id)
}
pub fn user_interaction_task_source(&self, pipeline_id: PipelineId) -> UserInteractionTaskSource {
UserInteractionTaskSource(self.user_interaction_task_sender.clone(), pipeline_id)
}
pub fn networking_task_source(&self, pipeline_id: PipelineId) -> NetworkingTaskSource {
NetworkingTaskSource(self.networking_task_sender.clone(), pipeline_id)
}
pub fn file_reading_task_source(&self, pipeline_id: PipelineId) -> FileReadingTaskSource {
FileReadingTaskSource(self.file_reading_task_sender.clone(), pipeline_id)
}
/// Handles a request for the window title.
@ -2105,8 +2111,6 @@ impl ScriptThread {
debug!("ScriptThread: loading {} on pipeline {:?}", incomplete.url, incomplete.pipeline_id);
let MainThreadScriptChan(ref sender) = self.chan;
let DOMManipulationTaskSource(ref dom_sender) = self.dom_manipulation_task_source;
let UserInteractionTaskSource(ref user_sender) = self.user_interaction_task_source;
let HistoryTraversalTaskSource(ref history_sender) = self.history_traversal_task_source;
let (ipc_timer_event_chan, ipc_timer_event_port) = ipc::channel().unwrap();
@ -2128,12 +2132,12 @@ impl ScriptThread {
let window = Window::new(
self.js_runtime.clone(),
MainThreadScriptChan(sender.clone()),
DOMManipulationTaskSource(dom_sender.clone()),
UserInteractionTaskSource(user_sender.clone()),
self.networking_task_source.clone(),
self.dom_manipulation_task_source(incomplete.pipeline_id),
self.user_interaction_task_source(incomplete.pipeline_id),
self.networking_task_source(incomplete.pipeline_id),
HistoryTraversalTaskSource(history_sender.clone()),
self.file_reading_task_source.clone(),
self.performance_timeline_task_source.clone(),
self.file_reading_task_source(incomplete.pipeline_id),
self.performance_timeline_task_source(incomplete.pipeline_id).clone(),
self.image_cache_channel.clone(),
self.image_cache.clone(),
self.resource_threads.clone(),
@ -2650,7 +2654,7 @@ impl ScriptThread {
fn handle_paint_metric(&self,
pipeline_id: PipelineId,
metric_type: PWMType,
metric_type: ProgressiveWebMetricType,
metric_value: f64) {
let window = self.documents.borrow().find_window(pipeline_id);
if let Some(window) = window {

View file

@ -153,19 +153,21 @@ impl JobQueue {
// https://w3c.github.io/ServiceWorker/#register-algorithm
fn run_register(&self, job: &Job, scope_url: ServoUrl, script_thread: &ScriptThread) {
debug!("running register job");
let global = &*job.client.global();
let pipeline_id = global.pipeline_id();
// Step 1-3
if !UrlHelper::is_origin_trustworthy(&job.script_url) {
// Step 1.1
reject_job_promise(job,
Error::Type("Invalid script ServoURL".to_owned()),
script_thread.dom_manipulation_task_source());
&script_thread.dom_manipulation_task_source(pipeline_id));
// Step 1.2 (see run_job)
return;
} else if job.script_url.origin() != job.referrer.origin() || job.scope_url.origin() != job.referrer.origin() {
// Step 2.1/3.1
reject_job_promise(job,
Error::Security,
script_thread.dom_manipulation_task_source());
&script_thread.dom_manipulation_task_source(pipeline_id));
// Step 2.2/3.2 (see run_job)
return;
}
@ -180,17 +182,15 @@ impl JobQueue {
if let Some(ref newest_worker) = reg.get_newest_worker() {
if (&*newest_worker).get_script_url() == job.script_url {
// Step 5.3.1
resolve_job_promise(job, &*reg, script_thread.dom_manipulation_task_source());
resolve_job_promise(job, &*reg, &script_thread.dom_manipulation_task_source(pipeline_id));
// Step 5.3.2 (see run_job)
return;
}
}
} else {
// Step 6.1
let global = &*job.client.global();
let pipeline = global.pipeline_id();
let new_reg = ServiceWorkerRegistration::new(&*global, &job.script_url, scope_url);
script_thread.handle_serviceworker_registration(&job.scope_url, &*new_reg, pipeline);
script_thread.handle_serviceworker_registration(&job.scope_url, &*new_reg, pipeline_id);
}
// Step 7
self.update(job, script_thread)
@ -218,13 +218,16 @@ impl JobQueue {
// https://w3c.github.io/ServiceWorker/#update-algorithm
fn update(&self, job: &Job, script_thread: &ScriptThread) {
debug!("running update job");
let global = &*job.client.global();
let pipeline_id = global.pipeline_id();
// Step 1
let reg = match script_thread.handle_get_registration(&job.scope_url) {
Some(reg) => reg,
None => {
let err_type = Error::Type("No registration to update".to_owned());
// Step 2.1
reject_job_promise(job, err_type, script_thread.dom_manipulation_task_source());
reject_job_promise(job, err_type, &script_thread.dom_manipulation_task_source(pipeline_id));
// Step 2.2 (see run_job)
return;
}
@ -233,7 +236,7 @@ impl JobQueue {
if reg.get_uninstalling() {
let err_type = Error::Type("Update called on an uninstalling registration".to_owned());
// Step 2.1
reject_job_promise(job, err_type, script_thread.dom_manipulation_task_source());
reject_job_promise(job, err_type, &script_thread.dom_manipulation_task_source(pipeline_id));
// Step 2.2 (see run_job)
return;
}
@ -244,7 +247,7 @@ impl JobQueue {
if newest_worker_url.as_ref() == Some(&job.script_url) && job.job_type == JobType::Update {
let err_type = Error::Type("Invalid script ServoURL".to_owned());
// Step 4.1
reject_job_promise(job, err_type, script_thread.dom_manipulation_task_source());
reject_job_promise(job, err_type, &script_thread.dom_manipulation_task_source(pipeline_id));
// Step 4.2 (see run_job)
return;
}
@ -252,7 +255,7 @@ impl JobQueue {
if let Some(newest_worker) = newest_worker {
job.client.set_controller(&*newest_worker);
// Step 8.1
resolve_job_promise(job, &*reg, script_thread.dom_manipulation_task_source());
resolve_job_promise(job, &*reg, &script_thread.dom_manipulation_task_source(pipeline_id));
// Step 8.2 present in run_job
}
// TODO Step 9 (create new service worker)

View file

@ -7,6 +7,7 @@ use dom::bindings::refcounted::Trusted;
use dom::event::{EventBubbles, EventCancelable, EventTask, SimpleEventTask};
use dom::eventtarget::EventTarget;
use dom::window::Window;
use msg::constellation_msg::PipelineId;
use script_runtime::{CommonScriptMsg, ScriptThreadEventCategory};
use script_thread::MainThreadScriptMsg;
use servo_atoms::Atom;
@ -17,7 +18,7 @@ use task::{TaskCanceller, TaskOnce};
use task_source::TaskSource;
#[derive(Clone, JSTraceable)]
pub struct DOMManipulationTaskSource(pub Sender<MainThreadScriptMsg>);
pub struct DOMManipulationTaskSource(pub Sender<MainThreadScriptMsg>, pub PipelineId);
impl fmt::Debug for DOMManipulationTaskSource {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@ -37,7 +38,7 @@ impl TaskSource for DOMManipulationTaskSource {
let msg = MainThreadScriptMsg::Common(CommonScriptMsg::Task(
ScriptThreadEventCategory::ScriptEvent,
Box::new(canceller.wrap_task(task)),
None //TODO
Some(self.1)
));
self.0.send(msg).map_err(|_| ())
}

View file

@ -4,17 +4,18 @@
use dom::domexception::DOMErrorName;
use dom::filereader::{FileReader, TrustedFileReader, GenerationId, ReadMetaData};
use msg::constellation_msg::PipelineId;
use script_runtime::{CommonScriptMsg, ScriptThreadEventCategory, ScriptChan};
use std::sync::Arc;
use task::{TaskCanceller, TaskOnce};
use task_source::TaskSource;
#[derive(JSTraceable)]
pub struct FileReadingTaskSource(pub Box<ScriptChan + Send + 'static>);
pub struct FileReadingTaskSource(pub Box<ScriptChan + Send + 'static>, pub PipelineId);
impl Clone for FileReadingTaskSource {
fn clone(&self) -> FileReadingTaskSource {
FileReadingTaskSource(self.0.clone())
FileReadingTaskSource(self.0.clone(), self.1.clone())
}
}
@ -30,7 +31,7 @@ impl TaskSource for FileReadingTaskSource {
self.0.send(CommonScriptMsg::Task(
ScriptThreadEventCategory::FileRead,
Box::new(canceller.wrap_task(task)),
None //TODO
Some(self.1),
))
}
}

View file

@ -2,16 +2,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use msg::constellation_msg::PipelineId;
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory};
use task::{TaskCanceller, TaskOnce};
use task_source::TaskSource;
#[derive(JSTraceable)]
pub struct NetworkingTaskSource(pub Box<ScriptChan + Send + 'static>);
pub struct NetworkingTaskSource(pub Box<ScriptChan + Send + 'static>, pub PipelineId);
impl Clone for NetworkingTaskSource {
fn clone(&self) -> NetworkingTaskSource {
NetworkingTaskSource(self.0.clone())
NetworkingTaskSource(self.0.clone(), self.1.clone())
}
}
@ -27,7 +28,7 @@ impl TaskSource for NetworkingTaskSource {
self.0.send(CommonScriptMsg::Task(
ScriptThreadEventCategory::NetworkEvent,
Box::new(canceller.wrap_task(task)),
None
Some(self.1),
))
}
}
@ -42,7 +43,7 @@ impl NetworkingTaskSource {
self.0.send(CommonScriptMsg::Task(
ScriptThreadEventCategory::NetworkEvent,
Box::new(task),
None //TODO
Some(self.1),
))
}
}

View file

@ -8,6 +8,7 @@
use dom::bindings::refcounted::Trusted;
use dom::globalscope::GlobalScope;
use msg::constellation_msg::PipelineId;
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory};
use std::fmt;
use std::result::Result;
@ -15,11 +16,11 @@ use task::{TaskCanceller, TaskOnce};
use task_source::TaskSource;
#[derive(JSTraceable)]
pub struct PerformanceTimelineTaskSource(pub Box<ScriptChan + Send + 'static>);
pub struct PerformanceTimelineTaskSource(pub Box<ScriptChan + Send + 'static>, pub PipelineId);
impl Clone for PerformanceTimelineTaskSource {
fn clone(&self) -> PerformanceTimelineTaskSource {
PerformanceTimelineTaskSource(self.0.clone())
PerformanceTimelineTaskSource(self.0.clone(), self.1.clone())
}
}
@ -41,7 +42,7 @@ impl TaskSource for PerformanceTimelineTaskSource {
let msg = CommonScriptMsg::Task(
ScriptThreadEventCategory::PerformanceTimelineTask,
Box::new(canceller.wrap_task(task)),
None
Some(self.1)
);
self.0.send(msg).map_err(|_| ())
}

View file

@ -7,6 +7,7 @@ use dom::bindings::refcounted::Trusted;
use dom::event::{EventBubbles, EventCancelable, EventTask};
use dom::eventtarget::EventTarget;
use dom::window::Window;
use msg::constellation_msg::PipelineId;
use script_runtime::{CommonScriptMsg, ScriptThreadEventCategory};
use script_thread::MainThreadScriptMsg;
use servo_atoms::Atom;
@ -17,7 +18,7 @@ use task::{TaskCanceller, TaskOnce};
use task_source::TaskSource;
#[derive(Clone, JSTraceable)]
pub struct UserInteractionTaskSource(pub Sender<MainThreadScriptMsg>);
pub struct UserInteractionTaskSource(pub Sender<MainThreadScriptMsg>, pub PipelineId);
impl fmt::Debug for UserInteractionTaskSource {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@ -37,7 +38,7 @@ impl TaskSource for UserInteractionTaskSource {
let msg = MainThreadScriptMsg::Common(CommonScriptMsg::Task(
ScriptThreadEventCategory::InputEvent,
Box::new(canceller.wrap_task(task)),
None
Some(self.1)
));
self.0.send(msg).map_err(|_| ())
}