2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsHttpPipeline_h__
|
|
|
|
#define nsHttpPipeline_h__
|
|
|
|
|
|
|
|
#include "nsHttp.h"
|
|
|
|
#include "nsAHttpConnection.h"
|
|
|
|
#include "nsAHttpTransaction.h"
|
|
|
|
#include "nsIInputStream.h"
|
|
|
|
#include "nsIOutputStream.h"
|
2009-02-22 17:05:28 -08:00
|
|
|
#include "nsTArray.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
|
|
|
|
class nsHttpPipeline : public nsAHttpConnection
|
|
|
|
, public nsAHttpTransaction
|
|
|
|
, public nsAHttpSegmentReader
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
2012-05-14 10:25:28 -07:00
|
|
|
NS_DECL_NSAHTTPCONNECTION(mConnection)
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_DECL_NSAHTTPTRANSACTION
|
|
|
|
NS_DECL_NSAHTTPSEGMENTREADER
|
|
|
|
|
2012-03-22 16:39:31 -07:00
|
|
|
nsHttpPipeline();
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual ~nsHttpPipeline();
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsresult FillSendBuf();
|
|
|
|
|
|
|
|
static NS_METHOD ReadFromPipe(nsIInputStream *, void *, const char *,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t, uint32_t, uint32_t *);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// convenience functions
|
2012-08-22 08:56:38 -07:00
|
|
|
nsAHttpTransaction *Request(int32_t i)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-02-22 17:05:28 -08:00
|
|
|
if (mRequestQ.Length() == 0)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-02-22 17:05:28 -08:00
|
|
|
return mRequestQ[i];
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-08-22 08:56:38 -07:00
|
|
|
nsAHttpTransaction *Response(int32_t i)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-02-22 17:05:28 -08:00
|
|
|
if (mResponseQ.Length() == 0)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-02-22 17:05:28 -08:00
|
|
|
return mResponseQ[i];
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-03-22 16:39:31 -07:00
|
|
|
// overload of nsAHttpTransaction::QueryPipeline()
|
|
|
|
nsHttpPipeline *QueryPipeline();
|
|
|
|
|
2009-02-22 17:05:28 -08:00
|
|
|
nsAHttpConnection *mConnection;
|
|
|
|
nsTArray<nsAHttpTransaction*> mRequestQ; // array of transactions
|
|
|
|
nsTArray<nsAHttpTransaction*> mResponseQ; // array of transactions
|
|
|
|
nsresult mStatus;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// these flags indicate whether or not the first request or response
|
|
|
|
// is partial. a partial request means that Request(0) has been
|
|
|
|
// partially written out to the socket. a partial response means
|
|
|
|
// that Response(0) has been partially read in from the socket.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mRequestIsPartial;
|
|
|
|
bool mResponseIsPartial;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// indicates whether or not the pipeline has been explicitly closed.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mClosed;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-22 16:39:31 -07:00
|
|
|
// indicates whether or not a true pipeline (more than 1 request without
|
|
|
|
// a synchronous response) has been formed.
|
|
|
|
bool mUtilizedPipeline;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// used when calling ReadSegments/WriteSegments on a transaction.
|
|
|
|
nsAHttpSegmentReader *mReader;
|
|
|
|
|
|
|
|
// send buffer
|
|
|
|
nsCOMPtr<nsIInputStream> mSendBufIn;
|
|
|
|
nsCOMPtr<nsIOutputStream> mSendBufOut;
|
|
|
|
|
2010-04-20 09:32:28 -07:00
|
|
|
// the push back buffer. not exceeding nsIOService::gDefaultSegmentSize bytes.
|
2007-03-22 10:30:00 -07:00
|
|
|
char *mPushBackBuf;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mPushBackLen;
|
|
|
|
uint32_t mPushBackMax;
|
2011-12-01 06:19:41 -08:00
|
|
|
|
2011-12-13 07:55:50 -08:00
|
|
|
// The number of transactions completed on this pipeline.
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mHttp1xTransactionCount;
|
2011-12-13 07:55:50 -08:00
|
|
|
|
2011-12-01 06:19:41 -08:00
|
|
|
// For support of OnTransportStatus()
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t mReceivingFromProgress;
|
|
|
|
uint64_t mSendingToProgress;
|
2011-12-01 06:19:41 -08:00
|
|
|
bool mSuppressSendEvents;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsHttpPipeline_h__
|