michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_net_Http2Push_Internal_h michael@0: #define mozilla_net_Http2Push_Internal_h michael@0: michael@0: #include "Http2Session.h" michael@0: #include "Http2Stream.h" michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "mozilla/TimeStamp.h" michael@0: #include "nsHttpRequestHead.h" michael@0: #include "nsILoadGroup.h" michael@0: #include "nsString.h" michael@0: #include "PSpdyPush.h" michael@0: michael@0: namespace mozilla { michael@0: namespace net { michael@0: michael@0: class Http2PushTransactionBuffer; michael@0: michael@0: class Http2PushedStream MOZ_FINAL : public Http2Stream michael@0: { michael@0: public: michael@0: Http2PushedStream(Http2PushTransactionBuffer *aTransaction, michael@0: Http2Session *aSession, michael@0: Http2Stream *aAssociatedStream, michael@0: uint32_t aID); michael@0: virtual ~Http2PushedStream() {} michael@0: michael@0: bool GetPushComplete(); michael@0: Http2Stream *GetConsumerStream() { return mConsumerStream; }; michael@0: void SetConsumerStream(Http2Stream *aStream) { mConsumerStream = aStream; } michael@0: bool GetHashKey(nsCString &key); michael@0: michael@0: // override of Http2Stream michael@0: nsresult ReadSegments(nsAHttpSegmentReader *, uint32_t, uint32_t *); michael@0: nsresult WriteSegments(nsAHttpSegmentWriter *, uint32_t, uint32_t *); michael@0: michael@0: nsILoadGroupConnectionInfo *LoadGroupConnectionInfo() { return mLoadGroupCI; }; michael@0: void ConnectPushedStream(Http2Stream *consumer); michael@0: michael@0: bool DeferCleanupOnSuccess() { return mDeferCleanupOnSuccess; } michael@0: void SetDeferCleanupOnSuccess(bool val) { mDeferCleanupOnSuccess = val; } michael@0: michael@0: bool IsOrphaned(TimeStamp now); michael@0: michael@0: nsresult GetBufferedData(char *buf, uint32_t count, uint32_t *countWritten); michael@0: michael@0: // overload of Http2Stream michael@0: virtual bool HasSink() { return !!mConsumerStream; } michael@0: michael@0: private: michael@0: michael@0: Http2Stream *mConsumerStream; // paired request stream that consumes from michael@0: // real http/2 one.. null until a match is made. michael@0: michael@0: nsCOMPtr mLoadGroupCI; michael@0: michael@0: Http2PushTransactionBuffer *mBufferedPush; michael@0: mozilla::TimeStamp mLastRead; michael@0: michael@0: nsCString mHashKey; michael@0: nsresult mStatus; michael@0: bool mPushCompleted; // server push FIN received michael@0: bool mDeferCleanupOnSuccess; michael@0: }; michael@0: michael@0: class Http2PushTransactionBuffer MOZ_FINAL : public nsAHttpTransaction michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSAHTTPTRANSACTION michael@0: michael@0: Http2PushTransactionBuffer(); michael@0: virtual ~Http2PushTransactionBuffer(); michael@0: michael@0: nsresult GetBufferedData(char *buf, uint32_t count, uint32_t *countWritten); michael@0: void SetPushStream(Http2PushedStream *stream) { mPushStream = stream; } michael@0: michael@0: private: michael@0: const static uint32_t kDefaultBufferSize = 4096; michael@0: michael@0: nsresult mStatus; michael@0: nsHttpRequestHead *mRequestHead; michael@0: Http2PushedStream *mPushStream; michael@0: bool mIsDone; michael@0: michael@0: nsAutoArrayPtr mBufferedHTTP1; michael@0: uint32_t mBufferedHTTP1Size; michael@0: uint32_t mBufferedHTTP1Used; michael@0: uint32_t mBufferedHTTP1Consumed; michael@0: }; michael@0: michael@0: } // namespace mozilla::net michael@0: } // namespace mozilla michael@0: michael@0: #endif // mozilla_net_Http2Push_Internal_h