Bug 1522579 - Part 4: Remove {As,Is}ContentParent, r=mccr8
authorNika Layzell <nika@thelayzells.com>
Mon, 25 Feb 2019 20:04:51 +0000
changeset 460972 e1a05b9c3e37846d5c2ed1d42be92eebb7c88edb
parent 460971 9cdcafda796e043e3b471c0ab82993c12932a82f
child 460973 5174b698bd098ee509ee33df2653b537fb4c7d3a
push id35613
push usernerli@mozilla.com
push dateTue, 26 Feb 2019 03:52:35 +0000
treeherdermozilla-central@faec87a80ed1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1522579
milestone67.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 1522579 - Part 4: Remove {As,Is}ContentParent, r=mccr8 These casts are now unnecessary after Part 2, due to all consumers directly using `ContentParent`. Depends on D20551 Differential Revision: https://phabricator.services.mozilla.com/D20552
dom/base/nsFrameLoader.cpp
dom/events/EventStateManager.cpp
dom/ipc/ContentParent.h
dom/ipc/ProcessPriorityManager.cpp
dom/ipc/TabParent.cpp
dom/ipc/nsIContentParent.cpp
dom/ipc/nsIContentParent.h
layout/ipc/RenderFrame.cpp
netwerk/protocol/http/HttpChannelParentListener.cpp
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -2391,19 +2391,18 @@ static Tuple<ContentParent*, TabParent*>
 
   RefPtr<nsFrameLoader> otherLoader;
   browser->GetSameProcessAsFrameLoader(getter_AddRefs(otherLoader));
   if (!otherLoader) {
     return ReturnTuple(nullptr, nullptr);
   }
 
   TabParent* tabParent = TabParent::GetFrom(otherLoader);
