aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorJaved Nissar <javed.nissar@mail.utoronto.ca>2019-09-17 18:01:40 -0400
committerJaved Nissar <javed.nissar@mail.utoronto.ca>2019-09-18 11:54:28 -0400
commit7596c36959c512f09190d5a3d412b624dcd37b73 (patch)
treeb65bdf5057ef4ecc2e3c8e9e8035635ca28816f4 /components
parentbb8166bb978cca01e06125490f8367b684776cef (diff)
downloadservo-7596c36959c512f09190d5a3d412b624dcd37b73.tar.gz
servo-7596c36959c512f09190d5a3d412b624dcd37b73.zip
Move ResourceFetchTiming into Arc
The purpose of this commit is to ensure that the Response object has access to Timing updates as previously the Response object simply stored a ResourceFetchTiming struct so updates on ResourceFetchTiming that were not explicitly done on the Response would not be passed down. The references to ServoArc are added because Response uses servo_arc::Arc rather than std::sync::Arc as is used elsewhere. So, we've switched those other places to servo_arc::Arc instead of switching Response to std::sync::Arc.
Diffstat (limited to 'components')
-rw-r--r--components/net/fetch/methods.rs3
-rw-r--r--components/net/resource_thread.rs3
-rw-r--r--components/net/tests/fetch.rs3
-rw-r--r--components/net/tests/main.rs3
-rw-r--r--components/net_traits/response.rs13
5 files changed, 16 insertions, 9 deletions
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<Sender<DevtoolsControlMsg>>,
pub filemanager: FileManager,
pub cancellation_listener: Arc<Mutex<CancellationListener>>,
- pub timing: Arc<Mutex<ResourceFetchTiming>>,
+ pub timing: ServoArc<Mutex<ResourceFetchTiming>>,
}
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<AtomicBool>,
/// track network metrics
- pub resource_timing: ResourceFetchTiming,
+ #[ignore_malloc_size_of = "Mutex heap size undefined"]
+ pub resource_timing: Arc<Mutex<ResourceFetchTiming>>,
}
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<Mutex<ResourceFetchTiming>> {
+ Arc::clone(&self.resource_timing)
}
/// Convert to a filtered response, of type `filter_type`.