mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Implement trait-based ResourceThreads and clean up related naming issues
Changes include: - Introduce an IpcSend trait to abstract over a collection of IpcSenders - Implement ResourceThreads collection to abstract the resource-related sub threads across the component - Rename original ResourceThread and ControlMsg into an unifed CoreResource__ to accommodate above changes and avoid confusions
This commit is contained in:
parent
051a749e0d
commit
a51db4cfa8
22 changed files with 213 additions and 179 deletions
|
@ -44,9 +44,9 @@ use ipc_channel::router::ROUTER;
|
|||
use js::jsapi::JS_ClearPendingException;
|
||||
use js::jsapi::{JSContext, JS_ParseJSON, RootedValue};
|
||||
use js::jsval::{JSVal, NullValue, UndefinedValue};
|
||||
use net_traits::ControlMsg::Load;
|
||||
use net_traits::CoreResourceMsg::Load;
|
||||
use net_traits::{AsyncResponseListener, AsyncResponseTarget, Metadata, NetworkError};
|
||||
use net_traits::{LoadConsumer, LoadContext, LoadData, ResourceCORSData, ResourceThread};
|
||||
use net_traits::{LoadConsumer, LoadContext, LoadData, ResourceCORSData, CoreResourceThread};
|
||||
use network_listener::{NetworkListener, PreInvoke};
|
||||
use parse::html::{ParseContext, parse_html};
|
||||
use parse::xml::{self, parse_xml};
|
||||
|
@ -207,13 +207,13 @@ impl XMLHttpRequest {
|
|||
load_data: LoadData,
|
||||
req: CORSRequest,
|
||||
script_chan: Box<ScriptChan + Send>,
|
||||
resource_thread: ResourceThread) {
|
||||
core_resource_thread: CoreResourceThread) {
|
||||
struct CORSContext {
|
||||
xhr: Arc<Mutex<XHRContext>>,
|
||||
load_data: RefCell<Option<LoadData>>,
|
||||
req: CORSRequest,
|
||||
script_chan: Box<ScriptChan + Send>,
|
||||
resource_thread: ResourceThread,
|
||||
core_resource_thread: CoreResourceThread,
|
||||
}
|
||||
|
||||
impl AsyncCORSResponseListener for CORSContext {
|
||||
|
@ -233,7 +233,7 @@ impl XMLHttpRequest {
|
|||
});
|
||||
|
||||
XMLHttpRequest::initiate_async_xhr(self.xhr.clone(), self.script_chan.clone(),
|
||||
self.resource_thread.clone(), load_data);
|
||||
self.core_resource_thread.clone(), load_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,7 @@ impl XMLHttpRequest {
|
|||
load_data: RefCell::new(Some(load_data)),
|
||||
req: req.clone(),
|
||||
script_chan: script_chan.clone(),
|
||||
resource_thread: resource_thread,
|
||||
core_resource_thread: core_resource_thread,
|
||||
};
|
||||
|
||||
req.http_fetch_async(box cors_context, script_chan);
|
||||
|
@ -250,7 +250,7 @@ impl XMLHttpRequest {
|
|||
|
||||
fn initiate_async_xhr(context: Arc<Mutex<XHRContext>>,
|
||||
script_chan: Box<ScriptChan + Send>,
|
||||
resource_thread: ResourceThread,
|
||||
core_resource_thread: CoreResourceThread,
|
||||
load_data: LoadData) {
|
||||
impl AsyncResponseListener for XHRContext {
|
||||
fn headers_available(&mut self, metadata: Result<Metadata, NetworkError>) {
|
||||
|
@ -291,7 +291,7 @@ impl XMLHttpRequest {
|
|||
ROUTER.add_route(action_receiver.to_opaque(), box move |message| {
|
||||
listener.notify(message.to().unwrap());
|
||||
});
|
||||
resource_thread.send(Load(load_data, LoadConsumer::Listener(response_target), None)).unwrap();
|
||||
core_resource_thread.send(Load(load_data, LoadConsumer::Listener(response_target), None)).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1318,13 +1318,13 @@ impl XMLHttpRequest {
|
|||
(global.networking_task_source(), None)
|
||||
};
|
||||
|
||||
let resource_thread = global.resource_thread();
|
||||
let core_resource_thread = global.core_resource_thread();
|
||||
if let Some(req) = cors_request {
|
||||
XMLHttpRequest::check_cors(context.clone(), load_data, req.clone(),
|
||||
script_chan.clone(), resource_thread);
|
||||
script_chan.clone(), core_resource_thread);
|
||||
} else {
|
||||
XMLHttpRequest::initiate_async_xhr(context.clone(), script_chan,
|
||||
resource_thread, load_data);
|
||||
core_resource_thread, load_data);
|
||||
}
|
||||
|
||||
if let Some(script_port) = script_port {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue