LCOV - code coverage report
Current view: top level - dom/base - nsIGlobalObject.h (source / functions) Hit Total Coverage
Test: output.info Lines: 8 8 100.0 %
Date: 2017-07-14 16:53:18 Functions: 3 3 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 nsIGlobalObject_h__
       8             : #define nsIGlobalObject_h__
       9             : 
      10             : #include "mozilla/dom/DispatcherTrait.h"
      11             : #include "nsISupports.h"
      12             : #include "nsTArray.h"
      13             : #include "js/TypeDecls.h"
      14             : 
      15             : #define NS_IGLOBALOBJECT_IID \
      16             : { 0x11afa8be, 0xd997, 0x4e07, \
      17             : { 0xa6, 0xa3, 0x6f, 0x87, 0x2e, 0xc3, 0xee, 0x7f } }
      18             : 
      19             : class nsACString;
      20             : class nsCString;
      21             : class nsCycleCollectionTraversalCallback;
      22             : class nsIPrincipal;
      23             : 
      24             : class nsIGlobalObject : public nsISupports,
      25             :                         public mozilla::dom::DispatcherTrait
      26             : {
      27             :   nsTArray<nsCString> mHostObjectURIs;
      28             :   bool mIsDying;
      29             : 
      30             : protected:
      31         299 :   nsIGlobalObject()
      32         299 :    : mIsDying(false)
      33         299 :   {}
      34             : 
      35             : public:
      36             :   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IGLOBALOBJECT_IID)
      37             : 
      38             :   /**
      39             :    * This check is added to deal with Promise microtask queues. On the main
      40             :    * thread, we do not impose restrictions about when script stops running or
      41             :    * when runnables can no longer be dispatched to the main thread. This means
      42             :    * it is possible for a Promise chain to keep resolving an infinite chain of
      43             :    * promises, preventing the browser from shutting down. See Bug 1058695. To
      44             :    * prevent this, the nsGlobalWindow subclass sets this flag when it is
      45             :    * closed. The Promise implementation checks this and prohibits new runnables
      46             :    * from being dispatched.
      47             :    *
      48             :    * We pair this with checks during processing the promise microtask queue
      49             :    * that pops up the slow script dialog when the Promise queue is preventing
      50             :    * a window from going away.
      51             :    */
      52             :   bool
      53         235 :   IsDying() const
      54             :   {
      55         235 :     return mIsDying;
      56             :   }
      57             : 
      58             :   // GetGlobalJSObject may return a gray object.  If this ever changes so that
      59             :   // it stops doing that, please simplify the code in FindAssociatedGlobal in
      60             :   // BindingUtils.h that does JS::ExposeObjectToActiveJS on the return value of
      61             :   // GetGlobalJSObject.  Also, in that case the JS::ExposeObjectToActiveJS in
      62             :   // AutoJSAPI::InitInternal can probably be removed.  And also the similar
      63             :   // calls in XrayWrapper and nsGlobalWindow.
      64             :   virtual JSObject* GetGlobalJSObject() = 0;
      65             : 
      66             :   // This method is not meant to be overridden.
      67             :   nsIPrincipal* PrincipalOrNull();
      68             : 
      69             :   void RegisterHostObjectURI(const nsACString& aURI);
      70             : 
      71             :   void UnregisterHostObjectURI(const nsACString& aURI);
      72             : 
      73             :   // Any CC class inheriting nsIGlobalObject should call these 2 methods if it
      74             :   // exposes the URL API.
      75             :   void UnlinkHostObjectURIs();
      76             :   void TraverseHostObjectURIs(nsCycleCollectionTraversalCallback &aCb);
      77             : 
      78             : protected:
      79             :   virtual ~nsIGlobalObject();
      80             : 
      81             :   void
      82           2 :   StartDying()
      83             :   {
      84           2 :     mIsDying = true;
      85           2 :   }
      86             : };
      87             : 
      88             : NS_DEFINE_STATIC_IID_ACCESSOR(nsIGlobalObject,
      89             :                               NS_IGLOBALOBJECT_IID)
      90             : 
      91             : #endif // nsIGlobalObject_h__

Generated by: LCOV version 1.13