LCOV - code coverage report
Current view: top level - netwerk/protocol/http - Http2Push.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 8 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 9 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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/. */
       5             : 
       6             : #ifndef mozilla_net_Http2Push_Internal_h
       7             : #define mozilla_net_Http2Push_Internal_h
       8             : 
       9             : // HTTP/2 - RFC 7540
      10             : // https://www.rfc-editor.org/rfc/rfc7540.txt
      11             : 
      12             : #include "Http2Session.h"
      13             : #include "Http2Stream.h"
      14             : 
      15             : #include "mozilla/Attributes.h"
      16             : #include "mozilla/TimeStamp.h"
      17             : #include "mozilla/UniquePtr.h"
      18             : #include "nsHttpRequestHead.h"
      19             : #include "nsILoadGroup.h"
      20             : #include "nsIRequestContext.h"
      21             : #include "nsString.h"
      22             : #include "PSpdyPush.h"
      23             : 
      24             : namespace mozilla {
      25             : namespace net {
      26             : 
      27             : class Http2PushTransactionBuffer;
      28             : 
      29             : class Http2PushedStream final : public Http2Stream
      30             : {
      31             : public:
      32             :   Http2PushedStream(Http2PushTransactionBuffer *aTransaction,
      33             :                     Http2Session *aSession,
      34             :                     Http2Stream *aAssociatedStream,
      35             :                     uint32_t aID);
      36           0 :   virtual ~Http2PushedStream() {}
      37             : 
      38             :   bool GetPushComplete();
      39             : 
      40             :   // The consumer stream is the synthetic pull stream hooked up to this push
      41           0 :   virtual Http2Stream *GetConsumerStream() override { return mConsumerStream; };
      42             : 
      43             :   void SetConsumerStream(Http2Stream *aStream);
      44             :   MOZ_MUST_USE bool GetHashKey(nsCString &key);
      45             : 
      46             :   // override of Http2Stream
      47             :   MOZ_MUST_USE nsresult ReadSegments(nsAHttpSegmentReader *,
      48             :                                      uint32_t, uint32_t *) override;
      49             :   MOZ_MUST_USE nsresult WriteSegments(nsAHttpSegmentWriter *,
      50             :                                       uint32_t, uint32_t *) override;
      51             :   void AdjustInitialWindow() override;
      52             : 
      53           0 :   nsIRequestContext *RequestContext() override { return mRequestContext; };
      54             :   void ConnectPushedStream(Http2Stream *consumer);
      55             : 
      56             :   MOZ_MUST_USE bool TryOnPush();
      57             :   static MOZ_MUST_USE bool TestOnPush(Http2Stream *consumer);
      58             : 
      59             :   virtual bool DeferCleanup(nsresult status) override;
      60           0 :   void SetDeferCleanupOnSuccess(bool val) { mDeferCleanupOnSuccess = val; }
      61             : 
      62             :   bool IsOrphaned(TimeStamp now);
      63           0 :   void OnPushFailed() { mDeferCleanupOnPush = false; mOnPushFailed = true; }
      64             : 
      65             :   MOZ_MUST_USE nsresult GetBufferedData(char *buf, uint32_t count,
      66             :                                         uint32_t *countWritten);
      67             : 
      68             :   // overload of Http2Stream
      69           0 :   virtual bool HasSink() override { return !!mConsumerStream; }
      70             : 
      71           0 :   nsCString &GetRequestString() { return mRequestString; }
      72             : 
      73             : private:
      74             : 
      75             :   Http2Stream *mConsumerStream; // paired request stream that consumes from
      76             :                                 // real http/2 one.. null until a match is made.
      77             : 
      78             :   nsCOMPtr<nsIRequestContext> mRequestContext;
      79             : 
      80             :   nsAHttpTransaction *mAssociatedTransaction;
      81             : 
      82             :   Http2PushTransactionBuffer *mBufferedPush;
      83             :   mozilla::TimeStamp mLastRead;
      84             : 
      85             :   nsCString mHashKey;
      86             :   nsresult mStatus;
      87             :   bool mPushCompleted; // server push FIN received
      88             :   bool mDeferCleanupOnSuccess;
      89             : 
      90             :   // mDeferCleanupOnPush prevents Http2Session::CleanupStream() from
      91             :   // destroying the push stream on an error code during the period between
      92             :   // when we need to do OnPush() on another thread and the time it takes
      93             :   // for that event to create a synthetic pull stream attached to this
      94             :   // object. That synthetic pull will become mConsuemerStream.
      95             :   // Ths is essentially a delete protecting reference.
      96             :   bool mDeferCleanupOnPush;
      97             :   bool mOnPushFailed;
      98             :   nsCString mRequestString;
      99             : 
     100             : };
     101             : 
     102             : class Http2PushTransactionBuffer final : public nsAHttpTransaction
     103             : {
     104             : public:
     105             :   NS_DECL_ISUPPORTS
     106             :   NS_DECL_NSAHTTPTRANSACTION
     107             : 
     108             :   Http2PushTransactionBuffer();
     109             : 
     110             :   MOZ_MUST_USE nsresult GetBufferedData(char *buf, uint32_t count,
     111             :                                         uint32_t *countWritten);
     112           0 :   void SetPushStream(Http2PushedStream *stream) { mPushStream = stream; }
     113             : 
     114             : private:
     115             :   virtual ~Http2PushTransactionBuffer();
     116             :   uint64_t Available();
     117             : 
     118             :   const static uint32_t kDefaultBufferSize = 4096;
     119             : 
     120             :   nsresult mStatus;
     121             :   nsHttpRequestHead *mRequestHead;
     122             :   Http2PushedStream *mPushStream;
     123             :   bool mIsDone;
     124             : 
     125             :   UniquePtr<char[]> mBufferedHTTP1;
     126             :   uint32_t mBufferedHTTP1Size;
     127             :   uint32_t mBufferedHTTP1Used;
     128             :   uint32_t mBufferedHTTP1Consumed;
     129             : };
     130             : 
     131             : } // namespace net
     132             : } // namespace mozilla
     133             : 
     134             : #endif // mozilla_net_Http2Push_Internal_h

Generated by: LCOV version 1.13