Bug 1406253 - Part 1: Rename imgIRequest.currentURI to finalURI to prevent confusion. r=bz
☠☠ backed out by 8794becbd0cb ☠ ☠
authorSamael Wang <freesamael@gmail.com>
Mon, 13 Nov 2017 16:31:24 +0800
changeset 392675 9ce01198e8a128e4c53a4adbfd643dbb857ad38b
parent 392674 48d015dec45aea204878154bbb00f99965b78b71
child 392676 aecb3d509a39cf61df2a934494bece60e552d13b
push id32939
push usercsabou@mozilla.com
push dateMon, 20 Nov 2017 21:59:19 +0000
treeherdermozilla-central@0bbed2e6a4cc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1406253
milestone59.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 1406253 - Part 1: Rename imgIRequest.currentURI to finalURI to prevent confusion. r=bz The "current URL" in the spec: https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-currentsrc maps to imgIRequest.URI, not currentURI. Rename imgIRequest.currentURI to finalURI to prevent such confusion. MozReview-Commit-ID: CjBh2V4z8K9
image/imgIRequest.idl
image/imgLoader.cpp
image/imgRequest.cpp
image/imgRequest.h
image/imgRequestProxy.cpp
--- a/image/imgIRequest.idl
+++ b/image/imgIRequest.idl
@@ -83,17 +83,17 @@ interface imgIRequest : nsIRequest
    * actual URI for the image (e.g. if HTTP redirects happened during the
    * load).
    */
   readonly attribute nsIURI URI;
 
   /**
    * The URI of the resource we ended up loading after all redirects, etc.
    */
-  readonly attribute nsIURI currentURI;
+  readonly attribute nsIURI finalURI;
 
   readonly attribute imgINotificationObserver notificationObserver;
 
   readonly attribute string mimeType;
 
   /**
    * Clone this request; the returned request will have aObserver as the
    * observer.  aObserver will be notified synchronously (before the clone()
--- a/image/imgLoader.cpp
+++ b/image/imgLoader.cpp
@@ -615,24 +615,24 @@ ShouldLoadCachedImage(imgRequest* aImgRe
                       nsISupports* aLoadingContext,
                       nsIPrincipal* aTriggeringPrincipal,
                       nsContentPolicyType aPolicyType)
 {
   /* Call content policies on cached images - Bug 1082837
    * Cached images are keyed off of the first uri in a redirect chain.
    * Hence content policies don't get a chance to test the intermediate hops
    * or the final desitnation.  Here we test the final destination using
-   * mCurrentURI off of the imgRequest and passing it into content policies.
+   * mFinalURI off of the imgRequest and passing it into content policies.
    * For Mixed Content Blocker, we do an additional check to determine if any
    * of the intermediary hops went through an insecure redirect with the
    * mHadInsecureRedirect flag
    */
   bool insecureRedirect = aImgRequest->HadInsecureRedirect();
   nsCOMPtr<nsIURI> contentLocation;
