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: */
|
2014-07-02 08:19:48 +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 mozilla_dom_PromiseDebugging_h
|
|
|
|
#define mozilla_dom_PromiseDebugging_h
|
|
|
|
|
2014-10-20 06:27:12 +04:00
|
|
|
#include "js/TypeDecls.h"
|
2014-10-20 06:27:36 +04:00
|
|
|
#include "nsTArray.h"
|
2015-10-18 08:24:48 +03:00
|
|
|
#include "mozilla/RefPtr.h"
|
2014-10-20 06:27:12 +04:00
|
|
|
|
2014-07-02 08:19:48 +04:00
|
|
|
namespace mozilla {
|
2014-10-20 21:02:21 +04:00
|
|
|
|
|
|
|
class ErrorResult;
|
|
|
|
|
2014-07-02 08:19:48 +04:00
|
|
|
namespace dom {
|
2015-04-10 18:27:57 +03:00
|
|
|
namespace workers {
|
|
|
|
class WorkerPrivate;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace workers
|
2014-07-02 08:19:48 +04:00
|
|
|
|
|
|
|
class Promise;
|
|
|
|
struct PromiseDebuggingStateHolder;
|
|
|
|
class GlobalObject;
|
2015-04-10 18:27:57 +03:00
|
|
|
class UncaughtRejectionObserver;
|
|
|
|
class FlushRejections;
|
2014-07-02 08:19:48 +04:00
|
|
|
|
|
|
|
class PromiseDebugging
|
|
|
|
{
|
|
|
|
public:
|
2015-04-10 18:27:57 +03:00
|
|
|
static void Init();
|
|
|
|
static void Shutdown();
|
|
|
|
|
2016-02-10 01:40:31 +03:00
|
|
|
#ifndef SPIDERMONKEY_PROMISE
|
2015-11-25 23:48:09 +03:00
|
|
|
static void GetState(GlobalObject&, JS::Handle<JSObject*> aPromise,
|
|
|
|
PromiseDebuggingStateHolder& aState,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
|
|
|
static void GetAllocationStack(GlobalObject&, JS::Handle<JSObject*> aPromise,
|
|
|
|
JS::MutableHandle<JSObject*> aStack,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
static void GetRejectionStack(GlobalObject&, JS::Handle<JSObject*> aPromise,
|
|
|
|
JS::MutableHandle<JSObject*> aStack,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
static void GetFullfillmentStack(GlobalObject&,
|
|
|
|
JS::Handle<JSObject*> aPromise,
|
|
|
|
JS::MutableHandle<JSObject*> aStack,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
static void GetDependentPromises(GlobalObject&,
|
|
|
|
JS::Handle<JSObject*> aPromise,
|
|
|
|
nsTArray<RefPtr<Promise>>& aPromises,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
static double GetPromiseLifetime(GlobalObject&,
|
|
|
|
JS::Handle<JSObject*> aPromise,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
static double GetTimeToSettle(GlobalObject&, JS::Handle<JSObject*> aPromise,
|
2014-10-20 21:02:21 +04:00
|
|
|
ErrorResult& aRv);
|
2015-04-10 18:27:57 +03:00
|
|
|
|
2015-11-25 23:48:09 +03:00
|
|
|
static void GetPromiseID(GlobalObject&, JS::Handle<JSObject*>, nsString&,
|
|
|
|
ErrorResult&);
|
2016-02-10 01:40:31 +03:00
|
|
|
#endif // SPIDERMONKEY_PROMISE
|
2015-04-10 18:27:57 +03:00
|
|
|
|
|
|
|
// Mechanism for watching uncaught instances of Promise.
|
2016-02-10 01:40:31 +03:00
|
|
|
// XXXbz figure out the plan
|
2015-04-10 18:27:57 +03:00
|
|
|
static void AddUncaughtRejectionObserver(GlobalObject&,
|
|
|
|
UncaughtRejectionObserver& aObserver);
|
|
|
|
static bool RemoveUncaughtRejectionObserver(GlobalObject&,
|
|
|
|
UncaughtRejectionObserver& aObserver);
|
|
|
|
|
2016-02-10 01:40:31 +03:00
|
|
|
#ifndef SPIDERMONKEY_PROMISE
|
2015-04-10 18:27:57 +03:00
|
|
|
// Mark a Promise as having been left uncaught at script completion.
|
|
|
|
static void AddUncaughtRejection(Promise&);
|
|
|
|
// Mark a Promise previously added with `AddUncaughtRejection` as
|
|
|
|
// eventually consumed.
|
|
|
|
static void AddConsumedRejection(Promise&);
|
2016-02-10 01:40:31 +03:00
|
|
|
#endif // SPIDERMONKEY_PROMISE
|
2015-04-10 18:27:57 +03:00
|
|
|
// Propagate the informations from AddUncaughtRejection
|
|
|
|
// and AddConsumedRejection to observers.
|
2016-02-10 01:40:31 +03:00
|
|
|
// XXXbz figure out the plan.
|
2015-04-10 18:27:57 +03:00
|
|
|
static void FlushUncaughtRejections();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static void FlushUncaughtRejectionsInternal();
|
|
|
|
friend class FlushRejections;
|
|
|
|
friend class WorkerPrivate;
|
|
|
|
private:
|
|
|
|
// Identity of the process.
|
|
|
|
// This property is:
|
|
|
|
// - set during initialization of the layout module,
|
|
|
|
// prior to any Worker using it;
|
|
|
|
// - read by both the main thread and the Workers;
|
|
|
|
// - unset during shutdown of the layout module,
|
|
|
|
// after any Worker has been shutdown.
|
|
|
|
static nsString sIDPrefix;
|
2014-07-02 08:19:48 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_PromiseDebugging_h
|