netwerk/protocol/http/Http2Push.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 #ifndef mozilla_net_Http2Push_Internal_h
     7 #define mozilla_net_Http2Push_Internal_h
     9 #include "Http2Session.h"
    10 #include "Http2Stream.h"
    12 #include "mozilla/Attributes.h"
    13 #include "mozilla/TimeStamp.h"
    14 #include "nsHttpRequestHead.h"
    15 #include "nsILoadGroup.h"
    16 #include "nsString.h"
    17 #include "PSpdyPush.h"
    19 namespace mozilla {
    20 namespace net {
    22 class Http2PushTransactionBuffer;
    24 class Http2PushedStream MOZ_FINAL : public Http2Stream
    25 {
    26 public:
    27   Http2PushedStream(Http2PushTransactionBuffer *aTransaction,
    28                     Http2Session *aSession,
    29                     Http2Stream *aAssociatedStream,
    30                     uint32_t aID);
    31   virtual ~Http2PushedStream() {}
    33   bool GetPushComplete();
    34   Http2Stream *GetConsumerStream() { return mConsumerStream; };
    35   void SetConsumerStream(Http2Stream *aStream) { mConsumerStream = aStream; }
    36   bool GetHashKey(nsCString &key);
    38   // override of Http2Stream
    39   nsresult ReadSegments(nsAHttpSegmentReader *,  uint32_t, uint32_t *);
    40   nsresult WriteSegments(nsAHttpSegmentWriter *, uint32_t, uint32_t *);
    42   nsILoadGroupConnectionInfo *LoadGroupConnectionInfo() { return mLoadGroupCI; };
    43   void ConnectPushedStream(Http2Stream *consumer);
    45   bool DeferCleanupOnSuccess() { return mDeferCleanupOnSuccess; }
    46   void SetDeferCleanupOnSuccess(bool val) { mDeferCleanupOnSuccess = val; }
    48   bool IsOrphaned(TimeStamp now);
    50   nsresult GetBufferedData(char *buf, uint32_t count, uint32_t *countWritten);
    52   // overload of Http2Stream
    53   virtual bool HasSink() { return !!mConsumerStream; }
    55 private:
    57   Http2Stream *mConsumerStream; // paired request stream that consumes from
    58                                 // real http/2 one.. null until a match is made.
    60   nsCOMPtr<nsILoadGroupConnectionInfo> mLoadGroupCI;
    62   Http2PushTransactionBuffer *mBufferedPush;
    63   mozilla::TimeStamp mLastRead;
    65   nsCString mHashKey;
    66   nsresult mStatus;
    67   bool mPushCompleted; // server push FIN received
    68   bool mDeferCleanupOnSuccess;
    69 };
    71 class Http2PushTransactionBuffer MOZ_FINAL : public nsAHttpTransaction
    72 {
    73 public:
    74   NS_DECL_ISUPPORTS
    75   NS_DECL_NSAHTTPTRANSACTION
    77   Http2PushTransactionBuffer();
    78   virtual ~Http2PushTransactionBuffer();
    80   nsresult GetBufferedData(char *buf, uint32_t count, uint32_t *countWritten);
    81   void SetPushStream(Http2PushedStream *stream) { mPushStream = stream; }
    83 private:
    84   const static uint32_t kDefaultBufferSize = 4096;
    86   nsresult mStatus;
    87   nsHttpRequestHead *mRequestHead;
    88   Http2PushedStream *mPushStream;
    89   bool mIsDone;
    91   nsAutoArrayPtr<char> mBufferedHTTP1;
    92   uint32_t mBufferedHTTP1Size;
    93   uint32_t mBufferedHTTP1Used;
    94   uint32_t mBufferedHTTP1Consumed;
    95 };
    97 } // namespace mozilla::net
    98 } // namespace mozilla
   100 #endif // mozilla_net_Http2Push_Internal_h

mercurial