Replace mpsc with crossbeam/servo channel, update ipc-channel

Co-authored-by: Gregory Terzian <gterzian@users.noreply.github.com>
This commit is contained in:
Simon Sapin 2017-12-17 23:53:32 +01:00 committed by Gregory Terzian
parent b977b4994c
commit 2a996fbc8f
89 changed files with 341 additions and 377 deletions

View file

@ -23,7 +23,7 @@ hyper = "0.10"
hyper_serde = "0.8"
hyper-openssl = "0.2.2"
immeta = "0.4"
ipc-channel = "0.10"
ipc-channel = "0.11"
lazy_static = "1"
log = "0.4"
malloc_size_of = { path = "../malloc_size_of" }
@ -39,6 +39,7 @@ serde = "1.0"
serde_json = "1.0"
servo_allocator = {path = "../allocator"}
servo_arc = {path = "../servo_arc"}
servo_channel = {path = "../channel"}
servo_config = {path = "../config"}
servo_url = {path = "../url"}
threadpool = "1.0"

View file

@ -21,6 +21,7 @@ use net_traits::{FetchTaskTarget, NetworkError, ReferrerPolicy};
use net_traits::request::{CredentialsMode, Destination, Referrer, Request, RequestMode};
use net_traits::request::{ResponseTainting, Origin, Window};
use net_traits::response::{Response, ResponseBody, ResponseType};
use servo_channel::{channel, Sender, Receiver};
use servo_url::ServoUrl;
use std::borrow::Cow;
use std::fmt;
@ -30,7 +31,6 @@ use std::mem;
use std::str;
use std::sync::{Arc, Mutex};
use std::sync::atomic::Ordering;
use std::sync::mpsc::{Sender, Receiver, channel};
use std::thread;
use subresource_integrity::is_response_integrity_valid;

View file

@ -20,13 +20,13 @@ use net_traits::{Metadata, FetchMetadata};
use net_traits::request::Request;
use net_traits::response::{HttpsState, Response, ResponseBody};
use servo_arc::Arc;
use servo_channel::{Sender, channel};
use servo_config::prefs::PREFS;
use servo_url::ServoUrl;
use std::collections::HashMap;
use std::str;
use std::sync::Mutex;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::{channel, Sender};
use time;
use time::{Duration, Tm};

View file

@ -39,6 +39,7 @@ use net_traits::request::{RedirectMode, Referrer, Request, RequestMode};
use net_traits::request::{ResponseTainting, ServiceWorkersMode};
use net_traits::response::{HttpsState, Response, ResponseBody, ResponseType};
use resource_thread::AuthCache;
use servo_channel::{channel, Sender};
use servo_url::{ImmutableOrigin, ServoUrl};
use std::collections::{HashMap, HashSet};
use std::error::Error;
@ -48,7 +49,6 @@ use std::mem;
use std::ops::Deref;
use std::str::FromStr;
use std::sync::RwLock;
use std::sync::mpsc::{channel, Sender};
use std::thread;
use time;
use time::Tm;

View file

@ -33,6 +33,7 @@ extern crate profile_traits;
extern crate serde_json;
extern crate servo_allocator;
extern crate servo_arc;
extern crate servo_channel;
extern crate servo_config;
extern crate servo_url;
extern crate time;

View file

@ -32,6 +32,7 @@ use profile_traits::time::ProfilerChan;
use serde::{Deserialize, Serialize};
use serde_json;
use servo_allocator;
use servo_channel::Sender;
use servo_config::opts;
use servo_url::ServoUrl;
use std::borrow::{Cow, ToOwned};
@ -42,7 +43,6 @@ use std::io::prelude::*;
use std::ops::Deref;
use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex, RwLock};
use std::sync::mpsc::Sender;
use std::thread;
use storage_thread::StorageThreadFactory;
use websocket_loader;

View file

