Skip to content

Commit

Permalink
Remove-ResponseAction
Browse files Browse the repository at this point in the history
Remove redundant code
  • Loading branch information
yysung1123 committed Dec 14, 2016
1 parent cd1d5f1 commit 55dddc8
Showing 1 changed file with 9 additions and 29 deletions.
38 changes: 9 additions & 29 deletions components/net/image_cache_thread.rs
Expand Up @@ -225,17 +225,8 @@ impl ImageListener {
}
}

/// A legacy type that's mostly redundant with FetchResponseMsg.
// FIXME(#13717): remove this type.
#[derive(Deserialize, Serialize)]
enum ResponseAction {
HeadersAvailable(Result<Metadata, NetworkError>),
DataAvailable(Vec<u8>),
ResponseComplete(Result<(), NetworkError>)
}

struct ResourceLoadInfo {
action: ResponseAction,
action: FetchResponseMsg,
key: LoadKey,
}

Expand Down Expand Up @@ -417,8 +408,10 @@ impl ImageCache {
// Handle progress messages from the resource thread
fn handle_progress(&mut self, msg: ResourceLoadInfo) {
match (msg.action, msg.key) {
(ResponseAction::HeadersAvailable(_), _) => {}
(ResponseAction::DataAvailable(data), _) => {
(FetchResponseMsg::ProcessRequestBody, _) |
(FetchResponseMsg::ProcessRequestEOF, _) => return,
(FetchResponseMsg::ProcessResponse(_), _) => {}
(FetchResponseMsg::ProcessResponseChunk(data), _) => {
let pending_load = self.pending_loads.get_by_key_mut(&msg.key).unwrap();
pending_load.bytes.extend_from_slice(&data);
//jmr0 TODO: possibly move to another task?
Expand All @@ -434,7 +427,7 @@ impl ImageCache {
}
}
}
(ResponseAction::ResponseComplete(result), key) => {
(FetchResponseMsg::ProcessResponseEOF(result), key) => {
match result {
Ok(()) => {
let pending_load = self.pending_loads.get_by_key_mut(&msg.key).unwrap();
Expand Down Expand Up @@ -550,20 +543,7 @@ impl ImageCache {
let action = match action {
FetchResponseMsg::ProcessRequestBody |
FetchResponseMsg::ProcessRequestEOF => return,
FetchResponseMsg::ProcessResponse(meta_result) => {
ResponseAction::HeadersAvailable(meta_result.map(|m| {
match m {
FetchMetadata::Unfiltered(m) => m,
FetchMetadata::Filtered { unsafe_, .. } => unsafe_
}
}))
}
FetchResponseMsg::ProcessResponseChunk(new_bytes) => {
ResponseAction::DataAvailable(new_bytes)
}
FetchResponseMsg::ProcessResponseEOF(response) => {
ResponseAction::ResponseComplete(response)
}
a => a
};
progress_sender.send(ResourceLoadInfo {
action: action,
Expand Down Expand Up @@ -630,12 +610,12 @@ impl ImageCache {
loaded_bytes: Vec<u8>) {
let (cache_result, load_key, _) = self.pending_loads.get_cached(ref_url.clone());
assert!(cache_result == CacheResult::Miss);
let action = ResponseAction::DataAvailable(loaded_bytes);
let action = FetchResponseMsg::ProcessResponseChunk(loaded_bytes);
let _ = self.progress_sender.send(ResourceLoadInfo {
action: action,
key: load_key,
});
let action = ResponseAction::ResponseComplete(Ok(()));
let action = FetchResponseMsg::ProcessResponseEOF(Ok(()));
let _ = self.progress_sender.send(ResourceLoadInfo {
action: action,
key: load_key,
Expand Down

0 comments on commit 55dddc8

Please sign in to comment.