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
--- 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() {}