@ -3,7 +3,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use {DEFAULT_USER_AGENT, new_fetch_context, create_embedder_proxy, fetch, make_server};
use devtools_traits::DevtoolsControlMsg;
use devtools_traits::HttpRequest as DevtoolsHttpRequest;
use devtools_traits::HttpResponse as DevtoolsHttpResponse;
use fetch_with_context;
@ -34,13 +33,13 @@ use net_traits::NetworkError;
use net_traits::ReferrerPolicy;
use net_traits::request::{Destination, Origin, RedirectMode, Referrer, Request, RequestMode};
use net_traits::response::{CacheState, Response, ResponseBody, ResponseType};
use servo_channel::{channel, Sender};
use servo_url::{ImmutableOrigin, ServoUrl};
use std::fs::File;
use std::io::Read;
use std::path::Path;
use std::sync::{Arc, Mutex};
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::mpsc::{Sender, channel};
use time::{self, Duration};
use unicase::UniCase;
@ -774,17 +773,17 @@ fn test_fetch_redirect_updates_method() {
assert_eq!(rx.recv().unwrap(), true);
assert_eq!(rx.recv().unwrap(), true);
// make sure the test doesn't send more data than expected
assert_eq!(rx.try_recv().is_err(), true);
assert_eq!(rx.try_recv().is_none(), true);
test_fetch_redirect_updates_method_runner(tx.clone(), StatusCode::Found, Method::Post);
assert_eq!(rx.recv().unwrap(), true);
assert_eq!(rx.recv().unwrap(), true);
assert_eq!(rx.try_recv().is_err(), true);
assert_eq!(rx.try_recv().is_none(), true);
test_fetch_redirect_updates_method_runner(tx.clone(), StatusCode::SeeOther, Method::Get);
assert_eq!(rx.recv().unwrap(), true);
assert_eq!(rx.recv().unwrap(), true);
assert_eq!(rx.try_recv().is_err(), true);
assert_eq!(rx.try_recv().is_none(), true);
let extension = Method::Extension("FOO".to_owned());
@ -792,18 +791,18 @@ fn test_fetch_redirect_updates_method() {
assert_eq!(rx.recv().unwrap(), true);
// for MovedPermanently and Found, Method should only be changed if it was Post
assert_eq!(rx.recv().unwrap(), false);
assert_eq!(rx.try_recv().is_err(), true);
assert_eq!(rx.try_recv().is_none(), true);
test_fetch_redirect_updates_method_runner(tx.clone(), StatusCode::Found, extension.clone());
assert_eq!(rx.recv().unwrap(), true);
assert_eq!(rx.recv().unwrap(), false);
assert_eq!(rx.try_recv().is_err(), true);
assert_eq!(rx.try_recv().is_none(), true);
test_fetch_redirect_updates_method_runner(tx.clone(), StatusCode::SeeOther, extension.clone());
assert_eq!(rx.recv().unwrap(), true);
// for SeeOther, Method should always be changed, so this should be true
assert_eq!(rx.recv().unwrap(), true);
assert_eq!(rx.try_recv().is_err(), true);
assert_eq!(rx.try_recv().is_none(), true);
}
fn response_is_done(response: &Response) -> bool {
@ -912,7 +911,7 @@ fn test_fetch_with_devtools() {
let mut request = Request::new(url.clone(), Some(origin), Some(TEST_PIPELINE_ID));
request.referrer = Referrer::NoReferrer;
let (devtools_chan, devtools_port) = channel::<DevtoolsControlMsg>();
let (devtools_chan, devtools_port) = channel();
let _ = fetch(&mut request, Some(devtools_chan));
let _ = server.close();

View file

@ -30,13 +30,13 @@ use net_traits::{CookieSource, NetworkError};
use net_traits::request::{Request, RequestInit, RequestMode, CredentialsMode, Destination};
use net_traits::response::ResponseBody;
use new_fetch_context;
use servo_channel::{channel, Receiver};
use servo_url::{ServoUrl, ImmutableOrigin};
use std::collections::HashMap;
use std::io::{Read, Write};
use std::str::FromStr;
use std::sync::{Arc, Mutex, RwLock, mpsc};
use std::sync::{Arc, Mutex, RwLock};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::Receiver;
fn mock_origin() -> ImmutableOrigin {
ServoUrl::parse("http://servo.org").unwrap().origin()
@ -213,7 +213,7 @@ fn test_request_and_response_data_with_network_messages() {
pipeline_id: Some(TEST_PIPELINE_ID),
.. RequestInit::default()
});
let (devtools_chan, devtools_port) = mpsc::channel();
let (devtools_chan, devtools_port) = channel();
let response = fetch(&mut request, Some(devtools_chan));
assert!(response.internal_response.unwrap().status.unwrap().is_success());
@ -300,14 +300,14 @@ fn test_request_and_response_message_from_devtool_without_pipeline_id() {
pipeline_id: None,
.. RequestInit::default()
});
let (devtools_chan, devtools_port) = mpsc::channel();
let (devtools_chan, devtools_port) = channel();
let response = fetch(&mut request, Some(devtools_chan));
assert!(response.internal_response.unwrap().status.unwrap().is_success());
let _ = server.close();
// notification received from devtools
assert!(devtools_port.try_recv().is_err());
assert!(devtools_port.try_recv().is_none());
}
#[test]
@ -334,7 +334,7 @@ fn test_redirected_request_to_devtools() {
pipeline_id: Some(TEST_PIPELINE_ID),
.. RequestInit::default()
});
let (devtools_chan, devtools_port) = mpsc::channel();
let (devtools_chan, devtools_port) = channel();
fetch(&mut request, Some(devtools_chan));
let _ = pre_server.close();

View file

@ -16,6 +16,7 @@ extern crate msg;
extern crate net;
extern crate net_traits;
extern crate profile_traits;
extern crate servo_channel;
extern crate servo_config;
extern crate servo_url;
extern crate time;
@ -46,9 +47,9 @@ use net::test::HttpState;
use net_traits::FetchTaskTarget;
use net_traits::request::Request;
use net_traits::response::Response;
use servo_channel::{channel, Sender};
use servo_url::ServoUrl;
use std::sync::{Arc, Mutex};
use std::sync::mpsc::{Sender, channel};
const DEFAULT_USER_AGENT: &'static str = "Such Browser. Very Layout. Wow.";