Bug 1278198 - Pipe through distinctive identifier and persistent state allowed. r=gerald

MozReview-Commit-ID: A92e0XGp5s4

--HG--
extra : rebase_source : 09f7ba18c9b81263aa345cc7f34f0ef2a2548482
This commit is contained in:
Chris Pearce 2016-07-07 17:26:15 +12:00
Родитель e2b41d3d04
Коммит f49856bc79
20 изменённых файлов: 99 добавлений и 33 удалений

Просмотреть файл

@ -50,8 +50,14 @@ public:
typedef MozPromise<DecryptResult, DecryptResult, /* IsExclusive = */ true> DecryptPromise;
// Main thread only.
CDMProxy(dom::MediaKeys* aKeys, const nsAString& aKeySystem)
: mKeys(aKeys), mKeySystem(aKeySystem)
CDMProxy(dom::MediaKeys* aKeys,
const nsAString& aKeySystem,
bool aDistinctiveIdentifierRequired,
bool aPersistentStateRequired)
: mKeys(aKeys)
, mKeySystem(aKeySystem)
, mDistinctiveIdentifierRequired(aDistinctiveIdentifierRequired)
, mPersistentStateRequired(aPersistentStateRequired)
{}
// Main thread only.
@ -229,6 +235,9 @@ protected:
nsCString mNodeId;
CDMCaps mCapabilites;
const bool mDistinctiveIdentifierRequired;
const bool mPersistentStateRequired;
};

Просмотреть файл

@ -92,7 +92,11 @@ MediaKeySystemAccess::GetConfiguration(MediaKeySystemConfiguration& aConfig)
already_AddRefed<Promise>
MediaKeySystemAccess::CreateMediaKeys(ErrorResult& aRv)
{
RefPtr<MediaKeys> keys(new MediaKeys(mParent, mKeySystem, mCDMVersion));
RefPtr<MediaKeys> keys(new MediaKeys(mParent,
mKeySystem,
mCDMVersion,
mConfig.mDistinctiveIdentifier == MediaKeysRequirement::Required,
mConfig.mPersistentState == MediaKeysRequirement::Required));
return keys->Init(aRv);
}

Просмотреть файл

@ -48,11 +48,15 @@ NS_INTERFACE_MAP_END
MediaKeys::MediaKeys(nsPIDOMWindowInner* aParent,
const nsAString& aKeySystem,
const nsAString& aCDMVersion)
const nsAString& aCDMVersion,
bool aDistinctiveIdentifierRequired,
bool aPersistentStateRequired)
: mParent(aParent)
, mKeySystem(aKeySystem)
, mCDMVersion(aCDMVersion)
, mCreatePromiseId(0)
, mDistinctiveIdentifierRequired(aDistinctiveIdentifierRequired)
, mPersistentStateRequired(aPersistentStateRequired)
{
EME_LOG("MediaKeys[%p] constructed keySystem=%s",
this, NS_ConvertUTF16toUTF8(mKeySystem).get());
@ -313,7 +317,11 @@ MediaKeys::Init(ErrorResult& aRv)
return nullptr;
}
mProxy = new GMPCDMProxy(this, mKeySystem, new MediaKeysGMPCrashHelper(this));
mProxy = new GMPCDMProxy(this,
mKeySystem,
new MediaKeysGMPCrashHelper(this),
mDistinctiveIdentifierRequired,
mPersistentStateRequired);
// Determine principal (at creation time) of the MediaKeys object.
nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(GetParentObject());

Просмотреть файл

@ -50,7 +50,10 @@ public:
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(MediaKeys)
MediaKeys(nsPIDOMWindowInner* aParentWindow,
const nsAString& aKeySystem, const nsAString& aCDMVersion);
const nsAString& aKeySystem,
const nsAString& aCDMVersion,
bool aDistinctiveIdentifierRequired,
bool aPersistentStateRequired);
already_AddRefed<DetailedPromise> Init(ErrorResult& aRv);
@ -147,6 +150,8 @@ private:
RefPtr<nsIPrincipal> mPrincipal;
RefPtr<nsIPrincipal> mTopLevelPrincipal;
const bool mDistinctiveIdentifierRequired;
const bool mPersistentStateRequired;
};
} // namespace dom

Просмотреть файл

