/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */

#ifndef mozilla_dom_PeerConnectionObserverBinding_h__
#define mozilla_dom_PeerConnectionObserverBinding_h__

#include "PeerConnectionObserverEnumsBinding.h"
#include "js/RootingAPI.h"
#include "jspubtd.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/CallbackInterface.h"
#include "nsWeakReference.h"

class JSObject;
class nsDOMDataChannel;

namespace mozilla {

class DOMMediaStream;

namespace dom {

struct MediaConstraintSet;
class NativePropertyHooks;
class PeerConnectionObserver;
class ProtoAndIfaceArray;
struct RTCStatsReportInternal;
class mozRTCPeerConnection;

} // namespace dom

} // namespace mozilla

namespace mozilla {
namespace dom {

namespace PeerConnectionObserverBinding {

  typedef mozilla::dom::PeerConnectionObserver 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[];
  JSObject*
  DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);

  bool
  ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);

  const JSClass*
  GetJSClass();

  JSObject*
  Wrap(JSContext* aCx, JS::Handle<JSObject*> aScope, mozilla::dom::PeerConnectionObserver* aObject, nsWrapperCache* aCache);

  template <class T>
  inline JSObject* Wrap(JSContext* aCx, JS::Handle<JSObject*> aScope, T* aObject)
  {
    return Wrap(aCx, aScope, aObject, aObject);
  }

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

  JS::Handle<JSObject*>
  GetProtoObject(JSContext* aCx, JS::Handle<JSObject*> aGlobal);

  JS::Handle<JSObject*>
  GetConstructorObject(JSContext* aCx, JS::Handle<JSObject*> aGlobal, bool aDefineOnGlobal = true);

} // namespace PeerConnectionObserverBinding



class PeerConnectionObserverJSImpl : public CallbackInterface
{
public:
  explicit inline PeerConnectionObserverJSImpl(JSObject* aCallback)
    : CallbackInterface(aCallback)
  {
  }

  void OnCreateOfferSuccess(const nsAString& offer, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnCreateOfferError(uint32_t name, const nsAString& message, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnCreateAnswerSuccess(const nsAString& answer, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnCreateAnswerError(uint32_t name, const nsAString& message, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnSetLocalDescriptionSuccess(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnSetRemoteDescriptionSuccess(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnSetLocalDescriptionError(uint32_t name, const nsAString& message, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnSetRemoteDescriptionError(uint32_t name, const nsAString& message, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnAddIceCandidateSuccess(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnAddIceCandidateError(uint32_t name, const nsAString& message, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnIceCandidate(uint16_t level, const nsAString& mid, const nsAString& candidate, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnGetStatsSuccess(const RTCStatsReportInternal& report, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnGetStatsError(uint32_t name, const nsAString& message, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnGetLoggingSuccess(const Sequence<nsString >& logs, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnGetLoggingError(uint32_t name, const nsAString& message, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void NotifyDataChannel(nsDOMDataChannel& channel, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void NotifyConnection(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void NotifyClosedConnection(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnStateChange(PCObserverStateType state, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnAddStream(mozilla::DOMMediaStream& stream, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnRemoveStream(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnAddTrack(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnRemoveTrack(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void GetSupportedConstraints(const MediaConstraintSet& constraints, MediaConstraintSet& retval, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void __Init(mozilla::dom::mozRTCPeerConnection& domPC, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
};


class PeerConnectionObserver MOZ_FINAL : public nsSupportsWeakReference,
                                         public nsWrapperCache
{
public:
  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PeerConnectionObserver)

private:
  nsRefPtr<PeerConnectionObserverJSImpl> mImpl;
  nsCOMPtr<nsISupports> mParent;

public:
  PeerConnectionObserver(JS::Handle<JSObject*> aJSImplObject, nsPIDOMWindow* aParent);

  nsISupports* GetParentObject() const;

  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;

  static already_AddRefed<PeerConnectionObserver> Constructor(const GlobalObject& global, JSContext* cx, mozilla::dom::mozRTCPeerConnection& domPC, ErrorResult& aRv);

  void OnCreateOfferSuccess(const nsAString& offer, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnCreateOfferError(uint32_t name, const nsAString& message, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnCreateAnswerSuccess(const nsAString& answer, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnCreateAnswerError(uint32_t name, const nsAString& message, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnSetLocalDescriptionSuccess(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnSetRemoteDescriptionSuccess(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnSetLocalDescriptionError(uint32_t name, const nsAString& message, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnSetRemoteDescriptionError(uint32_t name, const nsAString& message, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnAddIceCandidateSuccess(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnAddIceCandidateError(uint32_t name, const nsAString& message, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnIceCandidate(uint16_t level, const nsAString& mid, const nsAString& candidate, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnGetStatsSuccess(const RTCStatsReportInternal& report, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnGetStatsError(uint32_t name, const nsAString& message, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnGetLoggingSuccess(const Sequence<nsString >& logs, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnGetLoggingError(uint32_t name, const nsAString& message, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void NotifyDataChannel(nsDOMDataChannel& channel, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void NotifyConnection(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void NotifyClosedConnection(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnStateChange(PCObserverStateType state, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnAddStream(mozilla::DOMMediaStream& stream, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnRemoveStream(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnAddTrack(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void OnRemoveTrack(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  void GetSupportedConstraints(const MediaConstraintSet& constraints, MediaConstraintSet& retval, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);

  static bool
  _Create(JSContext* cx, unsigned argc, JS::Value* vp);
};


} // namespace dom
} // namespace mozilla

#endif // mozilla_dom_PeerConnectionObserverBinding_h__
