netwerk/protocol/http/SpdyPush3.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/protocol/http/SpdyPush3.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 Server Push as defined by
    1.10 +// http://dev.chromium.org/spdy/spdy-protocol/spdy-protocol-draft3
    1.11 +
    1.12 +#ifndef mozilla_net_SpdyPush3_Internal_h
    1.13 +#define mozilla_net_SpdyPush3_Internal_h
    1.14 +
    1.15 +#include "mozilla/Attributes.h"
    1.16 +#include "mozilla/TimeStamp.h"
    1.17 +#include "nsILoadGroup.h"
    1.18 +#include "nsString.h"
    1.19 +#include "SpdyStream3.h"
    1.20 +
    1.21 +namespace mozilla {
    1.22 +namespace net {
    1.23 +
    1.24 +class SpdySession3;
    1.25 +
    1.26 +class SpdyPush3TransactionBuffer;
    1.27 +
    1.28 +class SpdyPushedStream3 MOZ_FINAL : public SpdyStream3
    1.29 +{
    1.30 +public:
    1.31 +  SpdyPushedStream3(SpdyPush3TransactionBuffer *aTransaction,
    1.32 +                    SpdySession3 *aSession,
    1.33 +                    SpdyStream3 *aAssociatedStream,
    1.34 +                    uint32_t aID);
    1.35 +  virtual ~SpdyPushedStream3() {}
    1.36 +
    1.37 +  bool GetPushComplete();
    1.38 +  SpdyStream3 *GetConsumerStream() { return mConsumerStream; };
    1.39 +  void SetConsumerStream(SpdyStream3 *aStream) { mConsumerStream = aStream; }
    1.40 +  bool GetHashKey(nsCString &key);
    1.41 +
    1.42 +  // override of SpdyStream3
    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(SpdyStream3 *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 SpdyStream3
    1.57 +  virtual bool HasSink() { return !!mConsumerStream; }
    1.58 +
    1.59 +private:
    1.60 +
    1.61 +  SpdyStream3 *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 +  SpdyPush3TransactionBuffer *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 SpdyPush3TransactionBuffer MOZ_FINAL : public nsAHttpTransaction
    1.76 +{
    1.77 +public:
    1.78 +  NS_DECL_THREADSAFE_ISUPPORTS
    1.79 +  NS_DECL_NSAHTTPTRANSACTION
    1.80 +
    1.81 +  SpdyPush3TransactionBuffer();
    1.82 +  virtual ~SpdyPush3TransactionBuffer();
    1.83 +
    1.84 +  nsresult GetBufferedData(char *buf, uint32_t count, uint32_t *countWritten);
    1.85 +  void SetPushStream(SpdyPushedStream3 *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 +  SpdyPushedStream3 *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