/* THIS FILE IS AUTOGENERATED FROM RTCIdentityProvider.webidl BY Codegen.py - DO NOT EDIT */

#ifndef mozilla_dom_RTCIdentityProviderBinding_h
#define mozilla_dom_RTCIdentityProviderBinding_h

#include "js/RootingAPI.h"
#include "jspubtd.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/CallbackFunction.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/ToJSValue.h"

namespace mozilla {
namespace dom {

class GenerateAssertionCallback;
struct NativePropertyHooks;
class Promise;
class ProtoAndIfaceCache;
struct RTCIdentityAssertionResultAtoms;
struct RTCIdentityProviderAtoms;
struct RTCIdentityProviderDetails;
struct RTCIdentityProviderDetailsAtoms;
class RTCIdentityProviderRegistrar;
struct RTCIdentityProviderRegistrarAtoms;
struct RTCIdentityValidationResultAtoms;
class ValidateAssertionCallback;

} // namespace dom
} // namespace mozilla

namespace mozilla {
namespace dom {

struct RTCIdentityProvider : public DictionaryBase
{
  OwningNonNull<GenerateAssertionCallback> mGenerateAssertion;
  OwningNonNull<ValidateAssertionCallback> mValidateAssertion;

  RTCIdentityProvider();

  explicit inline RTCIdentityProvider(const FastDictionaryInitializer& )
  {
    // Do nothing here; this is used by our "Fast" subclass
  }

private:
  RTCIdentityProvider(const RTCIdentityProvider&) = delete;
  void operator=(const RTCIdentityProvider) = delete;

  static bool
  InitIds(JSContext* cx, RTCIdentityProviderAtoms* atomsCache);

public:
  bool
  Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);

  bool
  ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;

  void
  TraceDictionary(JSTracer* trc);
};

namespace binding_detail {
struct FastRTCIdentityProvider : public RTCIdentityProvider
{
  inline FastRTCIdentityProvider()
    : RTCIdentityProvider(FastDictionaryInitializer())
  {
    // Doesn't matter what int we pass to the parent constructor
  }
};
} // namespace binding_detail


struct RTCIdentityProviderDetails : public DictionaryBase
{
  nsString mDomain;
  nsString mProtocol;

  RTCIdentityProviderDetails();

  explicit inline RTCIdentityProviderDetails(const FastDictionaryInitializer& )
  {
    // Do nothing here; this is used by our "Fast" subclass
  }

  explicit inline RTCIdentityProviderDetails(const RTCIdentityProviderDetails& aOther)
  {
    *this = aOther;
  }

  bool
  Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);

  bool
  Init(const nsAString& aJSON);

  bool
  ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;

  bool
  ToJSON(nsAString& aJSON) const;

  void
  TraceDictionary(JSTracer* trc);

  void
  operator=(const RTCIdentityProviderDetails& aOther);

private:
  static bool
  InitIds(JSContext* cx, RTCIdentityProviderDetailsAtoms* atomsCache);
};

namespace binding_detail {
struct FastRTCIdentityProviderDetails : public RTCIdentityProviderDetails
{
  inline FastRTCIdentityProviderDetails()
    : RTCIdentityProviderDetails(FastDictionaryInitializer())
  {
    // Doesn't matter what int we pass to the parent constructor
  }
};
} // namespace binding_detail


struct RTCIdentityValidationResult : public DictionaryBase
{
  nsString mContents;
  nsString mIdentity;

  RTCIdentityValidationResult();

  explicit inline RTCIdentityValidationResult(const FastDictionaryInitializer& )
  {
    // Do nothing here; this is used by our "Fast" subclass
  }

  explicit inline RTCIdentityValidationResult(const RTCIdentityValidationResult& aOther)
  {
    *this = aOther;
  }

  bool
  Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);

  bool
  Init(const nsAString& aJSON);

  bool
  ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;

  bool
  ToJSON(nsAString& aJSON) const;

  void
  TraceDictionary(JSTracer* trc);

  void
  operator=(const RTCIdentityValidationResult& aOther);

private:
  static bool
  InitIds(JSContext* cx, RTCIdentityValidationResultAtoms* atomsCache);
};

namespace binding_detail {
struct FastRTCIdentityValidationResult : public RTCIdentityValidationResult
{
  inline FastRTCIdentityValidationResult()
    : RTCIdentityValidationResult(FastDictionaryInitializer())
  {
    // Doesn't matter what int we pass to the parent constructor
  }
};
} // namespace binding_detail


struct RTCIdentityAssertionResult : public DictionaryBase
{
  nsString mAssertion;
  RTCIdentityProviderDetails mIdp;

  RTCIdentityAssertionResult();

  explicit inline RTCIdentityAssertionResult(const FastDictionaryInitializer& )
    : mIdp(FastDictionaryInitializer())
  {
    // Do nothing here; this is used by our "Fast" subclass
  }

  explicit inline RTCIdentityAssertionResult(const RTCIdentityAssertionResult& aOther)
    : mIdp(FastDictionaryInitializer())
  {
    *this = aOther;
  }

  bool
  Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);

  bool
  Init(const nsAString& aJSON);

  bool
  ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;

  bool
  ToJSON(nsAString& aJSON) const;

  void
  TraceDictionary(JSTracer* trc);

  void
  operator=(const RTCIdentityAssertionResult& aOther);

private:
  static bool
  InitIds(JSContext* cx, RTCIdentityAssertionResultAtoms* atomsCache);
};

namespace binding_detail {
struct FastRTCIdentityAssertionResult : public RTCIdentityAssertionResult
{
  inline FastRTCIdentityAssertionResult()
    : RTCIdentityAssertionResult(FastDictionaryInitializer())
  {
    // Doesn't matter what int we pass to the parent constructor
  }
};
} // namespace binding_detail


class GenerateAssertionCallback : public CallbackFunction
{
public:
  explicit inline GenerateAssertionCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, nsIGlobalObject* aIncumbentGlobal)
    : CallbackFunction(aCx, aCallback, aIncumbentGlobal)
  {
    MOZ_ASSERT(JS::IsCallable(mCallback));
  }

  explicit inline GenerateAssertionCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, nsIGlobalObject* aIncumbentGlobal, const FastCallbackConstructor& )
    : CallbackFunction(aCx, aCallback, aIncumbentGlobal, FastCallbackConstructor())
  {
    MOZ_ASSERT(JS::IsCallable(mCallback));
  }

  explicit inline GenerateAssertionCallback(JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
    : CallbackFunction(aCallback, aAsyncStack, aIncumbentGlobal)
  {
    MOZ_ASSERT(JS::IsCallable(mCallback));
  }

  explicit inline GenerateAssertionCallback(CallbackFunction* aOther)
    : CallbackFunction(aOther)
  {
  }

  template <typename T>
  inline already_AddRefed<Promise>
  Call(const T& thisVal, const nsAString& contents, const nsAString& origin, const Optional<nsAString>& usernameHint, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
  {
    if (!aExecutionReason) {
      aExecutionReason = "GenerateAssertionCallback";
    }
    CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
    if (!s.GetContext()) {
      MOZ_ASSERT(aRv.Failed());
      return nullptr;
    }
    JS::Rooted<JS::Value> thisValJS(s.GetContext());
    if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) {
      aRv.Throw(NS_ERROR_FAILURE);
      return nullptr;
    }
    return Call(s.GetContext(), thisValJS, contents, origin, usernameHint, aRv);
  }

  inline already_AddRefed<Promise>
  Call(const nsAString& contents, const nsAString& origin, const Optional<nsAString>& usernameHint, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
  {
    if (!aExecutionReason) {
      aExecutionReason = "GenerateAssertionCallback";
    }
    CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
    if (!s.GetContext()) {
      MOZ_ASSERT(aRv.Failed());
      return nullptr;
    }
    return Call(s.GetContext(), JS::UndefinedHandleValue, contents, origin, usernameHint, aRv);
  }

  template <typename T>
  inline already_AddRefed<Promise>
  Call(const T& thisVal, const nsAString& contents, const nsAString& origin, const Optional<nsAString>& usernameHint, const char* aExecutionReason = nullptr)
  {
    IgnoredErrorResult rv;
    return Call(thisVal, contents, origin, usernameHint, rv, aExecutionReason);
  }

  inline already_AddRefed<Promise>
  Call(const nsAString& contents, const nsAString& origin, const Optional<nsAString>& usernameHint, const char* aExecutionReason = nullptr)
  {
    IgnoredErrorResult rv;
    return Call(contents, origin, usernameHint, rv, aExecutionReason, eReportExceptions, nullptr);
  }

  inline bool
  operator==(const GenerateAssertionCallback& aOther) const
  {
    return CallbackFunction::operator==(aOther);
  }

private:
  already_AddRefed<Promise> Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, const nsAString& contents, const nsAString& origin, const Optional<nsAString>& usernameHint, ErrorResult& aRv);
};


