mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Rust upgrade to rustc hash b03a2755193cd756583bcf5831cf4545d75ecb8a
This commit is contained in:
parent
26045d7fcb
commit
d1b433a3b3
160 changed files with 1427 additions and 1162 deletions
|
@ -24,7 +24,7 @@ pub fn factory(mut load_data: LoadData, start_chan: Sender<LoadResponse>) {
|
|||
chan.send(Done(Ok(())));
|
||||
return
|
||||
}
|
||||
"crash" => fail!("Loading the about:crash URL."),
|
||||
"crash" => panic!("Loading the about:crash URL."),
|
||||
"failure" => {
|
||||
let mut path = resources_dir_path();
|
||||
path.push("failure.html");
|
||||
|
|
|
@ -28,7 +28,7 @@ fn load(load_data: LoadData, start_chan: Sender<LoadResponse>) {
|
|||
// Split out content type and data.
|
||||
let mut scheme_data = match url.scheme_data {
|
||||
NonRelativeSchemeData(scheme_data) => scheme_data,
|
||||
_ => fail!("Expected a non-relative scheme URL.")
|
||||
_ => panic!("Expected a non-relative scheme URL.")
|
||||
};
|
||||
match url.query {
|
||||
Some(query) => {
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
//! with CORSRequest being expanded into FetchRequest (etc)
|
||||
|
||||
use http::method::Method;
|
||||
use std::ascii::StrAsciiExt;
|
||||
use std::ascii::AsciiExt;
|
||||
use std::comm::{Sender, Receiver, channel};
|
||||
use time;
|
||||
use time::{now, Timespec};
|
||||
|
|
|
@ -126,7 +126,7 @@ impl Request {
|
|||
},
|
||||
"blob" | "data" | "file" | "ftp" => {
|
||||
// XXXManishearth handle these
|
||||
fail!("Unimplemented scheme for Fetch")
|
||||
panic!("Unimplemented scheme for Fetch")
|
||||
},
|
||||
|
||||
_ => Response::network_error()
|
||||
|
|
|
@ -7,7 +7,7 @@ use http::status::{Status, UnregisteredStatus};
|
|||
use http::status::Ok as StatusOk;
|
||||
use http::headers::HeaderEnum;
|
||||
use http::headers::response::HeaderCollection;
|
||||
use std::ascii::OwnedStrAsciiExt;
|
||||
use std::ascii::OwnedAsciiExt;
|
||||
use std::comm::Receiver;
|
||||
|
||||
/// [Response type](http://fetch.spec.whatwg.org/#concept-response-type)
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
|
||||
use resource_task::{Metadata, Payload, Done, LoadResponse, LoadData, start_sending_opt};
|
||||
|
||||
use std::collections::hashmap::HashSet;
|
||||
use log;
|
||||
use std::collections::HashSet;
|
||||
use http::client::{RequestWriter, NetworkStream};
|
||||
use http::headers::HeaderEnum;
|
||||
use std::io::Reader;
|
||||
|
@ -98,10 +99,11 @@ fn load(load_data: LoadData, start_chan: Sender<LoadResponse>) {
|
|||
|
||||
// Dump headers, but only do the iteration if info!() is enabled.
|
||||
info!("got HTTP response {:s}, headers:", response.status.to_string());
|
||||
info!("{:?}",
|
||||
if log_enabled!(log::INFO) {
|
||||
for header in response.headers.iter() {
|
||||
info!(" - {:s}: {:s}", header.header_name(), header.header_value());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if 3 == (response.status.code() / 100) {
|
||||
match response.headers.location {
|
||||
|
|
|
@ -9,7 +9,8 @@ use resource_task::{LoadData, ResourceTask};
|
|||
use servo_util::task::spawn_named;
|
||||
use servo_util::taskpool::TaskPool;
|
||||
use std::comm::{channel, Receiver, Sender};
|
||||
use std::collections::hashmap::HashMap;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::hash_map::{Occupied, Vacant};
|
||||
use std::mem::replace;
|
||||
use std::result;
|
||||
use sync::{Arc, Mutex};
|
||||
|
@ -57,7 +58,7 @@ pub enum ImageResponseMsg {
|
|||
impl PartialEq for ImageResponseMsg {
|
||||
fn eq(&self, other: &ImageResponseMsg) -> bool {
|
||||
match (self, other) {
|
||||
(&ImageReady(..), &ImageReady(..)) => fail!("unimplemented comparison"),
|
||||
(&ImageReady(..), &ImageReady(..)) => panic!("unimplemented comparison"),
|
||||
(&ImageNotReady, &ImageNotReady) => true,
|
||||
(&ImageFailed, &ImageFailed) => true,
|
||||
|
||||
|
@ -169,8 +170,6 @@ impl ImageCache {
|
|||
loop {
|
||||
let msg = self.port.recv();
|
||||
|
||||
debug!("image_cache_task: received: {:?}", msg);
|
||||
|
||||
match msg {
|
||||
Prefetch(url) => self.prefetch(url),
|
||||
StorePrefetchedImageData(url, data) => {
|
||||
|
@ -231,7 +230,7 @@ impl ImageCache {
|
|||
}
|
||||
|
||||
fn get_state(&self, url: &Url) -> ImageState {
|
||||
match self.state_map.find(url) {
|
||||
match self.state_map.get(url) {
|
||||
Some(state) => state.clone(),
|
||||
None => Init
|
||||
}
|
||||
|
@ -289,14 +288,14 @@ impl ImageCache {
|
|||
| Decoding
|
||||
| Decoded(..)
|
||||
| Failed => {
|
||||
fail!("wrong state for storing prefetched image")
|
||||
panic!("wrong state for storing prefetched image")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn decode(&mut self, url: Url) {
|
||||
match self.get_state(&url) {
|
||||
Init => fail!("decoding image before prefetch"),
|
||||
Init => panic!("decoding image before prefetch"),
|
||||
|
||||
Prefetching(DoNotDecode) => {
|
||||
// We don't have the data yet, queue up the decode
|
||||
|
@ -350,16 +349,16 @@ impl ImageCache {
|
|||
| Prefetched(..)
|
||||
| Decoded(..)
|
||||
| Failed => {
|
||||
fail!("incorrect state in store_image")
|
||||
panic!("incorrect state in store_image")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fn purge_waiters(&mut self, url: Url, f: || -> ImageResponseMsg) {
|
||||
match self.wait_map.pop(&url) {
|
||||
match self.wait_map.remove(&url) {
|
||||
Some(waiters) => {
|
||||
let mut items = waiters.lock();
|
||||
let items = waiters.lock();
|
||||
for response in items.iter() {
|
||||
response.send(f());
|
||||
}
|
||||
|
@ -370,9 +369,9 @@ impl ImageCache {
|
|||
|
||||
fn get_image(&self, url: Url, response: Sender<ImageResponseMsg>) {
|
||||
match self.get_state(&url) {
|
||||
Init => fail!("request for image before prefetch"),
|
||||
Init => panic!("request for image before prefetch"),
|
||||
Prefetching(DoDecode) => response.send(ImageNotReady),
|
||||
Prefetching(DoNotDecode) | Prefetched(..) => fail!("request for image before decode"),
|
||||
Prefetching(DoNotDecode) | Prefetched(..) => panic!("request for image before decode"),
|
||||
Decoding => response.send(ImageNotReady),
|
||||
Decoded(image) => response.send(ImageReady(image)),
|
||||
Failed => response.send(ImageFailed),
|
||||
|
@ -381,15 +380,20 @@ impl ImageCache {
|
|||
|
||||
fn wait_for_image(&mut self, url: Url, response: Sender<ImageResponseMsg>) {
|
||||
match self.get_state(&url) {
|
||||
Init => fail!("request for image before prefetch"),
|
||||
Init => panic!("request for image before prefetch"),
|
||||
|
||||
Prefetching(DoNotDecode) | Prefetched(..) => fail!("request for image before decode"),
|
||||
Prefetching(DoNotDecode) | Prefetched(..) => panic!("request for image before decode"),
|
||||
|
||||
Prefetching(DoDecode) | Decoding => {
|
||||
// We don't have this image yet
|
||||
self.wait_map.find_with_or_insert_with(url, response,
|
||||
|_, waiters, response| waiters.lock().push(response),
|
||||
|_, response| Arc::new(Mutex::new(vec!(response))));
|
||||
match self.wait_map.entry(url) {
|
||||
Occupied(mut entry) => {
|
||||
entry.get_mut().lock().push(response);
|
||||
}
|
||||
Vacant(entry) => {
|
||||
entry.set(Arc::new(Mutex::new(vec!(response))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Decoded(image) => {
|
||||
|
@ -618,7 +622,7 @@ mod tests {
|
|||
mock_resource_task.send(resource_task::Exit);
|
||||
match url_requested.try_recv() {
|
||||
Err(_) => (),
|
||||
Ok(_) => fail!(),
|
||||
Ok(_) => panic!(),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -660,7 +664,7 @@ mod tests {
|
|||
image_cache_task.send(GetImage(url, response_chan));
|
||||
match response_port.recv() {
|
||||
ImageReady(_) => (),
|
||||
_ => fail!("bleh")
|
||||
_ => panic!("bleh")
|
||||
}
|
||||
|
||||
image_cache_task.exit();
|
||||
|
@ -687,7 +691,7 @@ mod tests {
|
|||
image_cache_task.send(GetImage(url.clone(), response_chan));
|
||||
match response_port.recv() {
|
||||
ImageReady(_) => (),
|
||||
_ => fail!("bleh")
|
||||
_ => panic!("bleh")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -738,7 +742,7 @@ mod tests {
|
|||
// because it's already cached
|
||||
match image_bin_sent.try_recv() {
|
||||
Err(_) => (),
|
||||
Ok(_) => fail!(),
|
||||
Ok(_) => panic!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -787,7 +791,7 @@ mod tests {
|
|||
// because it's already cached
|
||||
match image_bin_sent.try_recv() {
|
||||
Err(_) => (),
|
||||
Ok(_) => fail!(),
|
||||
Ok(_) => panic!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -810,7 +814,7 @@ mod tests {
|
|||
image_cache_task.send(GetImage(url, response_chan));
|
||||
match response_port.recv() {
|
||||
ImageFailed => (),
|
||||
_ => fail!("bleh")
|
||||
_ => panic!("bleh")
|
||||
}
|
||||
|
||||
image_cache_task.exit();
|
||||
|
@ -836,7 +840,7 @@ mod tests {
|
|||
image_cache_task.send(GetImage(url.clone(), response_chan));
|
||||
match response_port.recv() {
|
||||
ImageFailed => (),
|
||||
_ => fail!("bleh")
|
||||
_ => panic!("bleh")
|
||||
}
|
||||
|
||||
// And ask again, we should get the same response
|
||||
|
@ -844,7 +848,7 @@ mod tests {
|
|||
image_cache_task.send(GetImage(url, response_chan));
|
||||
match response_port.recv() {
|
||||
ImageFailed => (),
|
||||
_ => fail!("bleh")
|
||||
_ => panic!("bleh")
|
||||
}
|
||||
|
||||
image_cache_task.exit();
|
||||
|
@ -872,7 +876,7 @@ mod tests {
|
|||
|
||||
match response_port.recv() {
|
||||
ImageFailed => (),
|
||||
_ => fail!("bleh")
|
||||
_ => panic!("bleh")
|
||||
}
|
||||
|
||||
image_cache_task.exit();
|
||||
|
@ -898,7 +902,7 @@ mod tests {
|
|||
image_cache_task.send(WaitForImage(url, response_chan));
|
||||
match response_port.recv() {
|
||||
ImageReady(..) => (),
|
||||
_ => fail!("bleh")
|
||||
_ => panic!("bleh")
|
||||
}
|
||||
|
||||
image_cache_task.exit();
|
||||
|
@ -924,7 +928,7 @@ mod tests {
|
|||
|
||||
match response_port.recv() {
|
||||
ImageReady(..) => (),
|
||||
_ => fail!("bleh")
|
||||
_ => panic!("bleh")
|
||||
}
|
||||
|
||||
image_cache_task.exit();
|
||||
|
@ -950,7 +954,7 @@ mod tests {
|
|||
|
||||
match response_port.recv() {
|
||||
ImageFailed => (),
|
||||
_ => fail!("bleh")
|
||||
_ => panic!("bleh")
|
||||
}
|
||||
|
||||
image_cache_task.exit();
|
||||
|
@ -971,7 +975,7 @@ mod tests {
|
|||
image_cache_task.send(GetImage(url, response_chan));
|
||||
match response_port.recv() {
|
||||
ImageReady(_) => (),
|
||||
_ => fail!("bleh")
|
||||
_ => panic!("bleh")
|
||||
}
|
||||
|
||||
image_cache_task.exit();
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
|
||||
#![feature(default_type_params, globs, phase)]
|
||||
|
||||
#![deny(unused_imports, unused_variable)]
|
||||
#![deny(unused_imports)]
|
||||
#![deny(unused_variables)]
|
||||
|
||||
extern crate debug;
|
||||
extern crate collections;
|
||||
extern crate geom;
|
||||
extern crate http;
|
||||
|
|
|
@ -12,7 +12,8 @@ use image_cache_task::{Decode, GetImage, ImageCacheTask, ImageFailed, ImageNotRe
|
|||
use image_cache_task::{ImageResponseMsg, Prefetch, WaitForImage};
|
||||
|
||||
use std::comm::{Receiver, channel};
|
||||
use std::collections::hashmap::HashMap;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::hash_map::{Occupied, Vacant};
|
||||
use servo_util::task::spawn_named;
|
||||
use url::Url;
|
||||
|
||||
|
@ -153,15 +154,15 @@ impl<NodeAddress: Send> LocalImageCache<NodeAddress> {
|
|||
}
|
||||
|
||||
fn get_state<'a>(&'a mut self, url: &Url) -> &'a mut ImageState {
|
||||
let state = self.state_map.find_or_insert_with(url.clone(), |_| {
|
||||
let new_state = ImageState {
|
||||
prefetched: false,
|
||||
decoded: false,
|
||||
last_request_round: 0,
|
||||
last_response: ImageNotReady
|
||||
};
|
||||
new_state
|
||||
});
|
||||
state
|
||||
match self.state_map.entry((*url).clone()) {
|
||||
Occupied(entry) => entry.into_mut(),
|
||||
Vacant(entry) =>
|
||||
entry.set(ImageState {
|
||||
prefetched: false,
|
||||
decoded: false,
|
||||
last_request_round: 0,
|
||||
last_response: ImageNotReady,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,9 +90,9 @@ impl Metadata {
|
|||
pub fn set_content_type(&mut self, content_type: &Option<MediaType>) {
|
||||
match *content_type {
|
||||
None => (),
|
||||
Some(MediaType { type_: ref type_,
|
||||
subtype: ref subtype,
|
||||
parameters: ref parameters }) => {
|
||||
Some(MediaType { ref type_,
|
||||
ref subtype,
|
||||
ref parameters }) => {
|
||||
self.content_type = Some((type_.clone(), subtype.clone()));
|
||||
for &(ref k, ref v) in parameters.iter() {
|
||||
if "charset" == k.as_slice() {
|
||||
|
@ -266,7 +266,7 @@ fn test_bad_scheme() {
|
|||
let response = start.recv();
|
||||
match response.progress_port.recv() {
|
||||
Done(result) => { assert!(result.is_err()) }
|
||||
_ => fail!("bleh")
|
||||
_ => panic!("bleh")
|
||||
}
|
||||
resource_task.send(Exit);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue