diff options
author | Zhen Zhang <izgzhen@gmail.com> | 2016-05-18 00:07:42 +0800 |
---|---|---|
committer | Zhen Zhang <izgzhen@gmail.com> | 2016-05-20 08:00:16 +0800 |
commit | a51db4cfa857d7567ce1078830f5c00ea7bd9f59 (patch) | |
tree | 9a604ff41983c9bded331f4ec80f94c9f6b1cd45 /components/script/script_thread.rs | |
parent | 051a749e0d0ff298a3cbce8c6284386dc0d67f24 (diff) | |
download | servo-a51db4cfa857d7567ce1078830f5c00ea7bd9f59.tar.gz servo-a51db4cfa857d7567ce1078830f5c00ea7bd9f59.zip |
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
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r-- | components/script/script_thread.rs | 18 |
1 files changed, 7 insertions, 11 deletions
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<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>, @@ -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, |