зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #12190 - Minor MIME renaming and aliasing cleanup (from frewsxcv:mime-renaming); r=jdm
Source-Repo: https://github.com/servo/servo Source-Revision: 194fb3e199922ef0e1ce7943036800ecac5bbfe3
This commit is contained in:
Родитель
df29454b47
Коммит
1c5addfe7a
|
@ -6,7 +6,7 @@ use file_loader;
|
|||
use hyper::header::ContentType;
|
||||
use hyper::http::RawStatus;
|
||||
use hyper::mime::{Mime, SubLevel, TopLevel};
|
||||
use mime_classifier::MIMEClassifier;
|
||||
use mime_classifier::MimeClassifier;
|
||||
use net_traits::ProgressMsg::Done;
|
||||
use net_traits::response::HttpsState;
|
||||
use net_traits::{LoadConsumer, LoadData, Metadata, NetworkError};
|
||||
|
@ -24,7 +24,7 @@ fn url_from_non_relative_scheme(load_data: &mut LoadData, filename: &str) {
|
|||
|
||||
pub fn factory(mut load_data: LoadData,
|
||||
start_chan: LoadConsumer,
|
||||
classifier: Arc<MIMEClassifier>,
|
||||
classifier: Arc<MimeClassifier>,
|
||||
cancel_listener: CancellationListener) {
|
||||
let url = load_data.url.clone();
|
||||
match url.path() {
|
||||
|
|
|
@ -7,7 +7,7 @@ use hyper::header::{DispositionType, ContentDisposition, DispositionParam};
|
|||
use hyper::header::{Headers, ContentType, ContentLength, Charset};
|
||||
use hyper::http::RawStatus;
|
||||
use mime::{Mime, Attr};
|
||||
use mime_classifier::MIMEClassifier;
|
||||
use mime_classifier::MimeClassifier;
|
||||
use net_traits::ProgressMsg::Done;
|
||||
use net_traits::blob_url_store::{parse_blob_url, BlobURLStoreEntry, BlobURLStoreError};
|
||||
use net_traits::response::HttpsState;
|
||||
|
@ -22,7 +22,7 @@ use std::sync::{Arc, RwLock};
|
|||
|
||||
pub fn load(load_data: LoadData, consumer: LoadConsumer,
|
||||
blob_url_store: Arc<RwLock<BlobURLStore>>,
|
||||
classifier: Arc<MIMEClassifier>) { // XXX: Move it into net process later
|
||||
classifier: Arc<MimeClassifier>) { // XXX: Move it into net process later
|
||||
|
||||
match parse_blob_url(&load_data.url) {
|
||||
None => {
|
||||
|
@ -48,7 +48,7 @@ pub fn load(load_data: LoadData, consumer: LoadConsumer,
|
|||
|
||||
fn load_blob(load_data: &LoadData,
|
||||
start_chan: LoadConsumer,
|
||||
classifier: Arc<MIMEClassifier>,
|
||||
classifier: Arc<MimeClassifier>,
|
||||
entry: &BlobURLStoreEntry) {
|
||||
let content_type: Mime = entry.type_string.parse().unwrap_or(mime!(Text / Plain));
|
||||
let charset = content_type.get_param(Attr::Charset);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use file_loader;
|
||||
use mime_classifier::MIMEClassifier;
|
||||
use mime_classifier::MimeClassifier;
|
||||
use net_traits::{LoadConsumer, LoadData, NetworkError};
|
||||
use resource_thread::{CancellationListener, send_error};
|
||||
use std::fs::canonicalize;
|
||||
|
@ -37,7 +37,7 @@ pub fn resolve_chrome_url(url: &Url) -> Result<Url, ()> {
|
|||
|
||||
pub fn factory(mut load_data: LoadData,
|
||||
start_chan: LoadConsumer,
|
||||
classifier: Arc<MIMEClassifier>,
|
||||
classifier: Arc<MimeClassifier>,
|
||||
cancel_listener: CancellationListener) {
|
||||
let file_url = match resolve_chrome_url(&load_data.url) {
|
||||
Ok(url) => url,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use hyper::mime::{Mime, TopLevel, SubLevel, Attr, Value};
|
||||
use mime_classifier::MIMEClassifier;
|
||||
use mime_classifier::MimeClassifier;
|
||||
use net_traits::LoadConsumer;
|
||||
use net_traits::ProgressMsg::{Payload, Done};
|
||||
use net_traits::{LoadData, Metadata, NetworkError};
|
||||
|
@ -15,7 +15,7 @@ use url::{Position, Url};
|
|||
|
||||
pub fn factory(load_data: LoadData,
|
||||
senders: LoadConsumer,
|
||||
classifier: Arc<MIMEClassifier>,
|
||||
classifier: Arc<MimeClassifier>,
|
||||
cancel_listener: CancellationListener) {
|
||||
// NB: we don't spawn a new thread.
|
||||
// Hypothesis: data URLs are too small for parallel base64 etc. to be worth it.
|
||||
|
@ -72,7 +72,7 @@ pub fn decode(url: &Url) -> Result<DecodeData, DecodeError> {
|
|||
|
||||
pub fn load(load_data: LoadData,
|
||||
start_chan: LoadConsumer,
|
||||
classifier: Arc<MIMEClassifier>,
|
||||
classifier: Arc<MimeClassifier>,
|
||||
cancel_listener: CancellationListener) {
|
||||
let url = load_data.url;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use about_loader;
|
||||
use mime_classifier::MIMEClassifier;
|
||||
use mime_classifier::MimeClassifier;
|
||||
use mime_guess::guess_mime_type;
|
||||
use msg::constellation_msg::{PipelineId, ReferrerPolicy};
|
||||
use net_traits::ProgressMsg::{Done, Payload};
|
||||
|
@ -72,7 +72,7 @@ fn read_all(reader: &mut File, progress_chan: &ProgressSender, cancel_listener:
|
|||
}
|
||||
|
||||
fn get_progress_chan(load_data: LoadData, file_path: PathBuf,
|
||||
senders: LoadConsumer, classifier: Arc<MIMEClassifier>, buf: &[u8])
|
||||
senders: LoadConsumer, classifier: Arc<MimeClassifier>, buf: &[u8])
|
||||
-> Result<ProgressSender, ()> {
|
||||
let mut metadata = Metadata::default(load_data.url);
|
||||
let mime_type = guess_mime_type(file_path.as_path());
|
||||
|
@ -82,7 +82,7 @@ fn get_progress_chan(load_data: LoadData, file_path: PathBuf,
|
|||
|
||||
pub fn factory(load_data: LoadData,
|
||||
senders: LoadConsumer,
|
||||
classifier: Arc<MIMEClassifier>,
|
||||
classifier: Arc<MimeClassifier>,
|
||||
cancel_listener: CancellationListener) {
|
||||
assert!(load_data.url.scheme() == "file");
|
||||
spawn_named("file_loader".to_owned(), move || {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use blob_loader;
|
||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||
use mime_classifier::MIMEClassifier;
|
||||
use mime_classifier::MimeClassifier;
|
||||
use mime_guess::guess_mime_type_opt;
|
||||
use net_traits::blob_url_store::{BlobURLStoreEntry, BlobURLStoreError, BlobURLStoreMsg};
|
||||
use net_traits::filemanager_thread::{FileManagerThreadMsg, FileManagerResult, FilterPattern};
|
||||
|
@ -90,7 +90,7 @@ impl<UI: 'static + UIProvider> FileManagerThreadFactory<UI> for IpcSender<FileMa
|
|||
struct FileManager<UI: 'static + UIProvider> {
|
||||
receiver: IpcReceiver<FileManagerThreadMsg>,
|
||||
idmap: HashMap<Uuid, PathBuf>,
|
||||
classifier: Arc<MIMEClassifier>,
|
||||
classifier: Arc<MimeClassifier>,
|
||||
blob_url_store: Arc<RwLock<BlobURLStore>>,
|
||||
ui: &'static UI,
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ impl<UI: 'static + UIProvider> FileManager<UI> {
|
|||
FileManager {
|
||||
receiver: recv,
|
||||
idmap: HashMap::new(),
|
||||
classifier: Arc::new(MIMEClassifier::new()),
|
||||
classifier: Arc::new(MimeClassifier::new()),
|
||||
blob_url_store: Arc::new(RwLock::new(BlobURLStore::new())),
|
||||
ui: ui
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ use hyper::net::Fresh;
|
|||
use hyper::status::{StatusClass, StatusCode};
|
||||
use ipc_channel::ipc;
|
||||
use log;
|
||||
use mime_classifier::MIMEClassifier;
|
||||
use mime_classifier::MimeClassifier;
|
||||
use msg::constellation_msg::{PipelineId, ReferrerPolicy};
|
||||
use net_traits::ProgressMsg::{Done, Payload};
|
||||
use net_traits::hosts::replace_hosts;
|
||||
|
@ -62,7 +62,7 @@ pub fn factory(user_agent: String,
|
|||
connector: Arc<Pool<Connector>>)
|
||||
-> Box<FnBox(LoadData,
|
||||
LoadConsumer,
|
||||
Arc<MIMEClassifier>,
|
||||
Arc<MimeClassifier>,
|
||||
CancellationListener) + Send> {
|
||||
box move |load_data: LoadData, senders, classifier, cancel_listener| {
|
||||
spawn_named(format!("http_loader for {}", load_data.url), move || {
|
||||
|
@ -127,7 +127,7 @@ fn precise_time_ms() -> u64 {
|
|||
|
||||
fn load_for_consumer(load_data: LoadData,
|
||||
start_chan: LoadConsumer,
|
||||
classifier: Arc<MIMEClassifier>,
|
||||
classifier: Arc<MimeClassifier>,
|
||||
connector: Arc<Pool<Connector>>,
|
||||
http_state: HttpState,
|
||||
devtools_chan: Option<Sender<DevtoolsControlMsg>>,
|
||||
|
@ -1093,7 +1093,7 @@ fn send_data<R: Read>(context: LoadContext,
|
|||
reader: &mut R,
|
||||
start_chan: LoadConsumer,
|
||||
metadata: Metadata,
|
||||
classifier: Arc<MIMEClassifier>,
|
||||
classifier: Arc<MimeClassifier>,
|
||||
cancel_listener: &CancellationListener) {
|
||||
let (progress_chan, mut chunk) = {
|
||||
let buf = match read_block(reader) {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use net_traits::LoadContext;
|
||||
use std::borrow::ToOwned;
|
||||
|
||||
pub struct MIMEClassifier {
|
||||
pub struct MimeClassifier {
|
||||
image_classifier: GroupedClassifier,
|
||||
audio_video_classifier: GroupedClassifier,
|
||||
scriptable_classifier: GroupedClassifier,
|
||||
|
@ -48,14 +48,16 @@ pub enum NoSniffFlag {
|
|||
OFF
|
||||
}
|
||||
|
||||
impl MIMEClassifier {
|
||||
pub type MimeType = (String, String);
|
||||
|
||||
impl MimeClassifier {
|
||||
//Performs MIME Type Sniffing Algorithm (sections 7 and 8)
|
||||
pub fn classify(&self,
|
||||
context: LoadContext,
|
||||
no_sniff_flag: NoSniffFlag,
|
||||
apache_bug_flag: ApacheBugFlag,
|
||||
supplied_type: &Option<(String, String)>,
|
||||
data: &[u8]) -> (String, String) {
|
||||
supplied_type: &Option<MimeType>,
|
||||
data: &[u8]) -> MimeType {
|
||||
let supplied_type_or_octet_stream = supplied_type.clone()
|
||||
.unwrap_or(("application".to_owned(),
|
||||
"octet-stream".to_owned()));
|
||||
|
@ -64,14 +66,14 @@ impl MIMEClassifier {
|
|||
None => self.sniff_unknown_type(no_sniff_flag, data),
|
||||
Some(ref supplied_type) => {
|
||||
let &(ref media_type, ref media_subtype) = supplied_type;
|
||||
if MIMEClassifier::is_explicit_unknown(media_type, media_subtype) {
|
||||
if MimeClassifier::is_explicit_unknown(media_type, media_subtype) {
|
||||
self.sniff_unknown_type(no_sniff_flag, data)
|
||||
} else {
|
||||
match no_sniff_flag {
|
||||
NoSniffFlag::ON => supplied_type.clone(),
|
||||
NoSniffFlag::OFF => match apache_bug_flag {
|
||||
ApacheBugFlag::ON => self.sniff_text_or_data(data),
|
||||
ApacheBugFlag::OFF => match MIMEClassifier::get_media_type(media_type,
|
||||
ApacheBugFlag::OFF => match MimeClassifier::get_media_type(media_type,
|
||||
media_subtype) {
|
||||
Some(MediaType::Html) => self.feeds_classifier.classify(data),
|
||||
Some(MediaType::Image) => self.image_classifier.classify(data),
|
||||
|
@ -85,14 +87,14 @@ impl MIMEClassifier {
|
|||
},
|
||||
LoadContext::Image => {
|
||||
// Section 8.2 Sniffing an image context
|
||||
match MIMEClassifier::maybe_get_media_type(supplied_type) {
|
||||
match MimeClassifier::maybe_get_media_type(supplied_type) {
|
||||
Some(MediaType::Xml) => None,
|
||||
_ => self.image_classifier.classify(data),
|
||||
}.unwrap_or(supplied_type_or_octet_stream)
|
||||
},
|
||||
LoadContext::AudioVideo => {
|
||||
// Section 8.3 Sniffing an image context
|
||||
match MIMEClassifier::maybe_get_media_type(supplied_type) {
|
||||
match MimeClassifier::maybe_get_media_type(supplied_type) {
|
||||
Some(MediaType::Xml) => None,
|
||||
_ => self.audio_video_classifier.classify(data),
|
||||
}.unwrap_or(supplied_type_or_octet_stream)
|
||||
|
@ -129,7 +131,7 @@ impl MIMEClassifier {
|
|||
},
|
||||
LoadContext::Font => {
|
||||
// 8.7 Sniffing in a font context
|
||||
match MIMEClassifier::maybe_get_media_type(supplied_type) {
|
||||
match MimeClassifier::maybe_get_media_type(supplied_type) {
|
||||
Some(MediaType::Xml) => None,
|
||||
_ => self.font_classifier.classify(data),
|
||||
}.unwrap_or(supplied_type_or_octet_stream)
|
||||
|
@ -151,8 +153,8 @@ impl MIMEClassifier {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new() -> MIMEClassifier {
|
||||
MIMEClassifier {
|
||||
pub fn new() -> MimeClassifier {
|
||||
MimeClassifier {
|
||||
image_classifier: GroupedClassifier::image_classifer(),
|
||||
audio_video_classifier: GroupedClassifier::audio_video_classifier(),
|
||||
scriptable_classifier: GroupedClassifier::scriptable_classifier(),
|
||||
|
@ -177,7 +179,7 @@ impl MIMEClassifier {
|
|||
}
|
||||
|
||||
//some sort of iterator over the classifiers might be better?
|
||||
fn sniff_unknown_type(&self, no_sniff_flag: NoSniffFlag, data: &[u8]) -> (String, String) {
|
||||
fn sniff_unknown_type(&self, no_sniff_flag: NoSniffFlag, data: &[u8]) -> MimeType {
|
||||
let should_sniff_scriptable = no_sniff_flag == NoSniffFlag::OFF;
|
||||
let sniffed = if should_sniff_scriptable {
|
||||
self.scriptable_classifier.classify(data)
|
||||
|
@ -193,7 +195,7 @@ impl MIMEClassifier {
|
|||
.expect("BinaryOrPlaintextClassifier always succeeds")
|
||||
}
|
||||
|
||||
fn sniff_text_or_data(&self, data: &[u8]) -> (String, String) {
|
||||
fn sniff_text_or_data(&self, data: &[u8]) -> MimeType {
|
||||
self.binary_or_plaintext.classify(data).expect("BinaryOrPlaintextClassifier always succeeds")
|
||||
}
|
||||
|
||||
|
@ -230,33 +232,33 @@ impl MIMEClassifier {
|
|||
|
||||
fn get_media_type(media_type: &str,
|
||||
media_subtype: &str) -> Option<MediaType> {
|
||||
if MIMEClassifier::is_xml(media_type, media_subtype) {
|
||||
if MimeClassifier::is_xml(media_type, media_subtype) {
|
||||
Some(MediaType::Xml)
|
||||
} else if MIMEClassifier::is_html(media_type, media_subtype) {
|
||||
} else if MimeClassifier::is_html(media_type, media_subtype) {
|
||||
Some(MediaType::Html)
|
||||
} else if MIMEClassifier::is_image(media_type) {
|
||||
} else if MimeClassifier::is_image(media_type) {
|
||||
Some(MediaType::Image)
|
||||
} else if MIMEClassifier::is_audio_video(media_type, media_subtype) {
|
||||
} else if MimeClassifier::is_audio_video(media_type, media_subtype) {
|
||||
Some(MediaType::AudioVideo)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn maybe_get_media_type(supplied_type: &Option<(String, String)>) -> Option<MediaType> {
|
||||
fn maybe_get_media_type(supplied_type: &Option<MimeType>) -> Option<MediaType> {
|
||||
supplied_type.as_ref().and_then(|&(ref media_type, ref media_subtype)| {
|
||||
MIMEClassifier::get_media_type(media_type, media_subtype)
|
||||
MimeClassifier::get_media_type(media_type, media_subtype)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_string_option(tup: Option<(&'static str, &'static str)>) -> Option<(String, String)> {
|
||||
pub fn as_string_option(tup: Option<(&'static str, &'static str)>) -> Option<MimeType> {
|
||||
tup.map(|(a, b)| (a.to_owned(), b.to_owned()))
|
||||
}
|
||||
|
||||
//Interface used for composite types
|
||||
trait MIMEChecker {
|
||||
fn classify(&self, data: &[u8]) -> Option<(String, String)>;
|
||||
fn classify(&self, data: &[u8]) -> Option<MimeType>;
|
||||
/// Validate the MIME checker configuration
|
||||
fn validate(&self) -> Result<(), String>;
|
||||
}
|
||||
|
@ -322,7 +324,7 @@ impl ByteMatcher {
|
|||
}
|
||||
|
||||
impl MIMEChecker for ByteMatcher {
|
||||
fn classify(&self, data: &[u8]) -> Option<(String, String)> {
|
||||
fn classify(&self, data: &[u8]) -> Option<MimeType> {
|
||||
self.matches(data).map(|_| {
|
||||
(self.content_type.0.to_owned(), self.content_type.1.to_owned())
|
||||
})
|
||||
|
@ -358,7 +360,7 @@ struct TagTerminatedByteMatcher {
|
|||
}
|
||||
|
||||
impl MIMEChecker for TagTerminatedByteMatcher {
|
||||
fn classify(&self, data: &[u8]) -> Option<(String, String)> {
|
||||
fn classify(&self, data: &[u8]) -> Option<MimeType> {
|
||||
self.matcher.matches(data).and_then(|j|
|
||||
if j < data.len() && (data[j] == b' ' || data[j] == b'>') {
|
||||
Some((self.matcher.content_type.0.to_owned(),
|
||||
|
@ -399,7 +401,7 @@ impl Mp4Matcher {
|
|||
|
||||
}
|
||||
impl MIMEChecker for Mp4Matcher {
|
||||
fn classify(&self, data: &[u8]) -> Option<(String, String)> {
|
||||
fn classify(&self, data: &[u8]) -> Option<MimeType> {
|
||||
if self.matches(data) {
|
||||
Some(("video".to_owned(), "mp4".to_owned()))
|
||||
} else {
|
||||
|
@ -432,7 +434,7 @@ impl BinaryOrPlaintextClassifier {
|
|||
}
|
||||
}
|
||||
impl MIMEChecker for BinaryOrPlaintextClassifier {
|
||||
fn classify(&self, data: &[u8]) -> Option<(String, String)> {
|
||||
fn classify(&self, data: &[u8]) -> Option<MimeType> {
|
||||
as_string_option(Some(self.classify_impl(data)))
|
||||
}
|
||||
|
||||
|
@ -532,7 +534,7 @@ impl GroupedClassifier {
|
|||
}
|
||||
}
|
||||
impl MIMEChecker for GroupedClassifier {
|
||||
fn classify(&self, data: &[u8]) -> Option<(String, String)> {
|
||||
fn classify(&self, data: &[u8]) -> Option<MimeType> {
|
||||
self.byte_matchers
|
||||
.iter()
|
||||
.filter_map(|matcher| matcher.classify(data))
|
||||
|
@ -643,7 +645,7 @@ impl FeedsClassifier {
|
|||
}
|
||||
|
||||
impl MIMEChecker for FeedsClassifier {
|
||||
fn classify(&self, data: &[u8]) -> Option<(String, String)> {
|
||||
fn classify(&self, data: &[u8]) -> Option<MimeType> {
|
||||
as_string_option(self.classify_impl(data))
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ use hyper::client::pool::Pool;
|
|||
use hyper::header::{ContentType, Header, SetCookie};
|
||||
use hyper::mime::{Mime, SubLevel, TopLevel};
|
||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender, IpcReceiverSet};
|
||||
use mime_classifier::{ApacheBugFlag, MIMEClassifier, NoSniffFlag};
|
||||
use mime_classifier::{ApacheBugFlag, MimeClassifier, NoSniffFlag};
|
||||
use net_traits::LoadContext;
|
||||
use net_traits::ProgressMsg::Done;
|
||||
use net_traits::filemanager_thread::FileManagerThreadMsg;
|
||||
|
@ -95,7 +95,7 @@ pub fn send_error(url: Url, err: NetworkError, start_chan: LoadConsumer) {
|
|||
|
||||
/// For use by loaders in responding to a Load message that allows content sniffing.
|
||||
pub fn start_sending_sniffed(start_chan: LoadConsumer, metadata: Metadata,
|
||||
classifier: Arc<MIMEClassifier>, partial_body: &[u8],
|
||||
classifier: Arc<MimeClassifier>, partial_body: &[u8],
|
||||
context: LoadContext)
|
||||
-> ProgressSender {
|
||||
start_sending_sniffed_opt(start_chan, metadata, classifier, partial_body, context).ok().unwrap()
|
||||
|
@ -103,7 +103,7 @@ pub fn start_sending_sniffed(start_chan: LoadConsumer, metadata: Metadata,
|
|||
|
||||
/// For use by loaders in responding to a Load message that allows content sniffing.
|
||||
pub fn start_sending_sniffed_opt(start_chan: LoadConsumer, mut metadata: Metadata,
|
||||
classifier: Arc<MIMEClassifier>, partial_body: &[u8],
|
||||
classifier: Arc<MimeClassifier>, partial_body: &[u8],
|
||||
context: LoadContext)
|
||||
-> Result<ProgressSender, ()> {
|
||||
if PREFS.get("network.mime.sniff").as_boolean().unwrap_or(false) {
|
||||
|
@ -459,7 +459,7 @@ pub struct AuthCache {
|
|||
|
||||
pub struct CoreResourceManager {
|
||||
user_agent: String,
|
||||
mime_classifier: Arc<MIMEClassifier>,
|
||||
mime_classifier: Arc<MimeClassifier>,
|
||||
devtools_chan: Option<Sender<DevtoolsControlMsg>>,
|
||||
profiler_chan: ProfilerChan,
|
||||
cancel_load_map: HashMap<ResourceId, Sender<()>>,
|
||||
|
@ -472,7 +472,7 @@ impl CoreResourceManager {
|
|||
profiler_chan: ProfilerChan) -> CoreResourceManager {
|
||||
CoreResourceManager {
|
||||
user_agent: user_agent,
|
||||
mime_classifier: Arc::new(MIMEClassifier::new()),
|
||||
mime_classifier: Arc::new(MimeClassifier::new()),
|
||||
devtools_chan: devtools_channel,
|
||||
profiler_chan: profiler_chan,
|
||||
cancel_load_map: HashMap::new(),
|
||||
|
@ -510,10 +510,10 @@ impl CoreResourceManager {
|
|||
id_sender: Option<IpcSender<ResourceId>>,
|
||||
resource_thread: CoreResourceThread,
|
||||
resource_grp: &ResourceGroup) {
|
||||
fn from_factory(factory: fn(LoadData, LoadConsumer, Arc<MIMEClassifier>, CancellationListener))
|
||||
fn from_factory(factory: fn(LoadData, LoadConsumer, Arc<MimeClassifier>, CancellationListener))
|
||||
-> Box<FnBox(LoadData,
|
||||
LoadConsumer,
|
||||
Arc<MIMEClassifier>,
|
||||
Arc<MimeClassifier>,
|
||||
CancellationListener) + Send> {
|
||||
box move |load_data, senders, classifier, cancel_listener| {
|
||||
factory(load_data, senders, classifier, cancel_listener)
|
||||
|
|
|
@ -36,12 +36,12 @@ fn assert_parse(url: &'static str,
|
|||
charset: Option<String>,
|
||||
data: Option<Vec<u8>>) {
|
||||
use net::data_loader::load;
|
||||
use net::mime_classifier::MIMEClassifier;
|
||||
use net::mime_classifier::MimeClassifier;
|
||||
use net::resource_thread::CancellationListener;
|
||||
use std::sync::Arc;
|
||||
|
||||
let (start_chan, start_port) = ipc::channel().unwrap();
|
||||
let classifier = Arc::new(MIMEClassifier::new());
|
||||
let classifier = Arc::new(MimeClassifier::new());
|
||||
load(LoadData::new(LoadContext::Browsing, Url::parse(url).unwrap(), &DataLoadTest),
|
||||
Channel(start_chan),
|
||||
classifier, CancellationListener::new(None));
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use net::mime_classifier::as_string_option;
|
||||
use net::mime_classifier::{Mp4Matcher, MIMEClassifier, ApacheBugFlag, NoSniffFlag};
|
||||
use net::mime_classifier::{Mp4Matcher, MimeClassifier, ApacheBugFlag, NoSniffFlag};
|
||||
use net_traits::LoadContext;
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
|
@ -52,7 +52,7 @@ fn test_sniff_mp4_matcher_long() {
|
|||
|
||||
#[test]
|
||||
fn test_validate_classifier() {
|
||||
let classifier = MIMEClassifier::new();
|
||||
let classifier = MimeClassifier::new();
|
||||
classifier.validate().expect("Validation error")
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ fn test_sniff_with_flags(filename_orig: &path::Path,
|
|||
let mut filename = PathBuf::from("parsable_mime/");
|
||||
filename.push(filename_orig);
|
||||
|
||||
let classifier = MIMEClassifier::new();
|
||||
let classifier = MimeClassifier::new();
|
||||
|
||||
let read_result = read_file(&filename);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче