mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Auto merge of #24508 - pajamapants3000:21254, r=jdm
Add start_time to resource timing. <!-- Please describe your changes on the following line: --> `start_time` property added to `ResourceFetchTiming`, which enables the setting of `start_time` in the `PerformanceEntry` member of `PerformanceResourceTiming`. Following the specification at https://w3c.github.io/resource-timing/#dfn-starttime, `start_time` is set to the value of `redirect_start` if redirection occurs and the timing allow check passes. Otherwise it has the same value as `fetch_start`. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #21254 <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
commit
bf587f22d7
8 changed files with 277 additions and 15 deletions
|
@ -22,8 +22,8 @@ use net_traits::filemanager_thread::RelativePos;
|
|||
use net_traits::request::{CredentialsMode, Destination, Referrer, Request, RequestMode};
|
||||
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 net_traits::{ResourceAttribute, ResourceTimeValue};
|
||||
use servo_arc::Arc as ServoArc;
|
||||
use servo_url::ServoUrl;
|
||||
use std::borrow::Cow;
|
||||
|
@ -90,12 +90,19 @@ pub type DoneChannel = Option<(Sender<Data>, Receiver<Data>)>;
|
|||
|
||||
/// [Fetch](https://fetch.spec.whatwg.org#concept-fetch)
|
||||
pub fn fetch(request: &mut Request, target: Target, context: &FetchContext) {
|
||||
// Step 7 of https://w3c.github.io/resource-timing/#processing-model
|
||||
// Steps 7,4 of https://w3c.github.io/resource-timing/#processing-model
|
||||
// rev order okay since spec says they're equal - https://w3c.github.io/resource-timing/#dfn-starttime
|
||||
context
|
||||
.timing
|
||||
.lock()
|
||||
.unwrap()
|
||||
.set_attribute(ResourceAttribute::FetchStart);
|
||||
context
|
||||
.timing
|
||||
.lock()
|
||||
.unwrap()
|
||||
.set_attribute(ResourceAttribute::StartTime(ResourceTimeValue::FetchStart));
|
||||
|
||||
fetch_with_cors_cache(request, &mut CorsCache::new(), target, context);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,9 @@ use net_traits::request::{RedirectMode, Referrer, Request, RequestBuilder, Reque
|
|||
use net_traits::request::{ResponseTainting, ServiceWorkersMode};
|
||||
use net_traits::response::{HttpsState, Response, ResponseBody, ResponseType};
|
||||
use net_traits::{CookieSource, FetchMetadata, NetworkError, ReferrerPolicy};
|
||||
use net_traits::{RedirectEndValue, RedirectStartValue, ResourceAttribute, ResourceFetchTiming};
|
||||
use net_traits::{
|
||||
RedirectEndValue, RedirectStartValue, ResourceAttribute, ResourceFetchTiming, ResourceTimeValue,
|
||||
};
|
||||
use openssl::ssl::SslConnectorBuilder;
|
||||
use servo_arc::Arc;
|
||||
use servo_url::{ImmutableOrigin, ServoUrl};
|
||||
|
@ -572,8 +574,6 @@ pub fn http_fetch(
|
|||
// Generally, we use a persistent connection, so we will also set other PerformanceResourceTiming
|
||||
// attributes to this as well (domain_lookup_start, domain_lookup_end, connect_start, connect_end,
|
||||
// secure_connection_start)
|
||||
// TODO(#21254) also set startTime equal to either fetch_start or redirect_start
|
||||
// (https://w3c.github.io/resource-timing/#dfn-starttime)
|
||||
context
|
||||
.timing
|
||||
.lock()
|
||||
|
@ -737,6 +737,21 @@ pub fn http_redirect_fetch(
|
|||
.unwrap()
|
||||
.set_attribute(ResourceAttribute::FetchStart);
|
||||
|
||||
// start_time should equal redirect_start if nonzero; else fetch_start
|
||||
context
|
||||
.timing
|
||||
.lock()
|
||||
.unwrap()
|
||||
.set_attribute(ResourceAttribute::StartTime(ResourceTimeValue::FetchStart));
|
||||
|
||||
context
|
||||
.timing
|
||||
.lock()
|
||||
.unwrap()
|
||||
.set_attribute(ResourceAttribute::StartTime(
|
||||
ResourceTimeValue::RedirectStart,
|
||||
)); // updates start_time only if redirect_start is nonzero (implying TAO)
|
||||
|
||||
// Step 5
|
||||
if request.redirect_count >= 20 {
|
||||
return Response::network_error(NetworkError::Internal("Too many redirects".into()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue