michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_net_ASpdySession_h michael@0: #define mozilla_net_ASpdySession_h michael@0: michael@0: #include "nsAHttpTransaction.h" michael@0: #include "prinrval.h" michael@0: #include "nsString.h" michael@0: michael@0: class nsISocketTransport; michael@0: michael@0: namespace mozilla { namespace net { michael@0: michael@0: class ASpdySession : public nsAHttpTransaction michael@0: { michael@0: public: michael@0: virtual bool AddStream(nsAHttpTransaction *, int32_t) = 0; michael@0: virtual bool CanReuse() = 0; michael@0: virtual bool RoomForMoreStreams() = 0; michael@0: virtual PRIntervalTime IdleTime() = 0; michael@0: virtual uint32_t ReadTimeoutTick(PRIntervalTime now) = 0; michael@0: virtual void DontReuse() = 0; michael@0: michael@0: static ASpdySession *NewSpdySession(uint32_t version, michael@0: nsAHttpTransaction *, michael@0: nsISocketTransport *, michael@0: int32_t); michael@0: michael@0: virtual void PrintDiagnostics (nsCString &log) = 0; michael@0: michael@0: bool ResponseTimeoutEnabled() const MOZ_OVERRIDE MOZ_FINAL { michael@0: return true; michael@0: } michael@0: michael@0: const static uint32_t kSendingChunkSize = 4095; michael@0: const static uint32_t kTCPSendBufferSize = 131072; michael@0: michael@0: // until we have an API that can push back on receiving data (right now michael@0: // WriteSegments is obligated to accept data and buffer) there is no michael@0: // reason to throttle with the rwin other than in server push michael@0: // scenarios. michael@0: const static uint32_t kInitialRwin = 256 * 1024 * 1024; michael@0: michael@0: bool SoftStreamError(nsresult code) michael@0: { michael@0: return (code == NS_BASE_STREAM_CLOSED || code == NS_BINDING_FAILED || michael@0: code == NS_BINDING_ABORTED || code == NS_BINDING_REDIRECTED || michael@0: code == NS_BINDING_RETARGETED); michael@0: } michael@0: }; michael@0: michael@0: // this is essentially a single instantiation as a member of nsHttpHandler. michael@0: // It could be all static except using static ctors of XPCOM objects is a michael@0: // bad idea. michael@0: class SpdyInformation michael@0: { michael@0: public: michael@0: SpdyInformation(); michael@0: ~SpdyInformation() {} michael@0: michael@0: static const uint32_t kCount = 3; michael@0: michael@0: // determine if a version of the protocol is enabled for index <= kCount michael@0: bool ProtocolEnabled(uint32_t index); michael@0: michael@0: // lookup a version enum based on an npn string. returns NS_OK if michael@0: // string was known. michael@0: nsresult GetNPNVersionIndex(const nsACString &npnString, uint8_t *result); michael@0: michael@0: uint8_t Version[kCount]; michael@0: nsCString VersionString[kCount]; michael@0: }; michael@0: michael@0: }} // namespace mozilla::net michael@0: michael@0: #endif // mozilla_net_ASpdySession_h