mirror of
https://github.com/servo/servo.git
synced 2025-07-29 10:10:34 +01:00
Send response for image requests progressively to image cache.
This commit is contained in:
parent
21118f0a8a
commit
0d2ec852ac
5 changed files with 59 additions and 58 deletions
|
@ -396,8 +396,11 @@ impl ImageCache {
|
|||
// TODO(#15501): look for opportunities to clean up cache if this send fails.
|
||||
let _ = consumer.send(result);
|
||||
}
|
||||
ImageCacheCommand::StoreDecodeImage(id, image_vector) => {
|
||||
self.store_decode_image(id, image_vector);
|
||||
ImageCacheCommand::StoreDecodeImage(id, data) => {
|
||||
self.handle_progress(ResourceLoadInfo {
|
||||
action: data,
|
||||
key: id
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -409,7 +412,7 @@ impl ImageCache {
|
|||
match (msg.action, msg.key) {
|
||||
(FetchResponseMsg::ProcessRequestBody, _) |
|
||||
(FetchResponseMsg::ProcessRequestEOF, _) => return,
|
||||
(FetchResponseMsg::ProcessResponse(_), _) => {}
|
||||
(FetchResponseMsg::ProcessResponse(_response), _) => {}
|
||||
(FetchResponseMsg::ProcessResponseChunk(data), _) => {
|
||||
let pending_load = self.pending_loads.get_by_key_mut(&msg.key).unwrap();
|
||||
pending_load.bytes.extend_from_slice(&data);
|
||||
|
@ -581,21 +584,6 @@ impl ImageCache {
|
|||
None => Err(ImageState::LoadError),
|
||||
}
|
||||
}
|
||||
|
||||
fn store_decode_image(&mut self,
|
||||
id: PendingImageId,
|
||||
loaded_bytes: Vec<u8>) {
|
||||
let action = FetchResponseMsg::ProcessResponseChunk(loaded_bytes);
|
||||
self.handle_progress(ResourceLoadInfo {
|
||||
action: action,
|
||||
key: id,
|
||||
});
|
||||
let action = FetchResponseMsg::ProcessResponseEOF(Ok(()));
|
||||
self.handle_progress(ResourceLoadInfo {
|
||||
action: action,
|
||||
key: id,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new image cache.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue