mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Force all messages to worker tasks to send a TrustedWorkerAddress along with the ScriptMsg. This ensures that the main-thread Worker object is rooted for as long as there are events in flight or being processed.
This commit is contained in:
parent
2f059c15e7
commit
9a7cd31134
11 changed files with 234 additions and 121 deletions
|
@ -117,7 +117,7 @@ impl XHRProgress {
|
|||
|
||||
enum SyncOrAsync<'a> {
|
||||
Sync(JSRef<'a, XMLHttpRequest>),
|
||||
Async(TrustedXHRAddress, &'a ScriptChan)
|
||||
Async(TrustedXHRAddress, Box<ScriptChan+Send>)
|
||||
}
|
||||
|
||||
enum TerminateReason {
|
||||
|
@ -214,9 +214,8 @@ impl XMLHttpRequest {
|
|||
SyncOrAsync::Sync(xhr) => {
|
||||
xhr.process_partial_response(msg);
|
||||
},
|
||||
SyncOrAsync::Async(ref addr, script_chan) => {
|
||||
let ScriptChan(ref chan) = *script_chan;
|
||||
chan.send(ScriptMsg::RunnableMsg(box XHRProgressHandler::new(addr.clone(), msg)));
|
||||
SyncOrAsync::Async(ref addr, ref script_chan) => {
|
||||
script_chan.send(ScriptMsg::RunnableMsg(box XHRProgressHandler::new(addr.clone(), msg)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -614,16 +613,14 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> {
|
|||
terminate_receiver, cors_request, gen_id, start_port);
|
||||
} else {
|
||||
self.fetch_time.set(time::now().to_timespec().sec);
|
||||
let script_chan = global.root_ref().script_chan().clone();
|
||||
// Pin the object before launching the fetch task.
|
||||
// The `ScriptMsg::RunnableMsg` sent when the fetch task completes will
|
||||
// unpin it. This is to ensure that the object will stay alive
|
||||
// as long as there are (possibly cancelled) inflight events queued up
|
||||
// in the script task's port
|
||||
let script_chan = global.root_ref().script_chan();
|
||||
// Pin the object before launching the fetch task. This is to ensure that
|
||||
// the object will stay alive as long as there are (possibly cancelled)
|
||||
// inflight events queued up in the script task's port.
|
||||
let addr = Trusted::new(self.global.root().root_ref().get_cx(), self,
|
||||
script_chan.clone());
|
||||
spawn_named("XHRTask", proc() {
|
||||
let _ = XMLHttpRequest::fetch(&mut SyncOrAsync::Async(addr, &script_chan),
|
||||
let _ = XMLHttpRequest::fetch(&mut SyncOrAsync::Async(addr, script_chan),
|
||||
resource_task,
|
||||
load_data,
|
||||
terminate_receiver,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue