netwerk/protocol/http/Http2Push.h

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

mercurial