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

This commit is contained in:
Christoph Kerschbaumer
2016-05-19 11:54:02 +02:00
parent 61c6c69c00
commit dcac96fb7a
5 changed files with 17 additions and 28 deletions

View File

@@ -1400,7 +1400,14 @@ WebSocketChannel::BeginOpenInternal()
}
#endif
rv = localChannel->AsyncOpen(this, mHttpChannel);
nsCOMPtr<nsILoadInfo> loadInfo = localChannel->GetLoadInfo();
if (loadInfo && loadInfo->GetEnforceSecurity()) {
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);
@@ -3550,7 +3557,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");
@@ -3711,7 +3718,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();
@@ -3874,7 +3881,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