diff options
Diffstat (limited to 'components/net/file_loader.rs')
-rw-r--r-- | components/net/file_loader.rs | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/components/net/file_loader.rs b/components/net/file_loader.rs index f85b6b7dac7..2274279dda1 100644 --- a/components/net/file_loader.rs +++ b/components/net/file_loader.rs @@ -5,8 +5,9 @@ use about_loader; use mime_classifier::MIMEClassifier; use mime_guess::guess_mime_type; +use msg::constellation_msg::{PipelineId, ReferrerPolicy}; use net_traits::ProgressMsg::{Done, Payload}; -use net_traits::{LoadConsumer, LoadData, Metadata, NetworkError}; +use net_traits::{LoadConsumer, LoadData, Metadata, NetworkError, LoadOrigin, RequestSource}; use resource_thread::{CancellationListener, ProgressSender}; use resource_thread::{send_error, start_sending_sniffed_opt}; use std::borrow::ToOwned; @@ -30,6 +31,22 @@ enum LoadResult { Finished, } +struct FileLoadOrigin; +impl LoadOrigin for FileLoadOrigin { + fn referrer_url(&self) -> Option<Url> { + None + } + fn referrer_policy(&self) -> Option<ReferrerPolicy> { + None + } + fn request_source(&self) -> RequestSource { + RequestSource::None + } + fn pipeline_id(&self) -> Option<PipelineId> { + None + } +} + fn read_block(reader: &mut File) -> Result<ReadStatus, String> { let mut buf = vec![0; READ_SIZE]; match reader.read(&mut buf) { @@ -84,11 +101,12 @@ pub fn factory(load_data: LoadData, // http://doc.rust-lang.org/std/fs/struct.OpenOptions.html#method.open // but, we'll go for a "file not found!" let url = Url::parse("about:not-found").unwrap(); - let load_data_404 = LoadData::new(load_data.context, url, None, None, None); + let load_data_404 = LoadData::new(load_data.context, url, &FileLoadOrigin); about_loader::factory(load_data_404, senders, classifier, cancel_listener); return; } }; + if cancel_listener.is_cancelled() { if let Ok(progress_chan) = get_progress_chan(load_data, file_path, senders, classifier, &[]) { @@ -96,6 +114,7 @@ pub fn factory(load_data: LoadData, } return; } + match read_block(reader) { Ok(ReadStatus::Partial(buf)) => { let progress_chan = get_progress_chan(load_data, file_path, |