Bug 1060179 - Percolate EME node id to EME child process. r=jesup
authorChris Pearce <cpearce@mozilla.com>
Mon, 13 Oct 2014 11:53:44 +1300
changeset 233253 77fcb81f442b5acf0c5dd122abe2916227d42b71
parent 233252 27ae9275cd05c8922a4f3fff4192cf99962536d7
child 233254 bd41106643fe8b7bfcf7cc447c337099f6627497
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs1060179
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1060179 - Percolate EME node id to EME child process. r=jesup
content/media/gmp/GMPChild.cpp
content/media/gmp/GMPChild.h
content/media/gmp/GMPDecryptorChild.cpp
content/media/gmp/GMPDecryptorChild.h
content/media/gmp/GMPParent.cpp
content/media/gmp/PGMP.ipdl
--- a/content/media/gmp/GMPChild.cpp
+++ b/content/media/gmp/GMPChild.cpp
@@ -263,30 +263,40 @@ GMPChild::Init(const std::string& aPlugi
   if (!Open(aChannel, aParentProcessHandle, aIOLoop)) {
     return false;
   }
 
 #ifdef MOZ_CRASHREPORTER
   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()
+{
 #ifdef XP_WIN
-  PreLoadLibraries(aPluginPath);
+  PreLoadLibraries(mPluginPath);
 #endif
 
 #if defined(MOZ_SANDBOX) && defined(XP_WIN)
   mozilla::SandboxTarget::Instance()->StartSandbox();
 #endif
 
-  return LoadPluginLibrary(aPluginPath);
+  return LoadPluginLibrary(mPluginPath);
 }
 
 #ifdef XP_WIN
 // Pre-load DLLs that need to be used by the EME plugin but that can't be
 // loaded after the sandbox has started
 bool
 GMPChild::PreLoadLibraries(const std::string& aPluginPath)
 {
@@ -494,17 +504,17 @@ GMPChild::DeallocPGMPVideoDecoderChild(P
 {
   delete aActor;
   return true;
 }
 
 PGMPDecryptorChild*
 GMPChild::AllocPGMPDecryptorChild()
 {
-  GMPDecryptorChild* actor = new GMPDecryptorChild(this);
+  GMPDecryptorChild* actor = new GMPDecryptorChild(this, mNodeId);
   actor->AddRef();
   return actor;
 }
 
 bool
 GMPChild::DeallocPGMPDecryptorChild(PGMPDecryptorChild* aActor)
 {
   static_cast<GMPDecryptorChild*>(aActor)->Release();
--- a/content/media/gmp/GMPChild.h
+++ b/content/media/gmp/GMPChild.h
@@ -45,16 +45,20 @@ public:
 
   // GMPSharedMem
   virtual void CheckThread() MOZ_OVERRIDE;
 
   // GMPAsyncShutdownHost
   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;
 
   virtual PGMPVideoDecoderChild* AllocPGMPVideoDecoderChild() MOZ_OVERRIDE;
   virtual bool DeallocPGMPVideoDecoderChild(PGMPVideoDecoderChild* aActor) MOZ_OVERRIDE;
   virtual bool RecvPGMPVideoDecoderConstructor(PGMPVideoDecoderChild* aActor) MOZ_OVERRIDE;
 
   virtual PGMPVideoEncoderChild* AllocPGMPVideoEncoderChild() MOZ_OVERRIDE;
@@ -83,18 +87,19 @@ private:
 
   GMPAsyncShutdown* mAsyncShutdown;
   nsRefPtr<GMPTimerChild> mTimerChild;
   nsRefPtr<GMPStorageChild> mStorage;
 
   PRLibrary* mLib;
   GMPGetAPIFunc mGetAPIFunc;
   MessageLoop* mGMPMessageLoop;
+  std::string mPluginPath;
 #if defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
-  std::string mPluginPath;
   nsCString mPluginBinaryPath;
 #endif
+  std::string mNodeId;
 };
 
 } // namespace gmp
 } // namespace mozilla
 
 #endif // GMPChild_h_
--- a/content/media/gmp/GMPDecryptorChild.cpp
+++ b/content/media/gmp/GMPDecryptorChild.cpp
@@ -21,19 +21,20 @@
         FROM_HERE, NewRunnableMethod(this, &GMPDecryptorChild::_func, __VA_ARGS__) \
       ); \
     } \
   } while(false)
 
 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);
 }
 
 GMPDecryptorChild::~GMPDecryptorChild()
 {
 }
 
