LCOV - code coverage report
Current view: top level - dom/ipc - ContentBridgeParent.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 81 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 30 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
       5             :  * You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #include "mozilla/dom/ContentBridgeParent.h"
       8             : #include "mozilla/dom/TabParent.h"
       9             : #include "mozilla/jsipc/CrossProcessObjectWrappers.h"
      10             : #include "nsXULAppAPI.h"
      11             : #include "nsIObserverService.h"
      12             : #include "base/task.h"
      13             : 
      14             : using namespace mozilla::ipc;
      15             : using namespace mozilla::jsipc;
      16             : 
      17             : namespace mozilla {
      18             : namespace dom {
      19             : 
      20           0 : NS_IMPL_ISUPPORTS(ContentBridgeParent,
      21             :                   nsIContentParent,
      22             :                   nsIObserver)
      23             : 
      24           0 : ContentBridgeParent::ContentBridgeParent()
      25           0 :   : mIsForJSPlugin(false)
      26           0 : {}
      27             : 
      28           0 : ContentBridgeParent::~ContentBridgeParent()
      29             : {
      30           0 : }
      31             : 
      32             : void
      33           0 : ContentBridgeParent::ActorDestroy(ActorDestroyReason aWhy)
      34             : {
      35           0 :   nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
      36           0 :   if (os) {
      37           0 :     os->RemoveObserver(this, "content-child-shutdown");
      38             :   }
      39           0 :   MessageLoop::current()->PostTask(
      40           0 :     NewRunnableMethod("dom::ContentBridgeParent::DeferredDestroy",
      41             :                       this,
      42           0 :                       &ContentBridgeParent::DeferredDestroy));
      43           0 : }
      44             : 
      45             : /*static*/ ContentBridgeParent*
      46           0 : ContentBridgeParent::Create(Endpoint<PContentBridgeParent>&& aEndpoint)
      47             : {
      48           0 :   RefPtr<ContentBridgeParent> bridge = new ContentBridgeParent();
      49           0 :   bridge->mSelfRef = bridge;
      50             : 
      51           0 :   DebugOnly<bool> ok = aEndpoint.Bind(bridge);
      52           0 :   MOZ_ASSERT(ok);
      53             : 
      54           0 :   nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
      55           0 :   if (os) {
      56           0 :     os->AddObserver(bridge, "content-child-shutdown", false);
      57             :   }
      58             : 
      59             :   // Initialize the message manager (and load delayed scripts) now that we
      60             :   // have established communications with the child.
      61           0 :   bridge->mMessageManager->InitWithCallback(bridge);
      62             : 
      63           0 :   return bridge.get();
      64             : }
      65             : 
      66             : void
      67           0 : ContentBridgeParent::DeferredDestroy()
      68             : {
      69           0 :   mSelfRef = nullptr;
      70             :   // |this| was just destroyed, hands off
      71           0 : }
      72             : 
      73             : mozilla::ipc::IPCResult
      74           0 : ContentBridgeParent::RecvSyncMessage(const nsString& aMsg,
      75             :                                      const ClonedMessageData& aData,
      76             :                                      InfallibleTArray<jsipc::CpowEntry>&& aCpows,
      77             :                                      const IPC::Principal& aPrincipal,
      78             :                                      nsTArray<StructuredCloneData>* aRetvals)
      79             : {
      80           0 :   return nsIContentParent::RecvSyncMessage(aMsg, aData, Move(aCpows),
      81           0 :                                            aPrincipal, aRetvals);
      82             : }
      83             : 
      84             : mozilla::ipc::IPCResult
      85           0 : ContentBridgeParent::RecvAsyncMessage(const nsString& aMsg,
      86             :                                       InfallibleTArray<jsipc::CpowEntry>&& aCpows,
      87             :                                       const IPC::Principal& aPrincipal,
      88             :                                       const ClonedMessageData& aData)
      89             : {
      90           0 :   return nsIContentParent::RecvAsyncMessage(aMsg, Move(aCpows),
      91           0 :                                             aPrincipal, aData);
      92             : }
      93             : 
      94             : PBrowserParent*
      95           0 : ContentBridgeParent::SendPBrowserConstructor(PBrowserParent* aActor,
      96             :                                              const TabId& aTabId,
      97             :                                              const TabId& aSameTabGroupAs,
      98             :                                              const IPCTabContext& aContext,
      99             :                                              const uint32_t& aChromeFlags,
     100             :                                              const ContentParentId& aCpID,
     101             :                                              const bool& aIsForBrowser)
     102             : {
     103           0 :   return PContentBridgeParent::SendPBrowserConstructor(aActor,
     104             :                                                        aTabId,
     105             :                                                        aSameTabGroupAs,
     106             :                                                        aContext,
     107             :                                                        aChromeFlags,
     108             :                                                        aCpID,
     109           0 :                                                        aIsForBrowser);
     110             : }
     111             : 
     112             : PParentToChildStreamParent*
     113           0 : ContentBridgeParent::SendPParentToChildStreamConstructor(PParentToChildStreamParent* aActor)
     114             : {
     115           0 :   return PContentBridgeParent::SendPParentToChildStreamConstructor(aActor);
     116             : }
     117             : 
     118             : PIPCBlobInputStreamParent*
     119           0 : ContentBridgeParent::SendPIPCBlobInputStreamConstructor(PIPCBlobInputStreamParent* aActor,
     120             :                                                         const nsID& aID,
     121             :                                                         const uint64_t& aSize)
     122             : {
     123             :   return
     124           0 :     PContentBridgeParent::SendPIPCBlobInputStreamConstructor(aActor, aID, aSize);
     125             : }
     126             : 
     127             : PIPCBlobInputStreamParent*
     128           0 : ContentBridgeParent::AllocPIPCBlobInputStreamParent(const nsID& aID,
     129             :                                                     const uint64_t& aSize)
     130             : {
     131           0 :   return nsIContentParent::AllocPIPCBlobInputStreamParent(aID, aSize);
     132             : }
     133             : 
     134             : bool
     135           0 : ContentBridgeParent::DeallocPIPCBlobInputStreamParent(PIPCBlobInputStreamParent* aActor)
     136             : {
     137           0 :   return nsIContentParent::DeallocPIPCBlobInputStreamParent(aActor);
     138             : }
     139             : 
     140             : mozilla::jsipc::PJavaScriptParent *
     141           0 : ContentBridgeParent::AllocPJavaScriptParent()
     142             : {
     143           0 :   return nsIContentParent::AllocPJavaScriptParent();
     144             : }
     145             : 
     146             : bool
     147           0 : ContentBridgeParent::DeallocPJavaScriptParent(PJavaScriptParent *parent)
     148             : {
     149           0 :   return nsIContentParent::DeallocPJavaScriptParent(parent);
     150             : }
     151             : 
     152             : PBrowserParent*
     153           0 : ContentBridgeParent::AllocPBrowserParent(const TabId& aTabId,
     154             :                                          const TabId& aSameTabGroupAs,
     155             :                                          const IPCTabContext &aContext,
     156             :                                          const uint32_t& aChromeFlags,
     157             :                                          const ContentParentId& aCpID,
     158             :                                          const bool& aIsForBrowser)
     159             : {
     160           0 :   return nsIContentParent::AllocPBrowserParent(aTabId,
     161             :                                                aSameTabGroupAs,
     162             :                                                aContext,
     163             :                                                aChromeFlags,
     164             :                                                aCpID,
     165           0 :                                                aIsForBrowser);
     166             : }
     167             : 
     168             : bool
     169           0 : ContentBridgeParent::DeallocPBrowserParent(PBrowserParent* aParent)
     170             : {
     171           0 :   return nsIContentParent::DeallocPBrowserParent(aParent);
     172             : }
     173             : 
     174             : void
     175           0 : ContentBridgeParent::NotifyTabDestroyed()
     176             : {
     177           0 :   int32_t numLiveTabs = ManagedPBrowserParent().Count();
     178           0 :   if (numLiveTabs == 1) {
     179           0 :     MessageLoop::current()->PostTask(NewRunnableMethod(
     180           0 :       "dom::ContentBridgeParent::Close", this, &ContentBridgeParent::Close));
     181             :   }
     182           0 : }
     183             : 
     184             : // This implementation is identical to ContentParent::GetCPOWManager but we can't
     185             : // move it to nsIContentParent because it calls ManagedPJavaScriptParent() which
     186             : // only exists in PContentParent and PContentBridgeParent.
     187             : jsipc::CPOWManager*
     188           0 : ContentBridgeParent::GetCPOWManager()
     189             : {
     190           0 :   if (PJavaScriptParent* p = LoneManagedOrNullAsserts(ManagedPJavaScriptParent())) {
     191           0 :     return CPOWManagerFor(p);
     192             :   }
     193           0 :   return nullptr;
     194             : }
     195             : 
     196             : NS_IMETHODIMP
     197           0 : ContentBridgeParent::Observe(nsISupports* aSubject,
     198             :                              const char* aTopic,
     199             :                              const char16_t* aData)
     200             : {
     201           0 :   if (!strcmp(aTopic, "content-child-shutdown")) {
     202           0 :     Close();
     203             :   }
     204           0 :   return NS_OK;
     205             : }
     206             : 
     207             : PFileDescriptorSetParent*
     208           0 : ContentBridgeParent::SendPFileDescriptorSetConstructor(const FileDescriptor& aFD)
     209             : {
     210           0 :   return PContentBridgeParent::SendPFileDescriptorSetConstructor(aFD);
     211             : }
     212             : 
     213             : PFileDescriptorSetParent*
     214           0 : ContentBridgeParent::AllocPFileDescriptorSetParent(const FileDescriptor& aFD)
     215             : {
     216           0 :   return nsIContentParent::AllocPFileDescriptorSetParent(aFD);
     217             : }
     218             : 
     219             : bool
     220           0 : ContentBridgeParent::DeallocPFileDescriptorSetParent(PFileDescriptorSetParent* aActor)
     221             : {
     222           0 :   return nsIContentParent::DeallocPFileDescriptorSetParent(aActor);
     223             : }
     224             : 
     225             : PChildToParentStreamParent*
     226           0 : ContentBridgeParent::AllocPChildToParentStreamParent()
     227             : {
     228           0 :   return nsIContentParent::AllocPChildToParentStreamParent();
     229             : }
     230             : 
     231             : bool
     232           0 : ContentBridgeParent::DeallocPChildToParentStreamParent(PChildToParentStreamParent* aActor)
     233             : {
     234           0 :   return nsIContentParent::DeallocPChildToParentStreamParent(aActor);
     235             : }
     236             : 
     237             : PParentToChildStreamParent*
     238           0 : ContentBridgeParent::AllocPParentToChildStreamParent()
     239             : {
     240           0 :   return nsIContentParent::AllocPParentToChildStreamParent();
     241             : }
     242             : 
     243             : bool
     244           0 : ContentBridgeParent::DeallocPParentToChildStreamParent(PParentToChildStreamParent* aActor)
     245             : {
     246           0 :   return nsIContentParent::DeallocPParentToChildStreamParent(aActor);
     247             : }
     248             : 
     249             : } // namespace dom
     250             : } // namespace mozilla

Generated by: LCOV version 1.13