LCOV - code coverage report
Current view: top level - dom/media/webrtc - RTCIdentityProviderRegistrar.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 1 34 2.9 %
Date: 2017-07-14 16:53:18 Functions: 2 17 11.8 %
Legend: Lines: hit not hit

          Line data    Source code
       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           0 : NS_IMPL_CYCLE_COLLECTING_ADDREF(RTCIdentityProviderRegistrar)
      19           0 : NS_IMPL_CYCLE_COLLECTING_RELEASE(RTCIdentityProviderRegistrar)
      20             : 
      21           0 : NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(RTCIdentityProviderRegistrar,
      22             :                                       mGlobal,
      23             :                                       mGenerateAssertionCallback,
      24             :                                       mValidateAssertionCallback)
      25             : 
      26           0 : RTCIdentityProviderRegistrar::RTCIdentityProviderRegistrar(
      27           0 :     nsIGlobalObject* aGlobal)
      28             :     : mGlobal(aGlobal)
      29             :     , mGenerateAssertionCallback(nullptr)
      30           0 :     , mValidateAssertionCallback(nullptr)
      31             : {
      32           0 : }
      33             : 
      34           0 : RTCIdentityProviderRegistrar::~RTCIdentityProviderRegistrar()
      35             : {
      36           0 : }
      37             : 
      38             : nsIGlobalObject*
      39           0 : RTCIdentityProviderRegistrar::GetParentObject() const
      40             : {
      41           0 :   return mGlobal;
      42             : }
      43             : 
      44             : JSObject*
      45           0 : RTCIdentityProviderRegistrar::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
      46             : {
      47           0 :   return RTCIdentityProviderRegistrarBinding::Wrap(aCx, this, aGivenProto);
      48             : }
      49             : 
      50             : void
      51           0 : RTCIdentityProviderRegistrar::Register(const RTCIdentityProvider& aIdp)
      52             : {
      53           0 :   mGenerateAssertionCallback = aIdp.mGenerateAssertion;
      54           0 :   mValidateAssertionCallback = aIdp.mValidateAssertion;
      55           0 : }
      56             : 
      57             : bool
      58           0 : RTCIdentityProviderRegistrar::HasIdp() const
      59             : {
      60           0 :   return mGenerateAssertionCallback && mValidateAssertionCallback;
      61             : }
      62             : 
      63             : already_AddRefed<Promise>
      64           0 : RTCIdentityProviderRegistrar::GenerateAssertion(
      65             :   const nsAString& aContents, const nsAString& aOrigin,
      66             :   const Optional<nsAString>& aUsernameHint, ErrorResult& aRv)
      67             : {
      68           0 :   if (!mGenerateAssertionCallback) {
      69           0 :     aRv.Throw(NS_ERROR_NOT_INITIALIZED);
      70           0 :     return nullptr;
      71             :   }
      72           0 :   return mGenerateAssertionCallback->Call(aContents, aOrigin, aUsernameHint, aRv);
      73             : }
      74             : already_AddRefed<Promise>
      75           0 : RTCIdentityProviderRegistrar::ValidateAssertion(
      76             :   const nsAString& aAssertion, const nsAString& aOrigin, ErrorResult& aRv)
      77             : {
      78           0 :   if (!mValidateAssertionCallback) {
      79           0 :     aRv.Throw(NS_ERROR_NOT_INITIALIZED);
      80           0 :     return nullptr;
      81             :   }
      82           0 :   return mValidateAssertionCallback->Call(aAssertion, aOrigin, aRv);
      83             : }
      84             : 
      85             : 
      86             : 
      87             : } // namespace dom
      88           9 : } // namespace mozilla

Generated by: LCOV version 1.13