netwerk/protocol/http/Http2Push.h

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

mercurial