Bug 1041419 - Patch 2: Replace PBrowser with PBrowserOrId in PWyciwygChannel. r=honzab
authorKershaw Chang <kechang@mozilla.com>
Tue, 04 Nov 2014 02:58:00 +0100
changeset 214088 4e434f4b9d9db139629be3dd37666a858dac8a36
parent 214087 53a01a003e43f67fbe7f84f9d1ce14015b4191d8
child 214089 d3e330ef99c92e3b408c91a825a2fed8eb859c39
push id27771
push userryanvm@gmail.com
push dateWed, 05 Nov 2014 19:04:24 +0000
treeherdermozilla-central@305b4fecce99 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershonzab
bugs1041419
milestone36.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 1041419 - Patch 2: Replace PBrowser with PBrowserOrId in PWyciwygChannel. r=honzab
netwerk/protocol/http/HttpChannelChild.cpp
netwerk/protocol/wyciwyg/PWyciwygChannel.ipdl
netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp
netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp
netwerk/protocol/wyciwyg/WyciwygChannelParent.h
--- a/netwerk/protocol/http/HttpChannelChild.cpp
+++ b/netwerk/protocol/http/HttpChannelChild.cpp
@@ -1046,23 +1046,18 @@ HttpChannelChild::ConnectParent(uint32_t
     return NS_ERROR_ILLEGAL_VALUE;
   }
 
   // The socket transport in the chrome process now holds a logical ref to us
   // until OnStopRequest, or we do a redirect, or we hit an IPDL error.
   AddIPDLReference();
 
   HttpChannelConnectArgs connectArgs(id);
-  PBrowserOrId browser;
-  if (!tabChild ||
-      static_cast<ContentChild*>(gNeckoChild->Manager()) == tabChild->Manager()) {
-    browser = tabChild;
-  } else {
-    browser = tabChild->GetTabId();
-  }
+  PBrowserOrId browser = static_cast<ContentChild*>(gNeckoChild->Manager())
+                         ->GetBrowserOrId(tabChild);
   if (!gNeckoChild->
         SendPHttpChannelConstructor(this, browser,
                                     IPC::SerializedLoadContext(this),
                                     connectArgs)) {
     return NS_ERROR_FAILURE;
   }
 
   return NS_OK;
@@ -1516,23 +1511,18 @@ HttpChannelChild::ContinueAsyncOpen()
   openArgs.allowSpdy() = mAllowSpdy;
 
   propagateLoadInfo(mLoadInfo, openArgs);
 
   // The socket transport in the chrome process now holds a logical ref to us
   // until OnStopRequest, or we do a redirect, or we hit an IPDL error.
   AddIPDLReference();
 
