mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-15 08:53:07 +09:00
moebius#158: The Performance Resource Timing (added support for "workerStart")
https://github.com/MoonchildProductions/moebius/pull/158
This commit is contained in:
parent
6a97ee9379
commit
6885700c5b
26 changed files with 746 additions and 70 deletions
|
|
@ -105,6 +105,7 @@ HttpBaseChannel::HttpBaseChannel()
|
|||
, mHttpHandler(gHttpHandler)
|
||||
, mReferrerPolicy(REFERRER_POLICY_NO_REFERRER_WHEN_DOWNGRADE)
|
||||
, mRedirectCount(0)
|
||||
, mInternalRedirectCount(0)
|
||||
, mForcePending(false)
|
||||
, mCorsIncludeCredentials(false)
|
||||
, mCorsMode(nsIHttpChannelInternal::CORS_MODE_NO_CORS)
|
||||
|
|
@ -3128,12 +3129,6 @@ HttpBaseChannel::SetupReplacementChannel(nsIURI *newURI,
|
|||
// convey the mAllowPipelining and mAllowSTS flags
|
||||
httpChannel->SetAllowPipelining(mAllowPipelining);
|
||||
httpChannel->SetAllowSTS(mAllowSTS);
|
||||
// convey the new redirection limit
|
||||
// make sure we don't underflow
|
||||
uint32_t redirectionLimit = mRedirectionLimit
|
||||
? mRedirectionLimit - 1
|
||||
: 0;
|
||||
httpChannel->SetRedirectionLimit(redirectionLimit);
|
||||
|
||||
// convey the Accept header value
|
||||
{
|
||||
|
|
@ -3215,23 +3210,40 @@ HttpBaseChannel::SetupReplacementChannel(nsIURI *newURI,
|
|||
do_QueryInterface(static_cast<nsIHttpChannel*>(this)));
|
||||
if (oldTimedChannel && newTimedChannel) {
|
||||
newTimedChannel->SetTimingEnabled(mTimingEnabled);
|
||||
newTimedChannel->SetRedirectCount(mRedirectCount + 1);
|
||||
|
||||
if (redirectFlags & nsIChannelEventSink::REDIRECT_INTERNAL) {
|
||||
int8_t newCount = mInternalRedirectCount + 1;
|
||||
newTimedChannel->SetInternalRedirectCount(
|
||||
std::max(newCount, mInternalRedirectCount));
|
||||
} else {
|
||||
int8_t newCount = mRedirectCount + 1;
|
||||
newTimedChannel->SetRedirectCount(
|
||||
std::max(newCount, mRedirectCount));
|
||||
}
|
||||
|
||||
// If the RedirectStart is null, we will use the AsyncOpen value of the
|
||||
// previous channel (this is the first redirect in the redirects chain).
|
||||
if (mRedirectStartTimeStamp.IsNull()) {
|
||||
TimeStamp asyncOpen;
|
||||
oldTimedChannel->GetAsyncOpen(&asyncOpen);
|
||||
newTimedChannel->SetRedirectStart(asyncOpen);
|
||||
}
|
||||
else {
|
||||
// Only do this for real redirects. Internal redirects should be hidden.
|
||||
if (!(redirectFlags & nsIChannelEventSink::REDIRECT_INTERNAL)) {
|
||||
TimeStamp asyncOpen;
|
||||
oldTimedChannel->GetAsyncOpen(&asyncOpen);
|
||||
newTimedChannel->SetRedirectStart(asyncOpen);
|
||||
}
|
||||
} else {
|
||||
newTimedChannel->SetRedirectStart(mRedirectStartTimeStamp);
|
||||
}
|
||||
|
||||
// The RedirectEnd timestamp is equal to the previous channel response end.
|
||||
TimeStamp prevResponseEnd;
|
||||
oldTimedChannel->GetResponseEnd(&prevResponseEnd);
|
||||
newTimedChannel->SetRedirectEnd(prevResponseEnd);
|
||||
// For internal redirects just propagate the last redirect end time
|
||||
// forward. Otherwise the new redirect end time is the last response
|
||||
// end time.
|
||||
TimeStamp newRedirectEnd;
|
||||
if (redirectFlags & nsIChannelEventSink::REDIRECT_INTERNAL) {
|
||||
oldTimedChannel->GetRedirectEnd(&newRedirectEnd);
|
||||
} else {
|
||||
oldTimedChannel->GetResponseEnd(&newRedirectEnd);
|
||||
}
|
||||
newTimedChannel->SetRedirectEnd(newRedirectEnd);
|
||||
|
||||
nsAutoString initiatorType;
|
||||
oldTimedChannel->GetInitiatorType(initiatorType);
|
||||
|
|
@ -3253,6 +3265,16 @@ HttpBaseChannel::SetupReplacementChannel(nsIURI *newURI,
|
|||
mAllRedirectsPassTimingAllowCheck &&
|
||||
oldTimedChannel->TimingAllowCheck(principal));
|
||||
}
|
||||
|
||||
// Propagate service worker measurements across redirects. The
|
||||
// PeformanceResourceTiming.workerStart API expects to see the
|
||||
// worker start time after a redirect.
|
||||
newTimedChannel->SetLaunchServiceWorkerStart(mLaunchServiceWorkerStart);
|
||||
newTimedChannel->SetLaunchServiceWorkerEnd(mLaunchServiceWorkerEnd);
|
||||
newTimedChannel->SetDispatchFetchEventStart(mDispatchFetchEventStart);
|
||||
newTimedChannel->SetDispatchFetchEventEnd(mDispatchFetchEventEnd);
|
||||
newTimedChannel->SetHandleFetchEventStart(mHandleFetchEventStart);
|
||||
newTimedChannel->SetHandleFetchEventEnd(mHandleFetchEventEnd);
|
||||
}
|
||||
|
||||
// Pass the preferred alt-data type on to the new channel.
|
||||
|
|
@ -3318,19 +3340,33 @@ HttpBaseChannel::GetAsyncOpen(TimeStamp* _retval) {
|
|||
* redirects. This check must be done by the consumers.
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::GetRedirectCount(uint16_t *aRedirectCount)
|
||||
HttpBaseChannel::GetRedirectCount(uint8_t *aRedirectCount)
|
||||
{
|
||||
*aRedirectCount = mRedirectCount;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::SetRedirectCount(uint16_t aRedirectCount)
|
||||
HttpBaseChannel::SetRedirectCount(uint8_t aRedirectCount)
|
||||
{
|
||||
mRedirectCount = aRedirectCount;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::GetInternalRedirectCount(uint8_t *aRedirectCount)
|
||||
{
|
||||
*aRedirectCount = mInternalRedirectCount;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::SetInternalRedirectCount(uint8_t aRedirectCount)
|
||||
{
|
||||
mInternalRedirectCount = aRedirectCount;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::GetRedirectStart(TimeStamp* _retval)
|
||||
{
|
||||
|
|
@ -3430,6 +3466,84 @@ HttpBaseChannel::TimingAllowCheck(nsIPrincipal *aOrigin, bool *_retval)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::GetLaunchServiceWorkerStart(TimeStamp* _retval) {
|
||||
MOZ_ASSERT(_retval);
|
||||
*_retval = mLaunchServiceWorkerStart;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::SetLaunchServiceWorkerStart(TimeStamp aTimeStamp) {
|
||||
mLaunchServiceWorkerStart = aTimeStamp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::GetLaunchServiceWorkerEnd(TimeStamp* _retval) {
|
||||
MOZ_ASSERT(_retval);
|
||||
*_retval = mLaunchServiceWorkerEnd;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::SetLaunchServiceWorkerEnd(TimeStamp aTimeStamp) {
|
||||
mLaunchServiceWorkerEnd = aTimeStamp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::GetDispatchFetchEventStart(TimeStamp* _retval) {
|
||||
MOZ_ASSERT(_retval);
|
||||
*_retval = mDispatchFetchEventStart;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::SetDispatchFetchEventStart(TimeStamp aTimeStamp) {
|
||||
mDispatchFetchEventStart = aTimeStamp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::GetDispatchFetchEventEnd(TimeStamp* _retval) {
|
||||
MOZ_ASSERT(_retval);
|
||||
*_retval = mDispatchFetchEventEnd;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::SetDispatchFetchEventEnd(TimeStamp aTimeStamp) {
|
||||
mDispatchFetchEventEnd = aTimeStamp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::GetHandleFetchEventStart(TimeStamp* _retval) {
|
||||
MOZ_ASSERT(_retval);
|
||||
*_retval = mHandleFetchEventStart;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::SetHandleFetchEventStart(TimeStamp aTimeStamp) {
|
||||
mHandleFetchEventStart = aTimeStamp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::GetHandleFetchEventEnd(TimeStamp* _retval) {
|
||||
MOZ_ASSERT(_retval);
|
||||
*_retval = mHandleFetchEventEnd;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::SetHandleFetchEventEnd(TimeStamp aTimeStamp) {
|
||||
mHandleFetchEventEnd = aTimeStamp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::GetDomainLookupStart(TimeStamp* _retval) {
|
||||
*_retval = mTransactionTimings.domainLookupStart;
|
||||
|
|
@ -3520,6 +3634,12 @@ HttpBaseChannel::Get##name##Time(PRTime* _retval) { \
|
|||
|
||||
IMPL_TIMING_ATTR(ChannelCreation)
|
||||
IMPL_TIMING_ATTR(AsyncOpen)
|
||||
IMPL_TIMING_ATTR(LaunchServiceWorkerStart)
|
||||
IMPL_TIMING_ATTR(LaunchServiceWorkerEnd)
|
||||
IMPL_TIMING_ATTR(DispatchFetchEventStart)
|
||||
IMPL_TIMING_ATTR(DispatchFetchEventEnd)
|
||||
IMPL_TIMING_ATTR(HandleFetchEventStart)
|
||||
IMPL_TIMING_ATTR(HandleFetchEventEnd)
|
||||
IMPL_TIMING_ATTR(DomainLookupStart)
|
||||
IMPL_TIMING_ATTR(DomainLookupEnd)
|
||||
IMPL_TIMING_ATTR(ConnectStart)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue