netwerk/protocol/http/SpdyPush31.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/protocol/http/SpdyPush31.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,101 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     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 +// spdy/3.1
    1.10 +
    1.11 +#ifndef mozilla_net_SpdyPush31_Internal_h
    1.12 +#define mozilla_net_SpdyPush31_Internal_h
    1.13 +
    1.14 +#include "mozilla/Attributes.h"
    1.15 +#include "mozilla/TimeStamp.h"
    1.16 +#include "nsHttpRequestHead.h"
    1.17 +#include "nsILoadGroup.h"
    1.18 +#include "nsString.h"
    1.19 +#include "PSpdyPush.h"
    1.20 +#include "SpdySession31.h"
    1.21 +#include "SpdyStream31.h"
    1.22 +
    1.23 +namespace mozilla {
    1.24 +namespace net {
    1.25 +
    1.26 +class SpdyPush31TransactionBuffer;
    1.27 +
    1.28 +class SpdyPushedStream31 MOZ_FINAL : public SpdyStream31
    1.29 +{
    1.30 +public:
    1.31 +  SpdyPushedStream31(SpdyPush31TransactionBuffer *aTransaction,
    1.32 +                     SpdySession31 *aSession,
    1.33 +                     SpdyStream31 *aAssociatedStream,
    1.34 +                     uint32_t aID);
    1.35 +  virtual ~SpdyPushedStream31() {}
    1.36 +
    1.37 +  bool GetPushComplete();
    1.38 +  SpdyStream31 *GetConsumerStream() { return mConsumerStream; };
    1.39 +  void SetConsumerStream(SpdyStream31 *aStream) { mConsumerStream = aStream; }
    1.40 +  bool GetHashKey(nsCString &key);
    1.41 +
    1.42 +  // override of SpdyStream31
    1.43 +  nsresult ReadSegments(nsAHttpSegmentReader *,  uint32_t, uint32_t *);
    1.44 +  nsresult WriteSegments(nsAHttpSegmentWriter *, uint32_t, uint32_t *);
    1.45 +
    1.46 +  nsILoadGroupConnectionInfo *LoadGroupConnectionInfo() { return mLoadGroupCI; };
    1.47 +  void ConnectPushedStream(SpdyStream31 *consumer);
    1.48 +
    1.49 +  bool DeferCleanupOnSuccess() { return mDeferCleanupOnSuccess; }
    1.50 +  void SetDeferCleanupOnSuccess(bool val) { mDeferCleanupOnSuccess = val; }
    1.51 +
    1.52 +  bool IsOrphaned(TimeStamp now);
    1.53 +
    1.54 +  nsresult GetBufferedData(char *buf, uint32_t count, uint32_t *countWritten);
    1.55 +
    1.56 +  // overload of SpdyStream31
    1.57 +  virtual bool HasSink() { return !!mConsumerStream; }
    1.58 +
    1.59 +private:
    1.60 +
    1.61 +  SpdyStream31 *mConsumerStream; // paired request stream that consumes from
    1.62 +  // real spdy one.. null until a match is made.
    1.63 +
    1.64 +  nsCOMPtr<nsILoadGroupConnectionInfo> mLoadGroupCI;
    1.65 +
    1.66 +  SpdyPush31TransactionBuffer *mBufferedPush;
    1.67 +  TimeStamp          mLastRead;
    1.68 +
    1.69 +  nsCString mHashKey;
    1.70 +  nsresult mStatus;
    1.71 +  bool mPushCompleted; // server push FIN received
    1.72 +  bool mDeferCleanupOnSuccess;
    1.73 +};
    1.74 +
    1.75 +class SpdyPush31TransactionBuffer MOZ_FINAL : public nsAHttpTransaction
    1.76 +{
    1.77 +public:
    1.78 +  NS_DECL_ISUPPORTS
    1.79 +  NS_DECL_NSAHTTPTRANSACTION
    1.80 +
    1.81 +  SpdyPush31TransactionBuffer();
    1.82 +  virtual ~SpdyPush31TransactionBuffer();
    1.83 +
    1.84 +  nsresult GetBufferedData(char *buf, uint32_t count, uint32_t *countWritten);
    1.85 +  void SetPushStream(SpdyPushedStream31 *stream) { mPushStream = stream; }
    1.86 +
    1.87 +private:
    1.88 +  const static uint32_t kDefaultBufferSize = 4096;
    1.89 +
    1.90 +  nsresult mStatus;
    1.91 +  nsHttpRequestHead *mRequestHead;
    1.92 +  SpdyPushedStream31 *mPushStream;
    1.93 +  bool mIsDone;
    1.94 +
    1.95 +  nsAutoArrayPtr<char> mBufferedHTTP1;
    1.96 +  uint32_t mBufferedHTTP1Size;
    1.97 +  uint32_t mBufferedHTTP1Used;
    1.98 +  uint32_t mBufferedHTTP1Consumed;
    1.99 +};
   1.100 +
   1.101 +} // namespace mozilla::net
   1.102 +} // namespace mozilla
   1.103 +
   1.104 +#endif // mozilla_net_SpdyPush3_Internal_h

mercurial