Skip to content
Permalink
Browse files

Time distribution across script event categories.

  • Loading branch information...
benschulz committed Aug 23, 2015
1 parent 71b277d commit 1e6a2f08fc825c0179f44129485e6ef332ef8c33
@@ -17,9 +17,10 @@ use dom::bindings::structuredclone::StructuredCloneData;
use dom::bindings::utils::Reflectable;
use dom::eventtarget::{EventTarget, EventTargetTypeId};
use dom::messageevent::MessageEvent;
use dom::worker::{TrustedWorkerAddress, WorkerMessageHandler, WorkerEventHandler};
use dom::worker::{TrustedWorkerAddress, WorkerMessageHandler, SimpleWorkerErrorHandler};
use dom::workerglobalscope::WorkerGlobalScope;
use dom::workerglobalscope::{WorkerGlobalScopeTypeId, WorkerGlobalScopeInit};
use script_task::ScriptTaskEventCategory::WorkerEvent;
use script_task::{ScriptTask, ScriptChan, TimerSource, ScriptPort, StackRootTLS, CommonScriptMsg};

use devtools_traits::DevtoolScriptControlMsg;
@@ -207,8 +208,8 @@ impl DedicatedWorkerGlobalScope {
let (url, source) = match load_whole_resource(&init.resource_task, worker_url) {
Err(_) => {
println!("error loading script {}", serialized_worker_url);
parent_sender.send(CommonScriptMsg::RunnableMsg(
box WorkerEventHandler::new(worker))).unwrap();
parent_sender.send(CommonScriptMsg::RunnableMsg(WorkerEvent,
box SimpleWorkerErrorHandler::new(worker))).unwrap();
return;
}
Ok((metadata, bytes)) => {
@@ -308,7 +309,7 @@ impl DedicatedWorkerGlobalScope {
data.read(GlobalRef::Worker(scope), message.handle_mut());
MessageEvent::dispatch_jsval(target, GlobalRef::Worker(scope), message.handle());
},
WorkerScriptMsg::Common(CommonScriptMsg::RunnableMsg(runnable)) => {
WorkerScriptMsg::Common(CommonScriptMsg::RunnableMsg(_, runnable)) => {
runnable.handler()
},
WorkerScriptMsg::Common(CommonScriptMsg::RefcountCleanup(addr)) => {
@@ -359,7 +360,7 @@ impl DedicatedWorkerGlobalScopeMethods for DedicatedWorkerGlobalScope {
fn PostMessage(&self, cx: *mut JSContext, message: HandleValue) -> ErrorResult {
let data = try!(StructuredCloneData::write(cx, message));
let worker = self.worker.borrow().as_ref().unwrap().clone();
self.parent_sender.send(CommonScriptMsg::RunnableMsg(
self.parent_sender.send(CommonScriptMsg::RunnableMsg(WorkerEvent,
box WorkerMessageHandler::new(worker, data))).unwrap();
Ok(())
}
@@ -22,6 +22,7 @@ use encoding::label::encoding_from_whatwg_label;
use encoding::types::{EncodingRef, DecoderTrap};
use hyper::mime::{Mime, Attr};
use rustc_serialize::base64::{Config, ToBase64, CharacterSet, Newline};
use script_task::ScriptTaskEventCategory::FileRead;
use script_task::{ScriptChan, Runnable, ScriptPort, CommonScriptMsg};
use std::cell::{Cell, RefCell};
use std::sync::mpsc;
@@ -401,22 +402,22 @@ fn perform_annotated_read_operation(gen_id: GenerationId, data: ReadMetaData, bl
let chan = &script_chan;
// Step 4
let task = box FileReaderEvent::ProcessRead(filereader.clone(), gen_id);
chan.send(CommonScriptMsg::RunnableMsg(task)).unwrap();
chan.send(CommonScriptMsg::RunnableMsg(FileRead, task)).unwrap();

let task = box FileReaderEvent::ProcessReadData(filereader.clone(),
gen_id, DOMString::new());
chan.send(CommonScriptMsg::RunnableMsg(task)).unwrap();
chan.send(CommonScriptMsg::RunnableMsg(FileRead, task)).unwrap();

let bytes = match blob_contents.recv() {
Ok(bytes) => bytes,
Err(_) => {
let task = box FileReaderEvent::ProcessReadError(filereader,
gen_id, DOMErrorName::NotFoundError);
chan.send(CommonScriptMsg::RunnableMsg(task)).unwrap();
chan.send(CommonScriptMsg::RunnableMsg(FileRead, task)).unwrap();
return;
}
};

let task = box FileReaderEvent::ProcessReadEOF(filereader, gen_id, data, bytes);
chan.send(CommonScriptMsg::RunnableMsg(task)).unwrap();
chan.send(CommonScriptMsg::RunnableMsg(FileRead, task)).unwrap();
}
@@ -21,6 +21,7 @@ use dom::eventtarget::{EventTarget, EventTargetTypeId};
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
use dom::node::{document_from_node, Node, NodeTypeId, NodeDamage, window_from_node};
use dom::virtualmethods::VirtualMethods;
use script_task::ScriptTaskEventCategory::UpdateReplacedElement;
use script_task::{Runnable, ScriptChan, CommonScriptMsg};
use string_cache::Atom;
use util::str::DOMString;
@@ -131,7 +132,7 @@ impl HTMLImageElement {
// Return the image via a message to the script task, which marks the element
// as dirty and triggers a reflow.
let image_response = message.to().unwrap();
script_chan.send(CommonScriptMsg::RunnableMsg(
script_chan.send(CommonScriptMsg::RunnableMsg(UpdateReplacedElement,
box ImageResponseHandlerRunnable::new(
trusted_node.clone(), image_response))).unwrap();
});
@@ -32,6 +32,7 @@ use dom::window::ScriptHelpers;
use js::jsapi::RootedValue;
use js::jsval::UndefinedValue;
use network_listener::{NetworkListener, PreInvoke};
use script_task::ScriptTaskEventCategory::ScriptEvent;
use script_task::{ScriptChan, Runnable, CommonScriptMsg};

use encoding::all::UTF_8;
@@ -426,7 +427,7 @@ impl HTMLScriptElement {
element: handler,
is_error: false,
};
chan.send(CommonScriptMsg::RunnableMsg(dispatcher)).unwrap();
chan.send(CommonScriptMsg::RunnableMsg(ScriptEvent, dispatcher)).unwrap();
}
}

@@ -439,7 +440,7 @@ impl HTMLScriptElement {
element: handler,
is_error: true,
};
chan.send(CommonScriptMsg::RunnableMsg(dispatcher)).unwrap();
chan.send(CommonScriptMsg::RunnableMsg(ScriptEvent, dispatcher)).unwrap();
}

pub fn dispatch_before_script_execute_event(&self) -> bool {
@@ -25,6 +25,7 @@ use dom::node::{ChildrenMutation, Node, NodeDamage};
use dom::node::{NodeTypeId, document_from_node, window_from_node};
use dom::virtualmethods::VirtualMethods;
use msg::constellation_msg::ConstellationChan;
use script_task::ScriptTaskEventCategory::InputEvent;
use script_task::{Runnable, CommonScriptMsg};
use textinput::{TextInput, Lines, KeyReaction};

@@ -356,7 +357,7 @@ impl VirtualMethods for HTMLTextAreaElement {
let dispatcher = ChangeEventRunnable {
element: handler,
};
let _ = chan.send(CommonScriptMsg::RunnableMsg(box dispatcher));
let _ = chan.send(CommonScriptMsg::RunnableMsg(InputEvent, box dispatcher));
}

self.force_relayout();
@@ -22,6 +22,7 @@ use dom::closeevent::CloseEvent;
use dom::event::{Event, EventBubbles, EventCancelable};
use dom::eventtarget::{EventTarget, EventTargetTypeId};
use dom::messageevent::MessageEvent;
use script_task::ScriptTaskEventCategory::WebSocketEvent;
use script_task::{Runnable, CommonScriptMsg};

use net_traits::hosts::replace_hosts;
@@ -182,7 +183,7 @@ impl WebSocket {
let task = box CloseTask {
addr: address,
};
sender.send(CommonScriptMsg::RunnableMsg(task)).unwrap();
sender.send(CommonScriptMsg::RunnableMsg(WebSocketEvent, task)).unwrap();
return;
}
};
@@ -192,7 +193,7 @@ impl WebSocket {
addr: address.clone(),
sender: ws_sender.clone(),
};
sender.send(CommonScriptMsg::RunnableMsg(open_task)).unwrap();
sender.send(CommonScriptMsg::RunnableMsg(WebSocketEvent, open_task)).unwrap();

for message in receiver.incoming_messages() {
let message = match message {
@@ -208,7 +209,7 @@ impl WebSocket {
let task = box CloseTask {
addr: address,
};
sender.send(CommonScriptMsg::RunnableMsg(task)).unwrap();
sender.send(CommonScriptMsg::RunnableMsg(WebSocketEvent, task)).unwrap();
break;
},
Err(_) => break,
@@ -217,7 +218,7 @@ impl WebSocket {
address: address.clone(),
message: message,
};
sender.send(CommonScriptMsg::RunnableMsg(message_task)).unwrap();
sender.send(CommonScriptMsg::RunnableMsg(WebSocketEvent, message_task)).unwrap();
}
});

@@ -186,20 +186,20 @@ impl Runnable for WorkerMessageHandler {
}
}

pub struct WorkerEventHandler {
pub struct SimpleWorkerErrorHandler {
addr: TrustedWorkerAddress,
}

impl WorkerEventHandler {
pub fn new(addr: TrustedWorkerAddress) -> WorkerEventHandler {
WorkerEventHandler {
impl SimpleWorkerErrorHandler {
pub fn new(addr: TrustedWorkerAddress) -> SimpleWorkerErrorHandler {
SimpleWorkerErrorHandler {
addr: addr
}
}
}

impl Runnable for WorkerEventHandler {
fn handler(self: Box<WorkerEventHandler>) {
impl Runnable for SimpleWorkerErrorHandler {
fn handler(self: Box<SimpleWorkerErrorHandler>) {
let this = *self;
Worker::dispatch_simple_error(this.addr);
}
@@ -27,6 +27,7 @@ use dom::xmlhttprequesteventtarget::XMLHttpRequestEventTarget;
use dom::xmlhttprequesteventtarget::XMLHttpRequestEventTargetTypeId;
use dom::xmlhttprequestupload::XMLHttpRequestUpload;
use network_listener::{NetworkListener, PreInvoke};
use script_task::ScriptTaskEventCategory::XhrEvent;
use script_task::{ScriptChan, Runnable, ScriptPort, CommonScriptMsg};

use encoding::all::UTF_8;
@@ -989,7 +990,7 @@ impl XMLHttpRequest {
sleep_ms(duration_ms);
match cancel_rx.try_recv() {
Err(TryRecvError::Empty) => {
timeout_target.send(CommonScriptMsg::RunnableMsg(box XHRTimeout {
timeout_target.send(CommonScriptMsg::RunnableMsg(XhrEvent, box XHRTimeout {
xhr: xhr,
gen_id: gen_id,
})).unwrap();
@@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use net_traits::{AsyncResponseListener, ResponseAction};
use script_task::ScriptTaskEventCategory::NetworkEvent;
use script_task::{ScriptChan, Runnable, CommonScriptMsg};
use std::sync::{Arc, Mutex};

@@ -15,7 +16,7 @@ pub struct NetworkListener<T: AsyncResponseListener + PreInvoke + Send + 'static

impl<T: AsyncResponseListener + PreInvoke + Send + 'static> NetworkListener<T> {
pub fn notify(&self, action: ResponseAction) {
if let Err(err) = self.script_chan.send(CommonScriptMsg::RunnableMsg(box ListenerRunnable {
if let Err(err) = self.script_chan.send(CommonScriptMsg::RunnableMsg(NetworkEvent, box ListenerRunnable {
context: self.context.clone(),
action: action,
})) {
Oops, something went wrong.

0 comments on commit 1e6a2f0

Please sign in to comment.
You can’t perform that action at this time.