netwerk/protocol/http/SpdyPush31.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 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 // spdy/3.1
     8 #ifndef mozilla_net_SpdyPush31_Internal_h
     9 #define mozilla_net_SpdyPush31_Internal_h
    11 #include "mozilla/Attributes.h"
    12 #include "mozilla/TimeStamp.h"
    13 #include "nsHttpRequestHead.h"
    14 #include "nsILoadGroup.h"
    15 #include "nsString.h"
    16 #include "PSpdyPush.h"
    17 #include "SpdySession31.h"
    18 #include "SpdyStream31.h"
    20 namespace mozilla {
    21 namespace net {
    23 class SpdyPush31TransactionBuffer;
    25 class SpdyPushedStream31 MOZ_FINAL : public SpdyStream31
    26 {
    27 public:
    28   SpdyPushedStream31(SpdyPush31TransactionBuffer *aTransaction,
    29                      SpdySession31 *aSession,
    30                      SpdyStream31 *aAssociatedStream,
    31                      uint32_t aID);
    32   virtual ~SpdyPushedStream31() {}
    34   bool GetPushComplete();
    35   SpdyStream31 *GetConsumerStream() { return mConsumerStream; };
    36   void SetConsumerStream(SpdyStream31 *aStream) { mConsumerStream = aStream; }
    37   bool GetHashKey(nsCString &key);
    39   // override of SpdyStream31
    40   nsresult ReadSegments(nsAHttpSegmentReader *,  uint32_t, uint32_t *);
    41   nsresult WriteSegments(nsAHttpSegmentWriter *, uint32_t, uint32_t *);
    43   nsILoadGroupConnectionInfo *LoadGroupConnectionInfo() { return mLoadGroupCI; };
    44   void ConnectPushedStream(SpdyStream31 *consumer);
    46   bool DeferCleanupOnSuccess() { return mDeferCleanupOnSuccess; }
    47   void SetDeferCleanupOnSuccess(bool val) { mDeferCleanupOnSuccess = val; }
    49   bool IsOrphaned(TimeStamp now);
    51   nsresult GetBufferedData(char *buf, uint32_t count, uint32_t *countWritten);
    53   // overload of SpdyStream31
    54   virtual bool HasSink() { return !!mConsumerStream; }
    56 private:
    58   SpdyStream31 *mConsumerStream; // paired request stream that consumes from
    59   // real spdy one.. null until a match is made.
    61   nsCOMPtr<nsILoadGroupConnectionInfo> mLoadGroupCI;
    63   SpdyPush31TransactionBuffer *mBufferedPush;
    64   TimeStamp          mLastRead;
    66   nsCString mHashKey;
    67   nsresult mStatus;
    68   bool mPushCompleted; // server push FIN received
    69   bool mDeferCleanupOnSuccess;
    70 };
    72 class SpdyPush31TransactionBuffer MOZ_FINAL : public nsAHttpTransaction
    73 {
    74 public:
    75   NS_DECL_ISUPPORTS
    76   NS_DECL_NSAHTTPTRANSACTION
    78   SpdyPush31TransactionBuffer();
    79   virtual ~SpdyPush31TransactionBuffer();
    81   nsresult GetBufferedData(char *buf, uint32_t count, uint32_t *countWritten);
    82   void SetPushStream(SpdyPushedStream31 *stream) { mPushStream = stream; }
    84 private:
    85   const static uint32_t kDefaultBufferSize = 4096;
    87   nsresult mStatus;
    88   nsHttpRequestHead *mRequestHead;
    89   SpdyPushedStream31 *mPushStream;
    90   bool mIsDone;
    92   nsAutoArrayPtr<char> mBufferedHTTP1;
    93   uint32_t mBufferedHTTP1Size;
    94   uint32_t mBufferedHTTP1Used;
    95   uint32_t mBufferedHTTP1Consumed;
    96 };
    98 } // namespace mozilla::net
    99 } // namespace mozilla
   101 #endif // mozilla_net_SpdyPush3_Internal_h

mercurial