Bug 870916 - Make socket transport avoid off-main-thread usage of wrapped JS components. r=mcmanus

This commit is contained in:
Josh Matthews 2013-05-28 09:48:23 -04:00
Родитель ac2f174bae
Коммит 3a7fe9a2b2
1 изменённых файлов: 8 добавлений и 2 удалений

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

@ -17,6 +17,7 @@
#include "nsTransportUtils.h"
#include "nsProxyInfo.h"
#include "nsNetCID.h"
#include "nsNetUtil.h"
#include "nsAutoPtr.h"
#include "nsCOMPtr.h"
#include "netCore.h"
@ -1858,10 +1859,15 @@ nsSocketTransport::GetSecurityCallbacks(nsIInterfaceRequestor **callbacks)
NS_IMETHODIMP
nsSocketTransport::SetSecurityCallbacks(nsIInterfaceRequestor *callbacks)
{
nsCOMPtr<nsIInterfaceRequestor> threadsafeCallbacks;
NS_NewNotificationCallbacksAggregation(callbacks, nullptr,
NS_GetCurrentThread(),
getter_AddRefs(threadsafeCallbacks));
nsCOMPtr<nsISupports> secinfo;
{
MutexAutoLock lock(mLock);
mCallbacks = callbacks;
mCallbacks = threadsafeCallbacks;
SOCKET_LOG(("Reset callbacks for secinfo=%p callbacks=%p\n",
mSecInfo.get(), mCallbacks.get()));
@ -1871,7 +1877,7 @@ nsSocketTransport::SetSecurityCallbacks(nsIInterfaceRequestor *callbacks)
// don't call into PSM while holding mLock!!
nsCOMPtr<nsISSLSocketControl> secCtrl(do_QueryInterface(secinfo));
if (secCtrl)
secCtrl->SetNotificationCallbacks(callbacks);
secCtrl->SetNotificationCallbacks(threadsafeCallbacks);
return NS_OK;
}