mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
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
This commit is contained in:
parent
051a749e0d
commit
a51db4cfa8
22 changed files with 213 additions and 179 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue