1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/protocol/http/nsHttpPipeline.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,107 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nsHttpPipeline_h__ 1.10 +#define nsHttpPipeline_h__ 1.11 + 1.12 +#include "nsAHttpConnection.h" 1.13 +#include "nsAHttpTransaction.h" 1.14 +#include "nsTArray.h" 1.15 +#include "nsCOMPtr.h" 1.16 + 1.17 +class nsIInputStream; 1.18 +class nsIOutputStream; 1.19 + 1.20 +namespace mozilla { namespace net { 1.21 + 1.22 +class nsHttpPipeline : public nsAHttpConnection 1.23 + , public nsAHttpTransaction 1.24 + , public nsAHttpSegmentReader 1.25 +{ 1.26 +public: 1.27 + NS_DECL_THREADSAFE_ISUPPORTS 1.28 + NS_DECL_NSAHTTPCONNECTION(mConnection) 1.29 + NS_DECL_NSAHTTPTRANSACTION 1.30 + NS_DECL_NSAHTTPSEGMENTREADER 1.31 + 1.32 + nsHttpPipeline(); 1.33 + virtual ~nsHttpPipeline(); 1.34 + 1.35 + bool ResponseTimeoutEnabled() const MOZ_OVERRIDE MOZ_FINAL { 1.36 + return true; 1.37 + } 1.38 + 1.39 + uint32_t RequestDepth() { return mRequestQ.Length(); } 1.40 + 1.41 +private: 1.42 + nsresult FillSendBuf(); 1.43 + 1.44 + static NS_METHOD ReadFromPipe(nsIInputStream *, void *, const char *, 1.45 + uint32_t, uint32_t, uint32_t *); 1.46 + 1.47 + void ShuffleTransOrder(uint32_t); 1.48 + 1.49 + // convenience functions 1.50 + nsAHttpTransaction *Request(int32_t i) 1.51 + { 1.52 + if (mRequestQ.Length() == 0) 1.53 + return nullptr; 1.54 + 1.55 + return mRequestQ[i]; 1.56 + } 1.57 + nsAHttpTransaction *Response(int32_t i) 1.58 + { 1.59 + if (mResponseQ.Length() == 0) 1.60 + return nullptr; 1.61 + 1.62 + return mResponseQ[i]; 1.63 + } 1.64 + 1.65 + // overload of nsAHttpTransaction::QueryPipeline() 1.66 + nsHttpPipeline *QueryPipeline(); 1.67 + 1.68 + nsAHttpConnection *mConnection; 1.69 + nsTArray<nsAHttpTransaction*> mRequestQ; // array of transactions 1.70 + nsTArray<nsAHttpTransaction*> mResponseQ; // array of transactions 1.71 + nsresult mStatus; 1.72 + 1.73 + // these flags indicate whether or not the first request or response 1.74 + // is partial. a partial request means that Request(0) has been 1.75 + // partially written out to the socket. a partial response means 1.76 + // that Response(0) has been partially read in from the socket. 1.77 + bool mRequestIsPartial; 1.78 + bool mResponseIsPartial; 1.79 + 1.80 + // indicates whether or not the pipeline has been explicitly closed. 1.81 + bool mClosed; 1.82 + 1.83 + // indicates whether or not a true pipeline (more than 1 request without 1.84 + // a synchronous response) has been formed. 1.85 + bool mUtilizedPipeline; 1.86 + 1.87 + // used when calling ReadSegments/WriteSegments on a transaction. 1.88 + nsAHttpSegmentReader *mReader; 1.89 + 1.90 + // send buffer 1.91 + nsCOMPtr<nsIInputStream> mSendBufIn; 1.92 + nsCOMPtr<nsIOutputStream> mSendBufOut; 1.93 + 1.94 + // the push back buffer. not exceeding nsIOService::gDefaultSegmentSize bytes. 1.95 + char *mPushBackBuf; 1.96 + uint32_t mPushBackLen; 1.97 + uint32_t mPushBackMax; 1.98 + 1.99 + // The number of transactions completed on this pipeline. 1.100 + uint32_t mHttp1xTransactionCount; 1.101 + 1.102 + // For support of OnTransportStatus() 1.103 + uint64_t mReceivingFromProgress; 1.104 + uint64_t mSendingToProgress; 1.105 + bool mSuppressSendEvents; 1.106 +}; 1.107 + 1.108 +}} // namespace mozilla::net 1.109 + 1.110 +#endif // nsHttpPipeline_h__