mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
script: Fix test failures.
This commit is contained in:
parent
024c4df912
commit
61e3a9545e
5 changed files with 23 additions and 14 deletions
|
@ -9,6 +9,7 @@ use script_task::{ScriptMsg, ScriptChan};
|
||||||
use msg::constellation_msg::{PipelineId};
|
use msg::constellation_msg::{PipelineId};
|
||||||
use net_traits::{Metadata, load_whole_resource, ResourceTask, PendingAsyncLoad};
|
use net_traits::{Metadata, load_whole_resource, ResourceTask, PendingAsyncLoad};
|
||||||
use net_traits::AsyncResponseTarget;
|
use net_traits::AsyncResponseTarget;
|
||||||
|
use std::sync::Arc;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
#[derive(JSTraceable, PartialEq, Clone, Debug)]
|
#[derive(JSTraceable, PartialEq, Clone, Debug)]
|
||||||
|
@ -34,7 +35,9 @@ impl LoadType {
|
||||||
|
|
||||||
#[derive(JSTraceable)]
|
#[derive(JSTraceable)]
|
||||||
pub struct DocumentLoader {
|
pub struct DocumentLoader {
|
||||||
pub resource_task: ResourceTask,
|
/// We use an `Arc<ResourceTask>` here in order to avoid file descriptor exhaustion when there
|
||||||
|
/// are lots of iframes.
|
||||||
|
pub resource_task: Arc<ResourceTask>,
|
||||||
notifier_data: Option<NotifierData>,
|
notifier_data: Option<NotifierData>,
|
||||||
blocking_loads: Vec<LoadType>,
|
blocking_loads: Vec<LoadType>,
|
||||||
}
|
}
|
||||||
|
@ -50,7 +53,9 @@ impl DocumentLoader {
|
||||||
DocumentLoader::new_with_task(existing.resource_task.clone(), None, None)
|
DocumentLoader::new_with_task(existing.resource_task.clone(), None, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_with_task(resource_task: ResourceTask,
|
/// We use an `Arc<ResourceTask>` here in order to avoid file descriptor exhaustion when there
|
||||||
|
/// are lots of iframes.
|
||||||
|
pub fn new_with_task(resource_task: Arc<ResourceTask>,
|
||||||
data: Option<NotifierData>,
|
data: Option<NotifierData>,
|
||||||
initial_load: Option<Url>,)
|
initial_load: Option<Url>,)
|
||||||
-> DocumentLoader {
|
-> DocumentLoader {
|
||||||
|
@ -69,7 +74,7 @@ impl DocumentLoader {
|
||||||
let url = load.url().clone();
|
let url = load.url().clone();
|
||||||
self.blocking_loads.push(load);
|
self.blocking_loads.push(load);
|
||||||
let pipeline = self.notifier_data.as_ref().map(|data| data.pipeline);
|
let pipeline = self.notifier_data.as_ref().map(|data| data.pipeline);
|
||||||
PendingAsyncLoad::new(self.resource_task.clone(), url, pipeline)
|
PendingAsyncLoad::new((*self.resource_task).clone(), url, pipeline)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create and initiate a new network request.
|
/// Create and initiate a new network request.
|
||||||
|
|
|
@ -116,7 +116,7 @@ impl<'a> GlobalRef<'a> {
|
||||||
let doc = window.Document();
|
let doc = window.Document();
|
||||||
let doc = doc.r();
|
let doc = doc.r();
|
||||||
let loader = doc.loader();
|
let loader = doc.loader();
|
||||||
loader.resource_task.clone()
|
(*loader.resource_task).clone()
|
||||||
}
|
}
|
||||||
GlobalRef::Worker(ref worker) => worker.resource_task().clone(),
|
GlobalRef::Worker(ref worker) => worker.resource_task().clone(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,8 +74,9 @@ use std::default::Default;
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::mem as std_mem;
|
use std::mem as std_mem;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::mpsc::{channel, Receiver};
|
use std::sync::Arc;
|
||||||
use std::sync::mpsc::TryRecvError::{Empty, Disconnected};
|
use std::sync::mpsc::TryRecvError::{Empty, Disconnected};
|
||||||
|
use std::sync::mpsc::{channel, Receiver};
|
||||||
use time;
|
use time;
|
||||||
|
|
||||||
/// Current state of the window object
|
/// Current state of the window object
|
||||||
|
@ -173,7 +174,7 @@ pub struct Window {
|
||||||
window_size: Cell<Option<WindowSizeData>>,
|
window_size: Cell<Option<WindowSizeData>>,
|
||||||
|
|
||||||
/// Associated resource task for use by DOM objects like XMLHttpRequest
|
/// Associated resource task for use by DOM objects like XMLHttpRequest
|
||||||
resource_task: ResourceTask,
|
resource_task: Arc<ResourceTask>,
|
||||||
|
|
||||||
/// A handle for communicating messages to the storage task.
|
/// A handle for communicating messages to the storage task.
|
||||||
storage_task: StorageTask,
|
storage_task: StorageTask,
|
||||||
|
@ -883,7 +884,7 @@ impl<'a> WindowHelpers for &'a Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resource_task(self) -> ResourceTask {
|
fn resource_task(self) -> ResourceTask {
|
||||||
self.resource_task.clone()
|
(*self.resource_task).clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mem_profiler_chan(self) -> mem::ProfilerChan {
|
fn mem_profiler_chan(self) -> mem::ProfilerChan {
|
||||||
|
@ -1035,7 +1036,7 @@ impl Window {
|
||||||
control_chan: ScriptControlChan,
|
control_chan: ScriptControlChan,
|
||||||
compositor: ScriptListener,
|
compositor: ScriptListener,
|
||||||
image_cache_task: ImageCacheTask,
|
image_cache_task: ImageCacheTask,
|
||||||
resource_task: ResourceTask,
|
resource_task: Arc<ResourceTask>,
|
||||||
storage_task: StorageTask,
|
storage_task: StorageTask,
|
||||||
mem_profiler_chan: mem::ProfilerChan,
|
mem_profiler_chan: mem::ProfilerChan,
|
||||||
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
|
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
|
||||||
|
|
|
@ -15,10 +15,12 @@ pub struct NetworkListener<T: AsyncResponseListener + PreInvoke + Send + 'static
|
||||||
|
|
||||||
impl<T: AsyncResponseListener + PreInvoke + Send + 'static> NetworkListener<T> {
|
impl<T: AsyncResponseListener + PreInvoke + Send + 'static> NetworkListener<T> {
|
||||||
pub fn notify(&self, action: ResponseAction) {
|
pub fn notify(&self, action: ResponseAction) {
|
||||||
self.script_chan.send(ScriptMsg::RunnableMsg(box ListenerRunnable {
|
if let Err(err) = self.script_chan.send(ScriptMsg::RunnableMsg(box ListenerRunnable {
|
||||||
context: self.context.clone(),
|
context: self.context.clone(),
|
||||||
action: action,
|
action: action,
|
||||||
})).unwrap();
|
})) {
|
||||||
|
warn!("failed to deliver network data: {:?}", err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -287,8 +287,9 @@ pub struct ScriptTask {
|
||||||
incomplete_loads: DOMRefCell<Vec<InProgressLoad>>,
|
incomplete_loads: DOMRefCell<Vec<InProgressLoad>>,
|
||||||
/// A handle to the image cache task.
|
/// A handle to the image cache task.
|
||||||
image_cache_task: ImageCacheTask,
|
image_cache_task: ImageCacheTask,
|
||||||
/// A handle to the resource task.
|
/// A handle to the resource task. This is an `Arc` to avoid running out of file descriptors if
|
||||||
resource_task: ResourceTask,
|
/// there are many iframes.
|
||||||
|
resource_task: Arc<ResourceTask>,
|
||||||
/// A handle to the storage task.
|
/// A handle to the storage task.
|
||||||
storage_task: StorageTask,
|
storage_task: StorageTask,
|
||||||
|
|
||||||
|
@ -418,7 +419,7 @@ impl ScriptTaskFactory for ScriptTask {
|
||||||
control_chan,
|
control_chan,
|
||||||
control_port,
|
control_port,
|
||||||
constellation_chan,
|
constellation_chan,
|
||||||
resource_task,
|
Arc::new(resource_task),
|
||||||
storage_task,
|
storage_task,
|
||||||
image_cache_task,
|
image_cache_task,
|
||||||
mem_profiler_chan.clone(),
|
mem_profiler_chan.clone(),
|
||||||
|
@ -504,7 +505,7 @@ impl ScriptTask {
|
||||||
control_chan: ScriptControlChan,
|
control_chan: ScriptControlChan,
|
||||||
control_port: Receiver<ConstellationControlMsg>,
|
control_port: Receiver<ConstellationControlMsg>,
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
resource_task: ResourceTask,
|
resource_task: Arc<ResourceTask>,
|
||||||
storage_task: StorageTask,
|
storage_task: StorageTask,
|
||||||
image_cache_task: ImageCacheTask,
|
image_cache_task: ImageCacheTask,
|
||||||
mem_profiler_chan: mem::ProfilerChan,
|
mem_profiler_chan: mem::ProfilerChan,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue