Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Net: removed opts::get() usage #23520

Merged
merged 1 commit into from Jun 7, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Net: removed opts::get() usage

  • Loading branch information
oneturkmen committed Jun 7, 2019
commit 9034fb64b73040b586947d786c5f0f0f40e10431
@@ -34,7 +34,6 @@ use profile_traits::mem::ProfilerChan as MemProfilerChan;
use profile_traits::mem::{Report, ReportKind, ReportsChan};
use profile_traits::time::ProfilerChan;
use serde::{Deserialize, Serialize};
use servo_config::opts;
use servo_url::ServoUrl;
use std::borrow::{Cow, ToOwned};
use std::collections::HashMap;
@@ -54,6 +53,7 @@ pub fn new_resource_threads(
mem_profiler_chan: MemProfilerChan,
embedder_proxy: EmbedderProxy,
config_dir: Option<PathBuf>,
certificate_path: Option<String>,
) -> (ResourceThreads, ResourceThreads) {
let (public_core, private_core) = new_core_resource_thread(
user_agent,
@@ -62,6 +62,7 @@ pub fn new_resource_threads(
mem_profiler_chan,
embedder_proxy,
config_dir.clone(),
certificate_path,
);
let storage: IpcSender<StorageThreadMsg> = StorageThreadFactory::new(config_dir);
(
@@ -78,6 +79,7 @@ pub fn new_core_resource_thread(
mem_profiler_chan: MemProfilerChan,
embedder_proxy: EmbedderProxy,
config_dir: Option<PathBuf>,
certificate_path: Option<String>,
) -> (CoreResourceThread, CoreResourceThread) {
let (public_setup_chan, public_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,
time_profiler_chan,
embedder_proxy,
certificate_path.clone(),
);

let mut channel_manager = ResourceChannelManager {
resource_manager: resource_manager,
config_dir: config_dir,
resource_manager,
config_dir,
certificate_path,
};

mem_profiler_chan.run_with_memory_reporting(
@@ -112,9 +116,13 @@ pub fn new_core_resource_thread(
struct ResourceChannelManager {
resource_manager: CoreResourceManager,
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 auth_cache = AuthCache::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");
}

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"),
None => resources::read_string(Resource::SSLCertificates),
};
@@ -154,8 +162,10 @@ impl ResourceChannelManager {
private_receiver: IpcReceiver<CoreResourceMsg>,
memory_reporter: IpcReceiver<ReportsChan>,
) {
let (public_http_state, private_http_state) =
create_http_states(self.config_dir.as_ref().map(Deref::deref));
let (public_http_state, private_http_state) = create_http_states(
self.config_dir.as_ref().map(Deref::deref),
self.certificate_path.clone(),
);

let mut rx_set = IpcReceiverSet::new().unwrap();
let private_id = rx_set.add(private_receiver).unwrap();
@@ -407,6 +417,7 @@ pub struct CoreResourceManager {
swmanager_chan: Option<IpcSender<CustomResponseMediator>>,
filemanager: FileManager,
fetch_pool: rayon::ThreadPool,
certificate_path: Option<String>,
}

impl CoreResourceManager {
@@ -415,6 +426,7 @@ impl CoreResourceManager {
devtools_channel: Option<Sender<DevtoolsControlMsg>>,
_profiler_chan: ProfilerChan,
embedder_proxy: EmbedderProxy,
certificate_path: Option<String>,
) -> CoreResourceManager {
let pool = rayon::ThreadPoolBuilder::new()
.num_threads(16)
@@ -426,6 +438,7 @@ impl CoreResourceManager {
swmanager_chan: None,
filemanager: FileManager::new(embedder_proxy),
fetch_pool: pool,
certificate_path,
}
}

@@ -500,6 +513,12 @@ impl CoreResourceManager {
action_receiver: IpcReceiver<WebSocketDomAction>,
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),
create_embedder_proxy(),
None,
None,
);
resource_thread.send(CoreResourceMsg::Exit(sender)).unwrap();
receiver.recv().unwrap();
@@ -16,7 +16,6 @@ use net_traits::request::{RequestBuilder, RequestMode};
use net_traits::{CookieSource, MessageData};
use net_traits::{WebSocketDomAction, WebSocketNetworkEvent};
use openssl::ssl::SslStream;
use servo_config::opts;
use servo_url::ServoUrl;
use std::fs;
use std::sync::atomic::{AtomicBool, Ordering};
@@ -40,6 +39,7 @@ struct Client<'a> {
resource_url: &'a ServoUrl,
event_sender: &'a IpcSender<WebSocketNetworkEvent>,
protocol_in_use: Option<String>,
certificate_path: Option<String>,
}

impl<'a> Factory for Client<'a> {
@@ -153,7 +153,7 @@ impl<'a> Handler for Client<'a> {
stream: TcpStream,
url: &Url,
) -> 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"),
None => resources::read_string(Resource::SSLCertificates),
};
@@ -178,6 +178,7 @@ pub fn init(
resource_event_sender: IpcSender<WebSocketNetworkEvent>,
dom_action_receiver: IpcReceiver<WebSocketDomAction>,
http_state: Arc<HttpState>,
certificate_path: Option<String>,
) {
thread::Builder::new()
.name(format!("WebSocket connection to {}", req_builder.url))
@@ -229,6 +230,7 @@ pub fn init(
resource_url: &req_builder.url,
event_sender: &resource_event_sender,
protocol_in_use: None,
certificate_path,
};
let mut ws = WebSocket::new(client).unwrap();

@@ -630,6 +630,7 @@ fn create_constellation(
mem_profiler_chan.clone(),
embedder_proxy.clone(),
config_dir,
opts.certificate_path.clone(),
);
let font_cache_thread = FontCacheThread::new(
public_resource_threads.sender(),
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.