Bug 1525640 - Add nsIHttpChannelInternal.isResolvedByTRR r=dragana
authorValentin Gosu <valentin.gosu@gmail.com>
Mon, 06 May 2019 16:38:16 +0000
changeset 531608 83b1e5ce0132a17e6565fe55341f4c73c5c913a4
parent 531607 3b43b5e97f9e60f110a98869ca748956c47cda5a
child 531609 500cdbe0977e74d4c166ff56cfeaa6690c9c71bf
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdragana
bugs1525640
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1525640 - Add nsIHttpChannelInternal.isResolvedByTRR r=dragana Differential Revision: https://phabricator.services.mozilla.com/D26884
netwerk/protocol/http/ClassifierDummyChannel.cpp
netwerk/protocol/http/HttpBaseChannel.cpp
netwerk/protocol/http/HttpBaseChannel.h
netwerk/protocol/http/HttpChannelChild.cpp
netwerk/protocol/http/HttpChannelChild.h
netwerk/protocol/http/HttpChannelParent.cpp
netwerk/protocol/http/PHttpChannel.ipdl
netwerk/protocol/http/nsHttpChannel.h
netwerk/protocol/http/nsIHttpChannelInternal.idl
--- a/netwerk/protocol/http/ClassifierDummyChannel.cpp
+++ b/netwerk/protocol/http/ClassifierDummyChannel.cpp
@@ -481,16 +481,21 @@ ClassifierDummyChannel::GetIsTRRServiceC
 }
 
 NS_IMETHODIMP
 ClassifierDummyChannel::SetIsTRRServiceChannel(bool aTrr) {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
+ClassifierDummyChannel::GetIsResolvedByTRR(bool* aResolvedByTRR) {
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
 ClassifierDummyChannel::GetTlsFlags(uint32_t* aTlsFlags) {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 ClassifierDummyChannel::SetTlsFlags(uint32_t aTlsFlags) {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
--- a/netwerk/protocol/http/HttpBaseChannel.cpp
+++ b/netwerk/protocol/http/HttpBaseChannel.cpp
@@ -194,16 +194,17 @@ HttpBaseChannel::HttpBaseChannel()
       mChannelIsForDownload(false),
       mTracingEnabled(true),
       mTimingEnabled(false),
       mReportTiming(true),
       mAllowSpdy(true),
       mAllowAltSvc(true),
       mBeConservative(false),
       mIsTRRServiceChannel(false),
+      mResolvedByTRR(false),
       mResponseTimeoutEnabled(true),
       mAllRedirectsSameOrigin(true),
       mAllRedirectsPassTimingAllowCheck(true),
       mResponseCouldBeSynthesized(false),
       mBlockAuthPrompt(false),
       mAllowStaleCacheContent(false),
       mAddedAsNonTailRequest(false),
       mAsyncOpenWaitingForStreamLength(false),
@@ -2409,16 +2410,23 @@ HttpBaseChannel::GetIsTRRServiceChannel(
 
 NS_IMETHODIMP
 HttpBaseChannel::SetIsTRRServiceChannel(bool aIsTRRServiceChannel) {
   mIsTRRServiceChannel = aIsTRRServiceChannel;
   return NS_OK;
 }
 
 NS_IMETHODIMP
+HttpBaseChannel::GetIsResolvedByTRR(bool* aResolvedByTRR) {
+  NS_ENSURE_ARG_POINTER(aResolvedByTRR);
+  *aResolvedByTRR = mResolvedByTRR;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 HttpBaseChannel::GetTlsFlags(uint32_t* aTlsFlags) {
   NS_ENSURE_ARG_POINTER(aTlsFlags);
 
   *aTlsFlags = mTlsFlags;
   return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/netwerk/protocol/http/HttpBaseChannel.h
+++ b/netwerk/protocol/http/HttpBaseChannel.h
@@ -271,16 +271,17 @@ class HttpBaseChannel : public nsHashPro
   NS_IMETHOD GetAllowSpdy(bool* aAllowSpdy) override;
   NS_IMETHOD SetAllowSpdy(bool aAllowSpdy) override;
   NS_IMETHOD GetAllowAltSvc(bool* aAllowAltSvc) override;
   NS_IMETHOD SetAllowAltSvc(bool aAllowAltSvc) override;
   NS_IMETHOD GetBeConservative(bool* aBeConservative) override;
   NS_IMETHOD SetBeConservative(bool aBeConservative) override;
   NS_IMETHOD GetIsTRRServiceChannel(bool* aTRR) override;
   NS_IMETHOD SetIsTRRServiceChannel(bool aTRR) override;
+  NS_IMETHOD GetIsResolvedByTRR(bool* aResolvedByTRR) override;
   NS_IMETHOD GetTlsFlags(uint32_t* aTlsFlags) override;
   NS_IMETHOD SetTlsFlags(uint32_t aTlsFlags) override;
   NS_IMETHOD GetApiRedirectToURI(nsIURI** aApiRedirectToURI) override;
   virtual MOZ_MUST_USE nsresult AddSecurityMessage(
       const nsAString& aMessageTag, const nsAString& aMessageCategory);
   NS_IMETHOD TakeAllSecurityMessages(
       nsCOMArray<nsISecurityConsoleMessage>& aMessages) override;
   NS_IMETHOD GetResponseTimeoutEnabled(bool* aEnable) override;
@@ -688,17 +689,22 @@ class HttpBaseChannel : public nsHashPro
   uint32_t mTimingEnabled : 1;
   uint32_t mReportTiming : 1;
   uint32_t mAllowSpdy : 1;
   uint32_t mAllowAltSvc : 1;
   // !!! This is also used by the URL classifier to exempt channels from
   // classification. If this is changed or removed, make sure we also update
   // NS_ShouldClassifyChannel accordingly !!!
   uint32_t mBeConservative : 1;
+  // If the current channel is used to as a TRR connection.
   uint32_t mIsTRRServiceChannel : 1;
+  // If the request was performed to a TRR resolved IP address.
+  // Will be false if loading the resource does not create a connection
+  // (for example when it's loaded from the cache).
+  uint32_t mResolvedByTRR : 1;
   uint32_t mResponseTimeoutEnabled : 1;
   // A flag that should be false only if a cross-domain redirect occurred
   uint32_t mAllRedirectsSameOrigin : 1;
 
   // Is 1 if no redirects have occured or if all redirects
   // pass the Resource Timing timing-allow-check
   uint32_t mAllRedirectsPassTimingAllowCheck : 1;
 
--- a/netwerk/protocol/http/HttpChannelChild.cpp
+++ b/netwerk/protocol/http/HttpChannelChild.cpp
@@ -403,17 +403,17 @@ class StartRequestEvent : public NeckoTa
       const bool& aIsFromCache, const bool& aIsRacing,
       const bool& aCacheEntryAvailable, const uint64_t& aCacheEntryId,
       const int32_t& aCacheFetchCount, const uint32_t& aCacheExpirationTime,
       const nsCString& aCachedCharset,
       const nsCString& aSecurityInfoSerialization, const NetAddr& aSelfAddr,
       const NetAddr& aPeerAddr, const uint32_t& aCacheKey,
       const nsCString& altDataType, const int64_t& altDataLen,
       const bool& deliveringAltData, const bool& aApplyConversion,
-      const ResourceTimingStruct& aTiming)
+      const bool& aIsResolvedByTRR, const ResourceTimingStruct& aTiming)
       : NeckoTargetChannelEvent<HttpChannelChild>(aChild),
         mChannelStatus(aChannelStatus),
         mResponseHead(aResponseHead),
         mRequestHeaders(aRequestHeaders),
         mUseResponseHead(aUseResponseHead),
         mApplyConversion(aApplyConversion),
         mIsFromCache(aIsFromCache),
         mIsRacing(aIsRacing),
@@ -425,27 +425,28 @@ class StartRequestEvent : public NeckoTa
         mSecurityInfoSerialization(aSecurityInfoSerialization),
         mSelfAddr(aSelfAddr),
         mPeerAddr(aPeerAddr),
         mCacheKey(aCacheKey),
         mAltDataType(altDataType),
         mAltDataLen(altDataLen),
         mDeliveringAltData(deliveringAltData),
         mLoadInfoForwarder(loadInfoForwarder),
+        mIsResolvedByTRR(aIsResolvedByTRR),
         mTiming(aTiming) {}
 
   void Run() override {
     LOG(("StartRequestEvent [this=%p]\n", mChild));
     mChild->OnStartRequest(
         mChannelStatus, mResponseHead, mUseResponseHead, mRequestHeaders,
         mLoadInfoForwarder, mIsFromCache, mIsRacing, mCacheEntryAvailable,
         mCacheEntryId, mCacheFetchCount, mCacheExpirationTime, mCachedCharset,
         mSecurityInfoSerialization, mSelfAddr, mPeerAddr, mCacheKey,
         mAltDataType, mAltDataLen, mDeliveringAltData, mApplyConversion,
-        mTiming);
+        mIsResolvedByTRR, mTiming);
   }
 
  private:
   nsresult mChannelStatus;
   nsHttpResponseHead mResponseHead;
   nsHttpHeaderArray mRequestHeaders;
   bool mUseResponseHead;
   bool mApplyConversion;
@@ -459,32 +460,33 @@ class StartRequestEvent : public NeckoTa
   nsCString mSecurityInfoSerialization;
   NetAddr mSelfAddr;
   NetAddr mPeerAddr;
   uint32_t mCacheKey;
   nsCString mAltDataType;
   int64_t mAltDataLen;
   bool mDeliveringAltData;
   ParentLoadInfoForwarderArgs mLoadInfoForwarder;
+  bool mIsResolvedByTRR;
   ResourceTimingStruct mTiming;
 };
 
 mozilla::ipc::IPCResult HttpChannelChild::RecvOnStartRequest(
     const nsresult& channelStatus, const nsHttpResponseHead& responseHead,
     const bool& useResponseHead, const nsHttpHeaderArray& requestHeaders,
     const ParentLoadInfoForwarderArgs& loadInfoForwarder,
     const bool& isFromCache, const bool& isRacing,
     const bool& cacheEntryAvailable, const uint64_t& cacheEntryId,
     const int32_t& cacheFetchCount, const uint32_t& cacheExpirationTime,
     const nsCString& cachedCharset, const nsCString& securityInfoSerialization,
     const NetAddr& selfAddr, const NetAddr& peerAddr,
     const int16_t& redirectCount, const uint32_t& cacheKey,
     const nsCString& altDataType, const int64_t& altDataLen,
     const bool& deliveringAltData, const bool& aApplyConversion,
-    const ResourceTimingStruct& aTiming) {
+    const bool& aIsResolvedByTRR, const ResourceTimingStruct& aTiming) {
   AUTO_PROFILER_LABEL("HttpChannelChild::RecvOnStartRequest", NETWORK);
   LOG(("HttpChannelChild::RecvOnStartRequest [this=%p]\n", this));
   // mFlushedForDiversion and mDivertingToParent should NEVER be set at this
   // stage, as they are set in the listener's OnStartRequest.
   MOZ_RELEASE_ASSERT(
       !mFlushedForDiversion,
       "mFlushedForDiversion should be unset before OnStartRequest!");
   MOZ_RELEASE_ASSERT(
@@ -493,17 +495,18 @@ mozilla::ipc::IPCResult HttpChannelChild
 
   mRedirectCount = redirectCount;
 
   mEventQ->RunOrEnqueue(new StartRequestEvent(
       this, channelStatus, responseHead, useResponseHead, requestHeaders,
       loadInfoForwarder, isFromCache, isRacing, cacheEntryAvailable,
       cacheEntryId, cacheFetchCount, cacheExpirationTime, cachedCharset,
       securityInfoSerialization, selfAddr, peerAddr, cacheKey, altDataType,
-      altDataLen, deliveringAltData, aApplyConversion, aTiming));
+      altDataLen, deliveringAltData, aApplyConversion, aIsResolvedByTRR,
+      aTiming));
 
   {
     // Child's mEventQ is to control the execution order of the IPC messages
     // from both main thread IPDL and PBackground IPDL.
     // To guarantee the ordering, PBackground IPC messages that are sent after
     // OnStartRequest will be throttled until OnStartRequest hits the Child's
     // mEventQ.
     MutexAutoLock lock(mBgChildMutex);
@@ -527,17 +530,17 @@ void HttpChannelChild::OnStartRequest(
     const ParentLoadInfoForwarderArgs& loadInfoForwarder,
     const bool& isFromCache, const bool& isRacing,
     const bool& cacheEntryAvailable, const uint64_t& cacheEntryId,
     const int32_t& cacheFetchCount, const uint32_t& cacheExpirationTime,
     const nsCString& cachedCharset, const nsCString& securityInfoSerialization,
     const NetAddr& selfAddr, const NetAddr& peerAddr, const uint32_t& cacheKey,
     const nsCString& altDataType, const int64_t& altDataLen,
     const bool& deliveringAltData, const bool& aApplyConversion,
-    const ResourceTimingStruct& aTiming) {
+    const bool& aIsResolvedByTRR, const ResourceTimingStruct& aTiming) {
   LOG(("HttpChannelChild::OnStartRequest [this=%p]\n", this));
 
   // mFlushedForDiversion and mDivertingToParent should NEVER be set at this
   // stage, as they are set in the listener's OnStartRequest.
   MOZ_RELEASE_ASSERT(
       !mFlushedForDiversion,
       "mFlushedForDiversion should be unset before OnStartRequest!");
   MOZ_RELEASE_ASSERT(
@@ -581,16 +584,17 @@ void HttpChannelChild::OnStartRequest(
   mCacheExpirationTime = cacheExpirationTime;
   mCachedCharset = cachedCharset;
   mSelfAddr = selfAddr;
   mPeerAddr = peerAddr;
 
   mAvailableCachedAltDataType = altDataType;
   mDeliveringAltData = deliveringAltData;
   mAltDataLength = altDataLen;
+  mResolvedByTRR = aIsResolvedByTRR;
 
   SetApplyConversion(aApplyConversion);
 
   mAfterOnStartRequestBegun = true;
 
   AutoEventEnqueuer ensureSerialDispatch(mEventQ);
 
   mCacheKey = cacheKey;
--- a/netwerk/protocol/http/HttpChannelChild.h
+++ b/netwerk/protocol/http/HttpChannelChild.h
@@ -141,17 +141,17 @@ class HttpChannelChild final : public PH
       const bool& isFromCache, const bool& isRacing,
       const bool& cacheEntryAvailable, const uint64_t& cacheEntryId,
       const int32_t& cacheFetchCount, const uint32_t& cacheExpirationTime,
       const nsCString& cachedCharset,
       const nsCString& securityInfoSerialization, const NetAddr& selfAddr,
       const NetAddr& peerAddr, const int16_t& redirectCount,
       const uint32_t& cacheKey, const nsCString& altDataType,
       const int64_t& altDataLen, const bool& deliveringAltData,
-      const bool& aApplyConversion,
+      const bool& aApplyConversion, const bool& aIsResolvedByTRR,
       const ResourceTimingStruct& aTiming) override;
   mozilla::ipc::IPCResult RecvFailedAsyncOpen(const nsresult& status) override;
   mozilla::ipc::IPCResult RecvRedirect1Begin(
       const uint32_t& registrarId, const URIParams& newURI,
       const uint32_t& newLoadFlags, const uint32_t& redirectFlags,
       const ParentLoadInfoForwarderArgs& loadInfoForwarder,
       const nsHttpResponseHead& responseHead,
       const nsCString& securityInfoSerialization, const uint64_t& channelId,
@@ -474,17 +474,17 @@ class HttpChannelChild final : public PH
       const bool& isFromCache, const bool& isRacing,
       const bool& cacheEntryAvailable, const uint64_t& cacheEntryId,
       const int32_t& cacheFetchCount, const uint32_t& cacheExpirationTime,
       const nsCString& cachedCharset,
       const nsCString& securityInfoSerialization, const NetAddr& selfAddr,
       const NetAddr& peerAddr, const uint32_t& cacheKey,
       const nsCString& altDataType, const int64_t& altDataLen,
       const bool& deliveringAltData, const bool& aApplyConversion,
-      const ResourceTimingStruct& aTiming);
+      const bool& aIsResolvedByTRR, const ResourceTimingStruct& aTiming);
   void MaybeDivertOnData(const nsCString& data, const uint64_t& offset,
                          const uint32_t& count);
   void OnTransportAndData(const nsresult& channelStatus, const nsresult& status,
                           const uint64_t& offset, const uint32_t& count,
                           const nsCString& data);
   void OnStopRequest(const nsresult& channelStatus,
                      const ResourceTimingStruct& timing,
                      const nsHttpHeaderArray& aResponseTrailers);
--- a/netwerk/protocol/http/HttpChannelParent.cpp
+++ b/netwerk/protocol/http/HttpChannelParent.cpp
@@ -1459,26 +1459,29 @@ HttpChannelParent::OnStartRequest(nsIReq
     cleanedUpRequestHeaders = requestHead->Headers();
     cleanedUpRequestHeaders.ClearHeader(nsHttp::Cookie);
     cleanedUpRequest = true;
   }
 
   ResourceTimingStruct timing;
   GetTimingAttributes(mChannel, timing);
 
+  bool isResolvedByTRR = false;
+  chan->GetIsResolvedByTRR(&isResolvedByTRR);
+
   rv = NS_OK;
   if (mIPCClosed ||
       !SendOnStartRequest(
           channelStatus, *responseHead, useResponseHead,
           cleanedUpRequest ? cleanedUpRequestHeaders : requestHead->Headers(),
           loadInfoForwarderArg, isFromCache, isRacing,
           mCacheEntry ? true : false, cacheEntryId, fetchCount, expirationTime,
           cachedCharset, secInfoSerialization, chan->GetSelfAddr(),
           chan->GetPeerAddr(), redirectCount, cacheKey, altDataType, altDataLen,
-          deliveringAltData, applyConversion, timing)) {
+          deliveringAltData, applyConversion, isResolvedByTRR, timing)) {
     rv = NS_ERROR_UNEXPECTED;
   }
   requestHead->Exit();
 
   // OnStartRequest is sent to content process successfully.
   // Notify PHttpBackgroundChannelChild that all following IPC mesasges
   // should be run after OnStartRequest is handled.
   if (NS_SUCCEEDED(rv)) {
--- a/netwerk/protocol/http/PHttpChannel.ipdl
+++ b/netwerk/protocol/http/PHttpChannel.ipdl
@@ -123,16 +123,17 @@ child:
                        NetAddr             selfAddr,
                        NetAddr             peerAddr,
                        int16_t             redirectCount,
                        uint32_t            cacheKey,
                        nsCString           altDataType,
                        int64_t             altDataLength,
                        bool                deliveringAltData,
                        bool                applyConversion,
+                       bool                isResolvedByTRR,
                        ResourceTimingStruct timing);
 
   // Used to cancel child channel if we hit errors during creating and
   // AsyncOpen of nsHttpChannel on the parent.
   async FailedAsyncOpen(nsresult status);
 
   // Called to initiate content channel redirect, starts talking to sinks
   // on the content process and reports result via Redirect2Verify above
--- a/netwerk/protocol/http/nsHttpChannel.h
+++ b/netwerk/protocol/http/nsHttpChannel.h
@@ -717,20 +717,16 @@ class nsHttpChannel final : public HttpB
   // to the safe-browsing classifier rules, but the asynchronous cancellation
   // process hasn't finished yet.
   uint32_t mChannelClassifierCancellationPending : 1;
 
   // True only when we are between Resume and async fire of mCallOnResume.
   // Used to suspend any newly created pumps in mCallOnResume handler.
   uint32_t mAsyncResumePending : 1;
 
-  // If the request was performed to a TRR resolved IP address.
-  // Will be false if loaded from the cache.
-  uint32_t mResolvedByTRR : 1;
-
   // True only when we have checked whether this channel has been isolated for
   // anti-tracking purposes.
   uint32_t mHasBeenIsolatedChecked : 1;
   // True only when we have determined this channel should be isolated for
   // anti-tracking purposes.  Can never ben true unless mHasBeenIsolatedChecked
   // is true.
   uint32_t mIsIsolated : 1;
 
--- a/netwerk/protocol/http/nsIHttpChannelInternal.idl
+++ b/netwerk/protocol/http/nsIHttpChannelInternal.idl
@@ -241,16 +241,23 @@ interface nsIHttpChannelInternal : nsISu
 
     /**
      * True if channel is used by the internal trusted recursive resolver
      * This flag places data for the request in a cache segment specific to TRR
      */
     [noscript, must_use] attribute boolean isTRRServiceChannel;
 
     /**
+     * If the channel's remote IP was resolved using TRR.
+     * Is false for resources loaded from the cache or resources that have an
+     * IP literal host.
+     */
+    [noscript, must_use] readonly attribute boolean isResolvedByTRR;
+
+    /**
      * An opaque flags for non-standard behavior of the TLS system.
      * It is unlikely this will need to be set outside of telemetry studies
      * relating to the TLS implementation.
      */
     [must_use] attribute unsigned long tlsFlags;
 
     [must_use] readonly attribute PRTime lastModifiedTime;