diff --git a/components/net/fetch/methods.rs b/components/net/fetch/methods.rs index eadc3ea0597..503e93d3687 100644 --- a/components/net/fetch/methods.rs +++ b/components/net/fetch/methods.rs @@ -23,6 +23,7 @@ use net_traits::request::{Origin, ResponseTainting, Window}; use net_traits::response::{Response, ResponseBody, ResponseType}; use net_traits::ResourceAttribute; use net_traits::{FetchTaskTarget, NetworkError, ReferrerPolicy, ResourceFetchTiming}; +use servo_arc::Arc as ServoArc; use servo_url::ServoUrl; use std::borrow::Cow; use std::fs::File; @@ -52,7 +53,7 @@ pub struct FetchContext { pub devtools_chan: Option>, pub filemanager: FileManager, pub cancellation_listener: Arc>, - pub timing: Arc>, + pub timing: ServoArc>, } pub struct CancellationListener { diff --git a/components/net/resource_thread.rs b/components/net/resource_thread.rs index 6b7ac04b891..33f878f1207 100644 --- a/components/net/resource_thread.rs +++ b/components/net/resource_thread.rs @@ -36,6 +36,7 @@ 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_arc::Arc as ServoArc; use servo_url::ServoUrl; use std::borrow::{Cow, ToOwned}; use std::collections::HashMap; @@ -491,7 +492,7 @@ impl CoreResourceManager { devtools_chan: dc, filemanager: filemanager, cancellation_listener: Arc::new(Mutex::new(CancellationListener::new(cancel_chan))), - timing: Arc::new(Mutex::new(ResourceFetchTiming::new(request.timing_type()))), + timing: ServoArc::new(Mutex::new(ResourceFetchTiming::new(request.timing_type()))), }; match res_init_ { diff --git a/components/net/tests/fetch.rs b/components/net/tests/fetch.rs index b05635ee3b9..328ca734576 100644 --- a/components/net/tests/fetch.rs +++ b/components/net/tests/fetch.rs @@ -36,6 +36,7 @@ use net_traits::{ FetchTaskTarget, IncludeSubdomains, NetworkError, ReferrerPolicy, ResourceFetchTiming, ResourceTimingType, }; +use servo_arc::Arc as ServoArc; use servo_url::{ImmutableOrigin, ServoUrl}; use std::fs::File; use std::io::Read; @@ -665,7 +666,7 @@ fn test_fetch_with_hsts() { devtools_chan: None, filemanager: FileManager::new(create_embedder_proxy()), cancellation_listener: Arc::new(Mutex::new(CancellationListener::new(None))), - timing: Arc::new(Mutex::new(ResourceFetchTiming::new( + timing: ServoArc::new(Mutex::new(ResourceFetchTiming::new( ResourceTimingType::Navigation, ))), }; diff --git a/components/net/tests/main.rs b/components/net/tests/main.rs index 6a2c5ddb395..e68cc293fa6 100644 --- a/components/net/tests/main.rs +++ b/components/net/tests/main.rs @@ -38,6 +38,7 @@ use net_traits::request::Request; use net_traits::response::Response; use net_traits::{FetchTaskTarget, ResourceFetchTiming, ResourceTimingType}; use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod}; +use servo_arc::Arc as ServoArc; use servo_url::ServoUrl; use std::net::TcpListener as StdTcpListener; use std::path::PathBuf; @@ -95,7 +96,7 @@ fn new_fetch_context( devtools_chan: dc, filemanager: FileManager::new(sender), cancellation_listener: Arc::new(Mutex::new(CancellationListener::new(None))), - timing: Arc::new(Mutex::new(ResourceFetchTiming::new( + timing: ServoArc::new(Mutex::new(ResourceFetchTiming::new( ResourceTimingType::Navigation, ))), } diff --git a/components/net_traits/response.rs b/components/net_traits/response.rs index f8959163834..4ee8b37eb56 100644 --- a/components/net_traits/response.rs +++ b/components/net_traits/response.rs @@ -114,7 +114,8 @@ pub struct Response { #[ignore_malloc_size_of = "AtomicBool heap size undefined"] pub aborted: Arc, /// track network metrics - pub resource_timing: ResourceFetchTiming, + #[ignore_malloc_size_of = "Mutex heap size undefined"] + pub resource_timing: Arc>, } impl Response { @@ -137,7 +138,7 @@ impl Response { internal_response: None, return_internal: true, aborted: Arc::new(AtomicBool::new(false)), - resource_timing: resource_timing, + resource_timing: Arc::new(Mutex::new(resource_timing)), } } @@ -171,7 +172,9 @@ impl Response { internal_response: None, return_internal: true, aborted: Arc::new(AtomicBool::new(false)), - resource_timing: ResourceFetchTiming::new(ResourceTimingType::Error), + resource_timing: Arc::new(Mutex::new(ResourceFetchTiming::new( + ResourceTimingType::Error, + ))), } } @@ -217,8 +220,8 @@ impl Response { } } - pub fn get_resource_timing(&self) -> &ResourceFetchTiming { - &self.resource_timing + pub fn get_resource_timing(&self) -> Arc> { + Arc::clone(&self.resource_timing) } /// Convert to a filtered response, of type `filter_type`.