LCOV - code coverage report
Current view: top level - xpcom/base - HoldDropJSObjects.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 24 28 85.7 %
Date: 2017-07-14 16:53:18 Functions: 4 5 80.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 "mozilla/HoldDropJSObjects.h"
       8             : 
       9             : #include "mozilla/Assertions.h"
      10             : #include "mozilla/CycleCollectedJSRuntime.h"
      11             : 
      12             : namespace mozilla {
      13             : namespace cyclecollector {
      14             : 
      15             : void
      16        3461 : HoldJSObjectsImpl(void* aHolder, nsScriptObjectTracer* aTracer)
      17             : {
      18        3461 :   CycleCollectedJSRuntime* rt = CycleCollectedJSRuntime::Get();
      19        3461 :   MOZ_ASSERT(rt, "Should have a CycleCollectedJSRuntime by now");
      20        3461 :   rt->AddJSHolder(aHolder, aTracer);
      21        3461 : }
      22             : 
      23             : void
      24        3163 : HoldJSObjectsImpl(nsISupports* aHolder)
      25             : {
      26        3163 :   nsXPCOMCycleCollectionParticipant* participant = nullptr;
      27        3163 :   CallQueryInterface(aHolder, &participant);
      28        3163 :   MOZ_ASSERT(participant, "Failed to QI to nsXPCOMCycleCollectionParticipant!");
      29        3163 :   MOZ_ASSERT(participant->CheckForRightISupports(aHolder),
      30             :              "The result of QIing a JS holder should be the same as ToSupports");
      31             : 
      32        3163 :   HoldJSObjectsImpl(aHolder, participant);
      33        3163 : }
      34             : 
      35             : void
      36         281 : DropJSObjectsImpl(void* aHolder)
      37             : {
      38         281 :   CycleCollectedJSRuntime* rt = CycleCollectedJSRuntime::Get();
      39         281 :   MOZ_ASSERT(rt, "Should have a CycleCollectedJSRuntime by now");
      40         281 :   rt->RemoveJSHolder(aHolder);
      41         281 : }
      42             : 
      43             : void
      44         281 : DropJSObjectsImpl(nsISupports* aHolder)
      45             : {
      46             : #ifdef DEBUG
      47         281 :   nsXPCOMCycleCollectionParticipant* participant = nullptr;
      48         281 :   CallQueryInterface(aHolder, &participant);
      49         281 :   MOZ_ASSERT(participant, "Failed to QI to nsXPCOMCycleCollectionParticipant!");
      50         281 :   MOZ_ASSERT(participant->CheckForRightISupports(aHolder),
      51             :              "The result of QIing a JS holder should be the same as ToSupports");
      52             : #endif
      53         281 :   DropJSObjectsImpl(static_cast<void*>(aHolder));
      54         281 : }
      55             : 
      56             : } // namespace cyclecollector
      57             : 
      58             : #ifdef DEBUG
      59             : bool
      60           0 : IsJSHolder(void* aHolder)
      61             : {
      62           0 :   CycleCollectedJSRuntime* rt = CycleCollectedJSRuntime::Get();
      63           0 :   MOZ_ASSERT(rt, "Should have a CycleCollectedJSRuntime by now");
      64           0 :   return rt->IsJSHolder(aHolder);
      65             : }
      66             : #endif
      67             : 
      68             : } // namespace mozilla

Generated by: LCOV version 1.13