netwerk/protocol/http/SpdyPush31.h

branch
TOR_BUG_9701
changeset 11
deefc01c0e14
equal deleted inserted replaced
-1:000000000000 0:c549bf9fc143
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 // spdy/3.1
7
8 #ifndef mozilla_net_SpdyPush31_Internal_h
9 #define mozilla_net_SpdyPush31_Internal_h
10
11 #include "mozilla/Attributes.h"
12 #include "mozilla/TimeStamp.h"
13 #include "nsHttpRequestHead.h"
14 #include "nsILoadGroup.h"
15 #include "nsString.h"
16 #include "PSpdyPush.h"
17 #include "SpdySession31.h"
18 #include "SpdyStream31.h"
19
20 namespace mozilla {
21 namespace net {
22
23 class SpdyPush31TransactionBuffer;
24
25 class SpdyPushedStream31 MOZ_FINAL : public SpdyStream31
26 {
27 public:
28 SpdyPushedStream31(SpdyPush31TransactionBuffer *aTransaction,
29 SpdySession31 *aSession,
30 SpdyStream31 *aAssociatedStream,
31 uint32_t aID);
32 virtual ~SpdyPushedStream31() {}
33
34 bool GetPushComplete();
35 SpdyStream31 *GetConsumerStream() { return mConsumerStream; };
36 void SetConsumerStream(SpdyStream31 *aStream) { mConsumerStream = aStream; }
37 bool GetHashKey(nsCString &key);
38
39 // override of SpdyStream31
40 nsresult ReadSegments(nsAHttpSegmentReader *, uint32_t, uint32_t *);
41 nsresult WriteSegments(nsAHttpSegmentWriter *, uint32_t, uint32_t *);
42
43 nsILoadGroupConnectionInfo *LoadGroupConnectionInfo() { return mLoadGroupCI; };
44 void ConnectPushedStream(SpdyStream31 *consumer);
45
46 bool DeferCleanupOnSuccess() { return mDeferCleanupOnSuccess; }
47 void SetDeferCleanupOnSuccess(bool val) { mDeferCleanupOnSuccess = val; }
48
49 bool IsOrphaned(TimeStamp now);
50
51 nsresult GetBufferedData(char *buf, uint32_t count, uint32_t *countWritten);
52
53 // overload of SpdyStream31
54 virtual bool HasSink() { return !!mConsumerStream; }
55
56 private:
57
58 SpdyStream31 *mConsumerStream; // paired request stream that consumes from
59 // real spdy one.. null until a match is made.
60
61 nsCOMPtr<nsILoadGroupConnectionInfo> mLoadGroupCI;
62
63 SpdyPush31TransactionBuffer *mBufferedPush;
64 TimeStamp mLastRead;
65
66 nsCString mHashKey;
67 nsresult mStatus;
68 bool mPushCompleted; // server push FIN received
69 bool mDeferCleanupOnSuccess;
70 };
71
72 class SpdyPush31TransactionBuffer MOZ_FINAL : public nsAHttpTransaction
73 {
74 public:
75 NS_DECL_ISUPPORTS
76 NS_DECL_NSAHTTPTRANSACTION
77
78 SpdyPush31TransactionBuffer();
79 virtual ~SpdyPush31TransactionBuffer();
80
81 nsresult GetBufferedData(char *buf, uint32_t count, uint32_t *countWritten);
82 void SetPushStream(SpdyPushedStream31 *stream) { mPushStream = stream; }
83
84 private:
85 const static uint32_t kDefaultBufferSize = 4096;
86
87 nsresult mStatus;
88 nsHttpRequestHead *mRequestHead;
89 SpdyPushedStream31 *mPushStream;
90 bool mIsDone;
91
92 nsAutoArrayPtr<char> mBufferedHTTP1;
93 uint32_t mBufferedHTTP1Size;
94 uint32_t mBufferedHTTP1Used;
95 uint32_t mBufferedHTTP1Consumed;
96 };
97
98 } // namespace mozilla::net
99 } // namespace mozilla
100
101 #endif // mozilla_net_SpdyPush3_Internal_h

mercurial