LCOV - code coverage report
Current view: top level - dom/base - ProcessGlobal.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 40 58 69.0 %
Date: 2017-07-14 16:53:18 Functions: 9 15 60.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
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #include "ProcessGlobal.h"
       8             : 
       9             : #include "nsContentCID.h"
      10             : #include "nsDOMClassInfoID.h"
      11             : #include "mozilla/HoldDropJSObjects.h"
      12             : 
      13             : using namespace mozilla;
      14             : using namespace mozilla::dom;
      15             : 
      16           3 : ProcessGlobal::ProcessGlobal(nsFrameMessageManager* aMessageManager)
      17             :  : mInitialized(false),
      18           3 :    mMessageManager(aMessageManager)
      19             : {
      20           3 :   SetIsNotDOMBinding();
      21           3 :   mozilla::HoldJSObjects(this);
      22           3 : }
      23             : 
      24           0 : ProcessGlobal::~ProcessGlobal()
      25             : {
      26           0 :   mAnonymousGlobalScopes.Clear();
      27           0 :   mozilla::DropJSObjects(this);
      28           0 : }
      29             : 
      30             : ProcessGlobal*
      31          30 : ProcessGlobal::Get()
      32             : {
      33          60 :   nsCOMPtr<nsISyncMessageSender> service = do_GetService(NS_CHILDPROCESSMESSAGEMANAGER_CONTRACTID);
      34          30 :   if (!service) {
      35           0 :     return nullptr;
      36             :   }
      37          30 :   return static_cast<ProcessGlobal*>(service.get());
      38             : }
      39             : 
      40             : // This method isn't automatically forwarded safely because it's notxpcom, so
      41             : // the IDL binding doesn't know what value to return.
      42             : NS_IMETHODIMP_(bool)
      43           0 : ProcessGlobal::MarkForCC()
      44             : {
      45           0 :   MarkScopesForCC();
      46           0 :   return mMessageManager ? mMessageManager->MarkForCC() : false;
      47             : }
      48             : 
      49             : NS_IMPL_CYCLE_COLLECTION_CLASS(ProcessGlobal)
      50             : 
      51           0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(ProcessGlobal)
      52           0 :   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMessageManager)
      53           0 :   tmp->TraverseHostObjectURIs(cb);
      54           0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
      55             : 
      56           2 : NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(ProcessGlobal)
      57           2 :   NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
      58           2 :   tmp->nsMessageManagerScriptExecutor::Trace(aCallbacks, aClosure);
      59           2 : NS_IMPL_CYCLE_COLLECTION_TRACE_END
      60             : 
      61           0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ProcessGlobal)
      62           0 :   NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
      63           0 :   NS_IMPL_CYCLE_COLLECTION_UNLINK(mMessageManager)
      64           0 :   tmp->nsMessageManagerScriptExecutor::Unlink();
      65           0 :   tmp->UnlinkHostObjectURIs();
      66           0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_END
      67             : 
      68         512 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ProcessGlobal)
      69         498 :   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
      70         486 :   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContentProcessMessageManager)
      71         477 :   NS_INTERFACE_MAP_ENTRY(nsIMessageListenerManager)
      72         472 :   NS_INTERFACE_MAP_ENTRY(nsIMessageSender)
      73         465 :   NS_INTERFACE_MAP_ENTRY(nsISyncMessageSender)
      74         432 :   NS_INTERFACE_MAP_ENTRY(nsIContentProcessMessageManager)
      75         429 :   NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
      76         429 :   NS_INTERFACE_MAP_ENTRY(nsIGlobalObject)
      77          18 :   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
      78          18 :   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ContentProcessMessageManager)
      79          15 : NS_INTERFACE_MAP_END
      80             : 
      81         759 : NS_IMPL_CYCLE_COLLECTING_ADDREF(ProcessGlobal)
      82         741 : NS_IMPL_CYCLE_COLLECTING_RELEASE(ProcessGlobal)
      83             : 
      84             : bool
      85          30 : ProcessGlobal::Init()
      86             : {
      87          30 :   if (mInitialized) {
      88          27 :     return true;
      89             :   }
      90           3 :   mInitialized = true;
      91             : 
      92           3 :   nsISupports* scopeSupports = NS_ISUPPORTS_CAST(nsIContentProcessMessageManager*, this);
      93           3 :   return InitChildGlobalInternal(scopeSupports, NS_LITERAL_CSTRING("processChildGlobal"));
      94             : }
      95             : 
      96             : void
      97          27 : ProcessGlobal::LoadScript(const nsAString& aURL)
      98             : {
      99          27 :   Init();
     100          27 :   LoadScriptInternal(aURL, false);
     101          27 : }
     102             : 
     103             : void
     104           2 : ProcessGlobal::SetInitialProcessData(JS::HandleValue aInitialData)
     105             : {
     106           2 :   mMessageManager->SetInitialProcessData(aInitialData);
     107           2 : }

Generated by: LCOV version 1.13