Bug 813489 - Update the HTTP connection's security callbacks from the socket thread. r=mayhemer

This commit is contained in:
Josh Matthews 2012-12-05 17:10:19 -05:00
parent 42b1460c64
commit 6f203f7db0
2 changed files with 24 additions and 2 deletions

View File

@ -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<UpdateSecurityCallbacks> event = new UpdateSecurityCallbacks(this, aCallbacks);
gSocketTransportService->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL);
}
}

View File

@ -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<nsHttpTransaction> mTrans;
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
};
mozilla::Mutex mCallbacksLock;
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;