netwerk/protocol/http/nsHttpPipeline.h

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

michael@0 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef nsHttpPipeline_h__
michael@0 7 #define nsHttpPipeline_h__
michael@0 8
michael@0 9 #include "nsAHttpConnection.h"
michael@0 10 #include "nsAHttpTransaction.h"
michael@0 11 #include "nsTArray.h"
michael@0 12 #include "nsCOMPtr.h"
michael@0 13
michael@0 14 class nsIInputStream;
michael@0 15 class nsIOutputStream;
michael@0 16
michael@0 17 namespace mozilla { namespace net {
michael@0 18
michael@0 19 class nsHttpPipeline : public nsAHttpConnection
michael@0 20 , public nsAHttpTransaction
michael@0 21 , public nsAHttpSegmentReader
michael@0 22 {
michael@0 23 public:
michael@0 24 NS_DECL_THREADSAFE_ISUPPORTS
michael@0 25 NS_DECL_NSAHTTPCONNECTION(mConnection)
michael@0 26 NS_DECL_NSAHTTPTRANSACTION
michael@0 27 NS_DECL_NSAHTTPSEGMENTREADER
michael@0 28
michael@0 29 nsHttpPipeline();
michael@0 30 virtual ~nsHttpPipeline();
michael@0 31
michael@0 32 bool ResponseTimeoutEnabled() const MOZ_OVERRIDE MOZ_FINAL {
michael@0 33 return true;
michael@0 34 }
michael@0 35
michael@0 36 uint32_t RequestDepth() { return mRequestQ.Length(); }
michael@0 37
michael@0 38 private:
michael@0 39 nsresult FillSendBuf();
michael@0 40
michael@0 41 static NS_METHOD ReadFromPipe(nsIInputStream *, void *, const char *,
michael@0 42 uint32_t, uint32_t, uint32_t *);
michael@0 43
michael@0 44 void ShuffleTransOrder(uint32_t);
michael@0 45
michael@0 46 // convenience functions
michael@0 47 nsAHttpTransaction *Request(int32_t i)
michael@0 48 {
michael@0 49 if (mRequestQ.Length() == 0)
michael@0 50 return nullptr;
michael@0 51
michael@0 52 return mRequestQ[i];
michael@0 53 }
michael@0 54 nsAHttpTransaction *Response(int32_t i)
michael@0 55 {
michael@0 56 if (mResponseQ.Length() == 0)
michael@0 57 return nullptr;
michael@0 58
michael@0 59 return mResponseQ[i];
michael@0 60 }
michael@0 61
michael@0 62 // overload of nsAHttpTransaction::QueryPipeline()
michael@0 63 nsHttpPipeline *QueryPipeline();
michael@0 64
michael@0 65 nsAHttpConnection *mConnection;
michael@0 66 nsTArray<nsAHttpTransaction*> mRequestQ; // array of transactions
michael@0 67 nsTArray<nsAHttpTransaction*> mResponseQ; // array of transactions
michael@0 68 nsresult mStatus;
michael@0 69
michael@0 70 // these flags indicate whether or not the first request or response
michael@0 71 // is partial. a partial request means that Request(0) has been
michael@0 72 // partially written out to the socket. a partial response means
michael@0 73 // that Response(0) has been partially read in from the socket.
michael@0 74 bool mRequestIsPartial;
michael@0 75 bool mResponseIsPartial;
michael@0 76
michael@0 77 // indicates whether or not the pipeline has been explicitly closed.
michael@0 78 bool mClosed;
michael@0 79
michael@0 80 // indicates whether or not a true pipeline (more than 1 request without
michael@0 81 // a synchronous response) has been formed.
michael@0 82 bool mUtilizedPipeline;
michael@0 83
michael@0 84 // used when calling ReadSegments/WriteSegments on a transaction.
michael@0 85 nsAHttpSegmentReader *mReader;
michael@0 86
michael@0 87 // send buffer
michael@0 88 nsCOMPtr<nsIInputStream> mSendBufIn;
michael@0 89 nsCOMPtr<nsIOutputStream> mSendBufOut;
michael@0 90
michael@0 91 // the push back buffer. not exceeding nsIOService::gDefaultSegmentSize bytes.
michael@0 92 char *mPushBackBuf;
michael@0 93 uint32_t mPushBackLen;
michael@0 94 uint32_t mPushBackMax;
michael@0 95
michael@0 96 // The number of transactions completed on this pipeline.
michael@0 97 uint32_t mHttp1xTransactionCount;
michael@0 98
michael@0 99 // For support of OnTransportStatus()
michael@0 100 uint64_t mReceivingFromProgress;
michael@0 101 uint64_t mSendingToProgress;
michael@0 102 bool mSuppressSendEvents;
michael@0 103 };
michael@0 104
michael@0 105 }} // namespace mozilla::net
michael@0 106
michael@0 107 #endif // nsHttpPipeline_h__

mercurial