@@ -171,19 +172,18 @@ GMPDecryptorChild::SetCapabilities(uint6
 {
   CALL_ON_GMP_THREAD(SendSetCaps, aCaps);
 }
 
 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
 GMPDecryptorChild::GetSandboxVoucher(const uint8_t** aVoucher,
                                      uint8_t* aVoucherLength)
 {
   const char* voucher = "placeholder_sandbox_voucher.";
   *aVoucher = (uint8_t*)voucher;
--- a/content/media/gmp/GMPDecryptorChild.h
+++ b/content/media/gmp/GMPDecryptorChild.h
@@ -5,30 +5,31 @@
 
 #ifndef GMPDecryptorChild_h_
 #define GMPDecryptorChild_h_
 
 #include "mozilla/gmp/PGMPDecryptorChild.h"
 #include "gmp-decryption.h"
 #include "mozilla/gmp/GMPTypes.h"
 #include "GMPEncryptedBufferDataImpl.h"
+#include <string>
 
 namespace mozilla {
 namespace gmp {
 
 class GMPChild;
 
 class GMPDecryptorChild : public GMPDecryptorCallback
                         , public GMPDecryptorHost
                         , public PGMPDecryptorChild
 {
 public:
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPDecryptorChild);
 
-  explicit GMPDecryptorChild(GMPChild* aPlugin);
+  explicit GMPDecryptorChild(GMPChild* aPlugin, const std::string& aNodeId);
 
   void Init(GMPDecryptor* aSession);
 
   // GMPDecryptorCallback
   virtual void ResolveNewSessionPromise(uint32_t aPromiseId,
                                         const char* aSessionId,
                                         uint32_t aSessionIdLength) MOZ_OVERRIDE;
   virtual void ResolveLoadSessionPromise(uint32_t aPromiseId,
@@ -117,14 +118,16 @@ private:
                                         const nsTArray<uint8_t>& aServerCert) MOZ_OVERRIDE;
 
   virtual bool RecvDecryptingComplete() MOZ_OVERRIDE;
 
   // GMP's GMPDecryptor implementation.
   // Only call into this on the (GMP process) main thread.
   GMPDecryptor* mSession;
   GMPChild* mPlugin;
+
+  const std::string mNodeId;
 };
 
 } // namespace gmp
 } // namespace mozilla
 
 #endif // GMPDecryptorChild_h_
--- a/content/media/gmp/GMPParent.cpp
+++ b/content/media/gmp/GMPParent.cpp
@@ -145,16 +145,32 @@ GMPParent::LoadProcess()
 
     bool opened = Open(mProcess->GetChannel(), mProcess->GetChildProcessHandle());
     if (!opened) {
       mProcess->Delete();
       mProcess = nullptr;
       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;
 
   return NS_OK;
 }
 
 void
--- a/content/media/gmp/PGMP.ipdl
+++ b/content/media/gmp/PGMP.ipdl
@@ -35,14 +35,16 @@ parent:
   async AsyncShutdownRequired();
 
 child:
   async PGMPAudioDecoder();
   async PGMPDecryptor();
   async PGMPVideoDecoder();
   async PGMPVideoEncoder();
 
+  async SetNodeId(nsCString nodeId);
+  async StartPlugin();
   async BeginAsyncShutdown();
   async CrashPluginNow();
 };
 
 } // namespace gmp
 } // namespace mozilla