2015-05-03 19:32:37 +00: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-11-19 18:43:51 +00: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_PromiseNativeHandler_h
|
|
|
|
#define mozilla_dom_PromiseNativeHandler_h
|
|
|
|
|
|
|
|
#include "nsISupports.h"
|
2015-03-16 14:10:36 +00:00
|
|
|
#include "js/TypeDecls.h"
|
2013-11-19 18:43:51 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PromiseNativeHandler allows C++ to react to a Promise being rejected/resolved.
|
|
|
|
* A PromiseNativeHandler can be appended to a Promise using
|
|
|
|
* Promise::AppendNativeHandler().
|
|
|
|
*/
|
|
|
|
class PromiseNativeHandler : public nsISupports
|
|
|
|
{
|
2014-06-23 19:56:07 +00:00
|
|
|
protected:
|
|
|
|
virtual ~PromiseNativeHandler()
|
|
|
|
{ }
|
|
|
|
|
2013-11-19 18:43:51 +00:00
|
|
|
public:
|
|
|
|
virtual void
|
2014-02-24 13:56:54 +00:00
|
|
|
ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) = 0;
|
2013-11-19 18:43:51 +00:00
|
|
|
|
|
|
|
virtual void
|
2014-02-24 13:56:54 +00:00
|
|
|
RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) = 0;
|
2016-02-09 22:40:31 +00:00
|
|
|
|
|
|
|
#ifdef SPIDERMONKEY_PROMISE
|
2016-06-06 22:55:17 +00:00
|
|
|
bool WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto,
|
2016-02-09 22:40:31 +00:00
|
|
|
JS::MutableHandle<JSObject*> aWrapper);
|
|
|
|
#endif // SPIDERMONKEY_PROMISE
|
|
|
|
|
2013-11-19 18:43:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_PromiseNativeHandler_h
|