netwerk/protocol/http/ASpdySession.h

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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/. */
     7 #ifndef mozilla_net_ASpdySession_h
     8 #define mozilla_net_ASpdySession_h
    10 #include "nsAHttpTransaction.h"
    11 #include "prinrval.h"
    12 #include "nsString.h"
    14 class nsISocketTransport;
    16 namespace mozilla { namespace net {
    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;
    28   static ASpdySession *NewSpdySession(uint32_t version,
    29                                       nsAHttpTransaction *,
    30                                       nsISocketTransport *,
    31                                       int32_t);
    33   virtual void PrintDiagnostics (nsCString &log) = 0;
    35   bool ResponseTimeoutEnabled() const MOZ_OVERRIDE MOZ_FINAL {
    36     return true;
    37   }
    39   const static uint32_t kSendingChunkSize = 4095;
    40   const static uint32_t kTCPSendBufferSize = 131072;
    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;
    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 };
    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() {}
    65   static const uint32_t kCount = 3;
    67   // determine if a version of the protocol is enabled for index <= kCount
    68   bool ProtocolEnabled(uint32_t index);
    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);
    74   uint8_t   Version[kCount];
    75   nsCString VersionString[kCount];
    76 };
    78 }} // namespace mozilla::net
    80 #endif // mozilla_net_ASpdySession_h

mercurial