Bug 1119005 - No need to branch on NewChannelinternal callsites anymore - callsite updated (r=sicking)
authorChristoph Kerschbaumer <mozilla@christophkerschbaumer.com>
Thu, 19 Feb 2015 11:47:59 -0800
changeset 229938 2144c24dfa0169e3c3e44e22a2f13d6f9e92323b
parent 229937 9d623faf8c8b065dc0c18256e51a23daf75e8321
child 229939 f835c33057fd491c2d88430102938bf48d27b1c9
push id55844
push usermozilla@christophkerschbaumer.com
push dateFri, 20 Feb 2015 00:55:10 +0000
treeherdermozilla-inbound@2144c24dfa01 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs1119005
milestone38.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 1119005 - No need to branch on NewChannelinternal callsites anymore - callsite updated (r=sicking)
browser/components/about/AboutRedirector.cpp
chrome/nsChromeProtocolHandler.cpp
docshell/base/nsAboutRedirector.cpp
dom/base/nsHostObjectProtocolHandler.cpp
extensions/gio/nsGIOProtocolHandler.cpp
modules/libjar/nsJARChannel.cpp
netwerk/protocol/about/nsAboutBlank.cpp
netwerk/protocol/about/nsAboutBloat.cpp
netwerk/protocol/about/nsAboutCache.cpp
netwerk/protocol/about/nsAboutCacheEntry.cpp
netwerk/protocol/res/nsResProtocolHandler.cpp
toolkit/components/places/nsAnnoProtocolHandler.cpp
--- a/browser/components/about/AboutRedirector.cpp
+++ b/browser/components/about/AboutRedirector.cpp
@@ -158,28 +158,19 @@ AboutRedirector::NewChannel(nsIURI* aURI
 
   for (int i = 0; i < kRedirTotal; i++) {
     if (!strcmp(path.get(), kRedirMap[i].id)) {
       nsCOMPtr<nsIChannel> tempChannel;
       nsCOMPtr<nsIURI> tempURI;
       rv = NS_NewURI(getter_AddRefs(tempURI),
                      nsDependentCString(kRedirMap[i].url));
       NS_ENSURE_SUCCESS(rv, rv);
-      // Bug 1087720 (and Bug 1099296):
-      // Once all callsites have been updated to call NewChannel2()
-      // instead of NewChannel() we should have a non-null loadInfo
-      // consistently. Until then we have to branch on the loadInfo.
-      if (aLoadInfo) {
-        rv = NS_NewChannelInternal(getter_AddRefs(tempChannel),
-                                   tempURI,
-                                   aLoadInfo);
-      }
-      else {
-        rv = ioService->NewChannelFromURI(tempURI, getter_AddRefs(tempChannel));
-      }
+      rv = NS_NewChannelInternal(getter_AddRefs(tempChannel),
+                                 tempURI,
+                                 aLoadInfo);
       NS_ENSURE_SUCCESS(rv, rv);
 
       tempChannel->SetOriginalURI(aURI);
 
       NS_ADDREF(*result = tempChannel);
       return rv;
     }
   }
--- a/chrome/nsChromeProtocolHandler.cpp
+++ b/chrome/nsChromeProtocolHandler.cpp
@@ -142,30 +142,19 @@ nsChromeProtocolHandler::NewChannel2(nsI
 #ifdef DEBUG
         nsAutoCString spec;
         aURI->GetSpec(spec);
         printf("Couldn't convert chrome URL: %s\n", spec.get());
 #endif
         return rv;
     }
 
-    // Bug 1087720 (and Bug 1099296):
-    // Once all callsites have been updated to call NewChannel2() instead of NewChannel()
-    // we should have a non-null loadInfo consistently. Until then we have to branch on the
-    // loadInfo.
-    if (aLoadInfo) {
-        rv = NS_NewChannelInternal(getter_AddRefs(result),
-                                   resolvedURI,
-                                   aLoadInfo);
-    }
-    else {
-        nsCOMPtr<nsIIOService> ioServ(do_GetIOService(&rv));
-        NS_ENSURE_SUCCESS(rv, rv);
-        rv = ioServ->NewChannelFromURI(resolvedURI, getter_AddRefs(result));
-    }
+    rv = NS_NewChannelInternal(getter_AddRefs(result),
+                               resolvedURI,
+                               aLoadInfo);
     NS_ENSURE_SUCCESS(rv, rv);
 
 #ifdef DEBUG
     nsCOMPtr<nsIFileChannel> fileChan(do_QueryInterface(result));
     if (fileChan) {
         nsCOMPtr<nsIFile> file;
         fileChan->GetFile(getter_AddRefs(file));
 
--- a/docshell/base/nsAboutRedirector.cpp
+++ b/docshell/base/nsAboutRedirector.cpp
@@ -126,27 +126,19 @@ nsAboutRedirector::NewChannel(nsIURI* aU
   NS_ENSURE_SUCCESS(rv, rv);
 
   for (int i = 0; i < kRedirTotal; i++) {
     if (!strcmp(path.get(), kRedirMap[i].id)) {
       nsCOMPtr<nsIChannel> tempChannel;
       nsCOMPtr<nsIURI> tempURI;
       rv = NS_NewURI(getter_AddRefs(tempURI), kRedirMap[i].url);
       NS_ENSURE_SUCCESS(rv, rv);
-      // Bug 1087720 (and Bug 1099296):
-      // Once all callsites have been updated to call NewChannel2()
-      // instead of NewChannel() we should have a non-null loadInfo
-      // consistently. Until then we have to branch on the loadInfo.
-      if (aLoadInfo) {
-        rv = NS_NewChannelInternal(getter_AddRefs(tempChannel),
-                                   tempURI,
-                                   aLoadInfo);
-      } else {
-        rv = ioService->NewChannelFromURI(tempURI, getter_AddRefs(tempChannel));
-      }
+      rv = NS_NewChannelInternal(getter_AddRefs(tempChannel),
+                                 tempURI,
+                                 aLoadInfo);
       if (NS_FAILED(rv)) {
         return rv;
       }
 
       tempChannel->SetOriginalURI(aURI);
 
       NS_ADDREF(*aResult = tempChannel);
       return rv;
--- a/dom/base/nsHostObjectProtocolHandler.cpp
+++ b/dom/base/nsHostObjectProtocolHandler.cpp
@@ -513,36 +513,22 @@ nsHostObjectProtocolHandler::NewChannel2
   }
 #endif
 
   nsCOMPtr<nsIInputStream> stream;
   nsresult rv = blob->GetInternalStream(getter_AddRefs(stream));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIChannel> channel;
-  // Bug 1087720 (and Bug 1099296):
-  // Once all callsites have been updated to call NewChannel2() instead of NewChannel()
-  // we should have a non-null loadInfo consistently. Until then we have to brach on the
-  // loadInfo and provide default arguments to create a NewInputStreamChannel.
-  if (aLoadInfo) {
-    rv = NS_NewInputStreamChannelInternal(getter_AddRefs(channel),
-                                          uri,
-                                          stream,
-                                          EmptyCString(), // aContentType
-                                          EmptyCString(), // aContentCharset
-                                          aLoadInfo);
-  }
-  else {
-    rv = NS_NewInputStreamChannel(getter_AddRefs(channel),
-                                  uri,
-                                  stream,
-                                  info->mPrincipal,
-                                  nsILoadInfo::SEC_NORMAL,
-                                  nsIContentPolicy::TYPE_OTHER);
-  }
+  rv = NS_NewInputStreamChannelInternal(getter_AddRefs(channel),
+                                        uri,
+                                        stream,
+                                        EmptyCString(), // aContentType
+                                        EmptyCString(), // aContentCharset
+                                        aLoadInfo);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsString type;
   blob->GetType(type);
 
   if (blob->IsFile()) {
     nsString filename;
     blob->GetName(filename);
--- a/extensions/gio/nsGIOProtocolHandler.cpp
+++ b/extensions/gio/nsGIOProtocolHandler.cpp
@@ -1058,43 +1058,22 @@ nsGIOProtocolHandler::NewChannel2(nsIURI
   if (NS_FAILED(rv))
     return rv;
 
   nsRefPtr<nsGIOInputStream> stream = new nsGIOInputStream(spec);
   if (!stream) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  // Bug 1087720 (and Bug 1099296):
-  // Once all callsites have been updated to call NewChannel2() instead of NewChannel()
-  // we should have a non-null loadInfo consistently. Until then we have to brach on the
-  // loadInfo and provide default arguments to create a NewInputStreamChannel.
-  if (aLoadInfo) {
-    rv = NS_NewInputStreamChannelInternal(aResult,
-                                          aURI,
-                                          stream,
-                                          NS_LITERAL_CSTRING(UNKNOWN_CONTENT_TYPE),
-                                          EmptyCString(), // aContentCharset
-                                          aLoadInfo);
-  }
-  else {
-    nsCOMPtr<nsIPrincipal> nullPrincipal =
-      do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    // start out assuming an unknown content-type.  we'll set the content-type
-    // to something better once we open the URI.
-    rv = NS_NewInputStreamChannel(aResult,
-                                  aURI,
-                                  stream,
-                                  nullPrincipal,
-                                  nsILoadInfo::SEC_NORMAL,
-                                  nsIContentPolicy::TYPE_OTHER,
-                                  NS_LITERAL_CSTRING(UNKNOWN_CONTENT_TYPE));
-  }
+  rv = NS_NewInputStreamChannelInternal(aResult,
+                                        aURI,
+                                        stream,
+                                        NS_LITERAL_CSTRING(UNKNOWN_CONTENT_TYPE),
+                                        EmptyCString(), // aContentCharset
+                                        aLoadInfo);
   if (NS_SUCCEEDED(rv)) {
     stream->SetChannel(*aResult);
   }
   return rv;
 }
 
 NS_IMETHODIMP
 nsGIOProtocolHandler::NewChannel(nsIURI *aURI, nsIChannel **aResult)
--- a/modules/libjar/nsJARChannel.cpp
+++ b/modules/libjar/nsJARChannel.cpp
@@ -867,33 +867,22 @@ nsJARChannel::AsyncOpen(nsIStreamListene
         // Not a local file...
         // kick off an async download of the base URI...
         rv = NS_NewDownloader(getter_AddRefs(mDownloader), this);
         if (NS_SUCCEEDED(rv)) {
             // Since we might not have a loadinfo on all channels yet
             // we have to provide default arguments in case mLoadInfo is null;
             uint32_t loadFlags =
               mLoadFlags & ~(LOAD_DOCUMENT_URI | LOAD_CALL_CONTENT_SNIFFERS);
-            if (mLoadInfo) {
-              rv = NS_NewChannelInternal(getter_AddRefs(channel),
-                                         mJarBaseURI,
-                                         mLoadInfo,
-                                         mLoadGroup,
-                                         mCallbacks,
-                                         loadFlags);
-            } else {
-              rv = NS_NewChannel(getter_AddRefs(channel),
-                                 mJarBaseURI,
-                                 nsContentUtils::GetSystemPrincipal(),
-                                 nsILoadInfo::SEC_NORMAL,
-                                 nsIContentPolicy::TYPE_OTHER,
-                                 mLoadGroup,
-                                 mCallbacks,
-                                 loadFlags);
-            }
+            rv = NS_NewChannelInternal(getter_AddRefs(channel),
+                                       mJarBaseURI,
+                                       mLoadInfo,
+                                       mLoadGroup,
+                                       mCallbacks,
+                                       loadFlags);
             if (NS_FAILED(rv)) {
               mIsPending = false;
               mListenerContext = nullptr;
               mListener = nullptr;
               return rv;
             }
             channel->AsyncOpen(mDownloader, nullptr);
         }
--- a/netwerk/protocol/about/nsAboutBlank.cpp
+++ b/netwerk/protocol/about/nsAboutBlank.cpp
@@ -18,38 +18,22 @@ nsAboutBlank::NewChannel(nsIURI* aURI,
 {
     NS_ENSURE_ARG_POINTER(aURI);
 
     nsCOMPtr<nsIInputStream> in;
     nsresult rv = NS_NewCStringInputStream(getter_AddRefs(in), EmptyCString());
     if (NS_FAILED(rv)) return rv;
 
     nsCOMPtr<nsIChannel> channel;
-    // Bug 1087720 (and Bug 1099296):
-    // Once all callsites have been updated to call NewChannel2()
-    // instead of NewChannel() we should have a non-null loadInfo
-    // consistently. Until then we have to branch on the loadInfo.
-    if (aLoadInfo) {
-      rv = NS_NewInputStreamChannelInternal(getter_AddRefs(channel),
-                                            aURI,
-                                            in,
-                                            NS_LITERAL_CSTRING("text/html"),
-                                            NS_LITERAL_CSTRING("utf-8"),
-                                            aLoadInfo);
-    }
-    else {
-      rv = NS_NewInputStreamChannel(getter_AddRefs(channel),
-                                    aURI,
-                                    in,
-                                    nsContentUtils::GetSystemPrincipal(),
-                                    nsILoadInfo::SEC_NORMAL,
-                                    nsIContentPolicy::TYPE_OTHER,
-                                    NS_LITERAL_CSTRING("text/html"),
-                                    NS_LITERAL_CSTRING("utf-8"));
-    }
+    rv = NS_NewInputStreamChannelInternal(getter_AddRefs(channel),
+                                          aURI,
+                                          in,
+                                          NS_LITERAL_CSTRING("text/html"),
+                                          NS_LITERAL_CSTRING("utf-8"),
+                                          aLoadInfo);
     if (NS_FAILED(rv)) return rv;
 
     channel.forget(result);
     return rv;
 }
 
 NS_IMETHODIMP
 nsAboutBlank::GetURIFlags(nsIURI *aURI, uint32_t *result)
--- a/netwerk/protocol/about/nsAboutBloat.cpp
+++ b/netwerk/protocol/about/nsAboutBloat.cpp
@@ -107,38 +107,22 @@ nsAboutBloat::NewChannel(nsIURI* aURI,
         ::fclose(out);
         if (NS_FAILED(rv)) return rv;
 
         rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), file);
         if (NS_FAILED(rv)) return rv;
     }
 
     nsIChannel* channel = nullptr;
-    // Bug 1087720 (and Bug 1099296):
-    // Once all callsites have been updated to call NewChannel2()
-    // instead of NewChannel() we should have a non-null loadInfo
-    // consistently. Until then we have to branch on the loadInfo.
-    if (aLoadInfo) {
-      rv = NS_NewInputStreamChannelInternal(&channel,
-                                            aURI,
-                                            inStr,
-                                            NS_LITERAL_CSTRING("text/plain"),
-                                            NS_LITERAL_CSTRING("utf-8"),
-                                            aLoadInfo);
-    }
-    else {
-      rv = NS_NewInputStreamChannel(&channel,
-                                    aURI,
-                                    inStr,
-                                    nsContentUtils::GetSystemPrincipal(),
-                                    nsILoadInfo::SEC_NORMAL,
-                                    nsIContentPolicy::TYPE_OTHER,
-                                    NS_LITERAL_CSTRING("text/plain"),
-                                    NS_LITERAL_CSTRING("utf-8"));
-    }
+    rv = NS_NewInputStreamChannelInternal(&channel,
+                                          aURI,
+                                          inStr,
+                                          NS_LITERAL_CSTRING("text/plain"),
+                                          NS_LITERAL_CSTRING("utf-8"),
+                                          aLoadInfo);
     if (NS_FAILED(rv)) return rv;
 
     *result = channel;
     return rv;
 }
 
 NS_IMETHODIMP
 nsAboutBloat::GetURIFlags(nsIURI *aURI, uint32_t *result)
--- a/netwerk/protocol/about/nsAboutCache.cpp
+++ b/netwerk/protocol/about/nsAboutCache.cpp
@@ -59,38 +59,22 @@ nsAboutCache::NewChannel(nsIURI* aURI,
         // ...and visit just the specified storage, entries will output too
         mStorageList.AppendElement(storageName);
     }
 
     // The entries header is added on encounter of the first entry
     mEntriesHeaderAdded = false;
 
     nsCOMPtr<nsIChannel> channel;
-    // Bug 1087720 (and Bug 1099296):
-    // Once all callsites have been updated to call NewChannel2()
-    // instead of NewChannel() we should have a non-null loadInfo
-    // consistently. Until then we have to branch on the loadInfo.
-    if (aLoadInfo) {
-      rv = NS_NewInputStreamChannelInternal(getter_AddRefs(channel),
-                                            aURI,
-                                            inputStream,
-                                            NS_LITERAL_CSTRING("text/html"),
-                                            NS_LITERAL_CSTRING("utf-8"),
-                                            aLoadInfo);
-    }
-    else {
-      rv = NS_NewInputStreamChannel(getter_AddRefs(channel),
-                            aURI,
-                            inputStream,
-                            nsContentUtils::GetSystemPrincipal(),
-                            nsILoadInfo::SEC_NORMAL,
-                            nsIContentPolicy::TYPE_OTHER,
-                            NS_LITERAL_CSTRING("text/html"),
-                            NS_LITERAL_CSTRING("utf-8"));
-    }
+    rv = NS_NewInputStreamChannelInternal(getter_AddRefs(channel),
+                                          aURI,
+                                          inputStream,
+                                          NS_LITERAL_CSTRING("text/html"),
+                                          NS_LITERAL_CSTRING("utf-8"),
+                                          aLoadInfo);
     if (NS_FAILED(rv)) return rv;
 
     mBuffer.AssignLiteral(
         "<!DOCTYPE html>\n"
         "<html>\n"
         "<head>\n"
         "  <title>Network Cache Storage Information</title>\n"
         "  <meta charset=\"utf-8\">\n"
--- a/netwerk/protocol/about/nsAboutCacheEntry.cpp
+++ b/netwerk/protocol/about/nsAboutCacheEntry.cpp
@@ -94,36 +94,22 @@ nsAboutCacheEntry::NewChannel(nsIURI* ur
                               nsIChannel** result)
 {
     NS_ENSURE_ARG_POINTER(uri);
     nsresult rv;
 
     nsCOMPtr<nsIInputStream> stream;
     rv = GetContentStream(uri, getter_AddRefs(stream));
     if (NS_FAILED(rv)) return rv;
-    // Bug 1087720 (and Bug 1099296):
-    // Once all callsites have been updated to call NewChannel2()
-    // instead of NewChannel() we should have a non-null loadInfo
-    // consistently. Until then we have to branch on the loadInfo.
-    if (aLoadInfo) {
-      return NS_NewInputStreamChannelInternal(result,
-                                              uri,
-                                              stream,
-                                              NS_LITERAL_CSTRING("text/html"),
-                                              NS_LITERAL_CSTRING("utf-8"),
-                                              aLoadInfo);
-    }
-    return NS_NewInputStreamChannel(result,
-                                    uri,
-                                    stream,
-                                    nsContentUtils::GetSystemPrincipal(),
-                                    nsILoadInfo::SEC_NORMAL,
-                                    nsIContentPolicy::TYPE_OTHER,
-                                    NS_LITERAL_CSTRING("text/html"),
-                                    NS_LITERAL_CSTRING("utf-8"));
+    return NS_NewInputStreamChannelInternal(result,
+                                            uri,
+                                            stream,
+                                            NS_LITERAL_CSTRING("text/html"),
+                                            NS_LITERAL_CSTRING("utf-8"),
+                                            aLoadInfo);
 }
 
 NS_IMETHODIMP
 nsAboutCacheEntry::GetURIFlags(nsIURI *aURI, uint32_t *result)
 {
     *result = nsIAboutModule::HIDE_FROM_ABOUTABOUT;
     return NS_OK;
 }
--- a/netwerk/protocol/res/nsResProtocolHandler.cpp
+++ b/netwerk/protocol/res/nsResProtocolHandler.cpp
@@ -283,32 +283,23 @@ nsResProtocolHandler::NewChannel2(nsIURI
                                   nsILoadInfo* aLoadInfo,
                                   nsIChannel** result)
 {
     NS_ENSURE_ARG_POINTER(uri);
     nsAutoCString spec;
     nsresult rv = ResolveURI(uri, spec);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    // Bug 1087720 (and Bug 1099296):
-    // Once all callsites have been updated to call NewChannel2() instead of NewChannel()
-    // we should have a non-null loadInfo consistently. Until then we have to branch on the
-    // loadInfo.
     nsCOMPtr<nsIURI> newURI;
     rv = NS_NewURI(getter_AddRefs(newURI), spec);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    if (aLoadInfo) {
-        rv = NS_NewChannelInternal(result,
-                                   newURI,
-                                   aLoadInfo);
-    }
-    else {
-        rv = mIOService->NewChannelFromURI(newURI, result);
-    }
+    rv = NS_NewChannelInternal(result,
+                               newURI,
+                               aLoadInfo);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsLoadFlags loadFlags = 0;
     (*result)->GetLoadFlags(&loadFlags);
     (*result)->SetLoadFlags(loadFlags & ~nsIChannel::LOAD_REPLACE);
     return (*result)->SetOriginalURI(uri);
 }
 
--- a/toolkit/components/places/nsAnnoProtocolHandler.cpp
+++ b/toolkit/components/places/nsAnnoProtocolHandler.cpp
@@ -338,36 +338,22 @@ nsAnnoProtocolHandler::NewFaviconChannel
                            getter_AddRefs(outputStream),
                            MAX_FAVICON_SIZE, MAX_FAVICON_SIZE, true,
                            true);
   NS_ENSURE_SUCCESS(rv, GetDefaultIcon(_channel));
 
   // Create our channel.  We'll call SetContentType with the right type when
   // we know what it actually is.
   nsCOMPtr<nsIChannel> channel;
-  // Bug 1087720 (and Bug 1099296):
-  // Once all callsites have been updated to call NewChannel2() instead of NewChannel()
-  // we should have a non-null loadInfo consistently. Until then we have to brach on the
-  // loadInfo and provide default arguments to create a NewInputStreamChannel.
-  if (aLoadInfo) {
-    rv = NS_NewInputStreamChannelInternal(getter_AddRefs(channel),
-                                          aURI,
-                                          inputStream,
-                                          EmptyCString(), // aContentType
-                                          EmptyCString(), // aContentCharset
-                                          aLoadInfo);
-  }
-  else {
-    rv = NS_NewInputStreamChannel(getter_AddRefs(channel),
-                                  aURI,
-                                  inputStream,
-                                  nsContentUtils::GetSystemPrincipal(),
-                                  nsILoadInfo::SEC_NORMAL,
-                                  nsIContentPolicy::TYPE_IMAGE);
-  }
+  rv = NS_NewInputStreamChannelInternal(getter_AddRefs(channel),
+                                        aURI,
+                                        inputStream,
+                                        EmptyCString(), // aContentType
+                                        EmptyCString(), // aContentCharset
+                                        aLoadInfo);
   NS_ENSURE_SUCCESS(rv, GetDefaultIcon(_channel));
 
   // Now we go ahead and get our data asynchronously for the favicon.
   nsCOMPtr<mozIStorageStatementCallback> callback =
     new faviconAsyncLoader(channel, outputStream);
   NS_ENSURE_TRUE(callback, GetDefaultIcon(_channel));
   nsFaviconService* faviconService = nsFaviconService::GetFaviconService();
   NS_ENSURE_TRUE(faviconService, GetDefaultIcon(_channel));