mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1154389 - Stop leaking DeviceSuccessCallbackRunnable objects, and release its mOnSuccess and mOnFailure on the main thread if needed; r=jesup
This commit is contained in:
parent
68991a4890
commit
e2b1da84ff
@ -46,6 +46,7 @@
|
||||
#include "MediaTrackConstraints.h"
|
||||
#include "VideoUtils.h"
|
||||
#include "Latency.h"
|
||||
#include "nsProxyRelease.h"
|
||||
|
||||
// For PR_snprintf
|
||||
#include "prprf.h"
|
||||
@ -332,6 +333,18 @@ public:
|
||||
mOnFailure.swap(aOnFailure);
|
||||
}
|
||||
|
||||
~DeviceSuccessCallbackRunnable()
|
||||
{
|
||||
if (!NS_IsMainThread()) {
|
||||
// This can happen if the main thread processes the runnable before
|
||||
// GetUserMediaDevicesTask::Run returns.
|
||||
nsCOMPtr<nsIThread> mainThread = do_GetMainThread();
|
||||
|
||||
NS_ProxyRelease(mainThread, mOnSuccess);
|
||||
NS_ProxyRelease(mainThread, mOnFailure);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
AnonymizeId(nsAString& aId, const nsACString& aOriginKey)
|
||||
{
|
||||
@ -1498,10 +1511,7 @@ public:
|
||||
result->AppendElement(source);
|
||||
}
|
||||
}
|
||||
// In the case of failure with this newly allocated runnable, we
|
||||
// intentionally leak the runnable, because we've pawned mOnSuccess and
|
||||
// mOnFailure onto it which are main thread objects unsafe to release here.
|
||||
DeviceSuccessCallbackRunnable* runnable =
|
||||
nsRefPtr<DeviceSuccessCallbackRunnable> runnable =
|
||||
new DeviceSuccessCallbackRunnable(mWindowId, mOnSuccess, mOnFailure,
|
||||
result.forget());
|
||||
if (mPrivileged) {
|
||||
|
Loading…
Reference in New Issue
Block a user