From a51db4cfa857d7567ce1078830f5c00ea7bd9f59 Mon Sep 17 00:00:00 2001 From: Zhen Zhang Date: Wed, 18 May 2016 00:07:42 +0800 Subject: 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 --- components/script/script_thread.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'components/script/script_thread.rs') diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 0fe4ab3ea3c..960d39cc244 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -65,8 +65,8 @@ 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}; @@ -311,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, + resource_threads: ResourceThreads, /// A handle to the bluetooth thread. bluetooth_thread: IpcSender, - /// A handle to the storage thread. - storage_thread: StorageThread, /// The port on which the script thread receives messages (load URL, exit, etc.) port: Receiver, @@ -557,9 +555,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()), @@ -1444,9 +1441,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(), @@ -1542,7 +1538,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())); @@ -1899,7 +1895,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, -- cgit v1.2.3