Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef mozilla_net_Http2Push_Internal_h |
michael@0 | 7 | #define mozilla_net_Http2Push_Internal_h |
michael@0 | 8 | |
michael@0 | 9 | #include "Http2Session.h" |
michael@0 | 10 | #include "Http2Stream.h" |
michael@0 | 11 | |
michael@0 | 12 | #include "mozilla/Attributes.h" |
michael@0 | 13 | #include "mozilla/TimeStamp.h" |
michael@0 | 14 | #include "nsHttpRequestHead.h" |
michael@0 | 15 | #include "nsILoadGroup.h" |
michael@0 | 16 | #include "nsString.h" |
michael@0 | 17 | #include "PSpdyPush.h" |
michael@0 | 18 | |
michael@0 | 19 | namespace mozilla { |
michael@0 | 20 | namespace net { |
michael@0 | 21 | |
michael@0 | 22 | class Http2PushTransactionBuffer; |
michael@0 | 23 | |
michael@0 | 24 | class Http2PushedStream MOZ_FINAL : public Http2Stream |
michael@0 | 25 | { |
michael@0 | 26 | public: |
michael@0 | 27 | Http2PushedStream(Http2PushTransactionBuffer *aTransaction, |
michael@0 | 28 | Http2Session *aSession, |
michael@0 | 29 | Http2Stream *aAssociatedStream, |
michael@0 | 30 | uint32_t aID); |
michael@0 | 31 | virtual ~Http2PushedStream() {} |
michael@0 | 32 | |
michael@0 | 33 | bool GetPushComplete(); |
michael@0 | 34 | Http2Stream *GetConsumerStream() { return mConsumerStream; }; |
michael@0 | 35 | void SetConsumerStream(Http2Stream *aStream) { mConsumerStream = aStream; } |
michael@0 | 36 | bool GetHashKey(nsCString &key); |
michael@0 | 37 | |
michael@0 | 38 | // override of Http2Stream |
michael@0 | 39 | nsresult ReadSegments(nsAHttpSegmentReader *, uint32_t, uint32_t *); |
michael@0 | 40 | nsresult WriteSegments(nsAHttpSegmentWriter *, uint32_t, uint32_t *); |
michael@0 | 41 | |
michael@0 | 42 | nsILoadGroupConnectionInfo *LoadGroupConnectionInfo() { return mLoadGroupCI; }; |
michael@0 | 43 | void ConnectPushedStream(Http2Stream *consumer); |
michael@0 | 44 | |
michael@0 | 45 | bool DeferCleanupOnSuccess() { return mDeferCleanupOnSuccess; } |
michael@0 | 46 | void SetDeferCleanupOnSuccess(bool val) { mDeferCleanupOnSuccess = val; } |
michael@0 | 47 | |
michael@0 | 48 | bool IsOrphaned(TimeStamp now); |
michael@0 | 49 | |
michael@0 | 50 | nsresult GetBufferedData(char *buf, uint32_t count, uint32_t *countWritten); |
michael@0 | 51 | |
michael@0 | 52 | // overload of Http2Stream |
michael@0 | 53 | virtual bool HasSink() { return !!mConsumerStream; } |
michael@0 | 54 | |
michael@0 | 55 | private: |
michael@0 | 56 | |
michael@0 | 57 | Http2Stream *mConsumerStream; // paired request stream that consumes from |
michael@0 | 58 | // real http/2 one.. null until a match is made. |
michael@0 | 59 | |
michael@0 | 60 | nsCOMPtr<nsILoadGroupConnectionInfo> mLoadGroupCI; |
michael@0 | 61 | |
michael@0 | 62 | Http2PushTransactionBuffer *mBufferedPush; |
michael@0 | 63 | mozilla::TimeStamp mLastRead; |
michael@0 | 64 | |
michael@0 | 65 | nsCString mHashKey; |
michael@0 | 66 | nsresult mStatus; |
michael@0 | 67 | bool mPushCompleted; // server push FIN received |
michael@0 | 68 | bool mDeferCleanupOnSuccess; |
michael@0 | 69 | }; |
michael@0 | 70 | |
michael@0 | 71 | class Http2PushTransactionBuffer MOZ_FINAL : public nsAHttpTransaction |
michael@0 | 72 | { |
michael@0 | 73 | public: |
michael@0 | 74 | NS_DECL_ISUPPORTS |
michael@0 | 75 | NS_DECL_NSAHTTPTRANSACTION |
michael@0 | 76 | |
michael@0 | 77 | Http2PushTransactionBuffer(); |
michael@0 | 78 | virtual ~Http2PushTransactionBuffer(); |
michael@0 | 79 | |
michael@0 | 80 | nsresult GetBufferedData(char *buf, uint32_t count, uint32_t *countWritten); |
michael@0 | 81 | void SetPushStream(Http2PushedStream *stream) { mPushStream = stream; } |
michael@0 | 82 | |
michael@0 | 83 | private: |
michael@0 | 84 | const static uint32_t kDefaultBufferSize = 4096; |
michael@0 | 85 | |
michael@0 | 86 | nsresult mStatus; |
michael@0 | 87 | nsHttpRequestHead *mRequestHead; |
michael@0 | 88 | Http2PushedStream *mPushStream; |
michael@0 | 89 | bool mIsDone; |
michael@0 | 90 | |
michael@0 | 91 | nsAutoArrayPtr<char> mBufferedHTTP1; |
michael@0 | 92 | uint32_t mBufferedHTTP1Size; |
michael@0 | 93 | uint32_t mBufferedHTTP1Used; |
michael@0 | 94 | uint32_t mBufferedHTTP1Consumed; |
michael@0 | 95 | }; |
michael@0 | 96 | |
michael@0 | 97 | } // namespace mozilla::net |
michael@0 | 98 | } // namespace mozilla |
michael@0 | 99 | |
michael@0 | 100 | #endif // mozilla_net_Http2Push_Internal_h |