aboutsummaryrefslogtreecommitdiffstats
path: root/components/net/resource_thread.rs
diff options
context:
space:
mode:
authoreri <eri@inventati.org>2024-03-10 16:34:16 +0100
committerGitHub <noreply@github.com>2024-03-10 15:34:16 +0000
commit67b277c992d59dfed7d9177d4a62a1517d28a5b5 (patch)
tree951a1e41c34e05b2e72c5ae3065837a3db978624 /components/net/resource_thread.rs
parent099bb0fa194ad9a27c6e3512163eaaf42d91bbe6 (diff)
downloadservo-67b277c992d59dfed7d9177d4a62a1517d28a5b5.tar.gz
servo-67b277c992d59dfed7d9177d4a62a1517d28a5b5.zip
clippy: fix warnings in components/net (#31564)
* clippy: fix some warnings in components/net * fix: review comments * fix: tidy
Diffstat (limited to 'components/net/resource_thread.rs')
-rw-r--r--components/net/resource_thread.rs30
1 files changed, 14 insertions, 16 deletions
diff --git a/components/net/resource_thread.rs b/components/net/resource_thread.rs
index 642b158260d..ea8896df242 100644
--- a/components/net/resource_thread.rs
+++ b/components/net/resource_thread.rs
@@ -9,7 +9,6 @@ use std::collections::HashMap;
use std::fs::File;
use std::io::prelude::*;
use std::io::{self, BufReader};
-use std::ops::Deref;
use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex, RwLock};
use std::thread;
@@ -160,8 +159,8 @@ fn create_http_states(
ignore_certificate_errors: bool,
) -> (Arc<HttpState>, Arc<HttpState>) {
let mut hsts_list = HstsList::from_servo_preload();
- let mut auth_cache = AuthCache::new();
- let http_cache = HttpCache::new();
+ let mut auth_cache = AuthCache::default();
+ let http_cache = HttpCache::default();
let mut cookie_jar = CookieStorage::new(150);
if let Some(config_dir) = config_dir {
read_json_from_file(&mut auth_cache, config_dir, "auth_cache.json");
@@ -189,9 +188,9 @@ fn create_http_states(
let private_http_state = HttpState {
hsts_list: RwLock::new(HstsList::from_servo_preload()),
cookie_jar: RwLock::new(CookieStorage::new(150)),
- auth_cache: RwLock::new(AuthCache::new()),
+ auth_cache: RwLock::new(AuthCache::default()),
history_states: RwLock::new(HashMap::new()),
- http_cache: RwLock::new(HttpCache::new()),
+ http_cache: RwLock::new(HttpCache::default()),
http_cache_state: Mutex::new(HashMap::new()),
client: create_http_client(create_tls_config(
ca_certificates,
@@ -213,7 +212,7 @@ impl ResourceChannelManager {
memory_reporter: IpcReceiver<ReportsChan>,
) {
let (public_http_state, private_http_state) = create_http_states(
- self.config_dir.as_ref().map(Deref::deref),
+ self.config_dir.as_deref(),
self.ca_certificates.clone(),
self.ignore_certificate_errors,
);
@@ -426,11 +425,10 @@ pub fn write_json_to_file<T>(data: &T, config_dir: &Path, filename: &str)
where
T: Serialize,
{
- let json_encoded: String;
- match serde_json::to_string_pretty(&data) {
- Ok(d) => json_encoded = d,
+ let json_encoded: String = match serde_json::to_string_pretty(&data) {
+ Ok(d) => d,
Err(_) => return,
- }
+ };
let path = config_dir.join(filename);
let display = path.display();
@@ -451,9 +449,9 @@ pub struct AuthCacheEntry {
pub password: String,
}
-impl AuthCache {
- pub fn new() -> AuthCache {
- AuthCache {
+impl Default for AuthCache {
+ fn default() -> Self {
+ Self {
version: 1,
entries: HashMap::new(),
}
@@ -531,7 +529,7 @@ impl CoreResourceThreadPool {
.build()
.unwrap();
let state = Arc::new(Mutex::new(ThreadPoolState::new()));
- CoreResourceThreadPool { pool: pool, state }
+ CoreResourceThreadPool { pool, state }
}
/// Spawn work on the thread-pool, if still active.
@@ -613,7 +611,7 @@ impl CoreResourceManager {
let pool = CoreResourceThreadPool::new(16);
let pool_handle = Arc::new(pool);
CoreResourceManager {
- user_agent: user_agent,
+ user_agent,
devtools_sender,
sw_managers: Default::default(),
filemanager: FileManager::new(embedder_proxy, Arc::downgrade(&pool_handle)),
@@ -708,7 +706,7 @@ impl CoreResourceManager {
let response = Response::from_init(res_init, timing_type);
http_redirect_fetch(
&mut request,
- &mut CorsCache::new(),
+ &mut CorsCache::default(),
response,
true,
&mut sender,