mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Net: removed opts::get() usage
This commit is contained in:
parent
7a5ce048d2
commit
9034fb64b7
4 changed files with 33 additions and 10 deletions
|
@ -34,7 +34,6 @@ use profile_traits::mem::ProfilerChan as MemProfilerChan;
|
||||||
use profile_traits::mem::{Report, ReportKind, ReportsChan};
|
use profile_traits::mem::{Report, ReportKind, ReportsChan};
|
||||||
use profile_traits::time::ProfilerChan;
|
use profile_traits::time::ProfilerChan;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use servo_config::opts;
|
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
use std::borrow::{Cow, ToOwned};
|
use std::borrow::{Cow, ToOwned};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
@ -54,6 +53,7 @@ pub fn new_resource_threads(
|
||||||
mem_profiler_chan: MemProfilerChan,
|
mem_profiler_chan: MemProfilerChan,
|
||||||
embedder_proxy: EmbedderProxy,
|
embedder_proxy: EmbedderProxy,
|
||||||
config_dir: Option<PathBuf>,
|
config_dir: Option<PathBuf>,
|
||||||
|
certificate_path: Option<String>,
|
||||||
) -> (ResourceThreads, ResourceThreads) {
|
) -> (ResourceThreads, ResourceThreads) {
|
||||||
let (public_core, private_core) = new_core_resource_thread(
|
let (public_core, private_core) = new_core_resource_thread(
|
||||||
user_agent,
|
user_agent,
|
||||||
|
@ -62,6 +62,7 @@ pub fn new_resource_threads(
|
||||||
mem_profiler_chan,
|
mem_profiler_chan,
|
||||||
embedder_proxy,
|
embedder_proxy,
|
||||||
config_dir.clone(),
|
config_dir.clone(),
|
||||||
|
certificate_path,
|
||||||
);
|
);
|
||||||
let storage: IpcSender<StorageThreadMsg> = StorageThreadFactory::new(config_dir);
|
let storage: IpcSender<StorageThreadMsg> = StorageThreadFactory::new(config_dir);
|
||||||
(
|
(
|
||||||
|
@ -78,6 +79,7 @@ pub fn new_core_resource_thread(
|
||||||
mem_profiler_chan: MemProfilerChan,
|
mem_profiler_chan: MemProfilerChan,
|
||||||
embedder_proxy: EmbedderProxy,
|
embedder_proxy: EmbedderProxy,
|
||||||
config_dir: Option<PathBuf>,
|
config_dir: Option<PathBuf>,
|
||||||
|
certificate_path: Option<String>,
|
||||||
) -> (CoreResourceThread, CoreResourceThread) {
|
) -> (CoreResourceThread, CoreResourceThread) {
|
||||||
let (public_setup_chan, public_setup_port) = ipc::channel().unwrap();
|
let (public_setup_chan, public_setup_port) = ipc::channel().unwrap();
|
||||||
let (private_setup_chan, private_setup_port) = ipc::channel().unwrap();
|
let (private_setup_chan, private_setup_port) = ipc::channel().unwrap();
|
||||||
|
@ -91,11 +93,13 @@ pub fn new_core_resource_thread(
|
||||||
devtools_chan,
|
devtools_chan,
|
||||||
time_profiler_chan,
|
time_profiler_chan,
|
||||||
embedder_proxy,
|
embedder_proxy,
|
||||||
|
certificate_path.clone(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut channel_manager = ResourceChannelManager {
|
let mut channel_manager = ResourceChannelManager {
|
||||||
resource_manager: resource_manager,
|
resource_manager,
|
||||||
config_dir: config_dir,
|
config_dir,
|
||||||
|
certificate_path,
|
||||||
};
|
};
|
||||||
|
|
||||||
mem_profiler_chan.run_with_memory_reporting(
|
mem_profiler_chan.run_with_memory_reporting(
|
||||||
|
@ -112,9 +116,13 @@ pub fn new_core_resource_thread(
|
||||||
struct ResourceChannelManager {
|
struct ResourceChannelManager {
|
||||||
resource_manager: CoreResourceManager,
|
resource_manager: CoreResourceManager,
|
||||||
config_dir: Option<PathBuf>,
|
config_dir: Option<PathBuf>,
|
||||||
|
certificate_path: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_http_states(config_dir: Option<&Path>) -> (Arc<HttpState>, Arc<HttpState>) {
|
fn create_http_states(
|
||||||
|
config_dir: Option<&Path>,
|
||||||
|
certificate_path: Option<String>,
|
||||||
|
) -> (Arc<HttpState>, Arc<HttpState>) {
|
||||||
let mut hsts_list = HstsList::from_servo_preload();
|
let mut hsts_list = HstsList::from_servo_preload();
|
||||||
let mut auth_cache = AuthCache::new();
|
let mut auth_cache = AuthCache::new();
|
||||||
let http_cache = HttpCache::new();
|
let http_cache = HttpCache::new();
|
||||||
|
@ -125,7 +133,7 @@ fn create_http_states(config_dir: Option<&Path>) -> (Arc<HttpState>, Arc<HttpSta
|
||||||
read_json_from_file(&mut cookie_jar, config_dir, "cookie_jar.json");
|
read_json_from_file(&mut cookie_jar, config_dir, "cookie_jar.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
let certs = match opts::get().certificate_path {
|
let certs = match certificate_path {
|
||||||
Some(ref path) => fs::read_to_string(path).expect("Couldn't not find certificate file"),
|
Some(ref path) => fs::read_to_string(path).expect("Couldn't not find certificate file"),
|
||||||
None => resources::read_string(Resource::SSLCertificates),
|
None => resources::read_string(Resource::SSLCertificates),
|
||||||
};
|
};
|
||||||
|
@ -154,8 +162,10 @@ impl ResourceChannelManager {
|
||||||
private_receiver: IpcReceiver<CoreResourceMsg>,
|
private_receiver: IpcReceiver<CoreResourceMsg>,
|
||||||
memory_reporter: IpcReceiver<ReportsChan>,
|
memory_reporter: IpcReceiver<ReportsChan>,
|
||||||
) {
|
) {
|
||||||
let (public_http_state, private_http_state) =
|
let (public_http_state, private_http_state) = create_http_states(
|
||||||
create_http_states(self.config_dir.as_ref().map(Deref::deref));
|
self.config_dir.as_ref().map(Deref::deref),
|
||||||
|
self.certificate_path.clone(),
|
||||||
|
);
|
||||||
|
|
||||||
let mut rx_set = IpcReceiverSet::new().unwrap();
|
let mut rx_set = IpcReceiverSet::new().unwrap();
|
||||||
let private_id = rx_set.add(private_receiver).unwrap();
|
let private_id = rx_set.add(private_receiver).unwrap();
|
||||||
|
@ -407,6 +417,7 @@ pub struct CoreResourceManager {
|
||||||
swmanager_chan: Option<IpcSender<CustomResponseMediator>>,
|
swmanager_chan: Option<IpcSender<CustomResponseMediator>>,
|
||||||
filemanager: FileManager,
|
filemanager: FileManager,
|
||||||
fetch_pool: rayon::ThreadPool,
|
fetch_pool: rayon::ThreadPool,
|
||||||
|
certificate_path: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CoreResourceManager {
|
impl CoreResourceManager {
|
||||||
|
@ -415,6 +426,7 @@ impl CoreResourceManager {
|
||||||
devtools_channel: Option<Sender<DevtoolsControlMsg>>,
|
devtools_channel: Option<Sender<DevtoolsControlMsg>>,
|
||||||
_profiler_chan: ProfilerChan,
|
_profiler_chan: ProfilerChan,
|
||||||
embedder_proxy: EmbedderProxy,
|
embedder_proxy: EmbedderProxy,
|
||||||
|
certificate_path: Option<String>,
|
||||||
) -> CoreResourceManager {
|
) -> CoreResourceManager {
|
||||||
let pool = rayon::ThreadPoolBuilder::new()
|
let pool = rayon::ThreadPoolBuilder::new()
|
||||||
.num_threads(16)
|
.num_threads(16)
|
||||||
|
@ -426,6 +438,7 @@ impl CoreResourceManager {
|
||||||
swmanager_chan: None,
|
swmanager_chan: None,
|
||||||
filemanager: FileManager::new(embedder_proxy),
|
filemanager: FileManager::new(embedder_proxy),
|
||||||
fetch_pool: pool,
|
fetch_pool: pool,
|
||||||
|
certificate_path,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,6 +513,12 @@ impl CoreResourceManager {
|
||||||
action_receiver: IpcReceiver<WebSocketDomAction>,
|
action_receiver: IpcReceiver<WebSocketDomAction>,
|
||||||
http_state: &Arc<HttpState>,
|
http_state: &Arc<HttpState>,
|
||||||
) {
|
) {
|
||||||
websocket_loader::init(request, event_sender, action_receiver, http_state.clone());
|
websocket_loader::init(
|
||||||
|
request,
|
||||||
|
event_sender,
|
||||||
|
action_receiver,
|
||||||
|
http_state.clone(),
|
||||||
|
self.certificate_path.clone(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ fn test_exit() {
|
||||||
MemProfilerChan(mtx),
|
MemProfilerChan(mtx),
|
||||||
create_embedder_proxy(),
|
create_embedder_proxy(),
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
);
|
);
|
||||||
resource_thread.send(CoreResourceMsg::Exit(sender)).unwrap();
|
resource_thread.send(CoreResourceMsg::Exit(sender)).unwrap();
|
||||||
receiver.recv().unwrap();
|
receiver.recv().unwrap();
|
||||||
|
|
|
@ -16,7 +16,6 @@ use net_traits::request::{RequestBuilder, RequestMode};
|
||||||
use net_traits::{CookieSource, MessageData};
|
use net_traits::{CookieSource, MessageData};
|
||||||
use net_traits::{WebSocketDomAction, WebSocketNetworkEvent};
|
use net_traits::{WebSocketDomAction, WebSocketNetworkEvent};
|
||||||
use openssl::ssl::SslStream;
|
use openssl::ssl::SslStream;
|
||||||
use servo_config::opts;
|
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
|
@ -40,6 +39,7 @@ struct Client<'a> {
|
||||||
resource_url: &'a ServoUrl,
|
resource_url: &'a ServoUrl,
|
||||||
event_sender: &'a IpcSender<WebSocketNetworkEvent>,
|
event_sender: &'a IpcSender<WebSocketNetworkEvent>,
|
||||||
protocol_in_use: Option<String>,
|
protocol_in_use: Option<String>,
|
||||||
|
certificate_path: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Factory for Client<'a> {
|
impl<'a> Factory for Client<'a> {
|
||||||
|
@ -153,7 +153,7 @@ impl<'a> Handler for Client<'a> {
|
||||||
stream: TcpStream,
|
stream: TcpStream,
|
||||||
url: &Url,
|
url: &Url,
|
||||||
) -> WebSocketResult<SslStream<TcpStream>> {
|
) -> WebSocketResult<SslStream<TcpStream>> {
|
||||||
let certs = match opts::get().certificate_path {
|
let certs = match self.certificate_path {
|
||||||
Some(ref path) => fs::read_to_string(path).expect("Couldn't not find certificate file"),
|
Some(ref path) => fs::read_to_string(path).expect("Couldn't not find certificate file"),
|
||||||
None => resources::read_string(Resource::SSLCertificates),
|
None => resources::read_string(Resource::SSLCertificates),
|
||||||
};
|
};
|
||||||
|
@ -178,6 +178,7 @@ pub fn init(
|
||||||
resource_event_sender: IpcSender<WebSocketNetworkEvent>,
|
resource_event_sender: IpcSender<WebSocketNetworkEvent>,
|
||||||
dom_action_receiver: IpcReceiver<WebSocketDomAction>,
|
dom_action_receiver: IpcReceiver<WebSocketDomAction>,
|
||||||
http_state: Arc<HttpState>,
|
http_state: Arc<HttpState>,
|
||||||
|
certificate_path: Option<String>,
|
||||||
) {
|
) {
|
||||||
thread::Builder::new()
|
thread::Builder::new()
|
||||||
.name(format!("WebSocket connection to {}", req_builder.url))
|
.name(format!("WebSocket connection to {}", req_builder.url))
|
||||||
|
@ -229,6 +230,7 @@ pub fn init(
|
||||||
resource_url: &req_builder.url,
|
resource_url: &req_builder.url,
|
||||||
event_sender: &resource_event_sender,
|
event_sender: &resource_event_sender,
|
||||||
protocol_in_use: None,
|
protocol_in_use: None,
|
||||||
|
certificate_path,
|
||||||
};
|
};
|
||||||
let mut ws = WebSocket::new(client).unwrap();
|
let mut ws = WebSocket::new(client).unwrap();
|
||||||
|
|
||||||
|
|
|
@ -630,6 +630,7 @@ fn create_constellation(
|
||||||
mem_profiler_chan.clone(),
|
mem_profiler_chan.clone(),
|
||||||
embedder_proxy.clone(),
|
embedder_proxy.clone(),
|
||||||
config_dir,
|
config_dir,
|
||||||
|
opts.certificate_path.clone(),
|
||||||
);
|
);
|
||||||
let font_cache_thread = FontCacheThread::new(
|
let font_cache_thread = FontCacheThread::new(
|
||||||
public_resource_threads.sender(),
|
public_resource_threads.sender(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue