Bug 983910 - Set mParentListener for HttpChannelParent objects created after HTTP redirects. r=jduell, a=1.4+
authorSteve Workman <sworkman@mozilla.com>
Thu, 27 Mar 2014 13:11:50 -0700
changeset 192443 260eebb497087b0e49bad7bc976975dce465cae3
parent 192442 e807224656d80582047f2deb315b149b5246fff1
child 192444 11f743514fbde2299fdec536b2ddfabf24767198
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjduell, 1
bugs983910
milestone30.0a2
Bug 983910 - Set mParentListener for HttpChannelParent objects created after HTTP redirects. r=jduell, a=1.4+
netwerk/base/public/nsIDivertableChannel.idl
netwerk/base/public/nsIParentChannel.idl
netwerk/base/public/nsIParentRedirectingChannel.idl
netwerk/protocol/ftp/FTPChannelParent.cpp
netwerk/protocol/http/HttpChannelParent.cpp
netwerk/protocol/http/HttpChannelParentListener.cpp
--- a/netwerk/base/public/nsIDivertableChannel.idl
+++ b/netwerk/base/public/nsIDivertableChannel.idl
@@ -2,17 +2,16 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
 %{C++
-//#include "mozilla/net/ChannelDiverterChild.h"
 namespace mozilla {
 namespace net {
 class ChannelDiverterChild;
 }
 }
 %}
 
 [ptr] native ChannelDiverterChild(mozilla::net::ChannelDiverterChild);
--- a/netwerk/base/public/nsIParentChannel.idl
+++ b/netwerk/base/public/nsIParentChannel.idl
@@ -1,20 +1,35 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsIStreamListener.idl"
 
 interface nsITabParent;
 
+%{C++
+namespace mozilla {
+namespace net {
+class HttpChannelParentListener;
+}
+}
+%}
+
+[ptr] native HttpChannelParentListener(mozilla::net::HttpChannelParentListener);
+
 /**
  * Implemented by chrome side of IPC protocols.
  */
 
-[scriptable, uuid(723188c3-fff8-4d27-b657-a256e7209be0)]
+[scriptable, uuid(8bf3aa90-ec5d-4977-bd03-197274befc78)]
 interface nsIParentChannel : nsIStreamListener
 {
   /**
+   * Called to set the HttpChannelParentListener object (optional).
+   */
+  [noscript] void setParentListener(in HttpChannelParentListener listener);
+
+  /**
    * Called to invoke deletion of the IPC protocol.
    */
   void delete();
 };
--- a/netwerk/base/public/nsIParentRedirectingChannel.idl
+++ b/netwerk/base/public/nsIParentRedirectingChannel.idl
@@ -7,17 +7,17 @@
 interface nsITabParent;
 interface nsIChannel;
 interface nsIAsyncVerifyRedirectCallback;
 
 /**
  * Implemented by chrome side of IPC protocols that support redirect responses.
  */
 
-[scriptable, uuid(cb7edc1c-096f-44de-957c-cb93de1545f6)]
+[scriptable, uuid(3ed1d288-5324-46ee-8a98-33ac37d1080b)]
 interface nsIParentRedirectingChannel : nsIParentChannel
 {
   /**
    * Called when the channel got a response that redirects it to a different
    * URI.  The implementation is responsible for calling the redirect observers
    * on the child process and provide the decision result to the callback.
    *
    * @param newChannelId
--- a/netwerk/protocol/ftp/FTPChannelParent.cpp
+++ b/netwerk/protocol/ftp/FTPChannelParent.cpp
@@ -371,16 +371,23 @@ FTPChannelParent::OnDataAvailable(nsIReq
   return NS_OK;
 }
 
 //-----------------------------------------------------------------------------
 // FTPChannelParent::nsIParentChannel
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
+FTPChannelParent::SetParentListener(HttpChannelParentListener* aListener)
+{
+  // Do not need ptr to HttpChannelParentListener.
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 FTPChannelParent::Delete()
 {
   if (mIPCClosed || !SendDeleteSelf())
     return NS_ERROR_UNEXPECTED;
 
   return NS_OK;
 }
 
--- a/netwerk/protocol/http/HttpChannelParent.cpp
+++ b/netwerk/protocol/http/HttpChannelParent.cpp
@@ -695,16 +695,27 @@ HttpChannelParent::OnStatus(nsIRequest *
   return NS_OK;
 }
 
 //-----------------------------------------------------------------------------
 // HttpChannelParent::nsIParentChannel
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
+HttpChannelParent::SetParentListener(HttpChannelParentListener* aListener)
+{
+  MOZ_ASSERT(aListener);
+  MOZ_ASSERT(!mParentListener, "SetParentListener should only be called for "
+                               "new HttpChannelParents after a redirect, when "
+                               "mParentListener is null.");
+  mParentListener = aListener;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 HttpChannelParent::Delete()
 {
   if (!mIPCClosed)
     unused << SendDeleteSelf();
 
   return NS_OK;
 }
 
--- a/netwerk/protocol/http/HttpChannelParentListener.cpp
+++ b/netwerk/protocol/http/HttpChannelParentListener.cpp
@@ -214,16 +214,17 @@ HttpChannelParentListener::OnRedirectRes
   if (succeeded) {
     // Switch to redirect channel and delete the old one.
     nsCOMPtr<nsIParentChannel> parent;
     parent = do_QueryInterface(mNextListener);
     MOZ_ASSERT(parent);
     parent->Delete();
     mNextListener = do_QueryInterface(redirectChannel);
     MOZ_ASSERT(mNextListener);
+    redirectChannel->SetParentListener(this);
   } else if (redirectChannel) {
     // Delete the redirect target channel: continue using old channel
     redirectChannel->Delete();
   }
 
   return NS_OK;
 }