mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Introduce GlobalScope::core_resource_thread
This commit is contained in:
parent
de846f25a6
commit
71236e168a
5 changed files with 12 additions and 14 deletions
|
@ -22,7 +22,6 @@ use js::jsapi::{JSAutoCompartment, JSContext, JSObject};
|
||||||
use js::jsapi::{JS_GetClass, MutableHandleValue};
|
use js::jsapi::{JS_GetClass, MutableHandleValue};
|
||||||
use js::rust::CompileOptionsWrapper;
|
use js::rust::CompileOptionsWrapper;
|
||||||
use libc;
|
use libc;
|
||||||
use net_traits::{CoreResourceThread, IpcSend};
|
|
||||||
use profile_traits::time;
|
use profile_traits::time;
|
||||||
use script_runtime::{CommonScriptMsg, EnqueuedPromiseCallback, ScriptChan};
|
use script_runtime::{CommonScriptMsg, EnqueuedPromiseCallback, ScriptChan};
|
||||||
use script_runtime::{ScriptPort, maybe_take_panic_result};
|
use script_runtime::{ScriptPort, maybe_take_panic_result};
|
||||||
|
@ -68,11 +67,6 @@ impl<'a> GlobalRef<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the `CoreResourceThread` for this global scope
|
|
||||||
pub fn core_resource_thread(&self) -> CoreResourceThread {
|
|
||||||
self.as_global_scope().resource_threads().sender()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// `ScriptChan` used to send messages to the event loop of this global's
|
/// `ScriptChan` used to send messages to the event loop of this global's
|
||||||
/// thread.
|
/// thread.
|
||||||
pub fn script_chan(&self) -> Box<ScriptChan + Send> {
|
pub fn script_chan(&self) -> Box<ScriptChan + Send> {
|
||||||
|
|
|
@ -21,7 +21,7 @@ use dom::workerglobalscope::WorkerGlobalScope;
|
||||||
use ipc_channel::ipc::IpcSender;
|
use ipc_channel::ipc::IpcSender;
|
||||||
use js::jsapi::{HandleValue, JS_GetContext, JS_GetObjectRuntime, JSContext};
|
use js::jsapi::{HandleValue, JS_GetContext, JS_GetObjectRuntime, JSContext};
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
use net_traits::ResourceThreads;
|
use net_traits::{CoreResourceThread, ResourceThreads, IpcSend};
|
||||||
use profile_traits::{mem, time};
|
use profile_traits::{mem, time};
|
||||||
use script_traits::{ScriptMsg as ConstellationMsg, TimerEventRequest};
|
use script_traits::{ScriptMsg as ConstellationMsg, TimerEventRequest};
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
@ -252,6 +252,11 @@ impl GlobalScope {
|
||||||
pub fn resource_threads(&self) -> &ResourceThreads {
|
pub fn resource_threads(&self) -> &ResourceThreads {
|
||||||
&self.resource_threads
|
&self.resource_threads
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the `CoreResourceThread` for this global scope.
|
||||||
|
pub fn core_resource_thread(&self) -> CoreResourceThread {
|
||||||
|
self.resource_threads().sender()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn timestamp_in_ms(time: Timespec) -> u64 {
|
fn timestamp_in_ms(time: Timespec) -> u64 {
|
||||||
|
|
|
@ -265,7 +265,7 @@ impl WebSocket {
|
||||||
action_receiver: resource_action_receiver,
|
action_receiver: resource_action_receiver,
|
||||||
};
|
};
|
||||||
|
|
||||||
let _ = global.core_resource_thread().send(WebsocketConnect(connect, connect_data));
|
let _ = global_scope.core_resource_thread().send(WebsocketConnect(connect, connect_data));
|
||||||
|
|
||||||
*ws.sender.borrow_mut() = Some(dom_action_sender);
|
*ws.sender.borrow_mut() = Some(dom_action_sender);
|
||||||
|
|
||||||
|
@ -492,9 +492,8 @@ impl Runnable for ConnectionEstablishedTask {
|
||||||
if let Some(cookies) = self.headers.get_raw("set-cookie") {
|
if let Some(cookies) = self.headers.get_raw("set-cookie") {
|
||||||
for cookie in cookies.iter() {
|
for cookie in cookies.iter() {
|
||||||
if let Ok(cookie_value) = String::from_utf8(cookie.clone()) {
|
if let Ok(cookie_value) = String::from_utf8(cookie.clone()) {
|
||||||
let _ = ws.global().r().core_resource_thread().send(SetCookiesForUrl(ws.url.clone(),
|
let _ = ws.global_scope().core_resource_thread().send(
|
||||||
cookie_value,
|
SetCookiesForUrl(ws.url.clone(), cookie_value, HTTP));
|
||||||
HTTP));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1303,7 +1303,7 @@ impl XMLHttpRequest {
|
||||||
(global.networking_task_source(), None)
|
(global.networking_task_source(), None)
|
||||||
};
|
};
|
||||||
|
|
||||||
let core_resource_thread = global.core_resource_thread();
|
let core_resource_thread = global.as_global_scope().core_resource_thread();
|
||||||
XMLHttpRequest::initiate_async_xhr(context.clone(), script_chan,
|
XMLHttpRequest::initiate_async_xhr(context.clone(), script_chan,
|
||||||
core_resource_thread, init);
|
core_resource_thread, init);
|
||||||
|
|
||||||
|
|
|
@ -67,10 +67,10 @@ fn request_init_from_request(request: NetTraitsRequest) -> NetTraitsRequestInit
|
||||||
// https://fetch.spec.whatwg.org/#fetch-method
|
// https://fetch.spec.whatwg.org/#fetch-method
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn Fetch(global: GlobalRef, input: RequestOrUSVString, init: &RequestInit) -> Rc<Promise> {
|
pub fn Fetch(global: GlobalRef, input: RequestOrUSVString, init: &RequestInit) -> Rc<Promise> {
|
||||||
let core_resource_thread = global.core_resource_thread();
|
let global_scope = global.as_global_scope();
|
||||||
|
let core_resource_thread = global_scope.core_resource_thread();
|
||||||
|
|
||||||
// Step 1
|
// Step 1
|
||||||
let global_scope = global.as_global_scope();
|
|
||||||
let promise = Promise::new(global_scope);
|
let promise = Promise::new(global_scope);
|
||||||
let response = Response::new(global_scope);
|
let response = Response::new(global_scope);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue