Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

script: Make the resource task communication use IPC channels. #6586

Merged
merged 5 commits into from Jul 31, 2015
Prev

script: Fix test failures.

  • Loading branch information
pcwalton committed Jul 31, 2015
commit 61e3a9545ecd3b93e275af6dfa425a7fdd42f9db
@@ -9,6 +9,7 @@ use script_task::{ScriptMsg, ScriptChan};
use msg::constellation_msg::{PipelineId};
use net_traits::{Metadata, load_whole_resource, ResourceTask, PendingAsyncLoad};
use net_traits::AsyncResponseTarget;
use std::sync::Arc;
use url::Url;

#[derive(JSTraceable, PartialEq, Clone, Debug)]
@@ -34,7 +35,9 @@ impl LoadType {

#[derive(JSTraceable)]
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>,
blocking_loads: Vec<LoadType>,
}
@@ -50,7 +53,9 @@ impl DocumentLoader {
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>,
initial_load: Option<Url>,)
-> DocumentLoader {
@@ -69,7 +74,7 @@ impl DocumentLoader {
let url = load.url().clone();
self.blocking_loads.push(load);
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.
@@ -116,7 +116,7 @@ impl<'a> GlobalRef<'a> {
let doc = window.Document();
let doc = doc.r();
let loader = doc.loader();
loader.resource_task.clone()
(*loader.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::mem as std_mem;
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::{channel, Receiver};
use time;

/// Current state of the window object
@@ -173,7 +174,7 @@ pub struct Window {
window_size: Cell<Option<WindowSizeData>>,

/// 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.
storage_task: StorageTask,
@@ -883,7 +884,7 @@ impl<'a> WindowHelpers for &'a Window {
}

fn resource_task(self) -> ResourceTask {
self.resource_task.clone()
(*self.resource_task).clone()
}

fn mem_profiler_chan(self) -> mem::ProfilerChan {
@@ -1035,7 +1036,7 @@ impl Window {
control_chan: ScriptControlChan,
compositor: ScriptListener,
image_cache_task: ImageCacheTask,
resource_task: ResourceTask,
resource_task: Arc<ResourceTask>,
storage_task: StorageTask,
mem_profiler_chan: mem::ProfilerChan,
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> {
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(),
action: action,
})).unwrap();
})) {
warn!("failed to deliver network data: {:?}", err);
}
}
}

@@ -287,8 +287,9 @@ pub struct ScriptTask {
incomplete_loads: DOMRefCell<Vec<InProgressLoad>>,
/// A handle to the image cache task.
image_cache_task: ImageCacheTask,
/// A handle to the resource task.
resource_task: ResourceTask,
/// A handle to the resource task. This is an `Arc` to avoid running out of file descriptors if
/// there are many iframes.
resource_task: Arc<ResourceTask>,
/// A handle to the storage task.
storage_task: StorageTask,

@@ -418,7 +419,7 @@ impl ScriptTaskFactory for ScriptTask {
control_chan,
control_port,
constellation_chan,
resource_task,
Arc::new(resource_task),
storage_task,
image_cache_task,
mem_profiler_chan.clone(),
@@ -504,7 +505,7 @@ impl ScriptTask {
control_chan: ScriptControlChan,
control_port: Receiver<ConstellationControlMsg>,
constellation_chan: ConstellationChan,
resource_task: ResourceTask,
resource_task: Arc<ResourceTask>,
storage_task: StorageTask,
image_cache_task: ImageCacheTask,
mem_profiler_chan: mem::ProfilerChan,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.