RTCIdentityProviderRegistrar.h (2016B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 4 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 #ifndef RTCIDENTITYPROVIDER_H_ 7 #define RTCIDENTITYPROVIDER_H_ 8 9 #include "mozilla/Attributes.h" 10 #include "mozilla/RefPtr.h" 11 #include "mozilla/dom/BindingDeclarations.h" 12 #include "mozilla/dom/Promise.h" 13 #include "mozilla/dom/RTCIdentityProviderBinding.h" 14 #include "nsCOMPtr.h" 15 #include "nsIGlobalObject.h" 16 #include "nsISupportsImpl.h" 17 #include "nsWrapperCache.h" 18 19 namespace mozilla::dom { 20 21 struct RTCIdentityProvider; 22 23 class RTCIdentityProviderRegistrar final : public nsISupports, 24 public nsWrapperCache { 25 public: 26 NS_DECL_CYCLE_COLLECTING_ISUPPORTS 27 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(RTCIdentityProviderRegistrar) 28 29 explicit RTCIdentityProviderRegistrar(nsIGlobalObject* aGlobal); 30 31 // As required 32 nsIGlobalObject* GetParentObject() const; 33 virtual JSObject* WrapObject(JSContext* aCx, 34 JS::Handle<JSObject*> aGivenProto) override; 35 36 // setter and checker 37 void Register(const RTCIdentityProvider& aIdp); 38 bool HasIdp() const; 39 40 MOZ_CAN_RUN_SCRIPT 41 already_AddRefed<Promise> GenerateAssertion( 42 const nsAString& aContents, const nsAString& aOrigin, 43 const RTCIdentityProviderOptions& aOptions, ErrorResult& aRv); 44 MOZ_CAN_RUN_SCRIPT 45 already_AddRefed<Promise> ValidateAssertion(const nsAString& assertion, 46 const nsAString& origin, 47 ErrorResult& aRv); 48 49 private: 50 ~RTCIdentityProviderRegistrar(); 51 52 nsCOMPtr<nsIGlobalObject> mGlobal; 53 RefPtr<GenerateAssertionCallback> mGenerateAssertionCallback; 54 RefPtr<ValidateAssertionCallback> mValidateAssertionCallback; 55 }; 56 57 } // namespace mozilla::dom 58 59 #endif /* RTCIDENTITYPROVIDER_H_ */