aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_thread.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r--components/script/script_thread.rs63
1 files changed, 28 insertions, 35 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index 0e3d9935435..8f43e1b1bfc 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -59,15 +59,14 @@ use js::rust::Runtime;
use layout_interface::{ReflowQueryType};
use layout_interface::{self, LayoutChan, NewLayoutThreadInfo, ScriptLayoutChan};
use mem::heap_size_of_self_and_children;
-use msg::constellation_msg::{ConstellationChan, LoadData, PanicMsg};
-use msg::constellation_msg::{PipelineId, PipelineNamespace};
+use msg::constellation_msg::{LoadData, PanicMsg, PipelineId, PipelineNamespace};
use msg::constellation_msg::{SubpageId, WindowSizeData, WindowSizeType};
use msg::webdriver_msg::WebDriverScriptCommand;
use net_traits::LoadData as NetLoadData;
use net_traits::bluetooth_thread::BluetoothMethodMsg;
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheResult, ImageCacheThread};
-use net_traits::storage_thread::StorageThread;
-use net_traits::{AsyncResponseTarget, ControlMsg, LoadConsumer, LoadContext, Metadata, ResourceThread};
+use net_traits::{AsyncResponseTarget, CoreResourceMsg, LoadConsumer, LoadContext, Metadata};
+use net_traits::{ResourceThreads, IpcSend};
use network_listener::NetworkListener;
use parse::ParserRoot;
use parse::html::{ParseContext, parse_html};
@@ -312,11 +311,9 @@ pub struct ScriptThread {
image_cache_thread: ImageCacheThread,
/// A handle to the resource thread. This is an `Arc` to avoid running out of file descriptors if
/// there are many iframes.
- resource_thread: Arc<ResourceThread>,
+ resource_threads: ResourceThreads,
/// A handle to the bluetooth thread.
bluetooth_thread: IpcSender<BluetoothMethodMsg>,
- /// A handle to the storage thread.
- storage_thread: StorageThread,
/// The port on which the script thread receives messages (load URL, exit, etc.)
port: Receiver<MainThreadScriptMsg>,
@@ -342,10 +339,10 @@ pub struct ScriptThread {
control_port: Receiver<ConstellationControlMsg>,
/// For communicating load url messages to the constellation
- constellation_chan: ConstellationChan<ConstellationMsg>,
+ constellation_chan: IpcSender<ConstellationMsg>,
/// For communicating layout messages to the constellation
- layout_to_constellation_chan: ConstellationChan<LayoutMsg>,
+ layout_to_constellation_chan: IpcSender<LayoutMsg>,
/// A handle to the compositor for communicating ready state messages.
compositor: DOMRefCell<IpcSender<ScriptToCompositorMsg>>,
@@ -424,21 +421,20 @@ impl<'a> Drop for ScriptMemoryFailsafe<'a> {
}
impl ScriptThreadFactory for ScriptThread {
- fn create_layout_channel(_phantom: Option<&mut ScriptThread>) -> OpaqueScriptLayoutChannel {
+ fn create_layout_channel() -> OpaqueScriptLayoutChannel {
let (chan, port) = channel();
ScriptLayoutChan::new(chan, port)
}
- fn clone_layout_channel(_phantom: Option<&mut ScriptThread>, pair: &OpaqueScriptLayoutChannel)
+ fn clone_layout_channel(pair: &OpaqueScriptLayoutChannel)
-> Box<Any + Send> {
box pair.sender() as Box<Any + Send>
}
- fn create(_phantom: Option<&mut ScriptThread>,
- state: InitialScriptState,
+ fn create(state: InitialScriptState,
layout_chan: &OpaqueScriptLayoutChannel,
load_data: LoadData) {
- let ConstellationChan(panic_chan) = state.panic_chan.clone();
+ let panic_chan = state.panic_chan.clone();
let (script_chan, script_port) = channel();
let layout_chan = LayoutChan(layout_chan.sender());
let pipeline_id = state.id;
@@ -558,9 +554,8 @@ impl ScriptThread {
image_cache_channel: ImageCacheChan(ipc_image_cache_channel),
image_cache_port: image_cache_port,
- resource_thread: Arc::new(state.resource_thread),
+ resource_threads: state.resource_threads,
bluetooth_thread: state.bluetooth_thread,
- storage_thread: state.storage_thread,
port: port,
chan: MainThreadScriptChan(chan.clone()),
@@ -577,7 +572,7 @@ impl ScriptThread {
compositor: DOMRefCell::new(state.compositor),
time_profiler_chan: state.time_profiler_chan,
mem_profiler_chan: state.mem_profiler_chan,
- panic_chan: state.panic_chan.0,
+ panic_chan: state.panic_chan,
devtools_chan: state.devtools_chan,
devtools_port: devtools_port,
@@ -1081,9 +1076,8 @@ impl ScriptThread {
content_process_shutdown_chan,
} = new_layout_info;
- let layout_pair = ScriptThread::create_layout_channel(None::<&mut ScriptThread>);
+ let layout_pair = ScriptThread::create_layout_channel();
let layout_chan = LayoutChan(*ScriptThread::clone_layout_channel(
- None::<&mut ScriptThread>,
&layout_pair).downcast::<Sender<layout_interface::Msg>>().unwrap());
let layout_creation_info = NewLayoutThreadInfo {
@@ -1134,8 +1128,7 @@ impl ScriptThread {
let handler = box DocumentProgressHandler::new(Trusted::new(doc));
self.dom_manipulation_task_source.queue(DOMManipulationTask::DocumentProgress(handler)).unwrap();
- let ConstellationChan(ref chan) = self.constellation_chan;
- chan.send(ConstellationMsg::LoadComplete(pipeline)).unwrap();
+ self.constellation_chan.send(ConstellationMsg::LoadComplete(pipeline)).unwrap();
}
fn collect_reports(&self, reports_chan: ReportsChan) {
@@ -1398,8 +1391,9 @@ impl ScriptThread {
chan.send(layout_interface::Msg::SetFinalUrl(final_url.clone())).unwrap();
// update the pipeline url
- let ConstellationChan(ref chan) = self.constellation_chan;
- chan.send(ConstellationMsg::SetFinalUrl(incomplete.pipeline_id, final_url.clone())).unwrap();
+ self.constellation_chan
+ .send(ConstellationMsg::SetFinalUrl(incomplete.pipeline_id, final_url.clone()))
+ .unwrap();
}
debug!("ScriptThread: loading {} on pipeline {:?}", incomplete.url, incomplete.pipeline_id);
@@ -1445,9 +1439,8 @@ impl ScriptThread {
self.image_cache_channel.clone(),
self.compositor.borrow_mut().clone(),
self.image_cache_thread.clone(),
- self.resource_thread.clone(),
+ self.resource_threads.clone(),
self.bluetooth_thread.clone(),
- self.storage_thread.clone(),
self.mem_profiler_chan.clone(),
self.time_profiler_chan.clone(),
self.devtools_chan.clone(),
@@ -1543,7 +1536,7 @@ impl ScriptThread {
}
});
- let loader = DocumentLoader::new_with_thread(self.resource_thread.clone(),
+ let loader = DocumentLoader::new_with_thread(Arc::new(self.resource_threads.sender()),
Some(browsing_context.pipeline()),
Some(incomplete.url.clone()));
@@ -1569,8 +1562,9 @@ impl ScriptThread {
}
document.set_ready_state(DocumentReadyState::Loading);
- let ConstellationChan(ref chan) = self.constellation_chan;
- chan.send(ConstellationMsg::ActivateDocument(incomplete.pipeline_id)).unwrap();
+ self.constellation_chan
+ .send(ConstellationMsg::ActivateDocument(incomplete.pipeline_id))
+ .unwrap();
// Notify devtools that a new script global exists.
self.notify_devtools(document.Title(), final_url.clone(), (browsing_context.pipeline(), None));
@@ -1729,8 +1723,7 @@ impl ScriptThread {
});
let event = ConstellationMsg::NodeStatus(status);
- let ConstellationChan(ref chan) = self.constellation_chan;
- chan.send(event).unwrap();
+ self.constellation_chan.send(event).unwrap();
state_already_changed = true;
}
@@ -1744,8 +1737,7 @@ impl ScriptThread {
.filter_map(Root::downcast::<HTMLAnchorElement>)
.next() {
let event = ConstellationMsg::NodeStatus(None);
- let ConstellationChan(ref chan) = self.constellation_chan;
- chan.send(event).unwrap();
+ self.constellation_chan.send(event).unwrap();
}
}
}
@@ -1844,8 +1836,9 @@ impl ScriptThread {
}
}
None => {
- let ConstellationChan(ref const_chan) = self.constellation_chan;
- const_chan.send(ConstellationMsg::LoadUrl(pipeline_id, load_data)).unwrap();
+ self.constellation_chan
+ .send(ConstellationMsg::LoadUrl(pipeline_id, load_data))
+ .unwrap();
}
}
}
@@ -1900,7 +1893,7 @@ impl ScriptThread {
load_data.url = Url::parse("about:blank").unwrap();
}
- self.resource_thread.send(ControlMsg::Load(NetLoadData {
+ self.resource_threads.send(CoreResourceMsg::Load(NetLoadData {
context: LoadContext::Browsing,
url: load_data.url,
method: load_data.method,