LCOV - code coverage report
Current view: top level - xpcom/base - nsWeakReference.h (source / functions) Hit Total Coverage
Test: output.info Lines: 6 6 100.0 %
Date: 2017-07-14 16:53:18 Functions: 4 4 100.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             : #ifndef nsWeakReference_h__
       8             : #define nsWeakReference_h__
       9             : 
      10             : // nsWeakReference.h
      11             : 
      12             : // See mfbt/WeakPtr.h for a more typesafe C++ implementation of weak references
      13             : 
      14             : #include "nsIWeakReferenceUtils.h"
      15             : 
      16             : class nsWeakReference;
      17             : 
      18             : class nsSupportsWeakReference : public nsISupportsWeakReference
      19             : {
      20             : public:
      21        2071 :   nsSupportsWeakReference() : mProxy(0) {}
      22             : 
      23             :   NS_DECL_NSISUPPORTSWEAKREFERENCE
      24             : 
      25             : protected:
      26             :   inline ~nsSupportsWeakReference();
      27             : 
      28             : private:
      29             :   friend class nsWeakReference;
      30             : 
      31             :   // Called (only) by an |nsWeakReference| from _its_ dtor.
      32             :   // The thread safety check is made by the caller.
      33          30 :   void NoticeProxyDestruction() { mProxy = nullptr; }
      34             : 
      35             :   nsWeakReference* MOZ_NON_OWNING_REF mProxy;
      36             : 
      37             : protected:
      38             : 
      39             :   void ClearWeakReferences();
      40         216 :   bool HasWeakReferences() const { return !!mProxy; }
      41             : };
      42             : 
      43             : inline
      44         426 : nsSupportsWeakReference::~nsSupportsWeakReference()
      45             : {
      46         213 :   ClearWeakReferences();
      47         213 : }
      48             : 
      49             : #endif

Generated by: LCOV version 1.13