mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Auto merge of #22714 - aditj:patch-3, r=jdm
Added fetch_start functionality <!-- Please describe your changes on the following line: --> Added the fetch_start functionality in http_loader.rs (http_fetch function) --- <!-- 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 #21258 (GitHub issue number if applicable) <!-- 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. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22714) <!-- Reviewable:end -->
This commit is contained in:
commit
fe07d2c575
6 changed files with 27 additions and 20 deletions
|
@ -23,6 +23,7 @@ use net_traits::filemanager_thread::RelativePos;
|
||||||
use net_traits::request::{CredentialsMode, Destination, Referrer, Request, RequestMode};
|
use net_traits::request::{CredentialsMode, Destination, Referrer, Request, RequestMode};
|
||||||
use net_traits::request::{Origin, ResponseTainting, Window};
|
use net_traits::request::{Origin, ResponseTainting, Window};
|
||||||
use net_traits::response::{Response, ResponseBody, ResponseType};
|
use net_traits::response::{Response, ResponseBody, ResponseType};
|
||||||
|
use net_traits::ResourceAttribute;
|
||||||
use net_traits::{FetchTaskTarget, NetworkError, ReferrerPolicy, ResourceFetchTiming};
|
use net_traits::{FetchTaskTarget, NetworkError, ReferrerPolicy, ResourceFetchTiming};
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
@ -88,6 +89,12 @@ pub type DoneChannel = Option<(Sender<Data>, Receiver<Data>)>;
|
||||||
|
|
||||||
/// [Fetch](https://fetch.spec.whatwg.org#concept-fetch)
|
/// [Fetch](https://fetch.spec.whatwg.org#concept-fetch)
|
||||||
pub fn fetch(request: &mut Request, target: Target, context: &FetchContext) {
|
pub fn fetch(request: &mut Request, target: Target, context: &FetchContext) {
|
||||||
|
// Step 7 of https://w3c.github.io/resource-timing/#processing-model
|
||||||
|
context
|
||||||
|
.timing
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.set_attribute(ResourceAttribute::FetchStart);
|
||||||
fetch_with_cors_cache(request, &mut CorsCache::new(), target, context);
|
fetch_with_cors_cache(request, &mut CorsCache::new(), target, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -525,8 +525,6 @@ pub fn http_fetch(
|
||||||
request.service_workers_mode = ServiceWorkersMode::None;
|
request.service_workers_mode = ServiceWorkersMode::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Substep 3
|
|
||||||
// TODO(#21258) maybe set fetch_start (if this is the last resource)
|
|
||||||
// Generally, we use a persistent connection, so we will also set other PerformanceResourceTiming
|
// 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,
|
// attributes to this as well (domain_lookup_start, domain_lookup_end, connect_start, connect_end,
|
||||||
// secure_connection_start)
|
// secure_connection_start)
|
||||||
|
@ -660,6 +658,13 @@ pub fn http_redirect_fetch(
|
||||||
Some(Ok(url)) => url,
|
Some(Ok(url)) => url,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Step 1 of https://w3c.github.io/resource-timing/#dom-performanceresourcetiming-fetchstart
|
||||||
|
context
|
||||||
|
.timing
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.set_attribute(ResourceAttribute::FetchStart);
|
||||||
|
|
||||||
// Step 5
|
// Step 5
|
||||||
if request.redirect_count >= 20 {
|
if request.redirect_count >= 20 {
|
||||||
return Response::network_error(NetworkError::Internal("Too many redirects".into()));
|
return Response::network_error(NetworkError::Internal("Too many redirects".into()));
|
||||||
|
|
|
@ -447,6 +447,7 @@ pub struct ResourceFetchTiming {
|
||||||
pub redirect_count: u16,
|
pub redirect_count: u16,
|
||||||
pub request_start: u64,
|
pub request_start: u64,
|
||||||
pub response_start: u64,
|
pub response_start: u64,
|
||||||
|
pub fetch_start: u64,
|
||||||
// pub response_end: u64,
|
// pub response_end: u64,
|
||||||
// pub redirect_start: u64,
|
// pub redirect_start: u64,
|
||||||
// pub redirect_end: u64,
|
// pub redirect_end: u64,
|
||||||
|
@ -458,6 +459,7 @@ pub enum ResourceAttribute {
|
||||||
RedirectCount(u16),
|
RedirectCount(u16),
|
||||||
RequestStart,
|
RequestStart,
|
||||||
ResponseStart,
|
ResponseStart,
|
||||||
|
FetchStart,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)]
|
#[derive(Clone, Copy, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)]
|
||||||
|
@ -475,6 +477,7 @@ impl ResourceFetchTiming {
|
||||||
redirect_count: 0,
|
redirect_count: 0,
|
||||||
request_start: 0,
|
request_start: 0,
|
||||||
response_start: 0,
|
response_start: 0,
|
||||||
|
fetch_start: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -485,6 +488,7 @@ impl ResourceFetchTiming {
|
||||||
ResourceAttribute::RedirectCount(count) => self.redirect_count = count,
|
ResourceAttribute::RedirectCount(count) => self.redirect_count = count,
|
||||||
ResourceAttribute::RequestStart => self.request_start = precise_time_ns(),
|
ResourceAttribute::RequestStart => self.request_start = precise_time_ns(),
|
||||||
ResourceAttribute::ResponseStart => self.response_start = precise_time_ns(),
|
ResourceAttribute::ResponseStart => self.response_start = precise_time_ns(),
|
||||||
|
ResourceAttribute::FetchStart => self.fetch_start = precise_time_ns(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ impl PerformanceResourceTiming {
|
||||||
entry: PerformanceEntry::new_inherited(
|
entry: PerformanceEntry::new_inherited(
|
||||||
DOMString::from(url.into_string()),
|
DOMString::from(url.into_string()),
|
||||||
DOMString::from("resource"),
|
DOMString::from("resource"),
|
||||||
fetch_start,
|
0.,
|
||||||
0.,
|
0.,
|
||||||
),
|
),
|
||||||
initiator_type: initiator_type,
|
initiator_type: initiator_type,
|
||||||
|
@ -118,7 +118,7 @@ impl PerformanceResourceTiming {
|
||||||
worker_start: 0.,
|
worker_start: 0.,
|
||||||
redirect_start: 0.,
|
redirect_start: 0.,
|
||||||
redirect_end: 0.,
|
redirect_end: 0.,
|
||||||
fetch_start: 0.,
|
fetch_start: resource_timing.fetch_start as f64,
|
||||||
domain_lookup_start: 0.,
|
domain_lookup_start: 0.,
|
||||||
domain_lookup_end: 0.,
|
domain_lookup_end: 0.,
|
||||||
connect_start: 0.,
|
connect_start: 0.,
|
||||||
|
@ -184,4 +184,9 @@ impl PerformanceResourceTimingMethods for PerformanceResourceTiming {
|
||||||
// TODO
|
// TODO
|
||||||
Finite::wrap(self.response_start)
|
Finite::wrap(self.response_start)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://w3c.github.io/resource-timing/#dom-performanceresourcetiming-fetchstart
|
||||||
|
fn FetchStart(&self) -> DOMHighResTimeStamp {
|
||||||
|
Finite::wrap(self.fetch_start)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
* https://w3c.github.io/resource-timing/
|
* https://w3c.github.io/resource-timing/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// https://w3c.github.io/resource-timing/#sec-performanceresourcetiming
|
||||||
[Exposed=(Window,Worker)]
|
[Exposed=(Window,Worker)]
|
||||||
interface PerformanceResourceTiming : PerformanceEntry {
|
interface PerformanceResourceTiming : PerformanceEntry {
|
||||||
readonly attribute DOMString initiatorType;
|
readonly attribute DOMString initiatorType;
|
||||||
|
@ -13,7 +14,7 @@ interface PerformanceResourceTiming : PerformanceEntry {
|
||||||
// readonly attribute DOMHighResTimeStamp workerStart;
|
// readonly attribute DOMHighResTimeStamp workerStart;
|
||||||
// readonly attribute DOMHighResTimeStamp redirectStart;
|
// readonly attribute DOMHighResTimeStamp redirectStart;
|
||||||
// readonly attribute DOMHighResTimeStamp redirectEnd;
|
// readonly attribute DOMHighResTimeStamp redirectEnd;
|
||||||
// readonly attribute DOMHighResTimeStamp fetchStart;
|
readonly attribute DOMHighResTimeStamp fetchStart;
|
||||||
// readonly attribute DOMHighResTimeStamp domainLookupStart;
|
// readonly attribute DOMHighResTimeStamp domainLookupStart;
|
||||||
// readonly attribute DOMHighResTimeStamp domainLookupEnd;
|
// readonly attribute DOMHighResTimeStamp domainLookupEnd;
|
||||||
// readonly attribute DOMHighResTimeStamp connectStart;
|
// readonly attribute DOMHighResTimeStamp connectStart;
|
||||||
|
@ -27,9 +28,3 @@ interface PerformanceResourceTiming : PerformanceEntry {
|
||||||
/// readonly attribute unsigned long long decodedBodySize;
|
/// readonly attribute unsigned long long decodedBodySize;
|
||||||
// [Default] object toJSON();
|
// [Default] object toJSON();
|
||||||
};
|
};
|
||||||
|
|
||||||
// partial interface Performance {
|
|
||||||
// void clearResourceTimings();
|
|
||||||
// void setResourceTimingBufferSize(unsigned long maxSize);
|
|
||||||
// attribute EventHandler onresourcetimingbufferfull;
|
|
||||||
// };
|
|
||||||
|
|
|
@ -41,9 +41,6 @@
|
||||||
[PerformanceResourceTiming interface: attribute secureConnectionStart]
|
[PerformanceResourceTiming interface: attribute secureConnectionStart]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[PerformanceResourceTiming interface: attribute fetchStart]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[PerformanceResourceTiming interface: resource must inherit property "secureConnectionStart" with the proper type]
|
[PerformanceResourceTiming interface: resource must inherit property "secureConnectionStart" with the proper type]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -83,9 +80,6 @@
|
||||||
[PerformanceResourceTiming interface: attribute domainLookupEnd]
|
[PerformanceResourceTiming interface: attribute domainLookupEnd]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[PerformanceResourceTiming interface: resource must inherit property "fetchStart" with the proper type]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[PerformanceResourceTiming interface: attribute redirectStart]
|
[PerformanceResourceTiming interface: attribute redirectStart]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -175,9 +169,6 @@
|
||||||
[PerformanceResourceTiming interface: attribute secureConnectionStart]
|
[PerformanceResourceTiming interface: attribute secureConnectionStart]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[PerformanceResourceTiming interface: attribute fetchStart]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[PerformanceResourceTiming interface: attribute workerStart]
|
[PerformanceResourceTiming interface: attribute workerStart]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue