diff --git a/netwerk/protocol/http/nsHttpTransaction.cpp b/netwerk/protocol/http/nsHttpTransaction.cpp index 9acb5805262..a349f3945e9 100644 --- a/netwerk/protocol/http/nsHttpTransaction.cpp +++ b/netwerk/protocol/http/nsHttpTransaction.cpp @@ -27,6 +27,7 @@ #include "nsComponentManagerUtils.h" // do_CreateInstance #include "nsServiceManagerUtils.h" // do_GetService #include "nsIHttpActivityObserver.h" +#include "nsSocketTransportService2.h" using namespace mozilla; @@ -407,8 +408,10 @@ nsHttpTransaction::SetSecurityCallbacks(nsIInterfaceRequestor* aCallbacks) MutexAutoLock lock(mCallbacksLock); mCallbacks = aCallbacks; } - if (mConnection) { - mConnection->SetSecurityCallbacks(aCallbacks); + + if (gSocketTransportService) { + nsRefPtr event = new UpdateSecurityCallbacks(this, aCallbacks); + gSocketTransportService->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL); } } diff --git a/netwerk/protocol/http/nsHttpTransaction.h b/netwerk/protocol/http/nsHttpTransaction.h index f0cf58a0828..df3187068a5 100644 --- a/netwerk/protocol/http/nsHttpTransaction.h +++ b/netwerk/protocol/http/nsHttpTransaction.h @@ -29,6 +29,7 @@ class nsHttpRequestHead; class nsHttpResponseHead; class nsHttpChunkedDecoder; class nsIHttpActivityObserver; +class UpdateSecurityCallbacks; //----------------------------------------------------------------------------- // nsHttpTransaction represents a single HTTP transaction. It is thread-safe, @@ -142,6 +143,24 @@ private: bool TimingEnabled() const { return mCaps & NS_HTTP_TIMING_ENABLED; } private: + class UpdateSecurityCallbacks : public nsRunnable + { + public: + UpdateSecurityCallbacks(nsHttpTransaction* aTrans, + nsIInterfaceRequestor* aCallbacks) + : mTrans(aTrans), mCallbacks(aCallbacks) {} + + NS_IMETHOD Run() + { + if (mTrans->mConnection) + mTrans->mConnection->SetSecurityCallbacks(mCallbacks); + return NS_OK; + } + private: + nsRefPtr mTrans; + nsCOMPtr mCallbacks; + }; + mozilla::Mutex mCallbacksLock; nsCOMPtr mCallbacks;