aboutsummaryrefslogtreecommitdiffstats
path: root/components/net/image_cache_thread.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/net/image_cache_thread.rs')
-rw-r--r--components/net/image_cache_thread.rs26
1 files changed, 23 insertions, 3 deletions
diff --git a/components/net/image_cache_thread.rs b/components/net/image_cache_thread.rs
index 91a0cf0dc32..3ca281761d4 100644
--- a/components/net/image_cache_thread.rs
+++ b/components/net/image_cache_thread.rs
@@ -10,7 +10,7 @@ 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::{ResponseAction, LoadContext};
+use net_traits::{ResponseAction, LoadContext, NetworkError};
use std::borrow::ToOwned;
use std::collections::HashMap;
use std::collections::hash_map::Entry::{Occupied, Vacant};
@@ -44,7 +44,7 @@ struct PendingLoad {
metadata: Option<ImageMetadata>,
// Once loading is complete, the result of the operation.
- result: Option<Result<(), String>>,
+ result: Option<Result<(), NetworkError>>,
listeners: Vec<ImageListener>,
// The url being loaded. Do not forget that this may be several Mb
@@ -394,6 +394,9 @@ impl ImageCache {
let result = self.get_image_or_meta_if_available(url, use_placeholder);
consumer.send(result).unwrap();
}
+ ImageCacheCommand::StoreDecodeImage(url, image_vector) => {
+ self.store_decode_image(url, image_vector);
+ }
};
None
@@ -517,7 +520,7 @@ impl ImageCache {
CacheResult::Miss => {
// A new load request! Request the load from
// the resource thread.
- let load_data = LoadData::new(LoadContext::Image, (*ref_url).clone(), None);
+ let load_data = LoadData::new(LoadContext::Image, (*ref_url).clone(), None, None, None);
let (action_sender, action_receiver) = ipc::channel().unwrap();
let response_target = AsyncResponseTarget {
sender: action_sender,
@@ -588,6 +591,23 @@ impl ImageCache {
}
}
}
+
+ fn store_decode_image(&mut self,
+ ref_url: Url,
+ loaded_bytes: Vec<u8>) {
+ let (cache_result, load_key, _) = self.pending_loads.get_cached(Arc::new(ref_url));
+ assert!(cache_result == CacheResult::Miss);
+ let action = ResponseAction::DataAvailable(loaded_bytes);
+ let _ = self.progress_sender.send(ResourceLoadInfo {
+ action: action,
+ key: load_key,
+ });
+ let action = ResponseAction::ResponseComplete(Ok(()));
+ let _ = self.progress_sender.send(ResourceLoadInfo {
+ action: action,
+ key: load_key,
+ });
+ }
}
/// Create a new image cache.