Auto merge of #23145 - pylbrecht:performance.resource.timing, r=jdm

Add connectEnd attribute to PerformanceResourceTiming interface

<!-- Please describe your changes on the following line: -->

---
<!-- 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 #21262

<!-- Either: -->
- [X] There are tests for these changes

<!-- 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/23145)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-04-04 18:39:35 -04:00 committed by GitHub
commit f142b1d1c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 16 deletions

View file

@ -349,6 +349,7 @@ fn obtain_response(
iters: u32,
request_id: Option<&str>,
is_xhr: bool,
context: &FetchContext,
) -> Box<
dyn Future<
Item = (HyperResponse<Decoder>, Option<ChromeToDevtoolsControlMsg>),
@ -400,8 +401,12 @@ fn obtain_response(
};
*request.headers_mut() = headers.clone();
//TODO(#21262) connect_end
let connect_end = precise_time_ms();
context
.timing
.lock()
.unwrap()
.set_attribute(ResourceAttribute::ConnectEnd(connect_end));
let request_id = request_id.map(|v| v.to_owned());
let pipeline_id = pipeline_id.clone();
@ -1190,6 +1195,7 @@ fn http_network_fetch(
request.redirect_count + 1,
request_id.as_ref().map(Deref::deref),
is_xhr,
context,
);
let pipeline_id = request.pipeline_id;

View file

@ -452,7 +452,7 @@ pub struct ResourceFetchTiming {
pub redirect_start: u64,
// pub redirect_end: u64,
// pub connect_start: u64,
// pub connect_end: u64,
pub connect_end: u64,
}
pub enum RedirectStartValue {
@ -467,6 +467,7 @@ pub enum ResourceAttribute {
ResponseStart,
RedirectStart(RedirectStartValue),
FetchStart,
ConnectEnd(u64),
}
#[derive(Clone, Copy, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)]
@ -486,6 +487,7 @@ impl ResourceFetchTiming {
response_start: 0,
fetch_start: 0,
redirect_start: 0,
connect_end: 0,
}
}
@ -505,6 +507,7 @@ impl ResourceFetchTiming {
},
},
ResourceAttribute::FetchStart => self.fetch_start = precise_time_ns(),
ResourceAttribute::ConnectEnd(val) => self.connect_end = val,
}
}
}

View file

@ -122,7 +122,7 @@ impl PerformanceResourceTiming {
domain_lookup_start: 0.,
domain_lookup_end: 0.,
connect_start: 0.,
connect_end: 0.,
connect_end: resource_timing.connect_end as f64,
secure_connection_start: 0.,
request_start: resource_timing.request_start as f64,
response_start: resource_timing.response_start as f64,
@ -194,4 +194,9 @@ impl PerformanceResourceTimingMethods for PerformanceResourceTiming {
fn FetchStart(&self) -> DOMHighResTimeStamp {
Finite::wrap(self.fetch_start)
}
// https://w3c.github.io/resource-timing/#dom-performanceresourcetiming-connectend
fn ConnectEnd(&self) -> DOMHighResTimeStamp {
Finite::wrap(self.connect_end)
}
}

View file

@ -18,7 +18,7 @@ interface PerformanceResourceTiming : PerformanceEntry {
// readonly attribute DOMHighResTimeStamp domainLookupStart;
// readonly attribute DOMHighResTimeStamp domainLookupEnd;
// readonly attribute DOMHighResTimeStamp connectStart;
// readonly attribute DOMHighResTimeStamp connectEnd;
readonly attribute DOMHighResTimeStamp connectEnd;
// readonly attribute DOMHighResTimeStamp secureConnectionStart;
readonly attribute DOMHighResTimeStamp requestStart;
readonly attribute DOMHighResTimeStamp responseStart;