mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Remove UrlMap<T>, just use HashMap<rust_url::Url, T>
This commit is contained in:
parent
447655144d
commit
b902e0f8f5
3 changed files with 8 additions and 16 deletions
|
@ -5,9 +5,9 @@
|
||||||
use image::base::{Image, load_from_memory};
|
use image::base::{Image, load_from_memory};
|
||||||
use resource_task;
|
use resource_task;
|
||||||
use resource_task::{LoadData, ResourceTask};
|
use resource_task::{LoadData, ResourceTask};
|
||||||
use servo_util::url::{UrlMap, url_map};
|
|
||||||
|
|
||||||
use std::comm::{channel, Receiver, Sender};
|
use std::comm::{channel, Receiver, Sender};
|
||||||
|
use std::collections::hashmap::HashMap;
|
||||||
use std::mem::replace;
|
use std::mem::replace;
|
||||||
use std::task::spawn;
|
use std::task::spawn;
|
||||||
use std::result;
|
use std::result;
|
||||||
|
@ -88,8 +88,8 @@ impl ImageCacheTask {
|
||||||
resource_task: resource_task.clone(),
|
resource_task: resource_task.clone(),
|
||||||
port: port,
|
port: port,
|
||||||
chan: chan_clone,
|
chan: chan_clone,
|
||||||
state_map: url_map(),
|
state_map: HashMap::new(),
|
||||||
wait_map: url_map(),
|
wait_map: HashMap::new(),
|
||||||
need_exit: None
|
need_exit: None
|
||||||
};
|
};
|
||||||
cache.run();
|
cache.run();
|
||||||
|
@ -136,9 +136,9 @@ struct ImageCache {
|
||||||
/// A copy of the shared chan to give to child tasks
|
/// A copy of the shared chan to give to child tasks
|
||||||
chan: Sender<Msg>,
|
chan: Sender<Msg>,
|
||||||
/// The state of processsing an image for a URL
|
/// The state of processsing an image for a URL
|
||||||
state_map: UrlMap<ImageState>,
|
state_map: HashMap<Url, ImageState>,
|
||||||
/// List of clients waiting on a WaitForImage response
|
/// List of clients waiting on a WaitForImage response
|
||||||
wait_map: UrlMap<Arc<Mutex<Vec<Sender<ImageResponseMsg>>>>>,
|
wait_map: HashMap<Url, Arc<Mutex<Vec<Sender<ImageResponseMsg>>>>>,
|
||||||
need_exit: Option<Sender<()>>,
|
need_exit: Option<Sender<()>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ use image_cache_task::{Decode, GetImage, ImageCacheTask, ImageFailed, ImageNotRe
|
||||||
use image_cache_task::{ImageResponseMsg, Prefetch, WaitForImage};
|
use image_cache_task::{ImageResponseMsg, Prefetch, WaitForImage};
|
||||||
|
|
||||||
use std::comm::{Receiver, channel};
|
use std::comm::{Receiver, channel};
|
||||||
use servo_util::url::{UrlMap, url_map};
|
use std::collections::hashmap::HashMap;
|
||||||
use servo_util::task::spawn_named;
|
use servo_util::task::spawn_named;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ pub struct LocalImageCache {
|
||||||
image_cache_task: ImageCacheTask,
|
image_cache_task: ImageCacheTask,
|
||||||
round_number: uint,
|
round_number: uint,
|
||||||
on_image_available: Option<Box<ImageResponder+Send>>,
|
on_image_available: Option<Box<ImageResponder+Send>>,
|
||||||
state_map: UrlMap<ImageState>
|
state_map: HashMap<Url, ImageState>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LocalImageCache {
|
impl LocalImageCache {
|
||||||
|
@ -33,7 +33,7 @@ impl LocalImageCache {
|
||||||
image_cache_task: image_cache_task,
|
image_cache_task: image_cache_task,
|
||||||
round_number: 1,
|
round_number: 1,
|
||||||
on_image_available: None,
|
on_image_available: None,
|
||||||
state_map: url_map()
|
state_map: HashMap::new()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::collections::hashmap::HashMap;
|
|
||||||
use rust_url;
|
use rust_url;
|
||||||
use rust_url::{Url, UrlParser};
|
use rust_url::{Url, UrlParser};
|
||||||
|
|
||||||
|
@ -31,13 +30,6 @@ pub fn parse_url(str_url: &str, base_url: Option<rust_url::Url>) -> rust_url::Ur
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub type UrlMap<T> = HashMap<rust_url::Url, T>;
|
|
||||||
|
|
||||||
pub fn url_map<T: Clone + 'static>() -> UrlMap<T> {
|
|
||||||
HashMap::new()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
pub fn is_image_data(uri: &str) -> bool {
|
pub fn is_image_data(uri: &str) -> bool {
|
||||||
static types: &'static [&'static str] = &["data:image/png", "data:image/gif", "data:image/jpeg"];
|
static types: &'static [&'static str] = &["data:image/png", "data:image/gif", "data:image/jpeg"];
|
||||||
types.iter().any(|&type_| uri.starts_with(type_))
|
types.iter().any(|&type_| uri.starts_with(type_))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue