Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse srcset algo #10829

Closed
wants to merge 10 commits into from
Next

Added Command to ImageCache Task

  • Loading branch information
srm09 committed Apr 21, 2016
commit c83be39af50107cd11ebe2852880b7dc08402dfe
@@ -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) => {
let result = self.store_decode_image(url, image_vector);
}
};

None
@@ -588,6 +591,19 @@ impl ImageCache {
}
}
}

fn store_decode_image(&mut self,
ref_url: Url,
loaded_bytes: Vec<u8>) {
let (cache_result, load_key, mut pending_load) = self.pending_loads.get_cached(Arc::new(ref_url.clone()));

let progress_sender = self.progress_sender.clone();
let action: ResponseAction = ResponseAction::DataAvailable(loaded_bytes);
progress_sender.send(ResourceLoadInfo {
action: action,
key: load_key,
});
}
}

/// Create a new image cache.
@@ -92,6 +92,10 @@ pub enum ImageCacheCommand {
/// state and but its metadata has been made available, it will be sent as a response.
GetImageOrMetadataIfAvailable(Url, UsePlaceholder, IpcSender<Result<ImageOrMetadataAvailable, ImageState>>),

/// Instruct the cache to store this data as a newly-complete network request and continue
/// decoding the result into pixel data
StoreDecodeImage(Url, Vec<u8>),

/// Clients must wait for a response before shutting down the ResourceThread
Exit(IpcSender<()>),
}
@@ -157,6 +161,15 @@ impl ImageCacheThread {
receiver.recv().unwrap()
}

/// Get the vector of bytess ....
/// See ImageCacheCommand::StoreDecodeImage.
pub fn find_store_decode_image(&self,
url: Url,
image_data: Vec<u8>) {
let msg = ImageCacheCommand::StoreDecodeImage(url, image_data);
self.chan.send(msg).unwrap();
}

/// Shutdown the image cache thread.
pub fn exit(&self) {
let (response_chan, response_port) = ipc::channel().unwrap();
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.