diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /netwerk/protocol/http/ASpdySession.h | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'netwerk/protocol/http/ASpdySession.h')
-rw-r--r-- | netwerk/protocol/http/ASpdySession.h | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/netwerk/protocol/http/ASpdySession.h b/netwerk/protocol/http/ASpdySession.h new file mode 100644 index 000000000..e116d423b --- /dev/null +++ b/netwerk/protocol/http/ASpdySession.h @@ -0,0 +1,120 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ + +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_net_ASpdySession_h +#define mozilla_net_ASpdySession_h + +#include "nsAHttpTransaction.h" +#include "prinrval.h" +#include "nsString.h" + +class nsISocketTransport; + +namespace mozilla { namespace net { + +class ASpdySession : public nsAHttpTransaction +{ +public: + ASpdySession(); + virtual ~ASpdySession(); + + virtual bool AddStream(nsAHttpTransaction *, int32_t, + bool, nsIInterfaceRequestor *) = 0; + virtual bool CanReuse() = 0; + virtual bool RoomForMoreStreams() = 0; + virtual PRIntervalTime IdleTime() = 0; + virtual uint32_t ReadTimeoutTick(PRIntervalTime now) = 0; + virtual void DontReuse() = 0; + + static ASpdySession *NewSpdySession(uint32_t version, nsISocketTransport *); + + // MaybeReTunnel() is called by the connection manager when it cannot + // dispatch a tunneled transaction. That might be because the tunnels it + // expects to see are dead (and we may or may not be able to make more), + // or it might just need to wait longer for one of them to become free. + // + // return true if the session takes back ownership of the transaction from + // the connection manager. + virtual bool MaybeReTunnel(nsAHttpTransaction *) = 0; + + virtual void PrintDiagnostics (nsCString &log) = 0; + + bool ResponseTimeoutEnabled() const override final { + return true; + } + + virtual void SendPing() = 0; + + const static uint32_t kSendingChunkSize = 4095; + const static uint32_t kTCPSendBufferSize = 131072; + + // This is roughly the amount of data a suspended channel will have to + // buffer before h2 flow control kicks in. + const static uint32_t kInitialRwin = 12 * 1024 * 1024; // 12MB + + const static uint32_t kDefaultMaxConcurrent = 100; + + // soft errors are errors that terminate a stream without terminating the + // connection. In general non-network errors are stream errors as well + // as network specific items like cancels. + bool SoftStreamError(nsresult code) + { + if (NS_SUCCEEDED(code) || code == NS_BASE_STREAM_WOULD_BLOCK) { + return false; + } + + // this could go either way, but because there are network instances of + // it being a hard error we should consider it hard. + if (code == NS_ERROR_FAILURE || code == NS_ERROR_OUT_OF_MEMORY) { + return false; + } + + if (NS_ERROR_GET_MODULE(code) != NS_ERROR_MODULE_NETWORK) { + return true; + } + + // these are network specific soft errors + return (code == NS_BASE_STREAM_CLOSED || code == NS_BINDING_FAILED || + code == NS_BINDING_ABORTED || code == NS_BINDING_REDIRECTED || + code == NS_ERROR_INVALID_CONTENT_ENCODING || + code == NS_BINDING_RETARGETED || code == NS_ERROR_CORRUPTED_CONTENT); + } +}; + +typedef bool (*ALPNCallback) (nsISupports *); // nsISSLSocketControl is typical + +// this is essentially a single instantiation as a member of nsHttpHandler. +// It could be all static except using static ctors of XPCOM objects is a +// bad idea. +class SpdyInformation +{ +public: + SpdyInformation(); + ~SpdyInformation() {} + + static const uint32_t kCount = 1; + + // determine the index (0..kCount-1) of the spdy information that + // correlates to the npn string. NS_FAILED() if no match is found. + nsresult GetNPNIndex(const nsACString &npnString, uint32_t *result) const; + + // determine if a version of the protocol is enabled for index < kCount + bool ProtocolEnabled(uint32_t index) const; + + uint8_t Version[kCount]; // telemetry enum e.g. SPDY_VERSION_31 + nsCString VersionString[kCount]; // npn string e.g. "spdy/3.1" + + // the ALPNCallback function allows the protocol stack to decide whether or + // not to offer a particular protocol based on the known TLS information + // that we will offer in the client hello (such as version). There has + // not been a Server Hello received yet, so not much else can be considered. + ALPNCallback ALPNCallbacks[kCount]; +}; + +} // namespace net +} // namespace mozilla + +#endif // mozilla_net_ASpdySession_h |