|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 |
|
3 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef mozilla_net_ASpdySession_h |
|
8 #define mozilla_net_ASpdySession_h |
|
9 |
|
10 #include "nsAHttpTransaction.h" |
|
11 #include "prinrval.h" |
|
12 #include "nsString.h" |
|
13 |
|
14 class nsISocketTransport; |
|
15 |
|
16 namespace mozilla { namespace net { |
|
17 |
|
18 class ASpdySession : public nsAHttpTransaction |
|
19 { |
|
20 public: |
|
21 virtual bool AddStream(nsAHttpTransaction *, int32_t) = 0; |
|
22 virtual bool CanReuse() = 0; |
|
23 virtual bool RoomForMoreStreams() = 0; |
|
24 virtual PRIntervalTime IdleTime() = 0; |
|
25 virtual uint32_t ReadTimeoutTick(PRIntervalTime now) = 0; |
|
26 virtual void DontReuse() = 0; |
|
27 |
|
28 static ASpdySession *NewSpdySession(uint32_t version, |
|
29 nsAHttpTransaction *, |
|
30 nsISocketTransport *, |
|
31 int32_t); |
|
32 |
|
33 virtual void PrintDiagnostics (nsCString &log) = 0; |
|
34 |
|
35 bool ResponseTimeoutEnabled() const MOZ_OVERRIDE MOZ_FINAL { |
|
36 return true; |
|
37 } |
|
38 |
|
39 const static uint32_t kSendingChunkSize = 4095; |
|
40 const static uint32_t kTCPSendBufferSize = 131072; |
|
41 |
|
42 // until we have an API that can push back on receiving data (right now |
|
43 // WriteSegments is obligated to accept data and buffer) there is no |
|
44 // reason to throttle with the rwin other than in server push |
|
45 // scenarios. |
|
46 const static uint32_t kInitialRwin = 256 * 1024 * 1024; |
|
47 |
|
48 bool SoftStreamError(nsresult code) |
|
49 { |
|
50 return (code == NS_BASE_STREAM_CLOSED || code == NS_BINDING_FAILED || |
|
51 code == NS_BINDING_ABORTED || code == NS_BINDING_REDIRECTED || |
|
52 code == NS_BINDING_RETARGETED); |
|
53 } |
|
54 }; |
|
55 |
|
56 // this is essentially a single instantiation as a member of nsHttpHandler. |
|
57 // It could be all static except using static ctors of XPCOM objects is a |
|
58 // bad idea. |
|
59 class SpdyInformation |
|
60 { |
|
61 public: |
|
62 SpdyInformation(); |
|
63 ~SpdyInformation() {} |
|
64 |
|
65 static const uint32_t kCount = 3; |
|
66 |
|
67 // determine if a version of the protocol is enabled for index <= kCount |
|
68 bool ProtocolEnabled(uint32_t index); |
|
69 |
|
70 // lookup a version enum based on an npn string. returns NS_OK if |
|
71 // string was known. |
|
72 nsresult GetNPNVersionIndex(const nsACString &npnString, uint8_t *result); |
|
73 |
|
74 uint8_t Version[kCount]; |
|
75 nsCString VersionString[kCount]; |
|
76 }; |
|
77 |
|
78 }} // namespace mozilla::net |
|
79 |
|
80 #endif // mozilla_net_ASpdySession_h |