Bug 1060179 - Percolate EME node id to EME child process. r=jesup

This commit is contained in:
Chris Pearce 2014-10-09 17:01:03 +13:00
parent f2a222b010
commit b469435ef0
6 changed files with 46 additions and 11 deletions

View File

@ -232,16 +232,25 @@ GMPChild::Init(const std::string& aPluginPath,
SendPCrashReporterConstructor(CrashReporter::CurrentThreadId());
#endif
#if defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
mPluginPath = aPluginPath;
return true;
#endif
}
bool
GMPChild::RecvSetNodeId(const nsCString& aNodeId)
{
// TODO: hash mNodeId with machine specific data.
mNodeId = std::string(aNodeId.BeginReading(), aNodeId.EndReading());
return true;
}
bool
GMPChild::RecvStartPlugin()
{
#if defined(MOZ_SANDBOX) && defined(XP_WIN)
mozilla::SandboxTarget::Instance()->StartSandbox();
#endif
return LoadPluginLibrary(aPluginPath);
return LoadPluginLibrary(mPluginPath);
}
bool
@ -399,7 +408,7 @@ GMPChild::DeallocPGMPVideoDecoderChild(PGMPVideoDecoderChild* aActor)
PGMPDecryptorChild*
GMPChild::AllocPGMPDecryptorChild()
{
GMPDecryptorChild* actor = new GMPDecryptorChild(this);
GMPDecryptorChild* actor = new GMPDecryptorChild(this, mNodeId);
actor->AddRef();
return actor;
}

View File

@ -47,6 +47,10 @@ public:
void ShutdownComplete() MOZ_OVERRIDE;
private:
virtual bool RecvSetNodeId(const nsCString& aNodeId) MOZ_OVERRIDE;
virtual bool RecvStartPlugin() MOZ_OVERRIDE;
virtual PCrashReporterChild* AllocPCrashReporterChild(const NativeThreadId& aThread) MOZ_OVERRIDE;
virtual bool DeallocPCrashReporterChild(PCrashReporterChild*) MOZ_OVERRIDE;
@ -85,10 +89,11 @@ private:
PRLibrary* mLib;
GMPGetAPIFunc mGetAPIFunc;
MessageLoop* mGMPMessageLoop;
#if defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
std::string mPluginPath;
#if defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
nsCString mPluginBinaryPath;
#endif
std::string mNodeId;
};
} // namespace gmp

View File

@ -26,9 +26,10 @@
namespace mozilla {
namespace gmp {
GMPDecryptorChild::GMPDecryptorChild(GMPChild* aPlugin)
GMPDecryptorChild::GMPDecryptorChild(GMPChild* aPlugin, const std::string& aNodeId)
: mSession(nullptr)
, mPlugin(aPlugin)
, mNodeId(aNodeId)
{
MOZ_ASSERT(mPlugin);
}
@ -176,9 +177,8 @@ void
GMPDecryptorChild::GetNodeId(const char** aOutNodeId,
uint32_t* aOutNodeIdLength)
{
static const char* id = "placeholder_node_id";
*aOutNodeId = id;
*aOutNodeIdLength = strlen(id);
*aOutNodeId = mNodeId.c_str();
*aOutNodeIdLength = mNodeId.size();
}
void

View File

@ -10,6 +10,7 @@
#include "gmp-decryption.h"
#include "mozilla/gmp/GMPTypes.h"
#include "GMPEncryptedBufferDataImpl.h"
#include <string>
namespace mozilla {
namespace gmp {
@ -23,7 +24,7 @@ class GMPDecryptorChild : public GMPDecryptorCallback
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPDecryptorChild);
explicit GMPDecryptorChild(GMPChild* aPlugin);
explicit GMPDecryptorChild(GMPChild* aPlugin, const std::string& aNodeId);
void Init(GMPDecryptor* aSession);
@ -122,6 +123,8 @@ private:
// Only call into this on the (GMP process) main thread.
GMPDecryptor* mSession;
GMPChild* mPlugin;
const std::string mNodeId;
};
} // namespace gmp

View File

@ -150,6 +150,22 @@ GMPParent::LoadProcess()
return NS_ERROR_FAILURE;
}
LOGD(("%s::%s: Created new process %p", __CLASS__, __FUNCTION__, (void *)mProcess));
bool ok = SendSetNodeId(mNodeId);
if (!ok) {
mProcess->Delete();
mProcess = nullptr;
return NS_ERROR_FAILURE;
}
LOGD(("%s::%s: Failed to send node id %p", __CLASS__, __FUNCTION__, (void *)mProcess));
ok = SendStartPlugin();
if (!ok) {
mProcess->Delete();
mProcess = nullptr;
return NS_ERROR_FAILURE;
}
LOGD(("%s::%s: Failed to send start %p", __CLASS__, __FUNCTION__, (void *)mProcess));
}
mState = GMPStateLoaded;

View File

@ -40,6 +40,8 @@ child:
async PGMPVideoDecoder();
async PGMPVideoEncoder();
async SetNodeId(nsCString nodeId);
async StartPlugin();
async BeginAsyncShutdown();
async CrashPluginNow();
};