LCOV - code coverage report
Current view: top level - dom/media/gmp - DecryptJob.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 24 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 4 0.0 %
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
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #include "DecryptJob.h"
       7             : #include "mozilla/Atomics.h"
       8             : 
       9             : namespace mozilla {
      10             : 
      11             : static Atomic<uint32_t> sDecryptJobInstanceCount(0u);
      12             : 
      13           0 : DecryptJob::DecryptJob(MediaRawData* aSample)
      14           0 :   : mId(++sDecryptJobInstanceCount )
      15           0 :   , mSample(aSample)
      16             : {
      17           0 : }
      18             : 
      19             : RefPtr<DecryptPromise>
      20           0 : DecryptJob::Ensure()
      21             : {
      22           0 :   return mPromise.Ensure(__func__);
      23             : }
      24             : 
      25             : void
      26           0 : DecryptJob::PostResult(DecryptStatus aResult)
      27             : {
      28           0 :   nsTArray<uint8_t> empty;
      29           0 :   PostResult(aResult, empty);
      30           0 : }
      31             : 
      32             : void
      33           0 : DecryptJob::PostResult(DecryptStatus aResult,
      34             :                        Span<const uint8_t> aDecryptedData)
      35             : {
      36           0 :   if (aDecryptedData.Length() != mSample->Size()) {
      37           0 :     NS_WARNING("CDM returned incorrect number of decrypted bytes");
      38             :   }
      39           0 :   if (aResult == eme::Ok) {
      40           0 :     UniquePtr<MediaRawDataWriter> writer(mSample->CreateWriter());
      41           0 :     PodCopy(writer->Data(),
      42             :             aDecryptedData.Elements(),
      43           0 :             std::min<size_t>(aDecryptedData.Length(), mSample->Size()));
      44           0 :   } else if (aResult == eme::NoKeyErr) {
      45           0 :     NS_WARNING("CDM returned NoKeyErr");
      46             :     // We still have the encrypted sample, so we can re-enqueue it to be
      47             :     // decrypted again once the key is usable again.
      48             :   } else {
      49           0 :     nsAutoCString str("CDM returned decode failure DecryptStatus=");
      50           0 :     str.AppendInt(aResult);
      51           0 :     NS_WARNING(str.get());
      52             :   }
      53           0 :   mPromise.Resolve(DecryptResult(aResult, mSample), __func__);
      54           0 : }
      55             : 
      56             : } // namespace mozilla

Generated by: LCOV version 1.13