/src/mozilla-central/dom/media/webrtc/RTCIdentityProviderRegistrar.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | #include "RTCIdentityProviderRegistrar.h" |
7 | | #include "mozilla/Attributes.h" |
8 | | #include "nsCycleCollectionParticipant.h" |
9 | | |
10 | | namespace mozilla { |
11 | | namespace dom { |
12 | | |
13 | 0 | NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(RTCIdentityProviderRegistrar) |
14 | 0 | NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY |
15 | 0 | NS_INTERFACE_MAP_ENTRY(nsISupports) |
16 | 0 | NS_INTERFACE_MAP_END |
17 | | |
18 | | NS_IMPL_CYCLE_COLLECTING_ADDREF(RTCIdentityProviderRegistrar) |
19 | | NS_IMPL_CYCLE_COLLECTING_RELEASE(RTCIdentityProviderRegistrar) |
20 | | |
21 | | NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(RTCIdentityProviderRegistrar, |
22 | | mGlobal, |
23 | | mGenerateAssertionCallback, |
24 | | mValidateAssertionCallback) |
25 | | |
26 | | RTCIdentityProviderRegistrar::RTCIdentityProviderRegistrar( |
27 | | nsIGlobalObject* aGlobal) |
28 | | : mGlobal(aGlobal) |
29 | | , mGenerateAssertionCallback(nullptr) |
30 | | , mValidateAssertionCallback(nullptr) |
31 | 0 | { |
32 | 0 | } |
33 | | |
34 | | RTCIdentityProviderRegistrar::~RTCIdentityProviderRegistrar() |
35 | 0 | { |
36 | 0 | } |
37 | | |
38 | | nsIGlobalObject* |
39 | | RTCIdentityProviderRegistrar::GetParentObject() const |
40 | 0 | { |
41 | 0 | return mGlobal; |
42 | 0 | } |
43 | | |
44 | | JSObject* |
45 | | RTCIdentityProviderRegistrar::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) |
46 | 0 | { |
47 | 0 | return RTCIdentityProviderRegistrar_Binding::Wrap(aCx, this, aGivenProto); |
48 | 0 | } |
49 | | |
50 | | void |
51 | | RTCIdentityProviderRegistrar::Register(const RTCIdentityProvider& aIdp) |
52 | 0 | { |
53 | 0 | mGenerateAssertionCallback = aIdp.mGenerateAssertion; |
54 | 0 | mValidateAssertionCallback = aIdp.mValidateAssertion; |
55 | 0 | } |
56 | | |
57 | | bool |
58 | | RTCIdentityProviderRegistrar::HasIdp() const |
59 | 0 | { |
60 | 0 | return mGenerateAssertionCallback && mValidateAssertionCallback; |
61 | 0 | } |
62 | | |
63 | | already_AddRefed<Promise> |
64 | | RTCIdentityProviderRegistrar::GenerateAssertion( |
65 | | const nsAString& aContents, const nsAString& aOrigin, |
66 | | const RTCIdentityProviderOptions& aOptions, ErrorResult& aRv) |
67 | 0 | { |
68 | 0 | if (!mGenerateAssertionCallback) { |
69 | 0 | aRv.Throw(NS_ERROR_NOT_INITIALIZED); |
70 | 0 | return nullptr; |
71 | 0 | } |
72 | 0 | return mGenerateAssertionCallback->Call(aContents, aOrigin, aOptions, aRv); |
73 | 0 | } |
74 | | already_AddRefed<Promise> |
75 | | RTCIdentityProviderRegistrar::ValidateAssertion( |
76 | | const nsAString& aAssertion, const nsAString& aOrigin, ErrorResult& aRv) |
77 | 0 | { |
78 | 0 | if (!mValidateAssertionCallback) { |
79 | 0 | aRv.Throw(NS_ERROR_NOT_INITIALIZED); |
80 | 0 | return nullptr; |
81 | 0 | } |
82 | 0 | return mValidateAssertionCallback->Call(aAssertion, aOrigin, aRv); |
83 | 0 | } |
84 | | |
85 | | |
86 | | |
87 | | } // namespace dom |
88 | | } // namespace mozilla |