LCOV - code coverage report
Current view: top level - netwerk/protocol/http - NullHttpTransaction.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 6 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 5 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             : 
       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/. */
       6             : 
       7             : #ifndef mozilla_net_NullHttpTransaction_h
       8             : #define mozilla_net_NullHttpTransaction_h
       9             : 
      10             : #include "nsAHttpTransaction.h"
      11             : #include "mozilla/Attributes.h"
      12             : 
      13             : // This is the minimal nsAHttpTransaction implementation. A NullHttpTransaction
      14             : // can be used to drive connection level semantics (such as SSL handshakes
      15             : // tunnels) so that a nsHttpConnection becomes fully established in
      16             : // anticipation of a real transaction needing to use it soon.
      17             : 
      18             : class nsIHttpActivityObserver;
      19             : 
      20             : namespace mozilla { namespace net {
      21             : 
      22             : class nsAHttpConnection;
      23             : class nsHttpConnectionInfo;
      24             : class nsHttpRequestHead;
      25             : 
      26             : // 6c445340-3b82-4345-8efa-4902c3b8805a
      27             : #define NS_NULLHTTPTRANSACTION_IID \
      28             : { 0x6c445340, 0x3b82, 0x4345, {0x8e, 0xfa, 0x49, 0x02, 0xc3, 0xb8, 0x80, 0x5a }}
      29             : 
      30             : class NullHttpTransaction : public nsAHttpTransaction
      31             : {
      32             : public:
      33             :   NS_DECLARE_STATIC_IID_ACCESSOR(NS_NULLHTTPTRANSACTION_IID)
      34             :   NS_DECL_THREADSAFE_ISUPPORTS
      35             :   NS_DECL_NSAHTTPTRANSACTION
      36             : 
      37             :   NullHttpTransaction(nsHttpConnectionInfo *ci,
      38             :                       nsIInterfaceRequestor *callbacks,
      39             :                       uint32_t caps);
      40             : 
      41             :   MOZ_MUST_USE bool Claim();
      42             :   void Unclaim();
      43             : 
      44             :   // Overload of nsAHttpTransaction methods
      45           0 :   bool IsNullTransaction() override final { return true; }
      46           0 :   NullHttpTransaction *QueryNullTransaction() override final { return this; }
      47           0 :   bool ResponseTimeoutEnabled() const override final {return true; }
      48           0 :   PRIntervalTime ResponseTimeout() override final
      49             :   {
      50           0 :     return PR_SecondsToInterval(15);
      51             :   }
      52             : 
      53             :   // We have to override this function because |mTransaction| in nsHalfOpenSocket
      54             :   // could be either nsHttpTransaction or NullHttpTransaction.
      55             :   // NullHttpTransaction will be activated on the connection immediately after
      56             :   // creation and be never put in a pending queue, so it's OK to just return 0.
      57           0 :   uint64_t TopLevelOuterContentWindowId() override { return 0; }
      58             : 
      59             : protected:
      60             :   virtual ~NullHttpTransaction();
      61             : 
      62             : private:
      63             :   nsresult mStatus;
      64             : protected:
      65             :   uint32_t mCaps;
      66             :   nsHttpRequestHead *mRequestHead;
      67             : private:
      68             :   // mCapsToClear holds flags that should be cleared in mCaps, e.g. unset
      69             :   // NS_HTTP_REFRESH_DNS when DNS refresh request has completed to avoid
      70             :   // redundant requests on the network. The member itself is atomic, but
      71             :   // access to it from the networking thread may happen either before or
      72             :   // after the main thread modifies it. To deal with raciness, only unsetting
      73             :   // bitfields should be allowed: 'lost races' will thus err on the
      74             :   // conservative side, e.g. by going ahead with a 2nd DNS refresh.
      75             :   Atomic<uint32_t> mCapsToClear;
      76             :   bool mIsDone;
      77             :   bool mClaimed;
      78             : 
      79             : protected:
      80             :   RefPtr<nsAHttpConnection> mConnection;
      81             :   nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
      82             :   RefPtr<nsHttpConnectionInfo> mConnectionInfo;
      83             :   nsCOMPtr<nsIHttpActivityObserver> mActivityDistributor;
      84             : };
      85             : 
      86             : NS_DEFINE_STATIC_IID_ACCESSOR(NullHttpTransaction, NS_NULLHTTPTRANSACTION_IID)
      87             : 
      88             : } // namespace net
      89             : } // namespace mozilla
      90             : 
      91             : #endif // mozilla_net_NullHttpTransaction_h

Generated by: LCOV version 1.13