зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1057908 - GeckoMediaPluginService needs to be proxied from Content processes to parent process. Part 4 - make GetNodeId asynchronous. r=jwwang.
--HG-- extra : rebase_source : 59784b0a947cd870791a85b22c4d0607d9cdb835
This commit is contained in:
Родитель
75ade681f5
Коммит
8308cf3a1b
|
@ -125,25 +125,69 @@ private:
|
|||
nsAutoPtr<CDMProxy::InitData> mData;
|
||||
};
|
||||
|
||||
class gmp_InitGetGMPDecryptorCallback : public GetNodeIdCallback
|
||||
{
|
||||
public:
|
||||
gmp_InitGetGMPDecryptorCallback(CDMProxy* aCDMProxy,
|
||||
nsAutoPtr<CDMProxy::InitData>&& aData)
|
||||
: mCDMProxy(aCDMProxy),
|
||||
mData(aData)
|
||||
{
|
||||
}
|
||||
|
||||
void Done(nsresult aResult, const nsACString& aNodeId)
|
||||
{
|
||||
mCDMProxy->gmp_InitGetGMPDecryptor(aResult, aNodeId, Move(mData));
|
||||
}
|
||||
|
||||
private:
|
||||
nsRefPtr<CDMProxy> mCDMProxy;
|
||||
nsAutoPtr<CDMProxy::InitData> mData;
|
||||
};
|
||||
|
||||
void
|
||||
CDMProxy::gmp_Init(nsAutoPtr<InitData>&& aData)
|
||||
{
|
||||
MOZ_ASSERT(IsOnGMPThread());
|
||||
|
||||
uint32_t promiseID = aData->mPromiseId;
|
||||
nsCOMPtr<mozIGeckoMediaPluginService> mps =
|
||||
do_GetService("@mozilla.org/gecko-media-plugin-service;1");
|
||||
if (!mps) {
|
||||
RejectPromise(aData->mPromiseId, NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
// Make a copy before we transfer ownership of aData to the
|
||||
// gmp_InitGetGMPDecryptorCallback.
|
||||
InitData data(*aData);
|
||||
UniquePtr<GetNodeIdCallback> callback(
|
||||
new gmp_InitGetGMPDecryptorCallback(this, Move(aData)));
|
||||
nsresult rv = mps->GetNodeId(data.mOrigin,
|
||||
data.mTopLevelOrigin,
|
||||
data.mInPrivateBrowsing,
|
||||
Move(callback));
|
||||
if (NS_FAILED(rv)) {
|
||||
RejectPromise(data.mPromiseId, NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CDMProxy::gmp_InitGetGMPDecryptor(nsresult aResult,
|
||||
const nsACString& aNodeId,
|
||||
nsAutoPtr<InitData>&& aData)
|
||||
{
|
||||
uint32_t promiseID = aData->mPromiseId;
|
||||
if (NS_FAILED(aResult)) {
|
||||
RejectPromise(promiseID, NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
nsresult rv = mps->GetNodeId(aData->mOrigin,
|
||||
aData->mTopLevelOrigin,
|
||||
aData->mInPrivateBrowsing,
|
||||
mNodeId);
|
||||
mNodeId = aNodeId;
|
||||
MOZ_ASSERT(!GetNodeId().IsEmpty());
|
||||
if (NS_FAILED(rv)) {
|
||||
|
||||
nsCOMPtr<mozIGeckoMediaPluginService> mps =
|
||||
do_GetService("@mozilla.org/gecko-media-plugin-service;1");
|
||||
if (!mps) {
|
||||
RejectPromise(promiseID, NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return;
|
||||
}
|
||||
|
@ -159,7 +203,7 @@ CDMProxy::gmp_Init(nsAutoPtr<InitData>&& aData)
|
|||
|
||||
UniquePtr<GetGMPDecryptorCallback> callback(new gmp_InitDoneCallback(this,
|
||||
Move(aData)));
|
||||
rv = mps->GetGMPDecryptor(&tags, GetNodeId(), Move(callback));
|
||||
nsresult rv = mps->GetGMPDecryptor(&tags, GetNodeId(), Move(callback));
|
||||
if (NS_FAILED(rv)) {
|
||||
RejectPromise(promiseID, NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
}
|
||||
|
|
|
@ -175,6 +175,7 @@ public:
|
|||
|
||||
private:
|
||||
friend class gmp_InitDoneCallback;
|
||||
friend class gmp_InitGetGMPDecryptorCallback;
|
||||
|
||||
struct InitData {
|
||||
uint32_t mPromiseId;
|
||||
|
@ -186,6 +187,9 @@ private:
|
|||
// GMP thread only.
|
||||
void gmp_Init(nsAutoPtr<InitData>&& aData);
|
||||
void gmp_InitDone(GMPDecryptorProxy* aCDM, nsAutoPtr<InitData>&& aData);
|
||||
void gmp_InitGetGMPDecryptor(nsresult aResult,
|
||||
const nsACString& aNodeId,
|
||||
nsAutoPtr<InitData>&& aData);
|
||||
|
||||
// GMP thread only.
|
||||
void gmp_Shutdown();
|
||||
|
|
|
@ -863,7 +863,7 @@ GeckoMediaPluginServiceParent::IsPersistentStorageAllowed(const nsACString& aNod
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
GeckoMediaPluginServiceParent::GetNodeId(const nsAString& aOrigin,
|
||||
const nsAString& aTopLevelOrigin,
|
||||
bool aInPrivateBrowsing,
|
||||
|
@ -1011,6 +1011,18 @@ GeckoMediaPluginServiceParent::GetNodeId(const nsAString& aOrigin,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GeckoMediaPluginServiceParent::GetNodeId(const nsAString& aOrigin,
|
||||
const nsAString& aTopLevelOrigin,
|
||||
bool aInPrivateBrowsing,
|
||||
UniquePtr<GetNodeIdCallback>&& aCallback)
|
||||
{
|
||||
nsCString nodeId;
|
||||
nsresult rv = GetNodeId(aOrigin, aTopLevelOrigin, aInPrivateBrowsing, nodeId);
|
||||
aCallback->Done(rv, nodeId);
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool
|
||||
MatchOrigin(nsIFile* aPath, const nsACString& aOrigin)
|
||||
{
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
NS_IMETHOD GetNodeId(const nsAString& aOrigin,
|
||||
const nsAString& aTopLevelOrigin,
|
||||
bool aInPrivateBrowsingMode,
|
||||
nsACString& aOutId) override;
|
||||
UniquePtr<GetNodeIdCallback>&& aCallback) override;
|
||||
|
||||
NS_DECL_MOZIGECKOMEDIAPLUGINCHROMESERVICE
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
@ -65,6 +65,9 @@ private:
|
|||
const nsTArray<nsCString>& aTags,
|
||||
size_t* aOutPluginIndex);
|
||||
|
||||
nsresult GetNodeId(const nsAString& aOrigin, const nsAString& aTopLevelOrigin,
|
||||
bool aInPrivateBrowsing, nsACString& aOutId);
|
||||
|
||||
void UnloadPlugins();
|
||||
void CrashPlugins();
|
||||
void SetAsyncShutdownComplete();
|
||||
|
|
|
@ -36,6 +36,13 @@ typedef GMPGetterCallback<GMPDecryptorProxy> GetGMPDecryptorCallback;
|
|||
typedef GMPGetterCallback<GMPAudioDecoderProxy> GetGMPAudioDecoderCallback;
|
||||
typedef GMPVideoGetterCallback<GMPVideoDecoderProxy> GetGMPVideoDecoderCallback;
|
||||
typedef GMPVideoGetterCallback<GMPVideoEncoderProxy> GetGMPVideoEncoderCallback;
|
||||
class GetNodeIdCallback
|
||||
{
|
||||
public:
|
||||
GetNodeIdCallback() { MOZ_COUNT_CTOR(GetNodeIdCallback); }
|
||||
virtual ~GetNodeIdCallback() { MOZ_COUNT_DTOR(GetNodeIdCallback); }
|
||||
virtual void Done(nsresult aResult, const nsACString& aNodeId) = 0;
|
||||
};
|
||||
%}
|
||||
|
||||
[ptr] native TagArray(nsTArray<nsCString>);
|
||||
|
@ -43,8 +50,9 @@ native GetGMPDecryptorCallback(mozilla::UniquePtr<GetGMPDecryptorCallback>&&);
|
|||
native GetGMPAudioDecoderCallback(mozilla::UniquePtr<GetGMPAudioDecoderCallback>&&);
|
||||
native GetGMPVideoDecoderCallback(mozilla::UniquePtr<GetGMPVideoDecoderCallback>&&);
|
||||
native GetGMPVideoEncoderCallback(mozilla::UniquePtr<GetGMPVideoEncoderCallback>&&);
|
||||
native GetNodeIdCallback(mozilla::UniquePtr<GetNodeIdCallback>&&);
|
||||
|
||||
[scriptable, uuid(11bb248b-7a4b-4f62-bebb-8211551d8c20)]
|
||||
[scriptable, uuid(2b0c90e1-df89-4583-a123-8bdb2f5f7e39)]
|
||||
interface mozIGeckoMediaPluginService : nsISupports
|
||||
{
|
||||
|
||||
|
@ -134,7 +142,9 @@ interface mozIGeckoMediaPluginService : nsISupports
|
|||
/**
|
||||
* Gets the NodeId for a (origin, urlbarOrigin, isInprivateBrowsing) tuple.
|
||||
*/
|
||||
ACString getNodeId(in AString origin,
|
||||
[noscript]
|
||||
void getNodeId(in AString origin,
|
||||
in AString topLevelOrigin,
|
||||
in bool inPrivateBrowsingMode);
|
||||
in bool inPrivateBrowsingMode,
|
||||
in GetNodeIdCallback callback);
|
||||
};
|
||||
|
|
|
@ -460,6 +460,26 @@ SimulatePBModeExit()
|
|||
NS_DispatchToMainThread(new NotifyObserversTask("last-pb-context-exited"), NS_DISPATCH_SYNC);
|
||||
}
|
||||
|
||||
class TestGetNodeIdCallback : public GetNodeIdCallback
|
||||
{
|
||||
public:
|
||||
TestGetNodeIdCallback(nsCString& aNodeId, nsresult& aResult)
|
||||
: mNodeId(aNodeId),
|
||||
mResult(aResult)
|
||||
{
|
||||
}
|
||||
|
||||
void Done(nsresult aResult, const nsACString& aNodeId)
|
||||
{
|
||||
mResult = aResult;
|
||||
mNodeId = aNodeId;
|
||||
}
|
||||
|
||||
private:
|
||||
nsCString& mNodeId;
|
||||
nsresult& mResult;
|
||||
};
|
||||
|
||||
static nsCString
|
||||
GetNodeId(const nsAString& aOrigin,
|
||||
const nsAString& aTopLevelOrigin,
|
||||
|
@ -469,11 +489,16 @@ GetNodeId(const nsAString& aOrigin,
|
|||
GeckoMediaPluginServiceParent::GetSingleton();
|
||||
EXPECT_TRUE(service);
|
||||
nsCString nodeId;
|
||||
nsresult result;
|
||||
UniquePtr<GetNodeIdCallback> callback(new TestGetNodeIdCallback(nodeId,
|
||||
result));
|
||||
// We rely on the fact that the GetNodeId implementation for
|
||||
// GeckoMediaPluginServiceParent is synchronous.
|
||||
nsresult rv = service->GetNodeId(aOrigin,
|
||||
aTopLevelOrigin,
|
||||
aInPBMode,
|
||||
nodeId);
|
||||
EXPECT_TRUE(NS_SUCCEEDED(rv));
|
||||
Move(callback));
|
||||
EXPECT_TRUE(NS_SUCCEEDED(rv) && NS_SUCCEEDED(result));
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче