LCOV - code coverage report
Current view: top level - dom/media/eme - MediaEncryptedEvent.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 64 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 15 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
       5             :  * You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #include "MediaEncryptedEvent.h"
       8             : #include "mozilla/dom/MediaEncryptedEventBinding.h"
       9             : #include "nsContentUtils.h"
      10             : #include "jsfriendapi.h"
      11             : #include "nsINode.h"
      12             : #include "mozilla/dom/MediaKeys.h"
      13             : 
      14             : namespace mozilla {
      15             : namespace dom {
      16             : 
      17             : NS_IMPL_CYCLE_COLLECTION_CLASS(MediaEncryptedEvent)
      18             : 
      19           0 : NS_IMPL_ADDREF_INHERITED(MediaEncryptedEvent, Event)
      20           0 : NS_IMPL_RELEASE_INHERITED(MediaEncryptedEvent, Event)
      21             : 
      22           0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(MediaEncryptedEvent, Event)
      23           0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
      24             : 
      25           0 : NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(MediaEncryptedEvent, Event)
      26           0 :   NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mInitData)
      27           0 : NS_IMPL_CYCLE_COLLECTION_TRACE_END
      28             : 
      29           0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(MediaEncryptedEvent, Event)
      30           0 :   tmp->mInitData = nullptr;
      31           0 :   mozilla::DropJSObjects(this);
      32           0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_END
      33             : 
      34           0 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(MediaEncryptedEvent)
      35           0 : NS_INTERFACE_MAP_END_INHERITING(Event)
      36             : 
      37           0 : MediaEncryptedEvent::MediaEncryptedEvent(EventTarget* aOwner)
      38           0 :   : Event(aOwner, nullptr, nullptr)
      39             : {
      40           0 :   mozilla::HoldJSObjects(this);
      41           0 : }
      42             : 
      43           0 : MediaEncryptedEvent::~MediaEncryptedEvent()
      44             : {
      45           0 :   mInitData = nullptr;
      46           0 :   mozilla::DropJSObjects(this);
      47           0 : }
      48             : 
      49             : JSObject*
      50           0 : MediaEncryptedEvent::WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
      51             : {
      52           0 :   return MediaEncryptedEventBinding::Wrap(aCx, this, aGivenProto);
      53             : }
      54             : 
      55             : already_AddRefed<MediaEncryptedEvent>
      56           0 : MediaEncryptedEvent::Constructor(EventTarget* aOwner)
      57             : {
      58           0 :   RefPtr<MediaEncryptedEvent> e = new MediaEncryptedEvent(aOwner);
      59           0 :   e->InitEvent(NS_LITERAL_STRING("encrypted"), false, false);
      60           0 :   e->SetTrusted(true);
      61           0 :   return e.forget();
      62             : }
      63             : 
      64             : already_AddRefed<MediaEncryptedEvent>
      65           0 : MediaEncryptedEvent::Constructor(EventTarget* aOwner,
      66             :                                  const nsAString& aInitDataType,
      67             :                                  const nsTArray<uint8_t>& aInitData)
      68             : {
      69           0 :   RefPtr<MediaEncryptedEvent> e = new MediaEncryptedEvent(aOwner);
      70           0 :   e->InitEvent(NS_LITERAL_STRING("encrypted"), false, false);
      71           0 :   e->mInitDataType = aInitDataType;
      72           0 :   e->mRawInitData = aInitData;
      73           0 :   e->SetTrusted(true);
      74           0 :   return e.forget();
      75             : }
      76             : 
      77             : already_AddRefed<MediaEncryptedEvent>
      78           0 : MediaEncryptedEvent::Constructor(const GlobalObject& aGlobal,
      79             :                                  const nsAString& aType,
      80             :                                  const MediaKeyNeededEventInit& aEventInitDict,
      81             :                                  ErrorResult& aRv)
      82             : {
      83           0 :   nsCOMPtr<EventTarget> owner = do_QueryInterface(aGlobal.GetAsSupports());
      84           0 :   RefPtr<MediaEncryptedEvent> e = new MediaEncryptedEvent(owner);
      85           0 :   bool trusted = e->Init(owner);
      86           0 :   e->InitEvent(aType, aEventInitDict.mBubbles, aEventInitDict.mCancelable);
      87           0 :   e->mInitDataType = aEventInitDict.mInitDataType;
      88           0 :   if (!aEventInitDict.mInitData.IsNull()) {
      89           0 :     const auto& a = aEventInitDict.mInitData.Value();
      90           0 :     a.ComputeLengthAndData();
      91           0 :     e->mInitData = ArrayBuffer::Create(aGlobal.Context(),
      92             :                                        a.Length(),
      93           0 :                                        a.Data());
      94           0 :     if (!e->mInitData) {
      95           0 :       aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
      96           0 :       return nullptr;
      97             :     }
      98             :   }
      99           0 :   e->SetTrusted(trusted);
     100           0 :   return e.forget();
     101             : }
     102             : 
     103             : void
     104           0 : MediaEncryptedEvent::GetInitDataType(nsString& aRetVal) const
     105             : {
     106           0 :   aRetVal = mInitDataType;
     107           0 : }
     108             : 
     109             : void
     110           0 : MediaEncryptedEvent::GetInitData(JSContext* cx,
     111             :                                  JS::MutableHandle<JSObject*> aData,
     112             :                                  ErrorResult& aRv)
     113             : {
     114           0 :   if (mRawInitData.Length()) {
     115           0 :     mInitData = ArrayBuffer::Create(cx,
     116             :                                     this,
     117           0 :                                     mRawInitData.Length(),
     118           0 :                                     mRawInitData.Elements());
     119           0 :     if (!mInitData) {
     120           0 :       aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
     121           0 :       return;
     122             :     }
     123           0 :     mRawInitData.Clear();
     124             :   }
     125           0 :   aData.set(mInitData);
     126             : }
     127             : 
     128             : } // namespace dom
     129             : } // namespace mozilla

Generated by: LCOV version 1.13