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.)

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

mercurial