Bug 1267918 - Split LoadGMP message into select and load messages. r=gerald

This will allow us to attach a crash handler to a GMP process after deciding
which GMP to load but before actually loading it.


MozReview-Commit-ID: HwBZU2Q4TX6

--HG--
extra : rebase_source : a68b9cbc31c0b886ba491f8f15f02e4d0e32cae7
This commit is contained in:
Chris Pearce 2016-06-29 11:41:52 +12:00
Родитель ab7252caa2
Коммит fed9c17730
4 изменённых файлов: 80 добавлений и 31 удалений

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

@ -67,16 +67,21 @@ public:
return;
}
uint32_t pluginId;
nsresult rv;
bool ok = aGMPServiceChild->SendSelectGMP(mNodeId, mAPI, mTags, &pluginId, &rv);
if (!ok || rv == NS_ERROR_ILLEGAL_DURING_SHUTDOWN) {
mCallback->Done(nullptr);
return;
}
nsTArray<base::ProcessId> alreadyBridgedTo;
aGMPServiceChild->GetAlreadyBridgedTo(alreadyBridgedTo);
base::ProcessId otherProcess;
nsCString displayName;
uint32_t pluginId;
nsresult rv;
bool ok = aGMPServiceChild->SendLoadGMP(mNodeId, mAPI, mTags,
alreadyBridgedTo, &otherProcess,
&displayName, &pluginId, &rv);
ok = aGMPServiceChild->SendLaunchGMP(pluginId, alreadyBridgedTo, &otherProcess,
&displayName, &rv);
if (!ok || rv == NS_ERROR_ILLEGAL_DURING_SHUTDOWN) {
mCallback->Done(nullptr);
return;

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

@ -1818,6 +1818,18 @@ GeckoMediaPluginServiceParent::ClearStorage()
NS_DispatchToMainThread(new NotifyObserversTask("gmp-clear-storage-complete"), NS_DISPATCH_NORMAL);
}
already_AddRefed<GMPParent>
GeckoMediaPluginServiceParent::GetById(uint32_t aPluginId)
{
MutexAutoLock lock(mMutex);
for (const RefPtr<GMPParent>& gmp : mPlugins) {
if (gmp->GetPluginId() == aPluginId) {
return do_AddRef(gmp);
}
}
return nullptr;
}
GMPServiceParent::~GMPServiceParent()
{
RefPtr<DeleteTask<Transport>> task = new DeleteTask<Transport>(GetTransport());
@ -1825,34 +1837,57 @@ GMPServiceParent::~GMPServiceParent()
}
bool
GMPServiceParent::RecvLoadGMP(const nsCString& aNodeId,
const nsCString& aAPI,
nsTArray<nsCString>&& aTags,
nsTArray<ProcessId>&& aAlreadyBridgedTo,
ProcessId* aId,
nsCString* aDisplayName,
uint32_t* aPluginId,
nsresult* aRv)
GMPServiceParent::RecvSelectGMP(const nsCString& aNodeId,
const nsCString& aAPI,
nsTArray<nsCString>&& aTags,
uint32_t* aOutPluginId,
nsresult* aOutRv)
{
*aRv = NS_OK;
if (mService->IsShuttingDown()) {
*aRv = NS_ERROR_ILLEGAL_DURING_SHUTDOWN;
*aOutRv = NS_ERROR_ILLEGAL_DURING_SHUTDOWN;
return true;
}
RefPtr<GMPParent> gmp = mService->SelectPluginForAPI(aNodeId, aAPI, aTags);
if (gmp) {
*aOutPluginId = gmp->GetPluginId();
*aOutRv = NS_OK;
} else {
*aOutRv = NS_ERROR_FAILURE;
}
nsCString api = aTags[0];
LOGD(("%s: %p returning %p for api %s", __FUNCTION__, (void *)this, (void *)gmp, api.get()));
if (!gmp || !gmp->EnsureProcessLoaded(aId)) {
return true;
}
bool
GMPServiceParent::RecvLaunchGMP(const uint32_t& aPluginId,
nsTArray<ProcessId>&& aAlreadyBridgedTo,
ProcessId* aOutProcessId,
nsCString* aOutDisplayName,
nsresult* aOutRv)
{
*aOutRv = NS_OK;
if (mService->IsShuttingDown()) {
*aOutRv = NS_ERROR_ILLEGAL_DURING_SHUTDOWN;
return true;
}
RefPtr<GMPParent> gmp(mService->GetById(aPluginId));
if (!gmp) {
*aOutRv = NS_ERROR_FAILURE;
return true;
}
if (!gmp->EnsureProcessLoaded(aOutProcessId)) {
return false;
}
*aDisplayName = gmp->GetDisplayName();
*aPluginId = gmp->GetPluginId();
*aOutDisplayName = gmp->GetDisplayName();
return aAlreadyBridgedTo.Contains(*aId) || gmp->Bridge(this);
return aAlreadyBridgedTo.Contains(*aOutProcessId) || gmp->Bridge(this);
}
bool

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

@ -106,6 +106,8 @@ private:
void ForgetThisSiteOnGMPThread(const nsACString& aOrigin);
void ClearRecentHistoryOnGMPThread(PRTime aSince);
already_AddRefed<GMPParent> GetById(uint32_t aPluginId);
protected:
friend class GMPParent;
void ReAddOnGMPThread(const RefPtr<GMPParent>& aOld);
@ -225,14 +227,6 @@ public:
}
virtual ~GMPServiceParent();
bool RecvLoadGMP(const nsCString& aNodeId,
const nsCString& aApi,
nsTArray<nsCString>&& aTags,
nsTArray<ProcessId>&& aAlreadyBridgedTo,
base::ProcessId* aID,
nsCString* aDisplayName,
uint32_t* aPluginId,
nsresult* aRv) override;
bool RecvGetGMPNodeId(const nsString& aOrigin,
const nsString& aTopLevelOrigin,
const nsString& aGMPName,
@ -246,6 +240,18 @@ public:
static PGMPServiceParent* Create(Transport* aTransport, ProcessId aOtherPid);
bool RecvSelectGMP(const nsCString& aNodeId,
const nsCString& aAPI,
nsTArray<nsCString>&& aTags,
uint32_t* aOutPluginId,
nsresult* aOutRv) override;
bool RecvLaunchGMP(const uint32_t& aPluginId,
nsTArray<ProcessId>&& aAlreadyBridgedTo,
ProcessId* aOutID,
nsCString* aOutDisplayName,
nsresult* aOutRv) override;
private:
RefPtr<GeckoMediaPluginServiceParent> mService;
};

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

@ -15,10 +15,13 @@ sync protocol PGMPService
parent spawns PGMP as child;
parent:
sync LoadGMP(nsCString nodeId, nsCString api, nsCString[] tags,
ProcessId[] alreadyBridgedTo)
returns (ProcessId id, nsCString displayName, uint32_t pluginId,
nsresult aResult);
sync SelectGMP(nsCString nodeId, nsCString api, nsCString[] tags)
returns (uint32_t pluginId, nsresult aResult);
sync LaunchGMP(uint32_t pluginId, ProcessId[] alreadyBridgedTo)
returns (ProcessId id, nsCString displayName, nsresult aResult);
sync GetGMPNodeId(nsString origin, nsString topLevelOrigin,
nsString gmpName,
bool inPrivateBrowsing)