Auto merge of #10868 - frewsxcv:loadcancelled, r=Ms2ger

Add `NetworkError::LoadCancelled` variant.

<!-- 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/10868)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-04-27 01:26:05 -07:00
commit ad77d40360
5 changed files with 7 additions and 7 deletions

View file

@ -400,4 +400,3 @@ pub enum ReferrerPolicy {
OriginWhenCrossOrigin,
UnsafeUrl,
}

View file

@ -50,7 +50,7 @@ fn read_all(reader: &mut File, progress_chan: &ProgressSender, cancel_listener:
ReadStatus::EOF => return Ok(LoadResult::Finished),
}
}
let _ = progress_chan.send(Done(Err(NetworkError::Internal("load cancelled".to_owned()))));
let _ = progress_chan.send(Done(Err(NetworkError::LoadCancelled)));
Ok(LoadResult::Cancelled)
}
@ -92,7 +92,7 @@ pub fn factory(load_data: LoadData,
if cancel_listener.is_cancelled() {
if let Ok(progress_chan) = get_progress_chan(load_data, file_path,
senders, classifier, &[]) {
let _ = progress_chan.send(Done(Err(NetworkError::Internal("load cancelled".to_owned()))));
let _ = progress_chan.send(Done(Err(NetworkError::LoadCancelled)));
}
return;
}

View file

@ -160,6 +160,7 @@ fn load_for_consumer(load_data: LoadData,
LoadErrorType::Ssl { .. } => send_error(error.url.clone(),
NetworkError::SslValidation(error.url),
start_chan),
LoadErrorType::Cancelled => send_error(error.url, NetworkError::LoadCancelled, start_chan),
_ => send_error(error.url, NetworkError::Internal(error.error.description().to_owned()), start_chan)
}
}
@ -983,7 +984,7 @@ fn send_data<R: Read>(context: LoadContext,
loop {
if cancel_listener.is_cancelled() {
let _ = progress_chan.send(Done(Err(NetworkError::Internal("load cancelled".to_owned()))));
let _ = progress_chan.send(Done(Err(NetworkError::LoadCancelled)));
return;
}

View file

@ -437,9 +437,9 @@ pub enum ConstellationMsg {
/// Network errors that have to be exported out of the loaders
#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize, HeapSizeOf)]
pub enum NetworkError {
/// Could be any of the internal errors, like unsupported scheme, load
/// cancellation, connection errors, etc.
/// Could be any of the internal errors, like unsupported scheme, connection errors, etc.
Internal(String),
LoadCancelled,
/// SSL validation error that has to be handled in the HTML parser
SslValidation(Url),
}