netwerk/protocol/http/ASpdySession.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/protocol/http/ASpdySession.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,80 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef mozilla_net_ASpdySession_h
    1.11 +#define mozilla_net_ASpdySession_h
    1.12 +
    1.13 +#include "nsAHttpTransaction.h"
    1.14 +#include "prinrval.h"
    1.15 +#include "nsString.h"
    1.16 +
    1.17 +class nsISocketTransport;
    1.18 +
    1.19 +namespace mozilla { namespace net {
    1.20 +
    1.21 +class ASpdySession : public nsAHttpTransaction
    1.22 +{
    1.23 +public:
    1.24 +  virtual bool AddStream(nsAHttpTransaction *, int32_t) = 0;
    1.25 +  virtual bool CanReuse() = 0;
    1.26 +  virtual bool RoomForMoreStreams() = 0;
    1.27 +  virtual PRIntervalTime IdleTime() = 0;
    1.28 +  virtual uint32_t ReadTimeoutTick(PRIntervalTime now) = 0;
    1.29 +  virtual void DontReuse() = 0;
    1.30 +
    1.31 +  static ASpdySession *NewSpdySession(uint32_t version,
    1.32 +                                      nsAHttpTransaction *,
    1.33 +                                      nsISocketTransport *,
    1.34 +                                      int32_t);
    1.35 +
    1.36 +  virtual void PrintDiagnostics (nsCString &log) = 0;
    1.37 +
    1.38 +  bool ResponseTimeoutEnabled() const MOZ_OVERRIDE MOZ_FINAL {
    1.39 +    return true;
    1.40 +  }
    1.41 +
    1.42 +  const static uint32_t kSendingChunkSize = 4095;
    1.43 +  const static uint32_t kTCPSendBufferSize = 131072;
    1.44 +
    1.45 +  // until we have an API that can push back on receiving data (right now
    1.46 +  // WriteSegments is obligated to accept data and buffer) there is no
    1.47 +  // reason to throttle with the rwin other than in server push
    1.48 +  // scenarios.
    1.49 +  const static uint32_t kInitialRwin = 256 * 1024 * 1024;
    1.50 +
    1.51 +  bool SoftStreamError(nsresult code)
    1.52 +  {
    1.53 +    return (code == NS_BASE_STREAM_CLOSED || code == NS_BINDING_FAILED ||
    1.54 +            code == NS_BINDING_ABORTED || code == NS_BINDING_REDIRECTED ||
    1.55 +            code == NS_BINDING_RETARGETED);
    1.56 +  }
    1.57 +};
    1.58 +
    1.59 +// this is essentially a single instantiation as a member of nsHttpHandler.
    1.60 +// It could be all static except using static ctors of XPCOM objects is a
    1.61 +// bad idea.
    1.62 +class SpdyInformation
    1.63 +{
    1.64 +public:
    1.65 +  SpdyInformation();
    1.66 +  ~SpdyInformation() {}
    1.67 +
    1.68 +  static const uint32_t kCount = 3;
    1.69 +
    1.70 +  // determine if a version of the protocol is enabled for index <= kCount
    1.71 +  bool ProtocolEnabled(uint32_t index);
    1.72 +
    1.73 +  // lookup a version enum based on an npn string. returns NS_OK if
    1.74 +  // string was known.
    1.75 +  nsresult GetNPNVersionIndex(const nsACString &npnString, uint8_t *result);
    1.76 +
    1.77 +  uint8_t   Version[kCount];
    1.78 +  nsCString VersionString[kCount];
    1.79 +};
    1.80 +
    1.81 +}} // namespace mozilla::net
    1.82 +
    1.83 +#endif // mozilla_net_ASpdySession_h

mercurial