Bug 1271198 - Convert Websockets to use AsyncOpen2(). r=jduell

This commit is contained in:
Christoph Kerschbaumer
2016-05-17 12:04:11 +02:00
parent da9e24a295
commit 4dd7563d92
5 changed files with 59 additions and 35 deletions

View File

@@ -1402,7 +1402,14 @@ WebSocketChannel::BeginOpenInternal()
}
#endif
rv = localChannel->AsyncOpen(this, mHttpChannel);
nsCOMPtr<nsILoadInfo> loadInfo = localChannel->GetLoadInfo();
if (loadInfo && loadInfo->GetSecurityMode()) {
rv = localChannel->AsyncOpen2(this);
}
else {
rv = localChannel->AsyncOpen(this, nullptr);
}
if (NS_FAILED(rv)) {
LOG(("WebSocketChannel::BeginOpenInternal: cannot async open\n"));
AbortSession(NS_ERROR_CONNECTION_REFUSED);
@@ -3713,7 +3720,7 @@ WebSocketChannel::OnStartRequest(nsIRequest *aRequest,
nsISupports *aContext)
{
LOG(("WebSocketChannel::OnStartRequest(): %p [%p %p] recvdhttpupgrade=%d\n",
this, aRequest, aContext, mRecvdHttpUpgradeTransport));
this, aRequest, mHttpChannel.get(), mRecvdHttpUpgradeTransport));
MOZ_ASSERT(NS_IsMainThread(), "not main thread");
MOZ_ASSERT(!mGotUpgradeOK, "OTA duplicated");
@@ -3874,7 +3881,7 @@ WebSocketChannel::OnStopRequest(nsIRequest *aRequest,
nsresult aStatusCode)
{
LOG(("WebSocketChannel::OnStopRequest() %p [%p %p %x]\n",
this, aRequest, aContext, aStatusCode));
this, aRequest, mHttpChannel.get(), aStatusCode));
MOZ_ASSERT(NS_IsMainThread(), "not main thread");
ReportConnectionTelemetry();
@@ -4037,7 +4044,7 @@ WebSocketChannel::OnDataAvailable(nsIRequest *aRequest,
uint32_t aCount)
{
LOG(("WebSocketChannel::OnDataAvailable() %p [%p %p %p %llu %u]\n",
this, aRequest, aContext, aInputStream, aOffset, aCount));
this, aRequest, mHttpChannel.get(), aInputStream, aOffset, aCount));
// This is the HTTP OnDataAvailable Method, which means this is http data in
// response to the upgrade request and there should be no http response body