Bug 1351953 - Make DecryptJob::PostResult take a mozilla::Span instead of nsTArray. r=gerald draft
authorChris Pearce <cpearce@mozilla.com>
Wed, 05 Apr 2017 10:32:19 +1200
changeset 556490 44dfbc465db14bb689a653e6c0b3cbc626c0a0d1
parent 556489 04879d8c1639bf6f14cebc6031d8cc23e05e567a
child 556491 a0cb126e72bfb2905bcdf02e864dc654e8340410
push id52568
push userbmo:cpearce@mozilla.com
push dateWed, 05 Apr 2017 23:29:31 +0000
reviewersgerald
bugs1351953
milestone55.0a1
Bug 1351953 - Make DecryptJob::PostResult take a mozilla::Span instead of nsTArray. r=gerald This means we can pass anything that converts implicitly to a Span to PostResult, including an nsTArray<uint8_t>. We can also pass a Span that contains the contents of a Shmem's buffer. MozReview-Commit-ID: 8AAcRmVCEVy
dom/media/gmp/DecryptJob.cpp
dom/media/gmp/DecryptJob.h
--- a/dom/media/gmp/DecryptJob.cpp
+++ b/dom/media/gmp/DecryptJob.cpp
@@ -26,17 +26,17 @@ void
 DecryptJob::PostResult(DecryptStatus aResult)
 {
   nsTArray<uint8_t> empty;
   PostResult(aResult, empty);
 }
 
 void
 DecryptJob::PostResult(DecryptStatus aResult,
-                       const nsTArray<uint8_t>& aDecryptedData)
+                       Span<const uint8_t> aDecryptedData)
 {
   if (aDecryptedData.Length() != mSample->Size()) {
     NS_WARNING("CDM returned incorrect number of decrypted bytes");
   }
   if (aResult == Ok) {
     UniquePtr<MediaRawDataWriter> writer(mSample->CreateWriter());
     PodCopy(writer->Data(),
             aDecryptedData.Elements(),
--- a/dom/media/gmp/DecryptJob.h
+++ b/dom/media/gmp/DecryptJob.h
@@ -3,27 +3,27 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef DecryptJob_h_
 #define DecryptJob_h_
 
 #include "mozilla/CDMProxy.h"
+#include "mozilla/Span.h"
 
 namespace mozilla {
 
 class DecryptJob {
 public:
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(DecryptJob)
 
   explicit DecryptJob(MediaRawData* aSample);
 
-  void PostResult(DecryptStatus aResult,
-                  const nsTArray<uint8_t>& aDecryptedData);
+  void PostResult(DecryptStatus aResult, Span<const uint8_t> aDecryptedData);
   void PostResult(DecryptStatus aResult);
 
   RefPtr<DecryptPromise> Ensure();
 
   const uint32_t mId;
   RefPtr<MediaRawData> mSample;
 private:
   ~DecryptJob() {}