-  aImgRequest->GetCurrentURI(getter_AddRefs(contentLocation));
+  aImgRequest->GetFinalURI(getter_AddRefs(contentLocation));
   nsresult rv;
 
   int16_t decision = nsIContentPolicy::REJECT_REQUEST;
   rv = NS_CheckContentLoadPolicy(aPolicyType,
                                  contentLocation,
                                  aTriggeringPrincipal, // loading principal
                                  aTriggeringPrincipal,
                                  aLoadingContext,
@@ -2980,22 +2980,22 @@ imgCacheValidator::OnStartRequest(nsIReq
   nsCOMPtr<nsIChannel> channel(do_QueryInterface(aRequest));
   if (cacheChan && channel && !mRequest->CacheChanged(aRequest)) {
     bool isFromCache = false;
     cacheChan->IsFromCache(&isFromCache);
 
     nsCOMPtr<nsIURI> channelURI;
     channel->GetURI(getter_AddRefs(channelURI));
 
-    nsCOMPtr<nsIURI> currentURI;
-    mRequest->GetCurrentURI(getter_AddRefs(currentURI));
+    nsCOMPtr<nsIURI> finalURI;
+    mRequest->GetFinalURI(getter_AddRefs(finalURI));
 
     bool sameURI = false;
-    if (channelURI && currentURI) {
-      channelURI->Equals(currentURI, &sameURI);
+    if (channelURI && finalURI) {
+      channelURI->Equals(finalURI, &sameURI);
     }
 
     if (isFromCache && sameURI) {
       uint32_t count = mProxies.Count();
       for (int32_t i = count-1; i>=0; i--) {
         imgRequestProxy* proxy = static_cast<imgRequestProxy*>(mProxies[i]);
 
         // Proxies waiting on cache validation should be deferring
--- a/image/imgRequest.cpp
+++ b/image/imgRequest.cpp
@@ -84,57 +84,57 @@ imgRequest::~imgRequest()
     LOG_FUNC_WITH_PARAM(gImgLog, "imgRequest::~imgRequest()",
                         "keyuri", spec.get());
   } else
     LOG_FUNC(gImgLog, "imgRequest::~imgRequest()");
 }
 
 nsresult
 imgRequest::Init(nsIURI *aURI,
-                 nsIURI *aCurrentURI,
+                 nsIURI *aFinalURI,
                  bool aHadInsecureRedirect,
                  nsIRequest *aRequest,
                  nsIChannel *aChannel,
                  imgCacheEntry *aCacheEntry,
                  nsISupports* aCX,
                  nsIPrincipal* aTriggeringPrincipal,
                  int32_t aCORSMode,
                  ReferrerPolicy aReferrerPolicy)
 {
   MOZ_ASSERT(NS_IsMainThread(), "Cannot use nsIURI off main thread!");
 
   LOG_FUNC(gImgLog, "imgRequest::Init");
 
   MOZ_ASSERT(!mImage, "Multiple calls to init");
   MOZ_ASSERT(aURI, "No uri");
-  MOZ_ASSERT(aCurrentURI, "No current uri");
+  MOZ_ASSERT(aFinalURI, "No final uri");
   MOZ_ASSERT(aRequest, "No request");
   MOZ_ASSERT(aChannel, "No channel");
 
   mProperties = do_CreateInstance("@mozilla.org/properties;1");
 
   // Use ImageURL to ensure access to URI data off main thread.
   nsresult rv;
   mURI = new ImageURL(aURI, rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  mCurrentURI = aCurrentURI;
+  mFinalURI = aFinalURI;
   mRequest = aRequest;
   mChannel = aChannel;
   mTimedChannel = do_QueryInterface(mChannel);
 
   mTriggeringPrincipal = aTriggeringPrincipal;
   mCORSMode = aCORSMode;
   mReferrerPolicy = aReferrerPolicy;
 
-  // If the original URI and the current URI are different, check whether the
-  // original URI is secure. We deliberately don't take the current URI into
+  // If the original URI and the final URI are different, check whether the
+  // original URI is secure. We deliberately don't take the final URI into
   // account, as it needs to be handled using more complicated rules than
   // earlier elements of the redirect chain.
-  if (aURI != aCurrentURI) {
+  if (aURI != aFinalURI) {
     bool isHttps = false;
     bool isChrome = false;
     bool schemeLocal = false;
     if (NS_FAILED(aURI->SchemeIs("https", &isHttps)) ||
         NS_FAILED(aURI->SchemeIs("chrome", &isChrome)) ||
         NS_FAILED(NS_URIChainHasFlags(
                   aURI,
                   nsIProtocolHandler::URI_IS_LOCAL_RESOURCE , &schemeLocal))  ||
@@ -432,24 +432,24 @@ nsresult imgRequest::GetURI(ImageURL** a
     NS_ADDREF(*aURI);
     return NS_OK;
   }
 
   return NS_ERROR_FAILURE;
 }
 
 nsresult
-imgRequest::GetCurrentURI(nsIURI** aURI)
+imgRequest::GetFinalURI(nsIURI** aURI)
 {
   MOZ_ASSERT(aURI);
 
-  LOG_FUNC(gImgLog, "imgRequest::GetCurrentURI");
+  LOG_FUNC(gImgLog, "imgRequest::GetFinalURI");
 
-  if (mCurrentURI) {
-    *aURI = mCurrentURI;
+  if (mFinalURI) {
+    *aURI = mFinalURI;
     NS_ADDREF(*aURI);
     return NS_OK;
   }
 
   return NS_ERROR_FAILURE;
 }
 
 bool
@@ -1317,29 +1317,29 @@ imgRequest::OnRedirectVerifyCallback(nsr
 
   mChannel = mNewRedirectChannel;
   mTimedChannel = do_QueryInterface(mChannel);
   mNewRedirectChannel = nullptr;
 
   if (LOG_TEST(LogLevel::Debug)) {
     LOG_MSG_WITH_PARAM(gImgLog,
                        "imgRequest::OnChannelRedirect", "old",
-                       mCurrentURI ? mCurrentURI->GetSpecOrDefault().get()
-                                   : "");
+                       mFinalURI ? mFinalURI->GetSpecOrDefault().get()
+                                 : "");
   }
 
   // If the previous URI is a non-HTTPS URI, record that fact for later use by
   // security code, which needs to know whether there is an insecure load at any
   // point in the redirect chain.
   bool isHttps = false;
   bool isChrome = false;
   bool schemeLocal = false;
-  if (NS_FAILED(mCurrentURI->SchemeIs("https", &isHttps)) ||
-      NS_FAILED(mCurrentURI->SchemeIs("chrome", &isChrome)) ||
-      NS_FAILED(NS_URIChainHasFlags(mCurrentURI,
+  if (NS_FAILED(mFinalURI->SchemeIs("https", &isHttps)) ||
+      NS_FAILED(mFinalURI->SchemeIs("chrome", &isChrome)) ||
+      NS_FAILED(NS_URIChainHasFlags(mFinalURI,
                                     nsIProtocolHandler::URI_IS_LOCAL_RESOURCE,
                                     &schemeLocal))  ||
       (!isHttps && !isChrome && !schemeLocal)) {
     MutexAutoLock lock(mMutex);
 
     // The csp directive upgrade-insecure-requests performs an internal redirect
     // to upgrade all requests from http to https before any data is fetched from
     // the network. Do not pollute mHadInsecureRedirect in case of such an internal
@@ -1347,30 +1347,30 @@ imgRequest::OnRedirectVerifyCallback(nsr
     nsCOMPtr<nsILoadInfo> loadInfo = mChannel->GetLoadInfo();
     bool upgradeInsecureRequests = loadInfo ? loadInfo->GetUpgradeInsecureRequests()
                                             : false;
     if (!upgradeInsecureRequests) {
       mHadInsecureRedirect = true;
     }
   }
 
-  // Update the current URI.
-  mChannel->GetURI(getter_AddRefs(mCurrentURI));
+  // Update the final URI.
+  mChannel->GetURI(getter_AddRefs(mFinalURI));
 
   if (LOG_TEST(LogLevel::Debug)) {
     LOG_MSG_WITH_PARAM(gImgLog, "imgRequest::OnChannelRedirect", "new",
-                       mCurrentURI ? mCurrentURI->GetSpecOrDefault().get()
-                                   : "");
+                       mFinalURI ? mFinalURI->GetSpecOrDefault().get()
+                                 : "");
   }
 
   // Make sure we have a protocol that returns data rather than opens an
   // external application, e.g. 'mailto:'.
   bool doesNotReturnData = false;
   nsresult rv =
-    NS_URIChainHasFlags(mCurrentURI,
+    NS_URIChainHasFlags(mFinalURI,
                         nsIProtocolHandler::URI_DOES_NOT_RETURN_DATA,
                         &doesNotReturnData);
 
   if (NS_SUCCEEDED(rv) && doesNotReturnData) {
     rv = NS_ERROR_ABORT;
   }
 
   if (NS_FAILED(rv)) {
--- a/image/imgRequest.h
+++ b/image/imgRequest.h
@@ -61,17 +61,17 @@ public:
   NS_DECL_NSISTREAMLISTENER
   NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
   NS_DECL_NSIREQUESTOBSERVER
   NS_DECL_NSICHANNELEVENTSINK
   NS_DECL_NSIINTERFACEREQUESTOR
   NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK
 
   MOZ_MUST_USE nsresult Init(nsIURI* aURI,
-                             nsIURI* aCurrentURI,
+                             nsIURI* aFinalURI,
                              bool aHadInsecureRedirect,
                              nsIRequest* aRequest,
                              nsIChannel* aChannel,
                              imgCacheEntry* aCacheEntry,
                              nsISupports* aCX,
                              nsIPrincipal* aTriggeringPrincipal,
                              int32_t aCORSMode,
                              ReferrerPolicy aReferrerPolicy);
@@ -111,17 +111,17 @@ public:
   // application cache of the new load.  Also lack of application cache
   // on one of the loads is considered a change of a loading cache since
   // HTTP cache may contain a different data then app cache.
   bool CacheChanged(nsIRequest* aNewRequest);
 
   bool GetMultipart() const;
 
   // Returns whether we went through an insecure (non-HTTPS) redirect at some
-  // point during loading. This does not consider the current URI.
+  // point during loading. This does not consider the final URI.
   bool HadInsecureRedirect() const;
 
   // The CORS mode for which we loaded this image.
   int32_t GetCORSMode() const { return mCORSMode; }
 
   // The Referrer Policy in effect when loading this image.
   ReferrerPolicy GetReferrerPolicy() const { return mReferrerPolicy; }
 
@@ -147,17 +147,17 @@ public:
   /// Get the ImageCacheKey associated with this request.
   const ImageCacheKey& CacheKey() const { return mCacheKey; }
 
   // Resize the cache entry to 0 if it exists
   void ResetCacheEntry();
 
   // OK to use on any thread.
   nsresult GetURI(ImageURL** aURI);
-  nsresult GetCurrentURI(nsIURI** aURI);
+  nsresult GetFinalURI(nsIURI** aURI);
   bool IsScheme(const char* aScheme) const;
   bool IsChrome() const;
   bool IsData() const;
 
   nsresult GetImageErrorCode(void);
 
   /// Returns true if we've received any data.
   bool HasTransferredData() const;
@@ -232,17 +232,17 @@ private:
   // Weak reference to parent loader; this request cannot outlive its owner.
   imgLoader* mLoader;
   nsCOMPtr<nsIRequest> mRequest;
   // The original URI we were loaded with. This is the same as the URI we are
   // keyed on in the cache. We store a string here to avoid off main thread
   // refcounting issues with nsStandardURL.
   RefPtr<ImageURL> mURI;
   // The URI of the resource we ended up loading after all redirects, etc.
-  nsCOMPtr<nsIURI> mCurrentURI;
+  nsCOMPtr<nsIURI> mFinalURI;
   // The principal which triggered the load of this image. Generally either
   // the principal of the document the image is being loaded into, or of the
   // stylesheet which specified the image to load. Used when validating for CORS.
   nsCOMPtr<nsIPrincipal> mTriggeringPrincipal;
   // The principal of this image.
   nsCOMPtr<nsIPrincipal> mPrincipal;
   nsCOMPtr<nsIProperties> mProperties;
   nsCOMPtr<nsISupports> mSecurityInfo;
--- a/image/imgRequestProxy.cpp
+++ b/image/imgRequestProxy.cpp
@@ -740,23 +740,23 @@ imgRequestProxy::GetURI(nsIURI** aURI)
 {
   MOZ_ASSERT(NS_IsMainThread(), "Must be on main thread to convert URI");
   nsCOMPtr<nsIURI> uri = mURI->ToIURI();
   uri.forget(aURI);
   return NS_OK;
 }
 
 nsresult
-imgRequestProxy::GetCurrentURI(nsIURI** aURI)
+imgRequestProxy::GetFinalURI(nsIURI** aURI)
 {
   if (!GetOwner()) {
     return NS_ERROR_FAILURE;
   }
 
-  return GetOwner()->GetCurrentURI(aURI);
+  return GetOwner()->GetFinalURI(aURI);
 }
 
 nsresult
 imgRequestProxy::GetURI(ImageURL** aURI)
 {
   if (!mURI) {
     return NS_ERROR_FAILURE;
   }