class ValidateAssertionCallback : public CallbackFunction
{
public:
  explicit inline ValidateAssertionCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, nsIGlobalObject* aIncumbentGlobal)
    : CallbackFunction(aCx, aCallback, aIncumbentGlobal)
  {
    MOZ_ASSERT(JS::IsCallable(mCallback));
  }

  explicit inline ValidateAssertionCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, nsIGlobalObject* aIncumbentGlobal, const FastCallbackConstructor& )
    : CallbackFunction(aCx, aCallback, aIncumbentGlobal, FastCallbackConstructor())
  {
    MOZ_ASSERT(JS::IsCallable(mCallback));
  }

  explicit inline ValidateAssertionCallback(JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
    : CallbackFunction(aCallback, aAsyncStack, aIncumbentGlobal)
  {
    MOZ_ASSERT(JS::IsCallable(mCallback));
  }

  explicit inline ValidateAssertionCallback(CallbackFunction* aOther)
    : CallbackFunction(aOther)
  {
  }

  template <typename T>
  inline already_AddRefed<Promise>
  Call(const T& thisVal, const nsAString& assertion, const nsAString& origin, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
  {
    if (!aExecutionReason) {
      aExecutionReason = "ValidateAssertionCallback";
    }
    CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
    if (!s.GetContext()) {
      MOZ_ASSERT(aRv.Failed());
      return nullptr;
    }
    JS::Rooted<JS::Value> thisValJS(s.GetContext());
    if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) {
      aRv.Throw(NS_ERROR_FAILURE);
      return nullptr;
    }
    return Call(s.GetContext(), thisValJS, assertion, origin, aRv);
  }

  inline already_AddRefed<Promise>
  Call(const nsAString& assertion, const nsAString& origin, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
  {
    if (!aExecutionReason) {
      aExecutionReason = "ValidateAssertionCallback";
    }
    CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
    if (!s.GetContext()) {
      MOZ_ASSERT(aRv.Failed());
      return nullptr;
    }
    return Call(s.GetContext(), JS::UndefinedHandleValue, assertion, origin, aRv);
  }

  template <typename T>
  inline already_AddRefed<Promise>
  Call(const T& thisVal, const nsAString& assertion, const nsAString& origin, const char* aExecutionReason = nullptr)
  {
    IgnoredErrorResult rv;
    return Call(thisVal, assertion, origin, rv, aExecutionReason);
  }

  inline already_AddRefed<Promise>
  Call(const nsAString& assertion, const nsAString& origin, const char* aExecutionReason = nullptr)
  {
    IgnoredErrorResult rv;
    return Call(assertion, origin, rv, aExecutionReason, eReportExceptions, nullptr);
  }

  inline bool
  operator==(const ValidateAssertionCallback& aOther) const
  {
    return CallbackFunction::operator==(aOther);
  }

private:
  already_AddRefed<Promise> Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, const nsAString& assertion, const nsAString& origin, ErrorResult& aRv);
};


namespace binding_detail {
class FastGenerateAssertionCallback : public GenerateAssertionCallback
{
public:
  explicit inline FastGenerateAssertionCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, nsIGlobalObject* aIncumbentGlobal)
    : GenerateAssertionCallback(aCx, aCallback, aIncumbentGlobal, FastCallbackConstructor())
  {
  }

  inline void
  Trace(JSTracer* aTracer)
  {
    GenerateAssertionCallback::Trace(aTracer);
  }

  inline void
  HoldJSObjectsIfMoreThanOneOwner()
  {
    GenerateAssertionCallback::HoldJSObjectsIfMoreThanOneOwner();
  }
};
} // namespace binding_detail


namespace binding_detail {
class FastValidateAssertionCallback : public ValidateAssertionCallback
{
public:
  explicit inline FastValidateAssertionCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, nsIGlobalObject* aIncumbentGlobal)
    : ValidateAssertionCallback(aCx, aCallback, aIncumbentGlobal, FastCallbackConstructor())
  {
  }

  inline void
  Trace(JSTracer* aTracer)
  {
    ValidateAssertionCallback::Trace(aTracer);
  }

  inline void
  HoldJSObjectsIfMoreThanOneOwner()
  {
    ValidateAssertionCallback::HoldJSObjectsIfMoreThanOneOwner();
  }
};
} // namespace binding_detail


namespace RTCIdentityProviderRegistrarBinding {

  typedef mozilla::dom::RTCIdentityProviderRegistrar NativeType;

  // We declare this as an array so that retrieving a pointer to this
  // binding's property hooks only requires compile/link-time resolvable
  // address arithmetic.  Declaring it as a pointer instead would require
  // doing a run-time load to fetch a pointer to this binding's property
  // hooks.  And then structures which embedded a pointer to this structure
  // would require a run-time load for proper initialization, which would
  // then induce static constructors.  Lots of static constructors.
  extern const NativePropertyHooks sNativePropertyHooks[];

  const JSClass*
  GetJSClass();

  bool
  Wrap(JSContext* aCx, mozilla::dom::RTCIdentityProviderRegistrar* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);

  template <class T>
  inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
  {
    JS::Rooted<JSObject*> reflector(aCx);
    return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
  }

  void
  CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);

  JS::Handle<JSObject*>
  GetProtoObjectHandle(JSContext* aCx);

} // namespace RTCIdentityProviderRegistrarBinding



} // namespace dom
} // namespace mozilla

#endif // mozilla_dom_RTCIdentityProviderBinding_h
