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