Bug 1205410 - Do not wrap channels if NewChannel2 fails (r=sicking, a=ritu)
authorChristoph Kerschbaumer <mozilla@christophkerschbaumer.com>
Wed, 16 Sep 2015 16:33:18 -0700
changeset 283830 3d007874b9c29e1ad0479aa201334f4eca6261ff
parent 283829 77d4b385b761d0c3a9698552dc56757e1c6ff63c
child 283831 78c82e5cd77772e77ebb820420edb0b803a0836d
child 283833 e7347ad21d6c27e59d8e9afbcf16c47800495c8f
child 283837 1d61fe3d9c681b675293bfa5e7adfbde9db85b16
push id909
push userkwierso@gmail.com
push dateThu, 17 Sep 2015 18:22:11 +0000
treeherdermozilla-release@3d007874b9c2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking, ritu
bugs1205410
milestone41.0
Bug 1205410 - Do not wrap channels if NewChannel2 fails (r=sicking, a=ritu) DONTBUILD
netwerk/base/nsIOService.cpp
--- a/netwerk/base/nsIOService.cpp
+++ b/netwerk/base/nsIOService.cpp
@@ -663,43 +663,52 @@ nsIOService::NewChannelFromURIWithProxyF
     // NewChannel2() might *not* be implemented.
     // We do not want to break those addons, therefore we first try to create a channel
     // calling NewChannel2(); if that fails:
     // * we fall back to creating a channel by calling NewChannel()
     // * wrap the addon channel
     // * and attach the loadInfo to the channel wrapper
     nsCOMPtr<nsIChannel> channel;
     nsCOMPtr<nsIProxiedProtocolHandler> pph = do_QueryInterface(handler);
+
+    // temporary fix for 41 to not break any addons that do not implement newChannel2.
+    bool newChannel2Succeeded = true;
+
     if (pph) {
         rv = pph->NewProxiedChannel2(aURI, nullptr, aProxyFlags, aProxyURI,
                                      aLoadInfo, getter_AddRefs(channel));
         // if calling NewProxiedChannel2() fails we try to fall back to
         // creating a new proxied channel by calling NewProxiedChannel().
         if (NS_FAILED(rv)) {
+            newChannel2Succeeded = false;
             rv = pph->NewProxiedChannel(aURI, nullptr, aProxyFlags, aProxyURI,
                                         getter_AddRefs(channel));
             NS_ENSURE_SUCCESS(rv, rv);
-            // we have to wrap that channel
-            channel = new nsSecCheckWrapChannel(channel, aLoadInfo);
+            // temporary fix for 41: do not wrap any channels
+            // channel = new nsSecCheckWrapChannel(channel, aLoadInfo);
         }
     }
     else {
         rv = handler->NewChannel2(aURI, aLoadInfo, getter_AddRefs(channel));
         // if calling newChannel2() fails we try to fall back to
         // creating a new channel by calling NewChannel().
         if (NS_FAILED(rv)) {
+            newChannel2Succeeded = false;
             rv = handler->NewChannel(aURI, getter_AddRefs(channel));
             NS_ENSURE_SUCCESS(rv, rv);
-            // we have to wrap that channel
-            channel = new nsSecCheckWrapChannel(channel, aLoadInfo);
+            // temporary fix for 41: do not wrap any channels
+            // channel = new nsSecCheckWrapChannel(channel, aLoadInfo);
         }
     }
 
     // Make sure that all the individual protocolhandlers attach a loadInfo.
-    if (aLoadInfo) {
+
+    // temporary fix for 41: only check the loadInfo if the call to
+    // newChannel2 succeeded.
+    if (aLoadInfo && newChannel2Succeeded) {
       // make sure we have the same instance of loadInfo on the newly created channel
       nsCOMPtr<nsILoadInfo> loadInfo;
       channel->GetLoadInfo(getter_AddRefs(loadInfo));
 
       if (aLoadInfo != loadInfo) {
         MOZ_ASSERT(false, "newly created channel must have a loadinfo attached");
         return NS_ERROR_UNEXPECTED;
       }