LCOV - code coverage report
Current view: top level - layout/build - nsLayoutStatics.h (source / functions) Hit Total Coverage
Test: output.info Lines: 6 13 46.2 %
Date: 2017-07-14 16:53:18 Functions: 1 2 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* This Source Code Form is subject to the terms of the Mozilla Public
       2             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       3             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       4             : 
       5             : #ifndef nsLayoutStatics_h__
       6             : #define nsLayoutStatics_h__
       7             : 
       8             : #include "nscore.h"
       9             : #include "MainThreadUtils.h"
      10             : #include "nsISupportsImpl.h"
      11             : #include "nsDebug.h"
      12             : 
      13             : // This isn't really a class, it's a namespace for static methods.
      14             : // Documents and other objects can hold a reference to the layout static
      15             : // objects so that they last past the xpcom-shutdown notification.
      16             : 
      17             : class nsLayoutStatics
      18             : {
      19             : public:
      20             :   // Called by the layout module constructor. This call performs an AddRef()
      21             :   // internally.
      22             :   static nsresult Initialize();
      23             : 
      24          77 :   static void AddRef()
      25             :   {
      26          77 :     NS_ASSERTION(NS_IsMainThread(),
      27             :                  "nsLayoutStatics reference counting must be on main thread");
      28             : 
      29          77 :     NS_ASSERTION(sLayoutStaticRefcnt,
      30             :                  "nsLayoutStatics already dropped to zero!");
      31             : 
      32          77 :     ++sLayoutStaticRefcnt;
      33             :     NS_LOG_ADDREF(&sLayoutStaticRefcnt, sLayoutStaticRefcnt,
      34          77 :                   "nsLayoutStatics", 1);
      35          77 :   }
      36           0 :   static void Release()
      37             :   {
      38           0 :     NS_ASSERTION(NS_IsMainThread(),
      39             :                  "nsLayoutStatics reference counting must be on main thread");
      40             : 
      41           0 :     --sLayoutStaticRefcnt;
      42             :     NS_LOG_RELEASE(&sLayoutStaticRefcnt, sLayoutStaticRefcnt,
      43           0 :                    "nsLayoutStatics");
      44             : 
      45           0 :     if (!sLayoutStaticRefcnt)
      46           0 :       Shutdown();
      47           0 :   }
      48             : 
      49             : private:
      50             :   // not to be called!
      51             :   nsLayoutStatics();
      52             : 
      53             :   static void Shutdown();
      54             : 
      55             :   static nsrefcnt sLayoutStaticRefcnt;
      56             : };
      57             : 
      58             : class nsLayoutStaticsRef
      59             : {
      60             : public:
      61             :   nsLayoutStaticsRef()
      62             :   {
      63             :     nsLayoutStatics::AddRef();
      64             :   }
      65             :   ~nsLayoutStaticsRef()
      66             :   {
      67             :     nsLayoutStatics::Release();
      68             :   }
      69             : };
      70             : 
      71             : #endif // nsLayoutStatics_h__

Generated by: LCOV version 1.13