зеркало из https://github.com/mozilla/gecko-dev.git
Bug 778680 part 1 - Make netwerk status codes actually nsresult; r=jduell
This commit is contained in:
Родитель
8147287a2c
Коммит
5f722a9bf7
|
@ -108,6 +108,10 @@ interface nsISocketTransport : nsITransport
|
|||
* order). STATUS_RESOLVING may be skipped if the host does not need to be
|
||||
* resolved. STATUS_WAITING_FOR is an optional status code, which the impl
|
||||
* of this interface may choose not to generate.
|
||||
*
|
||||
* In C++, these constants have a type of PRUint32, so C++ callers must use
|
||||
* the NS_NET_STATUS_* constants defined below, which have a type of
|
||||
* nsresult.
|
||||
*/
|
||||
const unsigned long STATUS_RESOLVING = 0x804b0003;
|
||||
const unsigned long STATUS_RESOLVED = 0x804b000b;
|
||||
|
@ -160,13 +164,20 @@ interface nsISocketTransport : nsITransport
|
|||
|
||||
%{C++
|
||||
/**
|
||||
* #define's for compatibility
|
||||
* #define's with the correct type, for use by C++ code
|
||||
*/
|
||||
#define NS_NET_STATUS_RESOLVING_HOST nsISocketTransport::STATUS_RESOLVING
|
||||
#define NS_NET_STATUS_RESOLVED_HOST nsISocketTransport::STATUS_RESOLVED
|
||||
#define NS_NET_STATUS_CONNECTED_TO nsISocketTransport::STATUS_CONNECTED_TO
|
||||
#define NS_NET_STATUS_SENDING_TO nsISocketTransport::STATUS_SENDING_TO
|
||||
#define NS_NET_STATUS_RECEIVING_FROM nsISocketTransport::STATUS_RECEIVING_FROM
|
||||
#define NS_NET_STATUS_CONNECTING_TO nsISocketTransport::STATUS_CONNECTING_TO
|
||||
#define NS_NET_STATUS_WAITING_FOR nsISocketTransport::STATUS_WAITING_FOR
|
||||
#define NS_NET_STATUS_RESOLVING_HOST \
|
||||
static_cast<nsresult>(nsISocketTransport::STATUS_RESOLVING)
|
||||
#define NS_NET_STATUS_RESOLVED_HOST \
|
||||
static_cast<nsresult>(nsISocketTransport::STATUS_RESOLVED)
|
||||
#define NS_NET_STATUS_CONNECTED_TO \
|
||||
static_cast<nsresult>(nsISocketTransport::STATUS_CONNECTED_TO)
|
||||
#define NS_NET_STATUS_SENDING_TO \
|
||||
static_cast<nsresult>(nsISocketTransport::STATUS_SENDING_TO)
|
||||
#define NS_NET_STATUS_RECEIVING_FROM \
|
||||
static_cast<nsresult>(nsISocketTransport::STATUS_RECEIVING_FROM)
|
||||
#define NS_NET_STATUS_CONNECTING_TO \
|
||||
static_cast<nsresult>(nsISocketTransport::STATUS_CONNECTING_TO)
|
||||
#define NS_NET_STATUS_WAITING_FOR \
|
||||
static_cast<nsresult>(nsISocketTransport::STATUS_WAITING_FOR)
|
||||
%}
|
||||
|
|
|
@ -128,6 +128,10 @@ interface nsITransport : nsISupports
|
|||
* Generic nsITransportEventSink status codes. nsITransport
|
||||
* implementations may override these status codes with their own more
|
||||
* specific status codes (e.g., see nsISocketTransport).
|
||||
*
|
||||
* In C++, these constants have a type of PRUint32, so C++ callers must use
|
||||
* the NS_NET_STATUS_* constants defined below, which have a type of
|
||||
* nsresult.
|
||||
*/
|
||||
const unsigned long STATUS_READING = 0x804b0008;
|
||||
const unsigned long STATUS_WRITING = 0x804b0009;
|
||||
|
@ -157,3 +161,10 @@ interface nsITransportEventSink : nsISupports
|
|||
in unsigned long long aProgress,
|
||||
in unsigned long long aProgressMax);
|
||||
};
|
||||
|
||||
%{C++
|
||||
#define NS_NET_STATUS_READING \
|
||||
static_cast<nsresult>(nsITransport::STATUS_READING)
|
||||
#define NS_NET_STATUS_WRITING \
|
||||
static_cast<nsresult>(nsITransport::STATUS_WRITING)
|
||||
%}
|
||||
|
|
|
@ -748,7 +748,7 @@ nsBaseChannel::OnDataAvailable(nsIRequest *request, nsISupports *ctxt,
|
|||
if (mSynthProgressEvents && NS_SUCCEEDED(rv)) {
|
||||
PRUint64 prog = PRUint64(offset) + count;
|
||||
PRUint64 progMax = ContentLength64();
|
||||
OnTransportStatus(nullptr, nsITransport::STATUS_READING, prog, progMax);
|
||||
OnTransportStatus(nullptr, NS_NET_STATUS_READING, prog, progMax);
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
|
|
@ -358,7 +358,7 @@ nsSocketInputStream::Read(char *buf, PRUint32 count, PRUint32 *countRead)
|
|||
// only send this notification if we have indeed read some data.
|
||||
// see bug 196827 for an example of why this is important.
|
||||
if (n > 0)
|
||||
mTransport->SendStatus(nsISocketTransport::STATUS_RECEIVING_FROM);
|
||||
mTransport->SendStatus(NS_NET_STATUS_RECEIVING_FROM);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -581,7 +581,7 @@ nsSocketOutputStream::Write(const char *buf, PRUint32 count, PRUint32 *countWrit
|
|||
// only send this notification if we have indeed written some data.
|
||||
// see bug 196827 for an example of why this is important.
|
||||
if (n > 0)
|
||||
mTransport->SendStatus(nsISocketTransport::STATUS_SENDING_TO);
|
||||
mTransport->SendStatus(NS_NET_STATUS_SENDING_TO);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -869,10 +869,10 @@ nsSocketTransport::SendStatus(nsresult status)
|
|||
MutexAutoLock lock(mLock);
|
||||
sink = mEventSink;
|
||||
switch (status) {
|
||||
case STATUS_SENDING_TO:
|
||||
case NS_NET_STATUS_SENDING_TO:
|
||||
progress = mOutput.ByteCount();
|
||||
break;
|
||||
case STATUS_RECEIVING_FROM:
|
||||
case NS_NET_STATUS_RECEIVING_FROM:
|
||||
progress = mInput.ByteCount();
|
||||
break;
|
||||
default:
|
||||
|
@ -923,7 +923,7 @@ nsSocketTransport::ResolveHost()
|
|||
if (mConnectionFlags & nsSocketTransport::DISABLE_IPV6)
|
||||
dnsFlags |= nsIDNSService::RESOLVE_DISABLE_IPV6;
|
||||
|
||||
SendStatus(STATUS_RESOLVING);
|
||||
SendStatus(NS_NET_STATUS_RESOLVING_HOST);
|
||||
rv = dns->AsyncResolve(SocketHost(), dnsFlags, this, nullptr,
|
||||
getter_AddRefs(mDNSRequest));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
@ -1144,7 +1144,7 @@ nsSocketTransport::InitiateSocket()
|
|||
SOCKET_LOG((" advancing to STATE_CONNECTING\n"));
|
||||
mState = STATE_CONNECTING;
|
||||
mPollTimeout = mTimeouts[TIMEOUT_CONNECT];
|
||||
SendStatus(STATUS_CONNECTING_TO);
|
||||
SendStatus(NS_NET_STATUS_CONNECTING_TO);
|
||||
|
||||
#if defined(PR_LOGGING)
|
||||
if (SOCKET_LOG_ENABLED()) {
|
||||
|
@ -1381,7 +1381,7 @@ nsSocketTransport::OnSocketConnected()
|
|||
mFDconnected = true;
|
||||
}
|
||||
|
||||
SendStatus(STATUS_CONNECTED_TO);
|
||||
SendStatus(NS_NET_STATUS_CONNECTED_TO);
|
||||
}
|
||||
|
||||
PRFileDesc *
|
||||
|
@ -1444,7 +1444,7 @@ nsSocketTransport::OnSocketEvent(PRUint32 type, nsresult status, nsISupports *pa
|
|||
|
||||
case MSG_DNS_LOOKUP_COMPLETE:
|
||||
if (mDNSRequest) // only send this if we actually resolved anything
|
||||
SendStatus(STATUS_RESOLVED);
|
||||
SendStatus(NS_NET_STATUS_RESOLVED_HOST);
|
||||
|
||||
SOCKET_LOG((" MSG_DNS_LOOKUP_COMPLETE\n"));
|
||||
mDNSRequest = 0;
|
||||
|
|
|
@ -200,7 +200,8 @@ nsInputStreamTransport::Read(char *buf, PRUint32 count, PRUint32 *result)
|
|||
if (NS_SUCCEEDED(rv)) {
|
||||
mOffset += *result;
|
||||
if (mEventSink)
|
||||
mEventSink->OnTransportStatus(this, STATUS_READING, mOffset, mLimit);
|
||||
mEventSink->OnTransportStatus(this, NS_NET_STATUS_READING, mOffset,
|
||||
mLimit);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
@ -399,7 +400,8 @@ nsOutputStreamTransport::Write(const char *buf, PRUint32 count, PRUint32 *result
|
|||
if (NS_SUCCEEDED(rv)) {
|
||||
mOffset += *result;
|
||||
if (mEventSink)
|
||||
mEventSink->OnTransportStatus(this, STATUS_WRITING, mOffset, mLimit);
|
||||
mEventSink->OnTransportStatus(this, NS_NET_STATUS_WRITING, mOffset,
|
||||
mLimit);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ nsFileCopyEvent::DoCopy()
|
|||
// Dispatch progress notification
|
||||
if (mSink) {
|
||||
progress += num;
|
||||
mSink->OnTransportStatus(nullptr, nsITransport::STATUS_WRITING, progress,
|
||||
mSink->OnTransportStatus(nullptr, NS_NET_STATUS_WRITING, progress,
|
||||
mLen);
|
||||
}
|
||||
|
||||
|
|
|
@ -363,8 +363,8 @@ HttpChannelChild::OnTransportAndData(const nsresult& status,
|
|||
{
|
||||
// OnStatus
|
||||
//
|
||||
NS_ASSERTION(status == nsISocketTransport::STATUS_RECEIVING_FROM ||
|
||||
status == nsITransport::STATUS_READING,
|
||||
NS_ASSERTION(status == NS_NET_STATUS_RECEIVING_FROM ||
|
||||
status == NS_NET_STATUS_READING,
|
||||
"unexpected status code");
|
||||
|
||||
nsCAutoString host;
|
||||
|
|
|
@ -509,15 +509,15 @@ HttpChannelParent::OnProgress(nsIRequest *aRequest,
|
|||
{
|
||||
// OnStatus has always just set mStoredStatus. If it indicates this precedes
|
||||
// OnDataAvailable, store and ODA will send to child.
|
||||
if (mStoredStatus == nsISocketTransport::STATUS_RECEIVING_FROM ||
|
||||
mStoredStatus == nsITransport::STATUS_READING)
|
||||
if (mStoredStatus == NS_NET_STATUS_RECEIVING_FROM ||
|
||||
mStoredStatus == NS_NET_STATUS_READING)
|
||||
{
|
||||
mStoredProgress = aProgress;
|
||||
mStoredProgressMax = aProgressMax;
|
||||
} else {
|
||||
// Send to child now. The only case I've observed that this handles (i.e.
|
||||
// non-ODA status with progress > 0) is data upload progress notification
|
||||
// (status == nsISocketTransport::STATUS_SENDING_TO)
|
||||
// (status == NS_NET_STATUS_SENDING_TO)
|
||||
if (mIPCClosed || !SendOnProgress(aProgress, aProgressMax))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
@ -532,8 +532,8 @@ HttpChannelParent::OnStatus(nsIRequest *aRequest,
|
|||
const PRUnichar *aStatusArg)
|
||||
{
|
||||
// If this precedes OnDataAvailable, store and ODA will send to child.
|
||||
if (aStatus == nsISocketTransport::STATUS_RECEIVING_FROM ||
|
||||
aStatus == nsITransport::STATUS_READING)
|
||||
if (aStatus == NS_NET_STATUS_RECEIVING_FROM ||
|
||||
aStatus == NS_NET_STATUS_READING)
|
||||
{
|
||||
mStoredStatus = aStatus;
|
||||
return NS_OK;
|
||||
|
|
|
@ -5054,9 +5054,9 @@ nsHttpChannel::OnDataAvailable(nsIRequest *request, nsISupports *ctxt,
|
|||
//
|
||||
nsresult transportStatus;
|
||||
if (request == mCachePump)
|
||||
transportStatus = nsITransport::STATUS_READING;
|
||||
transportStatus = NS_NET_STATUS_READING;
|
||||
else
|
||||
transportStatus = nsISocketTransport::STATUS_RECEIVING_FROM;
|
||||
transportStatus = NS_NET_STATUS_RECEIVING_FROM;
|
||||
|
||||
// mResponseHead may reference new or cached headers, but either way it
|
||||
// holds our best estimate of the total content length. Even in the case
|
||||
|
@ -5108,8 +5108,8 @@ nsHttpChannel::OnTransportStatus(nsITransport *trans, nsresult status,
|
|||
if (!mProgressSink)
|
||||
GetCallback(mProgressSink);
|
||||
|
||||
if (status == nsISocketTransport::STATUS_CONNECTED_TO ||
|
||||
status == nsISocketTransport::STATUS_WAITING_FOR) {
|
||||
if (status == NS_NET_STATUS_CONNECTED_TO ||
|
||||
status == NS_NET_STATUS_WAITING_FOR) {
|
||||
nsCOMPtr<nsISocketTransport> socketTransport =
|
||||
do_QueryInterface(trans);
|
||||
if (socketTransport) {
|
||||
|
|
|
@ -1267,7 +1267,7 @@ nsHttpConnection::OnSocketWritable()
|
|||
// trumped (overwritten) if the server responds quickly.
|
||||
//
|
||||
mTransaction->OnTransportStatus(mSocketTransport,
|
||||
nsISocketTransport::STATUS_WAITING_FOR,
|
||||
NS_NET_STATUS_WAITING_FOR,
|
||||
LL_ZERO);
|
||||
|
||||
rv = ResumeRecv(); // start reading
|
||||
|
|
|
@ -2694,7 +2694,7 @@ nsHttpConnectionMgr::nsHalfOpenSocket::OnTransportStatus(nsITransport *trans,
|
|||
// just completed. We can't do coalescing if using a proxy because the
|
||||
// ip addresses are not available to the client.
|
||||
|
||||
if (status == nsISocketTransport::STATUS_CONNECTED_TO &&
|
||||
if (status == NS_NET_STATUS_CONNECTED_TO &&
|
||||
gHttpHandler->IsSpdyEnabled() &&
|
||||
gHttpHandler->CoalesceSpdy() &&
|
||||
mEnt && mEnt->mConnInfo && mEnt->mConnInfo->UsingSSL() &&
|
||||
|
@ -2725,7 +2725,7 @@ nsHttpConnectionMgr::nsHalfOpenSocket::OnTransportStatus(nsITransport *trans,
|
|||
}
|
||||
|
||||
switch (status) {
|
||||
case nsISocketTransport::STATUS_CONNECTING_TO:
|
||||
case NS_NET_STATUS_CONNECTING_TO:
|
||||
// Passed DNS resolution, now trying to connect, start the backup timer
|
||||
// only prevent creating another backup transport.
|
||||
// We also check for mEnt presence to not instantiate the timer after
|
||||
|
@ -2738,7 +2738,7 @@ nsHttpConnectionMgr::nsHalfOpenSocket::OnTransportStatus(nsITransport *trans,
|
|||
SetupBackupTimer();
|
||||
break;
|
||||
|
||||
case nsISocketTransport::STATUS_CONNECTED_TO:
|
||||
case NS_NET_STATUS_CONNECTED_TO:
|
||||
// TCP connection's up, now transfer or SSL negotiantion starts,
|
||||
// no need for backup socket
|
||||
CancelBackupTimer();
|
||||
|
|
|
@ -701,8 +701,7 @@ nsHttpPipeline::WriteSegments(nsAHttpSegmentWriter *writer,
|
|||
// previous transaction on the pipeline.
|
||||
nsITransport *transport = Transport();
|
||||
if (transport)
|
||||
OnTransportStatus(transport,
|
||||
nsISocketTransport::STATUS_RECEIVING_FROM,
|
||||
OnTransportStatus(transport, NS_NET_STATUS_RECEIVING_FROM,
|
||||
mReceivingFromProgress);
|
||||
|
||||
// the push back buffer is never larger than NS_HTTP_SEGMENT_SIZE,
|
||||
|
|
|
@ -404,13 +404,13 @@ nsHttpTransaction::OnTransportStatus(nsITransport* transport,
|
|||
this, status, progress));
|
||||
|
||||
if (TimingEnabled()) {
|
||||
if (status == nsISocketTransport::STATUS_RESOLVING) {
|
||||
if (status == NS_NET_STATUS_RESOLVING_HOST) {
|
||||
mTimings.domainLookupStart = mozilla::TimeStamp::Now();
|
||||
} else if (status == nsISocketTransport::STATUS_RESOLVED) {
|
||||
} else if (status == NS_NET_STATUS_RESOLVED_HOST) {
|
||||
mTimings.domainLookupEnd = mozilla::TimeStamp::Now();
|
||||
} else if (status == nsISocketTransport::STATUS_CONNECTING_TO) {
|
||||
} else if (status == NS_NET_STATUS_CONNECTING_TO) {
|
||||
mTimings.connectStart = mozilla::TimeStamp::Now();
|
||||
} else if (status == nsISocketTransport::STATUS_CONNECTED_TO) {
|
||||
} else if (status == NS_NET_STATUS_CONNECTED_TO) {
|
||||
mTimings.connectEnd = mozilla::TimeStamp::Now();
|
||||
}
|
||||
}
|
||||
|
@ -425,7 +425,7 @@ nsHttpTransaction::OnTransportStatus(nsITransport* transport,
|
|||
if (mActivityDistributor) {
|
||||
// upon STATUS_WAITING_FOR; report request body sent
|
||||
if ((mHasRequestBody) &&
|
||||
(status == nsISocketTransport::STATUS_WAITING_FOR))
|
||||
(status == NS_NET_STATUS_WAITING_FOR))
|
||||
mActivityDistributor->ObserveActivity(
|
||||
mChannel,
|
||||
NS_HTTP_ACTIVITY_TYPE_HTTP_TRANSACTION,
|
||||
|
@ -444,12 +444,12 @@ nsHttpTransaction::OnTransportStatus(nsITransport* transport,
|
|||
}
|
||||
|
||||
// nsHttpChannel synthesizes progress events in OnDataAvailable
|
||||
if (status == nsISocketTransport::STATUS_RECEIVING_FROM)
|
||||
if (status == NS_NET_STATUS_RECEIVING_FROM)
|
||||
return;
|
||||
|
||||
PRUint64 progressMax;
|
||||
|
||||
if (status == nsISocketTransport::STATUS_SENDING_TO) {
|
||||
if (status == NS_NET_STATUS_SENDING_TO) {
|
||||
// suppress progress when only writing request headers
|
||||
if (!mHasRequestBody)
|
||||
return;
|
||||
|
|
Загрузка…
Ссылка в новой задаче