-  if (tabParent && tabParent->Manager() &&
-      tabParent->Manager()->IsContentParent()) {
-    return MakeTuple(tabParent->Manager()->AsContentParent(), tabParent);
+  if (tabParent && tabParent->Manager()) {
+    return MakeTuple(tabParent->Manager(), tabParent);
   }
 
   return ReturnTuple(nullptr, nullptr);
 }
 
 bool nsFrameLoader::TryRemoteBrowser() {
   NS_ASSERTION(!mRemoteBrowser && !mRemoteFrameChild,
                "TryRemoteBrowser called with a remote browser already?");
@@ -2437,19 +2436,18 @@ bool nsFrameLoader::TryRemoteBrowser() {
   if (!parentDocShell) {
     return false;
   }
 
   TabParent* openingTab = TabParent::GetFrom(parentDocShell->GetOpener());
   RefPtr<ContentParent> openerContentParent;
   RefPtr<TabParent> sameTabGroupAs;
 
-  if (openingTab && openingTab->Manager() &&
-      openingTab->Manager()->IsContentParent()) {
-    openerContentParent = openingTab->Manager()->AsContentParent();
+  if (openingTab && openingTab->Manager()) {
+    openerContentParent = openingTab->Manager();
   }
 
   // <iframe mozbrowser> gets to skip these checks.
   // iframes for JS plugins also get to skip these checks. We control the URL
   // that gets loaded, but the load is triggered from the document containing
   // the plugin.
   // out of process iframes also get to skip this check.
   if (!OwnerIsMozBrowserFrame() && !XRE_IsContentProcess()) {
@@ -2964,17 +2962,17 @@ void nsFrameLoader::RequestUpdatePositio
 
 void nsFrameLoader::Print(uint64_t aOuterWindowID,
                           nsIPrintSettings* aPrintSettings,
                           nsIWebProgressListener* aProgressListener,
                           ErrorResult& aRv) {
 #if defined(NS_PRINTING)
   if (mRemoteBrowser) {
     RefPtr<embedding::PrintingParent> printingParent =
-        mRemoteBrowser->Manager()->AsContentParent()->GetPrintingParent();
+        mRemoteBrowser->Manager()->GetPrintingParent();
 
     embedding::PrintData printData;
     nsresult rv = printingParent->SerializeAndEnsureRemotePrintJob(
         aPrintSettings, aProgressListener, nullptr, &printData);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       aRv.Throw(rv);
       return;
     }
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -1240,20 +1240,17 @@ void EventStateManager::DispatchCrossPro
       // Let the child process synthesize a mouse event if needed, and
       // ensure we don't synthesize one in this process.
       *aStatus = nsEventStatus_eConsumeNoDefault;
       remote->SendRealTouchEvent(*aEvent->AsTouchEvent());
       return;
     }
     case eDragEventClass: {
       RefPtr<TabParent> tabParent = remote;
-      if (tabParent->Manager()->IsContentParent()) {
-        tabParent->Manager()->AsContentParent()->MaybeInvokeDragSession(
-            tabParent);
-      }
+      tabParent->Manager()->MaybeInvokeDragSession(tabParent);
 
       nsCOMPtr<nsIDragSession> dragSession = nsContentUtils::GetDragSession();
       uint32_t dropEffect = nsIDragService::DRAGDROP_ACTION_NONE;
       uint32_t action = nsIDragService::DRAGDROP_ACTION_NONE;
       nsCOMPtr<nsIPrincipal> principal;
       if (dragSession) {
         dragSession->DragEventDispatchedToChildProcess();
         dragSession->GetDragAction(&action);
@@ -5505,24 +5502,20 @@ nsresult EventStateManager::DoContentCom
     aEvent->mIsEnabled = canDoIt;
     if (canDoIt && !aEvent->mOnlyEnabledCheck) {
       switch (aEvent->mMessage) {
         case eContentCommandPasteTransferable: {
           nsFocusManager* fm = nsFocusManager::GetFocusManager();
           nsIContent* focusedContent = fm ? fm->GetFocusedElement() : nullptr;
           RefPtr<TabParent> remote = TabParent::GetFrom(focusedContent);
           if (remote) {
-            NS_ENSURE_TRUE(remote->Manager()->IsContentParent(),
-                           NS_ERROR_FAILURE);
-
             nsCOMPtr<nsITransferable> transferable = aEvent->mTransferable;
             IPCDataTransfer ipcDataTransfer;
-            ContentParent* cp = remote->Manager()->AsContentParent();
             nsContentUtils::TransferableToIPCTransferable(
-                transferable, &ipcDataTransfer, false, nullptr, cp);
+                transferable, &ipcDataTransfer, false, nullptr, remote->Manager());
             bool isPrivateData = transferable->GetIsPrivateData();
             nsCOMPtr<nsIPrincipal> requestingPrincipal =
                 transferable->GetRequestingPrincipal();
             nsContentPolicyType contentPolicyType =
                 transferable->GetContentPolicyType();
             remote->SendPasteTransferable(ipcDataTransfer, isPrivateData,
                                           IPC::Principal(requestingPrincipal),
                                           contentPolicyType);
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -127,18 +127,16 @@ class ContentParent final : public PCont
 
   friend class mozilla::PreallocatedProcessManagerImpl;
   friend class PContentParent;
 #ifdef FUZZING
   friend class mozilla::ipc::ProtocolFuzzerHelper;
 #endif
 
  public:
-  virtual bool IsContentParent() const override { return true; }
-
   using LaunchError = GeckoChildProcessHost::LaunchError;
   using LaunchPromise =
       GeckoChildProcessHost::LaunchPromise<RefPtr<ContentParent>>;
 
   /**
    * Create a subprocess suitable for use later as a content process.
    */
   static RefPtr<LaunchPromise> PreallocateProcess();
--- a/dom/ipc/ProcessPriorityManager.cpp
+++ b/dom/ipc/ProcessPriorityManager.cpp
@@ -437,17 +437,18 @@ void ProcessPriorityManagerImpl::SetProc
 }
 
 void ProcessPriorityManagerImpl::ObserveContentParentCreated(
     nsISupports* aContentParent) {
   // Do nothing; it's sufficient to get the PPPM.  But assign to nsRefPtr so we
   // don't leak the already_AddRefed object.
   nsCOMPtr<nsIContentParent> cp = do_QueryInterface(aContentParent);
   RefPtr<ParticularProcessPriorityManager> pppm =
-      GetParticularProcessPriorityManager(cp->AsContentParent());
+      GetParticularProcessPriorityManager(
+          static_cast<ContentParent*>(cp.get()));
 }
 
 void ProcessPriorityManagerImpl::ObserveContentParentDestroyed(
     nsISupports* aSubject) {
   nsCOMPtr<nsIPropertyBag2> props = do_QueryInterface(aSubject);
   NS_ENSURE_TRUE_VOID(props);
 
   uint64_t childID = CONTENT_PROCESS_ID_UNKNOWN;
@@ -472,19 +473,18 @@ void ProcessPriorityManagerImpl::NotifyP
   } else if (newPriority < PROCESS_PRIORITY_FOREGROUND_HIGH &&
              aOldPriority >= PROCESS_PRIORITY_FOREGROUND_HIGH) {
     mHighPriorityChildIDs.RemoveEntry(aParticularManager->ChildID());
   }
 }
 
 void ProcessPriorityManagerImpl::TabActivityChanged(TabParent* aTabParent,
                                                     bool aIsActive) {
-  ContentParent* cp = aTabParent->Manager()->AsContentParent();
   RefPtr<ParticularProcessPriorityManager> pppm =
-      GetParticularProcessPriorityManager(cp);
+      GetParticularProcessPriorityManager(aTabParent->Manager());
   if (!pppm) {
     return;
   }
 
   pppm->TabActivityChanged(aTabParent, aIsActive);
 }
 
 NS_IMPL_ISUPPORTS(ParticularProcessPriorityManager, nsIObserver,
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -380,34 +380,33 @@ void TabParent::Destroy() {
   if (mIsDestroyed) {
     return;
   }
 
   DestroyInternal();
 
   mIsDestroyed = true;
 
-  ContentParent::NotifyTabDestroying(this->GetTabId(),
-                                     Manager()->AsContentParent()->ChildID());
+  ContentParent::NotifyTabDestroying(this->GetTabId(), Manager()->ChildID());
 
   mMarkedDestroying = true;
 }
 
 mozilla::ipc::IPCResult TabParent::RecvEnsureLayersConnected(
     CompositorOptions* aCompositorOptions) {
   if (mRenderFrame.IsInitialized()) {
     mRenderFrame.EnsureLayersConnected(aCompositorOptions);
   }
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult TabParent::Recv__delete__() {
   MOZ_RELEASE_ASSERT(XRE_IsParentProcess());
-  ContentParent::UnregisterRemoteFrame(
-      mTabId, Manager()->AsContentParent()->ChildID(), mMarkedDestroying);
+  ContentParent::UnregisterRemoteFrame(mTabId, Manager()->ChildID(),
+                                       mMarkedDestroying);
 
   return IPC_OK();
 }
 
 void TabParent::ActorDestroy(ActorDestroyReason why) {
   if (mRenderFrame.IsInitialized()) {
     // It's important to unmap layers after the remote browser has been
     // destroyed, otherwise it may still send messages to the compositor which
@@ -947,17 +946,16 @@ auto TabParent::AllocPIndexedDBPermissio
     const Principal& aPrincipal) -> PIndexedDBPermissionRequestParent* {
   MOZ_ASSERT(NS_IsMainThread());
 
   nsCOMPtr<nsIPrincipal> principal(aPrincipal);
   if (!principal) {
     return nullptr;
   }
 
-  RefPtr<ContentParent> manager = Manager();
   if (NS_WARN_IF(!mFrameElement)) {
     return nullptr;
   }
 
   return mozilla::dom::indexedDB::AllocPIndexedDBPermissionRequestParent(
       mFrameElement, principal);
 }
 
@@ -1058,18 +1056,17 @@ void TabParent::SendRealMouseEvent(Widge
     }
     return;
   }
 
   ScrollableLayerGuid guid;
   uint64_t blockId;
   ApzAwareEventRoutingToChild(&guid, &blockId, nullptr);
 
-  bool isInputPriorityEventEnabled =
-      Manager()->AsContentParent()->IsInputPriorityEventEnabled();
+  bool isInputPriorityEventEnabled = Manager()->IsInputPriorityEventEnabled();
 
   if (mIsMouseEnterIntoWidgetEventSuppressed) {
     // In the case that the TabParent suppressed the eMouseEnterWidget event due
     // to its corresponding TabChild wasn't ready to handle it, we have to
     // resend it when the TabChild is ready.
     mIsMouseEnterIntoWidgetEventSuppressed = false;
     WidgetMouseEvent localEvent(aEvent);
     localEvent.mMessage = eMouseEnterIntoWidget;
@@ -1186,17 +1183,17 @@ bool TabParent::QueryDropLinksForVerific
 }
 
 void TabParent::SendRealDragEvent(WidgetDragEvent& aEvent, uint32_t aDragAction,
                                   uint32_t aDropEffect,
                                   const IPC::Principal& aPrincipal) {
   if (mIsDestroyed || !mIsReadyToHandleInputEvents) {
     return;
   }
-  MOZ_ASSERT(!Manager()->AsContentParent()->IsInputPriorityEventEnabled());
+  MOZ_ASSERT(!Manager()->IsInputPriorityEventEnabled());
   aEvent.mRefPoint += GetChildProcessOffset();
   if (aEvent.mMessage == eDrop) {
     if (!QueryDropLinksForVerification()) {
       return;
     }
   }
   DebugOnly<bool> ret = PBrowserParent::SendRealDragEvent(
       aEvent, aDragAction, aDropEffect, aPrincipal);
@@ -1209,17 +1206,17 @@ void TabParent::SendMouseWheelEvent(Widg
     return;
   }
 
   ScrollableLayerGuid guid;
   uint64_t blockId;
   ApzAwareEventRoutingToChild(&guid, &blockId, nullptr);
   aEvent.mRefPoint += GetChildProcessOffset();
   DebugOnly<bool> ret =
-      Manager()->AsContentParent()->IsInputPriorityEventEnabled()
+      Manager()->IsInputPriorityEventEnabled()
           ? PBrowserParent::SendMouseWheelEvent(aEvent, guid, blockId)
           : PBrowserParent::SendNormalPriorityMouseWheelEvent(aEvent, guid,
                                                               blockId);
 
   NS_WARNING_ASSERTION(ret, "PBrowserParent::SendMouseWheelEvent() failed");
   MOZ_ASSERT(!ret || aEvent.HasBeenPostedToRemoteProcess());
 }
 
@@ -1471,17 +1468,17 @@ void TabParent::SendRealKeyEvent(WidgetK
   if (aEvent.mMessage == eKeyPress) {
     // XXX Should we do this only when input context indicates an editor having
     //     focus and the key event won't cause inputting text?
     aEvent.InitAllEditCommands();
   } else {
     aEvent.PreventNativeKeyBindings();
   }
   DebugOnly<bool> ret =
-      Manager()->AsContentParent()->IsInputPriorityEventEnabled()
+      Manager()->IsInputPriorityEventEnabled()
           ? PBrowserParent::SendRealKeyEvent(aEvent)
           : PBrowserParent::SendNormalPriorityRealKeyEvent(aEvent);
 
   NS_WARNING_ASSERTION(ret, "PBrowserParent::SendRealKeyEvent() failed");
   MOZ_ASSERT(!ret || aEvent.HasBeenPostedToRemoteProcess());
 }
 
 void TabParent::SendRealTouchEvent(WidgetTouchEvent& aEvent) {
@@ -1510,18 +1507,17 @@ void TabParent::SendRealTouchEvent(Widge
     return;
   }
 
   LayoutDeviceIntPoint offset = GetChildProcessOffset();
   for (uint32_t i = 0; i < aEvent.mTouches.Length(); i++) {
     aEvent.mTouches[i]->mRefPoint += offset;
   }
 
-  bool inputPriorityEventEnabled =
-      Manager()->AsContentParent()->IsInputPriorityEventEnabled();
+  bool inputPriorityEventEnabled = Manager()->IsInputPriorityEventEnabled();
 
   if (aEvent.mMessage == eTouchMove) {
     DebugOnly<bool> ret =
         inputPriorityEventEnabled
             ? PBrowserParent::SendRealTouchMoveEvent(aEvent, guid, blockId,
                                                      apzResponse)
             : PBrowserParent::SendNormalPriorityRealTouchMoveEvent(
                   aEvent, guid, blockId, apzResponse);
@@ -1564,17 +1560,17 @@ bool TabParent::SendHandleTap(TapType aT
           fm->SetFocus(element, nsIFocusManager::FLAG_BYMOUSE |
                                     nsIFocusManager::FLAG_BYTOUCH |
                                     nsIFocusManager::FLAG_NOSCROLL);
         }
       }
     }
   }
   LayoutDeviceIntPoint offset = GetChildProcessOffset();
-  return Manager()->AsContentParent()->IsInputPriorityEventEnabled()
+  return Manager()->IsInputPriorityEventEnabled()
              ? PBrowserParent::SendHandleTap(aType, aPoint + offset, aModifiers,
                                              aGuid, aInputBlockId)
              : PBrowserParent::SendNormalPriorityHandleTap(
                    aType, aPoint + offset, aModifiers, aGuid, aInputBlockId);
 }
 
 mozilla::ipc::IPCResult TabParent::RecvSyncMessage(
     const nsString& aMessage, const ClonedMessageData& aData,
@@ -2174,17 +2170,17 @@ bool TabParent::SendCompositionEvent(Wid
   if (mIsDestroyed) {
     return false;
   }
 
   if (!mContentCache.OnCompositionEvent(aEvent)) {
     return true;
   }
 
-  bool ret = Manager()->AsContentParent()->IsInputPriorityEventEnabled()
+  bool ret = Manager()->IsInputPriorityEventEnabled()
                  ? PBrowserParent::SendCompositionEvent(aEvent)
                  : PBrowserParent::SendNormalPriorityCompositionEvent(aEvent);
   if (NS_WARN_IF(!ret)) {
     return false;
   }
   MOZ_ASSERT(aEvent.HasBeenPostedToRemoteProcess());
   return true;
 }
@@ -2193,17 +2189,17 @@ bool TabParent::SendSelectionEvent(Widge
   if (mIsDestroyed) {
     return false;
   }
   nsCOMPtr<nsIWidget> widget = GetWidget();
   if (!widget) {
     return true;
   }
   mContentCache.OnSelectionEvent(aEvent);
-  bool ret = Manager()->AsContentParent()->IsInputPriorityEventEnabled()
+  bool ret = Manager()->IsInputPriorityEventEnabled()
                  ? PBrowserParent::SendSelectionEvent(aEvent)
                  : PBrowserParent::SendNormalPrioritySelectionEvent(aEvent);
   if (NS_WARN_IF(!ret)) {
     return false;
   }
   MOZ_ASSERT(aEvent.HasBeenPostedToRemoteProcess());
   aEvent.mSucceeded = true;
   return true;
@@ -2600,17 +2596,17 @@ TabParent::SetDocShellIsActive(bool isAc
           a11y::nsWinUtils::HideNativeWindow(window);
         }
       }
     }
   }
 #endif
 
   // Keep track of how many active recording/replaying tabs there are.
-  if (Manager()->AsContentParent()->IsRecordingOrReplaying()) {
+  if (Manager()->IsRecordingOrReplaying()) {
     SetIsActiveRecordReplayTab(isActive);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 TabParent::GetDocShellIsActive(bool* aIsActive) {
@@ -2697,35 +2693,35 @@ void TabParent::SetRenderLayersInternal(
   // RenderLayers requests are ignored.
   mLayerTreeEpoch = mLayerTreeEpoch.Next();
 
   Unused << SendRenderLayers(aEnabled, aForceRepaint, mLayerTreeEpoch);
 
   // Ask the child to repaint using the PHangMonitor channel/thread (which may
   // be less congested).
   if (aEnabled) {
-    ContentParent* cp = Manager()->AsContentParent();
-    cp->PaintTabWhileInterruptingJS(this, aForceRepaint, mLayerTreeEpoch);
+    Manager()->PaintTabWhileInterruptingJS(this, aForceRepaint,
+                                           mLayerTreeEpoch);
   }
 }
 
 NS_IMETHODIMP
 TabParent::PreserveLayers(bool aPreserveLayers) {
   mPreserveLayers = aPreserveLayers;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 TabParent::SaveRecording(const nsAString& aFilename, bool* aRetval) {
   nsCOMPtr<nsIFile> file;
   nsresult rv = NS_NewLocalFile(aFilename, false, getter_AddRefs(file));
   if (NS_FAILED(rv)) {
     return rv;
   }
-  return Manager()->AsContentParent()->SaveRecording(file, aRetval);
+  return Manager()->SaveRecording(file, aRetval);
 }
 
 NS_IMETHODIMP
 TabParent::GetContentBlockingLog(Promise** aPromise) {
   NS_ENSURE_ARG_POINTER(aPromise);
 
   *aPromise = nullptr;
   if (!mFrameElement) {
@@ -3100,36 +3096,33 @@ mozilla::ipc::IPCResult TabParent::RecvA
 mozilla::ipc::IPCResult TabParent::RecvInvokeDragSession(
     nsTArray<IPCDataTransfer>&& aTransfers, const uint32_t& aAction,
     const OptionalShmem& aVisualDnDData, const uint32_t& aStride,
     const gfx::SurfaceFormat& aFormat, const LayoutDeviceIntRect& aDragRect,
     const IPC::Principal& aPrincipal) {
   mInitialDataTransferItems.Clear();
   nsIPresShell* shell = mFrameElement->OwnerDoc()->GetShell();
   if (!shell) {
-    if (Manager()->IsContentParent()) {
-      Unused << Manager()->AsContentParent()->SendEndDragSession(
-          true, true, LayoutDeviceIntPoint(), 0);
-      // Continue sending input events with input priority when stopping the dnd
-      // session.
-      Manager()->AsContentParent()->SetInputPriorityEventEnabled(true);
-    }
+    Unused << Manager()->SendEndDragSession(true, true, LayoutDeviceIntPoint(),
+                                            0);
+    // Continue sending input events with input priority when stopping the dnd
+    // session.
+    Manager()->SetInputPriorityEventEnabled(true);
     return IPC_OK();
   }
 
   EventStateManager* esm = shell->GetPresContext()->EventStateManager();
   for (uint32_t i = 0; i < aTransfers.Length(); ++i) {
     mInitialDataTransferItems.AppendElement(std::move(aTransfers[i].items()));
   }
-  if (Manager()->IsContentParent()) {
-    nsCOMPtr<nsIDragService> dragService =
-        do_GetService("@mozilla.org/widget/dragservice;1");
-    if (dragService) {
-      dragService->MaybeAddChildProcess(Manager()->AsContentParent());
-    }
+
+  nsCOMPtr<nsIDragService> dragService =
+      do_GetService("@mozilla.org/widget/dragservice;1");
+  if (dragService) {
+    dragService->MaybeAddChildProcess(Manager());
   }
 
   if (aVisualDnDData.type() == OptionalShmem::Tvoid_t ||
       !aVisualDnDData.get_Shmem().IsReadable() ||
       aVisualDnDData.get_Shmem().Size<char>() < aDragRect.height * aStride) {
     mDnDVisualization = nullptr;
   } else {
     mDnDVisualization = gfx::CreateDataSourceSurfaceFromData(
--- a/dom/ipc/nsIContentParent.cpp
+++ b/dom/ipc/nsIContentParent.cpp
@@ -44,21 +44,16 @@ using namespace mozilla::jsipc;
 
 namespace mozilla {
 namespace dom {
 
 nsIContentParent::nsIContentParent() {
   mMessageManager = nsFrameMessageManager::NewProcessMessageManager(true);
 }
 
-ContentParent* nsIContentParent::AsContentParent() {
-  MOZ_ASSERT(IsContentParent());
-  return static_cast<ContentParent*>(this);
-}
-
 PJavaScriptParent* nsIContentParent::AllocPJavaScriptParent() {
   return NewJavaScriptParent();
 }
 
 bool nsIContentParent::DeallocPJavaScriptParent(PJavaScriptParent* aParent) {
   ReleaseJavaScriptParent(aParent);
   return true;
 }
@@ -173,18 +168,18 @@ PBrowserParent* nsIContentParent::AllocP
   }
 
   // And because we're allocating a remote browser, of course the
   // window is remote.
   chromeFlags |= nsIWebBrowserChrome::CHROME_REMOTE_WINDOW;
 
   MaybeInvalidTabContext tc(aContext);
   MOZ_ASSERT(tc.IsValid());
-  TabParent* parent =
-      new TabParent(AsContentParent(), aTabId, tc.GetTabContext(), chromeFlags);
+  TabParent* parent = new TabParent(static_cast<ContentParent*>(this), aTabId,
+                                    tc.GetTabContext(), chromeFlags);
 
   // We release this ref in DeallocPBrowserParent()
   NS_ADDREF(parent);
   return parent;
 }
 
 bool nsIContentParent::DeallocPBrowserParent(PBrowserParent* aFrame) {
   TabParent* parent = TabParent::GetFrom(aFrame);
--- a/dom/ipc/nsIContentParent.h
+++ b/dom/ipc/nsIContentParent.h
@@ -69,20 +69,16 @@ class nsIContentParent : public nsISuppo
       mozilla::ipc::PIPCBlobInputStreamParent* aActor, const nsID& aID,
       const uint64_t& aSize) = 0;
 
   MOZ_MUST_USE virtual PBrowserParent* SendPBrowserConstructor(
       PBrowserParent* actor, const TabId& aTabId, const TabId& aSameTabGroupAs,
       const IPCTabContext& context, const uint32_t& chromeFlags,
       const ContentParentId& aCpId, const bool& aIsForBrowser) = 0;
 
-  virtual bool IsContentParent() const { return false; }
-
-  ContentParent* AsContentParent();
-
   mozilla::dom::ProcessMessageManager* GetMessageManager() const {
     return mMessageManager;
   }
 
   virtual bool SendActivate(PBrowserParent* aTab) = 0;
 
   virtual bool SendDeactivate(PBrowserParent* aTab) = 0;
 
--- a/layout/ipc/RenderFrame.cpp
+++ b/layout/ipc/RenderFrame.cpp
@@ -53,17 +53,17 @@ bool RenderFrame::Initialize(TabParent* 
   if (mInitialized || !aTabParent) {
     return false;
   }
 
   mTabParent = aTabParent;
   RefPtr<LayerManager> lm = GetLayerManager(mTabParent);
   PCompositorBridgeChild* compositor =
       lm ? lm->GetCompositorBridgeChild() : nullptr;
-  mTabProcessId = mTabParent->Manager()->AsContentParent()->OtherPid();
+  mTabProcessId = mTabParent->Manager()->OtherPid();
 
   // Our remote frame will push layers updates to the compositor,
   // and we'll keep an indirect reference to that tree.
   GPUProcessManager* gpm = GPUProcessManager::Get();
   mLayersConnected = gpm->AllocateAndConnectLayerTreeId(
       compositor, mTabProcessId, &mLayersId, &mCompositorOptions);
 
   mInitialized = true;
--- a/netwerk/protocol/http/HttpChannelParentListener.cpp
+++ b/netwerk/protocol/http/HttpChannelParentListener.cpp
@@ -191,19 +191,17 @@ nsresult HttpChannelParentListener::Trig
 
         nsCOMPtr<nsIURI> originalURI;
         channel->GetOriginalURI(getter_AddRefs(originalURI));
 
         uint64_t channelId;
         MOZ_ALWAYS_SUCCEEDS(httpChannel->GetChannelId(&channelId));
 
         dom::TabParent* tabParent = dom::TabParent::GetFrom(tp);
-        ContentParent* cp = tabParent->Manager()->AsContentParent();
-
-        auto result = cp->SendCrossProcessRedirect(
+        auto result = tabParent->Manager()->SendCrossProcessRedirect(
             self->mRedirectChannelId, uri, newLoadFlags, loadInfoArgs,
             channelId, originalURI, aIdentifier);
 
         MOZ_ASSERT(result, "SendCrossProcessRedirect failed");
 
         return result ? NS_OK : NS_ERROR_UNEXPECTED;
       },
       [httpChannel](nsresult aStatus) {