@ -16,7 +16,7 @@ public:
explicit FakeDecryptor(GMPDecryptorHost* aHost);
void Init(GMPDecryptorCallback* aCallback) override {
void Init(GMPDecryptorCallback* aCallback, bool, bool) override {
mCallback = aCallback;
}

Просмотреть файл

@ -27,8 +27,13 @@ namespace mozilla {
GMPCDMProxy::GMPCDMProxy(dom::MediaKeys* aKeys,
const nsAString& aKeySystem,
GMPCrashHelper* aCrashHelper)
: CDMProxy(aKeys, aKeySystem)
GMPCrashHelper* aCrashHelper,
bool aDistinctiveIdentifierRequired,
bool aPersistentStateRequired)
: CDMProxy(aKeys,
aKeySystem,
aDistinctiveIdentifierRequired,
aPersistentStateRequired)
, mCrashHelper(aCrashHelper)
, mCDM(nullptr)
, mDecryptionJobCount(0)
@ -123,7 +128,9 @@ GMPCDMProxy::gmp_InitDone(GMPDecryptorProxy* aCDM, nsAutoPtr<InitData>&& aData)
mCDM = aCDM;
mCallback = new GMPCDMCallbackProxy(this);
mCDM->Init(mCallback);
mCDM->Init(mCallback,
mDistinctiveIdentifierRequired,
mPersistentStateRequired);
nsCOMPtr<nsIRunnable> task(
NewRunnableMethod<uint32_t>(this,
&GMPCDMProxy::OnCDMCreated,
@ -237,7 +244,10 @@ GMPCDMProxy::gmp_InitGetGMPDecryptor(nsresult aResult,
RefPtr<GMPCrashHelper> crashHelper = Move(aData->mCrashHelper);
UniquePtr<GetGMPDecryptorCallback> callback(new gmp_InitDoneCallback(this,
Move(aData)));
nsresult rv = mps->GetGMPDecryptor(crashHelper, &tags, GetNodeId(), Move(callback));
nsresult rv = mps->GetGMPDecryptor(crashHelper,
&tags,
GetNodeId(),
Move(callback));
if (NS_FAILED(rv)) {
RejectPromise(promiseID, NS_ERROR_DOM_INVALID_STATE_ERR,
NS_LITERAL_CSTRING("Call to GetGMPDecryptor() failed early"));

Просмотреть файл

@ -24,7 +24,9 @@ public:
GMPCDMProxy(dom::MediaKeys* aKeys,
const nsAString& aKeySystem,
GMPCrashHelper* aCrashHelper);
GMPCrashHelper* aCrashHelper,
bool aDistinctiveIdentifierRequired,
bool aPersistentStateRequired);
void Init(PromiseId aPromiseId,
const nsAString& aOrigin,

Просмотреть файл

@ -220,12 +220,13 @@ GMPDecryptorChild::GetPluginVoucher(const uint8_t** aVoucher,
}
bool
GMPDecryptorChild::RecvInit()
GMPDecryptorChild::RecvInit(const bool& aDistinctiveIdentifierRequired,
const bool& aPersistentStateRequired)
{
if (!mSession) {
return false;
}
mSession->Init(this);
mSession->Init(this, aDistinctiveIdentifierRequired, aPersistentStateRequired);
return true;
}

Просмотреть файл

@ -83,7 +83,8 @@ private:
~GMPDecryptorChild();
// GMPDecryptorChild
bool RecvInit() override;
bool RecvInit(const bool& aDistinctiveIdentifierRequired,
const bool& aPersistentStateRequired) override;
bool RecvCreateSession(const uint32_t& aCreateSessionToken,
const uint32_t& aPromiseId,

Просмотреть файл

@ -41,7 +41,9 @@ GMPDecryptorParent::~GMPDecryptorParent()
}
nsresult
GMPDecryptorParent::Init(GMPDecryptorProxyCallback* aCallback)
GMPDecryptorParent::Init(GMPDecryptorProxyCallback* aCallback,
bool aDistinctiveIdentifierRequired,
bool aPersistentStateRequired)
{
LOGD(("GMPDecryptorParent[%p]::Init()", this));
@ -50,7 +52,7 @@ GMPDecryptorParent::Init(GMPDecryptorProxyCallback* aCallback)
return NS_ERROR_FAILURE;
}
mCallback = aCallback;
if (!SendInit()) {
if (!SendInit(aDistinctiveIdentifierRequired, aPersistentStateRequired)) {
return NS_ERROR_FAILURE;
}
mIsOpen = true;

Просмотреть файл

@ -33,7 +33,9 @@ public:
uint32_t GetPluginId() const override { return mPluginId; }
nsresult Init(GMPDecryptorProxyCallback* aCallback) override;
nsresult Init(GMPDecryptorProxyCallback* aCallback,
bool aDistinctiveIdentifierRequired,
bool aPersistentStateRequired) override;
void CreateSession(uint32_t aCreateSessionToken,
uint32_t aPromiseId,

Просмотреть файл

@ -59,7 +59,9 @@ public:
virtual uint32_t GetPluginId() const = 0;
virtual nsresult Init(GMPDecryptorProxyCallback* aCallback) = 0;
virtual nsresult Init(GMPDecryptorProxyCallback* aCallback,
bool aDistinctiveIdentifierRequired,
bool aPersistentStateRequired) = 0;
virtual void CreateSession(uint32_t aCreateSessionToken,
uint32_t aPromiseId,

Просмотреть файл

@ -20,7 +20,8 @@ async protocol PGMPDecryptor
manager PGMPContent;
child:
async Init();
async Init(bool aDistinctiveIdentifierRequired,
bool aPersistentStateRequired);
async CreateSession(uint32_t aCreateSessionToken,
uint32_t aPromiseId,

Просмотреть файл

@ -227,7 +227,9 @@ public:
// Sets the callback to use with the decryptor to return results
// to Gecko.
virtual void Init(GMPDecryptorCallback* aCallback) = 0;
virtual void Init(GMPDecryptorCallback* aCallback,
bool aDistinctiveIdentifierRequired,
bool aPersistentStateRequired) = 0;
// Initiates the creation of a session given |aType| and |aInitData|, and
// the generation of a license request message.

Просмотреть файл

@ -122,10 +122,6 @@ WidevineAdapter::GMPGetAPI(const char* aAPIName,
Log("cdm: 0x%x", cdm);
sCDMWrapper = new CDMWrapper(cdm);
decryptor->SetCDM(RefPtr<CDMWrapper>(sCDMWrapper));
cdm->Initialize(false, /* allow_distinctive_identifier */
false /* allow_persistent_state */);
*aPluginAPI = decryptor;
} else if (!strcmp(aAPIName, GMP_API_VIDEO_DECODER)) {

Просмотреть файл

@ -7,6 +7,7 @@
#include "WidevineAdapter.h"
#include "WidevineUtils.h"
#include "WidevineFileIO.h"
#include <mozilla/SizePrintfMacros.h>
#include <stdarg.h>
@ -35,10 +36,21 @@ WidevineDecryptor::SetCDM(RefPtr<CDMWrapper> aCDM)
}
void
WidevineDecryptor::Init(GMPDecryptorCallback* aCallback)
WidevineDecryptor::Init(GMPDecryptorCallback* aCallback,
bool aDistinctiveIdentifierRequired,
bool aPersistentStateRequired)
{
Log("WidevineDecryptor::Init() this=%p distinctiveId=%d persistentState=%d",
this, aDistinctiveIdentifierRequired, aPersistentStateRequired);
MOZ_ASSERT(aCallback);
mCallback = aCallback;
MOZ_ASSERT(mCDM);
mDistinctiveIdentifierRequired = aDistinctiveIdentifierRequired;
mPersistentStateRequired = aPersistentStateRequired;
if (CDM()) {
CDM()->Initialize(aDistinctiveIdentifierRequired,
aPersistentStateRequired);
}
}
static SessionType
@ -484,9 +496,10 @@ FileIO*
WidevineDecryptor::CreateFileIO(FileIOClient* aClient)
{
Log("Decryptor::CreateFileIO()");
// Persistent storage not required or supported!
MOZ_ASSERT(false);
return nullptr;
if (!mPersistentStateRequired) {
return nullptr;
}
return new WidevineFileIO(aClient);
}
} // namespace mozilla

Просмотреть файл

@ -27,7 +27,9 @@ public:
void SetCDM(RefPtr<CDMWrapper> aCDM);
// GMPDecryptor
void Init(GMPDecryptorCallback* aCallback) override;
void Init(GMPDecryptorCallback* aCallback,
bool aDistinctiveIdentifierRequired,
bool aPersistentStateRequired) override;
void CreateSession(uint32_t aCreateSessionToken,
uint32_t aPromiseId,
@ -120,6 +122,8 @@ private:
GMPDecryptorCallback* mCallback;
std::map<uint32_t, uint32_t> mPromiseIdToNewSessionTokens;
bool mDistinctiveIdentifierRequired = false;
bool mPersistentStateRequired = false;
};
} // namespace mozilla

Просмотреть файл

@ -606,7 +606,7 @@ class GMPStorageTest : public GMPDecryptorProxyCallback
EXPECT_TRUE(!!mRunner->mDecryptor);
if (mRunner->mDecryptor) {
mRunner->mDecryptor->Init(mRunner);
mRunner->mDecryptor->Init(mRunner, false, true);
}
nsCOMPtr<nsIThread> thread(GetGMPThread());
thread->Dispatch(mContinuation, NS_DISPATCH_NORMAL);

Просмотреть файл

@ -46,7 +46,9 @@ ClearKeySessionManager::~ClearKeySessionManager()
}
void
ClearKeySessionManager::Init(GMPDecryptorCallback* aCallback)
ClearKeySessionManager::Init(GMPDecryptorCallback* aCallback,
bool aDistinctiveIdentifierAllowed,
bool aPersistentStateAllowed)
{
CK_LOGD("ClearKeySessionManager::Init");
mCallback = aCallback;

Просмотреть файл

@ -34,7 +34,9 @@ class ClearKeySessionManager final : public GMPDecryptor
public:
ClearKeySessionManager();
virtual void Init(GMPDecryptorCallback* aCallback) override;
virtual void Init(GMPDecryptorCallback* aCallback,
bool aDistinctiveIdentifierAllowed,
bool aPersistentStateAllowed) override;
virtual void CreateSession(uint32_t aCreateSessionToken,
uint32_t aPromiseId,