mirror of
https://github.com/servo/servo.git
synced 2025-08-09 15:35:34 +01:00
Auto merge of #10767 - akhan7:command, r=jdm
Added Store Command to ImageCache Task Implemented last bullet of [Image conformance student project: Initial Steps](https://github.com/servo/servo/wiki/Image-load-conformance-student-project) <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10767) <!-- Reviewable:end -->
This commit is contained in:
commit
47efbea666
2 changed files with 32 additions and 1 deletions
|
@ -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
|
||||
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue