зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #10725 - A few minor `net` component cleanups (from frewsxcv:net-cleanup); r=KiChjang
Source-Repo: https://github.com/servo/servo Source-Revision: bebc1dc859192d7fdcfc53e550cbf51343f4375a
This commit is contained in:
Родитель
4781925f69
Коммит
939c774f41
|
@ -66,7 +66,7 @@ impl Cookie {
|
||||||
|
|
||||||
// Step 7
|
// Step 7
|
||||||
let mut path = cookie.path.unwrap_or("".to_owned());
|
let mut path = cookie.path.unwrap_or("".to_owned());
|
||||||
if path.is_empty() || path.as_bytes()[0] != b'/' {
|
if path.chars().next() != Some('/') {
|
||||||
let url_path = request.serialize_path();
|
let url_path = request.serialize_path();
|
||||||
let url_path = url_path.as_ref().map(|path| &**path);
|
let url_path = url_path.as_ref().map(|path| &**path);
|
||||||
path = Cookie::default_path(url_path.unwrap_or("")).to_owned();
|
path = Cookie::default_path(url_path.unwrap_or("")).to_owned();
|
||||||
|
@ -96,7 +96,7 @@ impl Cookie {
|
||||||
// http://tools.ietf.org/html/rfc6265#section-5.1.4
|
// http://tools.ietf.org/html/rfc6265#section-5.1.4
|
||||||
pub fn default_path(request_path: &str) -> &str {
|
pub fn default_path(request_path: &str) -> &str {
|
||||||
// Step 2
|
// Step 2
|
||||||
if request_path.is_empty() || !request_path.starts_with("/") {
|
if request_path.chars().next() != Some('/') {
|
||||||
return "/";
|
return "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,17 +44,14 @@ fn read_block(reader: &mut File) -> Result<ReadStatus, String> {
|
||||||
|
|
||||||
fn read_all(reader: &mut File, progress_chan: &ProgressSender, cancel_listener: &CancellationListener)
|
fn read_all(reader: &mut File, progress_chan: &ProgressSender, cancel_listener: &CancellationListener)
|
||||||
-> Result<LoadResult, String> {
|
-> Result<LoadResult, String> {
|
||||||
loop {
|
while !cancel_listener.is_cancelled() {
|
||||||
if cancel_listener.is_cancelled() {
|
|
||||||
let _ = progress_chan.send(Done(Err("load cancelled".to_owned())));
|
|
||||||
return Ok(LoadResult::Cancelled);
|
|
||||||
}
|
|
||||||
|
|
||||||
match try!(read_block(reader)) {
|
match try!(read_block(reader)) {
|
||||||
ReadStatus::Partial(buf) => progress_chan.send(Payload(buf)).unwrap(),
|
ReadStatus::Partial(buf) => progress_chan.send(Payload(buf)).unwrap(),
|
||||||
ReadStatus::EOF => return Ok(LoadResult::Finished),
|
ReadStatus::EOF => return Ok(LoadResult::Finished),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let _ = progress_chan.send(Done(Err("load cancelled".to_owned())));
|
||||||
|
Ok(LoadResult::Cancelled)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_progress_chan(load_data: LoadData, file_path: PathBuf,
|
fn get_progress_chan(load_data: LoadData, file_path: PathBuf,
|
||||||
|
|
|
@ -133,7 +133,7 @@ fn start_sending_opt(start_chan: LoadConsumer, metadata: Metadata) -> Result<Pro
|
||||||
|
|
||||||
/// Create a ResourceThread
|
/// Create a ResourceThread
|
||||||
pub fn new_resource_thread(user_agent: String,
|
pub fn new_resource_thread(user_agent: String,
|
||||||
devtools_chan: Option<Sender<DevtoolsControlMsg>>) -> ResourceThread {
|
devtools_chan: Option<Sender<DevtoolsControlMsg>>) -> ResourceThread {
|
||||||
let hsts_preload = HstsList::from_servo_preload();
|
let hsts_preload = HstsList::from_servo_preload();
|
||||||
let (setup_chan, setup_port) = ipc::channel().unwrap();
|
let (setup_chan, setup_port) = ipc::channel().unwrap();
|
||||||
let setup_chan_clone = setup_chan.clone();
|
let setup_chan_clone = setup_chan.clone();
|
||||||
|
@ -227,17 +227,15 @@ impl CancellationListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_cancelled(&self) -> bool {
|
pub fn is_cancelled(&self) -> bool {
|
||||||
match self.cancel_resource {
|
let resource = match self.cancel_resource {
|
||||||
Some(ref resource) => {
|
Some(ref resource) => resource,
|
||||||
match resource.cancel_receiver.try_recv() {
|
None => return false, // channel doesn't exist!
|
||||||
Ok(_) => {
|
};
|
||||||
self.cancel_status.set(true);
|
if resource.cancel_receiver.try_recv().is_ok() {
|
||||||
true
|
self.cancel_status.set(true);
|
||||||
},
|
true
|
||||||
Err(_) => self.cancel_status.get(),
|
} else {
|
||||||
}
|
self.cancel_status.get()
|
||||||
},
|
|
||||||
None => false, // channel doesn't exist!
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче