summaryrefslogtreecommitdiffstats
path: root/netwerk/protocol/http/HttpBaseChannel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'netwerk/protocol/http/HttpBaseChannel.cpp')
-rw-r--r--netwerk/protocol/http/HttpBaseChannel.cpp156
1 files changed, 138 insertions, 18 deletions
diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp
index 278c94db0..d161f9a43 100644
--- a/netwerk/protocol/http/HttpBaseChannel.cpp
+++ b/netwerk/protocol/http/HttpBaseChannel.cpp
@@ -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,20 +3340,34 @@ 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)
{
*_retval = mRedirectStartTimeStamp;
@@ -3431,6 +3467,84 @@ HttpBaseChannel::TimingAllowCheck(nsIPrincipal *aOrigin, bool *_retval)
}
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;
return NS_OK;
@@ -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)