2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-04-04 13:27:06 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef nsIGlobalObject_h__
|
|
|
|
#define nsIGlobalObject_h__
|
|
|
|
|
|
|
|
#include "nsISupports.h"
|
2015-05-07 10:05:43 +03:00
|
|
|
#include "nsTArray.h"
|
2013-08-28 06:59:14 +04:00
|
|
|
#include "js/TypeDecls.h"
|
2013-04-04 13:27:06 +04:00
|
|
|
|
|
|
|
#define NS_IGLOBALOBJECT_IID \
|
2015-05-07 10:05:43 +03:00
|
|
|
{ 0x11afa8be, 0xd997, 0x4e07, \
|
|
|
|
{ 0xa6, 0xa3, 0x6f, 0x87, 0x2e, 0xc3, 0xee, 0x7f } }
|
2013-04-04 13:27:06 +04:00
|
|
|
|
2015-05-07 10:05:43 +03:00
|
|
|
class nsACString;
|
|
|
|
class nsCString;
|
|
|
|
class nsCycleCollectionTraversalCallback;
|
2014-01-07 22:53:31 +04:00
|
|
|
class nsIPrincipal;
|
|
|
|
|
2013-09-09 07:28:48 +04:00
|
|
|
class nsIGlobalObject : public nsISupports
|
2013-04-04 13:27:06 +04:00
|
|
|
{
|
2015-06-29 19:44:18 +03:00
|
|
|
nsTArray<nsCString> mHostObjectURIs;
|
2015-04-27 22:00:41 +03:00
|
|
|
bool mIsDying;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
nsIGlobalObject()
|
|
|
|
: mIsDying(false)
|
|
|
|
{}
|
|
|
|
|
2013-04-04 13:27:06 +04:00
|
|
|
public:
|
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IGLOBALOBJECT_IID)
|
|
|
|
|
2015-04-27 22:00:41 +03:00
|
|
|
/**
|
|
|
|
* This check is added to deal with Promise microtask queues. On the main
|
|
|
|
* thread, we do not impose restrictions about when script stops running or
|
|
|
|
* when runnables can no longer be dispatched to the main thread. This means
|
|
|
|
* it is possible for a Promise chain to keep resolving an infinite chain of
|
|
|
|
* promises, preventing the browser from shutting down. See Bug 1058695. To
|
|
|
|
* prevent this, the nsGlobalWindow subclass sets this flag when it is
|
|
|
|
* closed. The Promise implementation checks this and prohibits new runnables
|
|
|
|
* from being dispatched.
|
|
|
|
*
|
|
|
|
* We pair this with checks during processing the promise microtask queue
|
|
|
|
* that pops up the slow script dialog when the Promise queue is preventing
|
|
|
|
* a window from going away.
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
IsDying() const
|
|
|
|
{
|
|
|
|
return mIsDying;
|
|
|
|
}
|
|
|
|
|
2016-07-27 18:05:36 +03:00
|
|
|
// GetGlobalJSObject may return a gray object. If this ever changes so that
|
|
|
|
// it stops doing that, please simplify the code in FindAssociatedGlobal in
|
|
|
|
// BindingUtils.h that does JS::ExposeObjectToActiveJS on the return value of
|
|
|
|
// GetGlobalJSObject.
|
2013-04-04 13:27:06 +04:00
|
|
|
virtual JSObject* GetGlobalJSObject() = 0;
|
2014-01-07 22:53:31 +04:00
|
|
|
|
|
|
|
// This method is not meant to be overridden.
|
|
|
|
nsIPrincipal* PrincipalOrNull();
|
2015-04-27 22:00:41 +03:00
|
|
|
|
2015-05-07 10:05:43 +03:00
|
|
|
void RegisterHostObjectURI(const nsACString& aURI);
|
|
|
|
|
|
|
|
void UnregisterHostObjectURI(const nsACString& aURI);
|
|
|
|
|
|
|
|
// Any CC class inheriting nsIGlobalObject should call these 2 methods if it
|
|
|
|
// exposes the URL API.
|
|
|
|
void UnlinkHostObjectURIs();
|
|
|
|
void TraverseHostObjectURIs(nsCycleCollectionTraversalCallback &aCb);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~nsIGlobalObject();
|
|
|
|
|
2015-04-27 22:00:41 +03:00
|
|
|
void
|
|
|
|
StartDying()
|
|
|
|
{
|
|
|
|
mIsDying = true;
|
|
|
|
}
|
2013-04-04 13:27:06 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsIGlobalObject,
|
|
|
|
NS_IGLOBALOBJECT_IID)
|
|
|
|
|
|
|
|
#endif // nsIGlobalObject_h__
|