-  PBrowserOrId browser;
-  if (!tabChild ||
-      static_cast<ContentChild*>(gNeckoChild->Manager()) == tabChild->Manager()) {
-    browser = tabChild;
-  } else {
-    browser = tabChild->GetTabId();
-  }
+  PBrowserOrId browser = static_cast<ContentChild*>(gNeckoChild->Manager())
+                         ->GetBrowserOrId(tabChild);
   gNeckoChild->SendPHttpChannelConstructor(this, browser,
                                            IPC::SerializedLoadContext(this),
                                            openArgs);
 
   if (fdSet) {
     FileDescriptorSetChild* fdSetActor =
       static_cast<FileDescriptorSetChild*>(fdSet);
 
--- a/netwerk/protocol/wyciwyg/PWyciwygChannel.ipdl
+++ b/netwerk/protocol/wyciwyg/PWyciwygChannel.ipdl
@@ -1,16 +1,17 @@
 /* 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 protocol PNecko;
 include protocol PBrowser;
 include URIParams;
 include PBackgroundSharedTypes;
+include PBrowserOrId;
 
 using class IPC::SerializedLoadContext from "SerializedLoadContext.h";
 
 namespace mozilla {
 namespace net {
 
 //-------------------------------------------------------------------
 protocol PWyciwygChannel
@@ -22,18 +23,18 @@ parent:
 
   Init(URIParams     uri,
        PrincipalInfo requestingPrincipalInfo,
        uint32_t      securityFlags,
        uint32_t      contentPolicyType);
   AsyncOpen(URIParams             originalURI,
             uint32_t              loadFlags,
             SerializedLoadContext loadContext,
-            PBrowser browser);
-  AppData(SerializedLoadContext loadContext, PBrowser browser);
+            PBrowserOrId browser);
+  AppData(SerializedLoadContext loadContext, PBrowserOrId browser);
 
   // methods corresponding to those of nsIWyciwygChannel
   WriteToCacheEntry(nsString data);
   CloseCacheEntry(nsresult reason);
   SetCharsetAndSource(int32_t source, nsCString charset);
   SetSecurityInfo(nsCString securityInfo);
   Cancel(nsresult status);
 
--- a/netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp
+++ b/netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp
@@ -4,29 +4,31 @@
 
 #include "nsWyciwyg.h"
 
 #include "base/compiler_specific.h"
 
 #include "mozilla/net/ChannelEventQueue.h"
 #include "WyciwygChannelChild.h"
 #include "mozilla/dom/TabChild.h"
+#include "mozilla/dom/ContentChild.h"
 
 #include "nsCharsetSource.h"
 #include "nsStringStream.h"
 #include "nsNetUtil.h"
 #include "nsISerializable.h"
 #include "nsSerializationHelper.h"
 #include "nsIProgressEventSink.h"
 #include "mozilla/ipc/URIUtils.h"
 #include "SerializedLoadContext.h"
 #include "mozilla/ipc/BackgroundUtils.h"
 #include "nsProxyRelease.h"
 
 using namespace mozilla::ipc;
+using namespace mozilla::dom;
 
 namespace mozilla {
 namespace net {
 
 NS_IMPL_ISUPPORTS(WyciwygChannelChild,
                   nsIRequest,
                   nsIChannel,
                   nsIWyciwygChannel,
@@ -668,17 +670,21 @@ WyciwygChannelChild::AsyncOpen(nsIStream
 NS_IMETHODIMP
 WyciwygChannelChild::WriteToCacheEntry(const nsAString & aData)
 {
   NS_ENSURE_TRUE((mState == WCC_INIT) ||
                  (mState == WCC_ONWRITE), NS_ERROR_UNEXPECTED);
 
   if (!mSentAppData) {
     mozilla::dom::TabChild* tabChild = GetTabChild(this);
-    SendAppData(IPC::SerializedLoadContext(this), tabChild);
+
+    PBrowserOrId browser = static_cast<ContentChild*>(Manager()->Manager())
+                           ->GetBrowserOrId(tabChild);
+
+    SendAppData(IPC::SerializedLoadContext(this), browser);
     mSentAppData = true;
   }
 
   SendWriteToCacheEntry(PromiseFlatString(aData));
   mState = WCC_ONWRITE;
   return NS_OK;
 }
 
--- a/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp
+++ b/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp
@@ -104,30 +104,30 @@ WyciwygChannelParent::RecvInit(const URI
   if (NS_FAILED(rv))
     return SendCancelEarly(rv);
 
   return true;
 }
 
 bool
 WyciwygChannelParent::RecvAppData(const IPC::SerializedLoadContext& loadContext,
-                                  PBrowserParent* parent)
+                                  const PBrowserOrId &parent)
 {
   LOG(("WyciwygChannelParent RecvAppData [this=%p]\n", this));
 
   if (!SetupAppData(loadContext, parent))
     return false;
 
   mChannel->SetNotificationCallbacks(this);
   return true;
 }
 
 bool
 WyciwygChannelParent::SetupAppData(const IPC::SerializedLoadContext& loadContext,
-                                   PBrowserParent* aParent)
+                                   const PBrowserOrId &aParent)
 {
   if (!mChannel)
     return true;
 
   const char* error = NeckoParent::CreateChannelLoadContext(aParent,
                                                             Manager()->Manager(),
                                                             loadContext,
                                                             mLoadContext);
@@ -146,17 +146,17 @@ WyciwygChannelParent::SetupAppData(const
   mReceivedAppData = true;
   return true;
 }
 
 bool
 WyciwygChannelParent::RecvAsyncOpen(const URIParams& aOriginal,
                                     const uint32_t& aLoadFlags,
                                     const IPC::SerializedLoadContext& loadContext,
-                                    PBrowserParent* aParent)
+                                    const PBrowserOrId &aParent)
 {
   nsCOMPtr<nsIURI> original = DeserializeURI(aOriginal);
   if (!original)
     return false;
 
   LOG(("WyciwygChannelParent RecvAsyncOpen [this=%p]\n", this));
 
   if (!mChannel)
--- a/netwerk/protocol/wyciwyg/WyciwygChannelParent.h
+++ b/netwerk/protocol/wyciwyg/WyciwygChannelParent.h
@@ -37,30 +37,30 @@ protected:
 
   virtual bool RecvInit(const URIParams&          uri,
                         const ipc::PrincipalInfo& aRequestingPrincipalInfo,
                         const uint32_t&           aSecurityFlags,
                         const uint32_t&           aContentPolicyType) MOZ_OVERRIDE;
   virtual bool RecvAsyncOpen(const URIParams& original,
                              const uint32_t& loadFlags,
                              const IPC::SerializedLoadContext& loadContext,
-                             PBrowserParent* parent) MOZ_OVERRIDE;
+                             const PBrowserOrId &parent) MOZ_OVERRIDE;
   virtual bool RecvWriteToCacheEntry(const nsString& data) MOZ_OVERRIDE;
   virtual bool RecvCloseCacheEntry(const nsresult& reason) MOZ_OVERRIDE;
   virtual bool RecvSetCharsetAndSource(const int32_t& source,
                                        const nsCString& charset) MOZ_OVERRIDE;
   virtual bool RecvSetSecurityInfo(const nsCString& securityInfo) MOZ_OVERRIDE;
   virtual bool RecvCancel(const nsresult& statusCode) MOZ_OVERRIDE;
   virtual bool RecvAppData(const IPC::SerializedLoadContext& loadContext,
-                           PBrowserParent* parent) MOZ_OVERRIDE;
+                           const PBrowserOrId &parent) MOZ_OVERRIDE;
 
   virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
 
   bool SetupAppData(const IPC::SerializedLoadContext& loadContext,
-                    PBrowserParent* aParent);
+                    const PBrowserOrId &aParent);
 
   nsCOMPtr<nsIWyciwygChannel> mChannel;
   bool mIPCClosed;
   bool mReceivedAppData;
   nsCOMPtr<nsILoadContext> mLoadContext;
 };
 
 } // namespace net