aboutsummaryrefslogtreecommitdiffstats
path: root/components/net/image_cache_thread.rs
diff options
context:
space:
mode:
authorZhen Zhang <izgzhen@gmail.com>2016-05-18 00:07:42 +0800
committerZhen Zhang <izgzhen@gmail.com>2016-05-20 08:00:16 +0800
commita51db4cfa857d7567ce1078830f5c00ea7bd9f59 (patch)
tree9a604ff41983c9bded331f4ec80f94c9f6b1cd45 /components/net/image_cache_thread.rs
parent051a749e0d0ff298a3cbce8c6284386dc0d67f24 (diff)
downloadservo-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/net/image_cache_thread.rs')
-rw-r--r--components/net/image_cache_thread.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/components/net/image_cache_thread.rs b/components/net/image_cache_thread.rs
index 3ca281761d4..6ecf32f5730 100644
--- a/components/net/image_cache_thread.rs
+++ b/components/net/image_cache_thread.rs
@@ -9,7 +9,7 @@ use net_traits::image::base::{Image, ImageMetadata, load_from_memory, PixelForma
use net_traits::image_cache_thread::ImageResponder;
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheCommand, ImageCacheThread, ImageState};
use net_traits::image_cache_thread::{ImageCacheResult, ImageOrMetadataAvailable, ImageResponse, UsePlaceholder};
-use net_traits::{AsyncResponseTarget, ControlMsg, LoadConsumer, LoadData, ResourceThread};
+use net_traits::{AsyncResponseTarget, CoreResourceMsg, LoadConsumer, LoadData, CoreResourceThread};
use net_traits::{ResponseAction, LoadContext, NetworkError};
use std::borrow::ToOwned;
use std::collections::HashMap;
@@ -240,7 +240,7 @@ struct ImageCache {
thread_pool: ThreadPool,
// Resource thread handle
- resource_thread: ResourceThread,
+ core_resource_thread: CoreResourceThread,
// Images that are loading over network, or decoding.
pending_loads: AllPendingLoads,
@@ -305,7 +305,7 @@ fn convert_format(format: PixelFormat) -> webrender_traits::ImageFormat {
}
impl ImageCache {
- fn run(resource_thread: ResourceThread,
+ fn run(core_resource_thread: CoreResourceThread,
webrender_api: Option<webrender_traits::RenderApi>,
ipc_command_receiver: IpcReceiver<ImageCacheCommand>) {
// Preload the placeholder image, used when images fail to load.
@@ -338,7 +338,7 @@ impl ImageCache {
thread_pool: ThreadPool::new(4),
pending_loads: AllPendingLoads::new(),
completed_loads: HashMap::new(),
- resource_thread: resource_thread,
+ core_resource_thread: core_resource_thread,
placeholder_image: placeholder_image,
webrender_api: webrender_api,
};
@@ -525,7 +525,7 @@ impl ImageCache {
let response_target = AsyncResponseTarget {
sender: action_sender,
};
- let msg = ControlMsg::Load(load_data,
+ let msg = CoreResourceMsg::Load(load_data,
LoadConsumer::Listener(response_target),
None);
let progress_sender = self.progress_sender.clone();
@@ -536,7 +536,7 @@ impl ImageCache {
key: load_key,
}).unwrap();
});
- self.resource_thread.send(msg).unwrap();
+ self.core_resource_thread.send(msg).unwrap();
}
CacheResult::Hit => {
// Request is already on its way.
@@ -611,12 +611,12 @@ impl ImageCache {
}
/// Create a new image cache.
-pub fn new_image_cache_thread(resource_thread: ResourceThread,
+pub fn new_image_cache_thread(core_resource_thread: CoreResourceThread,
webrender_api: Option<webrender_traits::RenderApi>) -> ImageCacheThread {
let (ipc_command_sender, ipc_command_receiver) = ipc::channel().unwrap();
spawn_named("ImageCacheThread".to_owned(), move || {
- ImageCache::run(resource_thread, webrender_api, ipc_command_receiver)
+ ImageCache::run(core_resource_thread, webrender_api, ipc_command_receiver)
});
ImageCacheThread::new(ipc_command_sender)