LCOV - code coverage report
Current view: top level - xpcom/base - HoldDropJSObjects.h (source / functions) Hit Total Coverage
Test: output.info Lines: 15 18 83.3 %
Date: 2017-07-14 16:53:18 Functions: 50 258 19.4 %
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             : #ifndef mozilla_HoldDropJSObjects_h
       8             : #define mozilla_HoldDropJSObjects_h
       9             : 
      10             : #include "mozilla/TypeTraits.h"
      11             : #include "nsCycleCollectionParticipant.h"
      12             : 
      13             : class nsISupports;
      14             : class nsScriptObjectTracer;
      15             : 
      16             : // Only HoldJSObjects and DropJSObjects should be called directly.
      17             : 
      18             : namespace mozilla {
      19             : namespace cyclecollector {
      20             : 
      21             : void HoldJSObjectsImpl(void* aHolder, nsScriptObjectTracer* aTracer);
      22             : void HoldJSObjectsImpl(nsISupports* aHolder);
      23             : void DropJSObjectsImpl(void* aHolder);
      24             : void DropJSObjectsImpl(nsISupports* aHolder);
      25             : 
      26             : } // namespace cyclecollector
      27             : 
      28             : 
      29             : template<class T, bool isISupports = IsBaseOf<nsISupports, T>::value>
      30             : struct HoldDropJSObjectsHelper
      31             : {
      32          39 :   static void Hold(T* aHolder)
      33             :   {
      34          39 :     cyclecollector::HoldJSObjectsImpl(aHolder,
      35             :                                       NS_CYCLE_COLLECTION_PARTICIPANT(T));
      36          39 :   }
      37           0 :   static void Drop(T* aHolder)
      38             :   {
      39           0 :     cyclecollector::DropJSObjectsImpl(aHolder);
      40           0 :   }
      41             : };
      42             : 
      43             : template<class T>
      44             : struct HoldDropJSObjectsHelper<T, true>
      45             : {
      46        3163 :   static void Hold(T* aHolder)
      47             :   {
      48        3163 :     cyclecollector::HoldJSObjectsImpl(ToSupports(aHolder));
      49        3163 :   }
      50         281 :   static void Drop(T* aHolder)
      51             :   {
      52         281 :     cyclecollector::DropJSObjectsImpl(ToSupports(aHolder));
      53         281 :   }
      54             : };
      55             : 
      56             : 
      57             : template<class T>
      58             : void
      59        3202 : HoldJSObjects(T* aHolder)
      60             : {
      61        3202 :   HoldDropJSObjectsHelper<T>::Hold(aHolder);
      62        3202 : }
      63             : 
      64             : template<class T>
      65             : void
      66         281 : DropJSObjects(T* aHolder)
      67             : {
      68         281 :   HoldDropJSObjectsHelper<T>::Drop(aHolder);
      69         281 : }
      70             : 
      71             : #ifdef DEBUG
      72             : bool IsJSHolder(void* aHolder);
      73             : #endif
      74             : 
      75             : } // namespace mozilla
      76             : 
      77             : #endif // mozilla_HoldDropJSObjects_h

Generated by: LCOV version 1.13