michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsHttpPipeline_h__ michael@0: #define nsHttpPipeline_h__ michael@0: michael@0: #include "nsAHttpConnection.h" michael@0: #include "nsAHttpTransaction.h" michael@0: #include "nsTArray.h" michael@0: #include "nsCOMPtr.h" michael@0: michael@0: class nsIInputStream; michael@0: class nsIOutputStream; michael@0: michael@0: namespace mozilla { namespace net { michael@0: michael@0: class nsHttpPipeline : public nsAHttpConnection michael@0: , public nsAHttpTransaction michael@0: , public nsAHttpSegmentReader michael@0: { michael@0: public: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: NS_DECL_NSAHTTPCONNECTION(mConnection) michael@0: NS_DECL_NSAHTTPTRANSACTION michael@0: NS_DECL_NSAHTTPSEGMENTREADER michael@0: michael@0: nsHttpPipeline(); michael@0: virtual ~nsHttpPipeline(); michael@0: michael@0: bool ResponseTimeoutEnabled() const MOZ_OVERRIDE MOZ_FINAL { michael@0: return true; michael@0: } michael@0: michael@0: uint32_t RequestDepth() { return mRequestQ.Length(); } michael@0: michael@0: private: michael@0: nsresult FillSendBuf(); michael@0: michael@0: static NS_METHOD ReadFromPipe(nsIInputStream *, void *, const char *, michael@0: uint32_t, uint32_t, uint32_t *); michael@0: michael@0: void ShuffleTransOrder(uint32_t); michael@0: michael@0: // convenience functions michael@0: nsAHttpTransaction *Request(int32_t i) michael@0: { michael@0: if (mRequestQ.Length() == 0) michael@0: return nullptr; michael@0: michael@0: return mRequestQ[i]; michael@0: } michael@0: nsAHttpTransaction *Response(int32_t i) michael@0: { michael@0: if (mResponseQ.Length() == 0) michael@0: return nullptr; michael@0: michael@0: return mResponseQ[i]; michael@0: } michael@0: michael@0: // overload of nsAHttpTransaction::QueryPipeline() michael@0: nsHttpPipeline *QueryPipeline(); michael@0: michael@0: nsAHttpConnection *mConnection; michael@0: nsTArray mRequestQ; // array of transactions michael@0: nsTArray mResponseQ; // array of transactions michael@0: nsresult mStatus; michael@0: michael@0: // these flags indicate whether or not the first request or response michael@0: // is partial. a partial request means that Request(0) has been michael@0: // partially written out to the socket. a partial response means michael@0: // that Response(0) has been partially read in from the socket. michael@0: bool mRequestIsPartial; michael@0: bool mResponseIsPartial; michael@0: michael@0: // indicates whether or not the pipeline has been explicitly closed. michael@0: bool mClosed; michael@0: michael@0: // indicates whether or not a true pipeline (more than 1 request without michael@0: // a synchronous response) has been formed. michael@0: bool mUtilizedPipeline; michael@0: michael@0: // used when calling ReadSegments/WriteSegments on a transaction. michael@0: nsAHttpSegmentReader *mReader; michael@0: michael@0: // send buffer michael@0: nsCOMPtr mSendBufIn; michael@0: nsCOMPtr mSendBufOut; michael@0: michael@0: // the push back buffer. not exceeding nsIOService::gDefaultSegmentSize bytes. michael@0: char *mPushBackBuf; michael@0: uint32_t mPushBackLen; michael@0: uint32_t mPushBackMax; michael@0: michael@0: // The number of transactions completed on this pipeline. michael@0: uint32_t mHttp1xTransactionCount; michael@0: michael@0: // For support of OnTransportStatus() michael@0: uint64_t mReceivingFromProgress; michael@0: uint64_t mSendingToProgress; michael@0: bool mSuppressSendEvents; michael@0: }; michael@0: michael@0: }} // namespace mozilla::net michael@0: michael@0: #endif // nsHttpPipeline_h__