зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset a418e4a81c02 (bug 1362388) for build bustage from netwerk/protocol/http/nsHttpChannel.cpp:597 not being declared. r=backout
This commit is contained in:
Родитель
4dc5072fcb
Коммит
a477978a5d
|
@ -144,12 +144,6 @@ public:
|
|||
return stream->Init(aStream, aBufferSize);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GetData(nsIInputStream **aResult) override
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
void
|
||||
MaybeStartReading();
|
||||
|
||||
|
|
|
@ -269,14 +269,6 @@ nsBufferedStream::SetEOF()
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsBufferedStream::GetData(nsISupports **aResult)
|
||||
{
|
||||
nsCOMPtr<nsISupports> rv(mStream);
|
||||
*aResult = rv.forget().take();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsBufferedInputStream
|
||||
|
||||
|
@ -687,16 +679,6 @@ nsBufferedInputStream::OnInputStreamReady(nsIAsyncInputStream* aStream)
|
|||
return callback->OnInputStreamReady(this);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBufferedInputStream::GetData(nsIInputStream **aResult)
|
||||
{
|
||||
nsCOMPtr<nsISupports> stream;
|
||||
nsBufferedStream::GetData(getter_AddRefs(stream));
|
||||
nsCOMPtr<nsIInputStream> inputStream = do_QueryInterface(stream);
|
||||
*aResult = inputStream.forget().take();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsBufferedOutputStream
|
||||
|
||||
|
@ -1051,15 +1033,6 @@ nsBufferedOutputStream::GetUnbufferedStream(nsISupports* *aStream)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBufferedOutputStream::GetData(nsIOutputStream **aResult)
|
||||
{
|
||||
nsCOMPtr<nsISupports> stream;
|
||||
nsBufferedStream::GetData(getter_AddRefs(stream));
|
||||
nsCOMPtr<nsIOutputStream> outputStream = do_QueryInterface(stream);
|
||||
*aResult = outputStream.forget().take();
|
||||
return NS_OK;
|
||||
}
|
||||
#undef METER
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -32,7 +32,6 @@ protected:
|
|||
virtual ~nsBufferedStream();
|
||||
|
||||
nsresult Init(nsISupports* stream, uint32_t bufferSize);
|
||||
nsresult GetData(nsISupports **aResult);
|
||||
NS_IMETHOD Fill() = 0;
|
||||
NS_IMETHOD Flush() = 0;
|
||||
|
||||
|
|
|
@ -18,11 +18,6 @@ interface nsIBufferedInputStream : nsIInputStream
|
|||
*/
|
||||
void init(in nsIInputStream fillFromStream,
|
||||
in unsigned long bufferSize);
|
||||
|
||||
/**
|
||||
* Get the wrapped data stream
|
||||
*/
|
||||
readonly attribute nsIInputStream data;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -39,9 +34,4 @@ interface nsIBufferedOutputStream : nsIOutputStream
|
|||
*/
|
||||
void init(in nsIOutputStream sinkToStream,
|
||||
in unsigned long bufferSize);
|
||||
|
||||
/**
|
||||
* Get the wrapped data stream
|
||||
*/
|
||||
readonly attribute nsIOutputStream data;
|
||||
};
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
interface nsITransport;
|
||||
interface nsIInputStream;
|
||||
interface nsIOutputStream;
|
||||
interface nsIInputAvailableCallback;
|
||||
|
||||
/**
|
||||
* This service read/writes a stream on a background thread.
|
||||
|
@ -43,8 +42,6 @@ interface nsIStreamTransportService : nsISupports
|
|||
in long long aReadLimit,
|
||||
in boolean aCloseWhenDone);
|
||||
|
||||
void InputAvailable(in nsIInputStream aStream,
|
||||
in nsIInputAvailableCallback aCallback);
|
||||
/**
|
||||
* CreateOutputTransport
|
||||
*
|
||||
|
@ -69,10 +66,3 @@ interface nsIStreamTransportService : nsISupports
|
|||
in long long aWriteLimit,
|
||||
in boolean aCloseWhenDone);
|
||||
};
|
||||
|
||||
[builtinclass, uuid(ff2da731-44d0-4dd9-8236-c99387fec721)]
|
||||
interface nsIInputAvailableCallback : nsISupports
|
||||
{
|
||||
void onInputAvailableComplete(in unsigned long long available,
|
||||
in nsresult available_return_code);
|
||||
};
|
||||
|
|
|
@ -559,63 +559,5 @@ nsStreamTransportService::Observe(nsISupports *subject, const char *topic,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
class AvailableEvent final : public Runnable
|
||||
{
|
||||
public:
|
||||
AvailableEvent(nsIInputStream *stream,
|
||||
nsIInputAvailableCallback *callback)
|
||||
: mStream(stream)
|
||||
, mCallback(callback)
|
||||
, mDoingCallback(false)
|
||||
{
|
||||
mCallbackTarget = NS_GetCurrentThread();
|
||||
}
|
||||
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
if (mDoingCallback) {
|
||||
// pong
|
||||
mCallback->OnInputAvailableComplete(mSize, mResultForCallback);
|
||||
mCallback = nullptr;
|
||||
} else {
|
||||
// ping
|
||||
mResultForCallback = mStream->Available(&mSize);
|
||||
mStream = nullptr;
|
||||
mDoingCallback = true;
|
||||
|
||||
nsCOMPtr<nsIRunnable> event(this); // overly cute
|
||||
mCallbackTarget->Dispatch(event.forget(), NS_DISPATCH_NORMAL);
|
||||
mCallbackTarget = nullptr;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
virtual ~AvailableEvent() { }
|
||||
|
||||
nsCOMPtr<nsIInputStream> mStream;
|
||||
nsCOMPtr<nsIInputAvailableCallback> mCallback;
|
||||
nsCOMPtr<nsIEventTarget> mCallbackTarget;
|
||||
bool mDoingCallback;
|
||||
uint64_t mSize;
|
||||
nsresult mResultForCallback;
|
||||
};
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStreamTransportService::InputAvailable(nsIInputStream *stream,
|
||||
nsIInputAvailableCallback *callback)
|
||||
{
|
||||
nsCOMPtr<nsIThreadPool> pool;
|
||||
{
|
||||
mozilla::MutexAutoLock lock(mShutdownLock);
|
||||
if (mIsShutdown) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
pool = mPool;
|
||||
}
|
||||
nsCOMPtr<nsIRunnable> event = new AvailableEvent(stream, callback);
|
||||
return pool->Dispatch(event.forget(), NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -107,10 +107,6 @@
|
|||
#include "CacheStorageService.h"
|
||||
#include "HttpChannelParent.h"
|
||||
#include "nsIThrottlingService.h"
|
||||
#include "nsIBufferedStreams.h"
|
||||
#include "nsIFileStreams.h"
|
||||
#include "nsIMIMEInputStream.h"
|
||||
#include "nsIMultiplexInputStream.h"
|
||||
|
||||
#ifdef MOZ_TASK_TRACER
|
||||
#include "GeckoTaskTracer.h"
|
||||
|
@ -292,8 +288,6 @@ nsHttpChannel::nsHttpChannel()
|
|||
, mStronglyFramed(false)
|
||||
, mUsedNetwork(0)
|
||||
, mAuthConnectionRestartable(0)
|
||||
, mReqContentLengthDetermined(0)
|
||||
, mReqContentLength(0U)
|
||||
, mPushedStream(nullptr)
|
||||
, mLocalBlocklist(false)
|
||||
, mWarningReporter(nullptr)
|
||||
|
@ -514,119 +508,9 @@ nsHttpChannel::TryHSTSPriming()
|
|||
return ContinueConnect();
|
||||
}
|
||||
|
||||
// nsIInputAvailableCallback (nsIStreamTransportService.idl)
|
||||
NS_IMETHODIMP
|
||||
nsHttpChannel::OnInputAvailableComplete(uint64_t size, nsresult status)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread(), "Wrong thread.");
|
||||
LOG(("nsHttpChannel::OnInputAvailableComplete %x\n", status));
|
||||
if (NS_SUCCEEDED(status)) {
|
||||
mReqContentLength = size;
|
||||
} else {
|
||||
// fall back to synchronous on the error path. should not happen.
|
||||
if (NS_SUCCEEDED(mUploadStream->Available(&size))) {
|
||||
mReqContentLength = size;
|
||||
}
|
||||
}
|
||||
|
||||
LOG(("nsHttpChannel::DetermineContentLength %p from sts\n", this));
|
||||
mReqContentLengthDetermined = 1;
|
||||
nsresult rv = mCanceled ? mStatus : ContinueConnect();
|
||||
if (NS_FAILED(rv)) {
|
||||
CloseCacheEntry(false);
|
||||
Unused << AsyncAbort(rv);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIFileStream needs to be sent to a worker thread
|
||||
// to do Available() as it may cause disk/IO. Unfortunately
|
||||
// we have to look at the streams wrapped by a few other
|
||||
// abstractions to be sure.
|
||||
static
|
||||
bool isFileStream(nsIInputStream *stream)
|
||||
{
|
||||
if (!stream) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFileInputStream> fileStream = do_QueryInterface(stream);
|
||||
if (fileStream) {
|
||||
return true;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIBufferedInputStream> bufferedStream = do_QueryInterface(stream);
|
||||
if (bufferedStream) {
|
||||
nsCOMPtr<nsIInputStream> innerStream;
|
||||
if (NS_SUCCEEDED(bufferedStream->GetData(getter_AddRefs(innerStream)))) {
|
||||
return isFileStream(innerStream);
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIMIMEInputStream> mimeStream = do_QueryInterface(stream);
|
||||
if (mimeStream) {
|
||||
nsCOMPtr<nsIInputStream> innerStream;
|
||||
if (NS_SUCCEEDED(mimeStream->GetData(getter_AddRefs(innerStream)))) {
|
||||
return isFileStream(innerStream);
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIMultiplexInputStream> muxStream = do_QueryInterface(stream);
|
||||
uint32_t muxCount = 0;
|
||||
if (muxStream) {
|
||||
muxStream->GetCount(&muxCount);
|
||||
for (uint32_t i = 0; i < muxCount; ++i) {
|
||||
nsCOMPtr<nsIInputStream> subStream;
|
||||
if (NS_SUCCEEDED(muxStream->GetStream(i, getter_AddRefs(subStream))) &&
|
||||
isFileStream(subStream)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
nsHttpChannel::DetermineContentLength()
|
||||
{
|
||||
// bug 1362498 has a patch to make this a cached service
|
||||
nsCOMPtr<nsIStreamTransportService> sts;
|
||||
|
||||
if (!mUploadStream ||
|
||||
!(sts = do_GetService(kStreamTransportServiceCID))) {
|
||||
LOG(("nsHttpChannel::DetermineContentLength %p no body\n", this));
|
||||
mReqContentLength = 0U;
|
||||
mReqContentLengthDetermined = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isFileStream(mUploadStream)) {
|
||||
mUploadStream->Available(&mReqContentLength);
|
||||
LOG(("nsHttpChannel::DetermineContentLength %p from mem\n", this));
|
||||
mReqContentLengthDetermined = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
LOG(("nsHttpChannel::DetermineContentLength Async [this=%p]\n", this));
|
||||
sts->InputAvailable(mUploadStream, this);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHttpChannel::ContinueConnect()
|
||||
{
|
||||
// If we have a request body that is going to require bouncing to the STS
|
||||
// in order to determine the content-length as doing it on the main thread
|
||||
// will incur file IO some of the time.
|
||||
if (!mReqContentLengthDetermined) {
|
||||
// C-L might be determined sync or async. Sync will set
|
||||
// mReqContentLengthDetermined to true in DetermineContentLength()
|
||||
DetermineContentLength();
|
||||
}
|
||||
if (!mReqContentLengthDetermined) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// If we have had HSTS priming, we need to reevaluate whether we need
|
||||
// a CORS preflight. Bug: 1272440
|
||||
// If we need to start a CORS preflight, do it now!
|
||||
|
@ -1120,8 +1004,7 @@ nsHttpChannel::SetupTransaction()
|
|||
|
||||
nsCOMPtr<nsIAsyncInputStream> responseStream;
|
||||
rv = mTransaction->Init(mCaps, mConnectionInfo, &mRequestHead,
|
||||
mUploadStream, mReqContentLength,
|
||||
mUploadStreamHasHeaders,
|
||||
mUploadStream, mUploadStreamHasHeaders,
|
||||
NS_GetCurrentThread(), callbacks, this,
|
||||
mTopLevelOuterContentWindowId,
|
||||
getter_AddRefs(responseStream));
|
||||
|
@ -5826,7 +5709,6 @@ NS_INTERFACE_MAP_BEGIN(nsHttpChannel)
|
|||
NS_INTERFACE_MAP_ENTRY(nsITransportEventSink)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsPriority)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIProtocolProxyCallback)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInputAvailableCallback)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIProxiedChannel)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIHttpAuthenticableChannel)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIApplicationCacheContainer)
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include "nsIApplicationCacheChannel.h"
|
||||
#include "nsIChannelWithDivertableParentListener.h"
|
||||
#include "nsIProtocolProxyCallback.h"
|
||||
#include "nsIStreamTransportService.h"
|
||||
#include "nsIHttpAuthenticableChannel.h"
|
||||
#include "nsIAsyncVerifyRedirectCallback.h"
|
||||
#include "nsIThreadRetargetableRequest.h"
|
||||
|
@ -70,7 +69,6 @@ class nsHttpChannel final : public HttpBaseChannel
|
|||
, public nsICacheEntryOpenCallback
|
||||
, public nsITransportEventSink
|
||||
, public nsIProtocolProxyCallback
|
||||
, public nsIInputAvailableCallback
|
||||
, public nsIHttpAuthenticableChannel
|
||||
, public nsIApplicationCacheChannel
|
||||
, public nsIAsyncVerifyRedirectCallback
|
||||
|
@ -94,7 +92,6 @@ public:
|
|||
NS_DECL_NSICACHEENTRYOPENCALLBACK
|
||||
NS_DECL_NSITRANSPORTEVENTSINK
|
||||
NS_DECL_NSIPROTOCOLPROXYCALLBACK
|
||||
NS_DECL_NSIINPUTAVAILABLECALLBACK
|
||||
NS_DECL_NSIPROXIEDCHANNEL
|
||||
NS_DECL_NSIAPPLICATIONCACHECONTAINER
|
||||
NS_DECL_NSIAPPLICATIONCACHECHANNEL
|
||||
|
@ -417,8 +414,6 @@ private:
|
|||
MOZ_MUST_USE nsresult ContinueAsyncRedirectChannelToURI(nsresult rv);
|
||||
MOZ_MUST_USE nsresult OpenRedirectChannel(nsresult rv);
|
||||
|
||||
void DetermineContentLength();
|
||||
|
||||
/**
|
||||
* A function that takes care of reading STS and PKP headers and enforcing
|
||||
* STS and PKP load rules. After a secure channel is erected, STS and PKP
|
||||
|
@ -637,10 +632,6 @@ private:
|
|||
// the next authentication request can be sent on a whole new connection
|
||||
uint32_t mAuthConnectionRestartable : 1;
|
||||
|
||||
uint32_t mReqContentLengthDetermined : 1;
|
||||
|
||||
uint64_t mReqContentLength;
|
||||
|
||||
nsTArray<nsContinueRedirectionFunc> mRedirectFuncStack;
|
||||
|
||||
// Needed for accurate DNS timing
|
||||
|
|
|
@ -198,7 +198,6 @@ nsHttpTransaction::Init(uint32_t caps,
|
|||
nsHttpConnectionInfo *cinfo,
|
||||
nsHttpRequestHead *requestHead,
|
||||
nsIInputStream *requestBody,
|
||||
uint64_t requestContentLength,
|
||||
bool requestBodyHasHeaders,
|
||||
nsIEventTarget *target,
|
||||
nsIInterfaceRequestor *callbacks,
|
||||
|
@ -327,12 +326,15 @@ nsHttpTransaction::Init(uint32_t caps,
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mHasRequestBody = !!requestBody;
|
||||
if (mHasRequestBody && !requestContentLength) {
|
||||
mHasRequestBody = false;
|
||||
if (mHasRequestBody) {
|
||||
// some non standard methods set a 0 byte content-length for
|
||||
// clarity, we can avoid doing the mulitplexed request stream for them
|
||||
uint64_t size;
|
||||
if (NS_SUCCEEDED(requestBody->Available(&size)) && !size) {
|
||||
mHasRequestBody = false;
|
||||
}
|
||||
}
|
||||
|
||||
requestContentLength += mReqHeaderBuf.Length();
|
||||
|
||||
if (mHasRequestBody) {
|
||||
// wrap the headers and request body in a multiplexed input stream.
|
||||
nsCOMPtr<nsIMultiplexInputStream> multi =
|
||||
|
@ -351,9 +353,9 @@ nsHttpTransaction::Init(uint32_t caps,
|
|||
rv = NS_NewBufferedInputStream(getter_AddRefs(mRequestStream), multi,
|
||||
nsIOService::gDefaultSegmentSize);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
} else {
|
||||
mRequestStream = headers;
|
||||
}
|
||||
else
|
||||
mRequestStream = headers;
|
||||
|
||||
nsCOMPtr<nsIThrottledInputChannel> throttled = do_QueryInterface(mChannel);
|
||||
nsIInputChannelThrottleQueue* queue;
|
||||
|
@ -374,8 +376,14 @@ nsHttpTransaction::Init(uint32_t caps,
|
|||
}
|
||||
}
|
||||
|
||||
// make sure request content-length fits within js MAX_SAFE_INTEGER
|
||||
mRequestSize = InScriptableRange(requestContentLength) ? static_cast<int64_t>(requestContentLength) : -1;
|
||||
uint64_t size_u64;
|
||||
rv = mRequestStream->Available(&size_u64);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// make sure it fits within js MAX_SAFE_INTEGER
|
||||
mRequestSize = InScriptableRange(size_u64) ? static_cast<int64_t>(size_u64) : -1;
|
||||
|
||||
// create pipe for response stream
|
||||
rv = NS_NewPipe2(getter_AddRefs(mPipeIn),
|
||||
|
|
|
@ -86,7 +86,6 @@ public:
|
|||
nsHttpConnectionInfo *connInfo,
|
||||
nsHttpRequestHead *reqHeaders,
|
||||
nsIInputStream *reqBody,
|
||||
uint64_t reqContentLength,
|
||||
bool reqBodyIncludesHeaders,
|
||||
nsIEventTarget *consumerTarget,
|
||||
nsIInterfaceRequestor *callbacks,
|
||||
|
|
|
@ -1265,14 +1265,6 @@ nsPipeInputStream::Init(nsIInputStream*, uint32_t)
|
|||
"nsIBufferedInputStream::Init!\n");
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPipeInputStream::GetData(nsIInputStream **aResult)
|
||||
{
|
||||
// as this was not created with init() we are not
|
||||
// wrapping anything
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
nsPipeInputStream::Available()
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче