LCOV - code coverage report
Current view: top level - dom/base - nsDOMNavigationTiming.h (source / functions) Hit Total Coverage
Test: output.info Lines: 10 30 33.3 %
Date: 2017-07-14 16:53:18 Functions: 6 15 40.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       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 nsDOMNavigationTiming_h___
       8             : #define nsDOMNavigationTiming_h___
       9             : 
      10             : #include "nsCOMPtr.h"
      11             : #include "nsCOMArray.h"
      12             : #include "mozilla/WeakPtr.h"
      13             : #include "mozilla/TimeStamp.h"
      14             : 
      15             : class nsDocShell;
      16             : class nsIURI;
      17             : 
      18             : typedef unsigned long long DOMTimeMilliSec;
      19             : typedef double DOMHighResTimeStamp;
      20             : 
      21             : class nsDOMNavigationTiming final
      22             : {
      23             : public:
      24             :   enum Type {
      25             :     TYPE_NAVIGATE = 0,
      26             :     TYPE_RELOAD = 1,
      27             :     TYPE_BACK_FORWARD = 2,
      28             :     TYPE_RESERVED = 255,
      29             :   };
      30             : 
      31             :   explicit nsDOMNavigationTiming(nsDocShell* aDocShell);
      32             : 
      33         158 :   NS_INLINE_DECL_REFCOUNTING(nsDOMNavigationTiming)
      34             : 
      35           0 :   Type GetType() const
      36             :   {
      37           0 :     return mNavigationType;
      38             :   }
      39             : 
      40         124 :   inline DOMHighResTimeStamp GetNavigationStartHighRes() const
      41             :   {
      42         124 :     return mNavigationStartHighRes;
      43             :   }
      44             : 
      45         124 :   DOMTimeMilliSec GetNavigationStart() const
      46             :   {
      47         124 :     return static_cast<int64_t>(GetNavigationStartHighRes());
      48             :   }
      49             : 
      50         196 :   mozilla::TimeStamp GetNavigationStartTimeStamp() const
      51             :   {
      52         196 :     return mNavigationStartTimeStamp;
      53             :   }
      54             : 
      55             :   DOMTimeMilliSec GetUnloadEventStart();
      56             :   DOMTimeMilliSec GetUnloadEventEnd();
      57           0 :   DOMTimeMilliSec GetDomLoading() const
      58             :   {
      59           0 :     return mDOMLoading;
      60             :   }
      61           0 :   DOMTimeMilliSec GetDomInteractive() const
      62             :   {
      63           0 :     return mDOMInteractive;
      64             :   }
      65           0 :   DOMTimeMilliSec GetDomContentLoadedEventStart() const
      66             :   {
      67           0 :     return mDOMContentLoadedEventStart;
      68             :   }
      69           0 :   DOMTimeMilliSec GetDomContentLoadedEventEnd() const
      70             :   {
      71           0 :     return mDOMContentLoadedEventEnd;
      72             :   }
      73           0 :   DOMTimeMilliSec GetDomComplete() const
      74             :   {
      75           0 :     return mDOMComplete;
      76             :   }
      77           0 :   DOMTimeMilliSec GetLoadEventStart() const
      78             :   {
      79           0 :     return mLoadEventStart;
      80             :   }
      81           0 :   DOMTimeMilliSec GetLoadEventEnd() const
      82             :   {
      83           0 :     return mLoadEventEnd;
      84             :   }
      85           0 :   DOMTimeMilliSec GetTimeToNonBlankPaint() const
      86             :   {
      87           0 :     if (mNonBlankPaintTimeStamp.IsNull()) {
      88           0 :       return 0;
      89             :     }
      90             : 
      91           0 :     return TimeStampToDOMHighRes(mNonBlankPaintTimeStamp);
      92             :   }
      93             : 
      94             :   enum class DocShellState : uint8_t {
      95             :     eActive,
      96             :     eInactive
      97             :   };
      98             : 
      99             :   void NotifyNavigationStart(DocShellState aDocShellState);
     100             :   void NotifyFetchStart(nsIURI* aURI, Type aNavigationType);
     101             :   void NotifyBeforeUnload();
     102             :   void NotifyUnloadAccepted(nsIURI* aOldURI);
     103             :   void NotifyUnloadEventStart();
     104             :   void NotifyUnloadEventEnd();
     105             :   void NotifyLoadEventStart();
     106             :   void NotifyLoadEventEnd();
     107             : 
     108             :   // Document changes state to 'loading' before connecting to timing
     109             :   void SetDOMLoadingTimeStamp(nsIURI* aURI, mozilla::TimeStamp aValue);
     110             :   void NotifyDOMLoading(nsIURI* aURI);
     111             :   void NotifyDOMInteractive(nsIURI* aURI);
     112             :   void NotifyDOMComplete(nsIURI* aURI);
     113             :   void NotifyDOMContentLoadedStart(nsIURI* aURI);
     114             :   void NotifyDOMContentLoadedEnd(nsIURI* aURI);
     115             : 
     116             :   void NotifyNonBlankPaintForRootContentDocument();
     117             :   void NotifyDocShellStateChanged(DocShellState aDocShellState);
     118             : 
     119             :   DOMTimeMilliSec TimeStampToDOM(mozilla::TimeStamp aStamp) const;
     120             : 
     121          29 :   inline DOMHighResTimeStamp TimeStampToDOMHighRes(mozilla::TimeStamp aStamp) const
     122             :   {
     123          29 :     mozilla::TimeDuration duration = aStamp - mNavigationStartTimeStamp;
     124          29 :     return duration.ToMilliseconds();
     125             :   }
     126             : 
     127             : private:
     128             :   nsDOMNavigationTiming(const nsDOMNavigationTiming &) = delete;
     129             :   ~nsDOMNavigationTiming();
     130             : 
     131             :   void Clear();
     132             : 
     133             :   bool IsTopLevelContentDocument() const;
     134             : 
     135             :   mozilla::WeakPtr<nsDocShell> mDocShell;
     136             : 
     137             :   nsCOMPtr<nsIURI> mUnloadedURI;
     138             :   nsCOMPtr<nsIURI> mLoadedURI;
     139             : 
     140             :   Type mNavigationType;
     141             :   DOMHighResTimeStamp mNavigationStartHighRes;
     142             :   mozilla::TimeStamp mNavigationStartTimeStamp;
     143             :   mozilla::TimeStamp mNonBlankPaintTimeStamp;
     144             :   DOMTimeMilliSec DurationFromStart();
     145             : 
     146             :   DOMTimeMilliSec mBeforeUnloadStart;
     147             :   DOMTimeMilliSec mUnloadStart;
     148             :   DOMTimeMilliSec mUnloadEnd;
     149             :   DOMTimeMilliSec mLoadEventStart;
     150             :   DOMTimeMilliSec mLoadEventEnd;
     151             : 
     152             :   DOMTimeMilliSec mDOMLoading;
     153             :   DOMTimeMilliSec mDOMInteractive;
     154             :   DOMTimeMilliSec mDOMContentLoadedEventStart;
     155             :   DOMTimeMilliSec mDOMContentLoadedEventEnd;
     156             :   DOMTimeMilliSec mDOMComplete;
     157             : 
     158             :   // Booleans to keep track of what things we've already been notified
     159             :   // about.  We don't update those once we've been notified about them
     160             :   // once.
     161             :   bool mLoadEventStartSet : 1;
     162             :   bool mLoadEventEndSet : 1;
     163             :   bool mDOMLoadingSet : 1;
     164             :   bool mDOMInteractiveSet : 1;
     165             :   bool mDOMContentLoadedEventStartSet : 1;
     166             :   bool mDOMContentLoadedEventEndSet : 1;
     167             :   bool mDOMCompleteSet : 1;
     168             :   bool mDocShellHasBeenActiveSinceNavigationStart : 1;
     169             : };
     170             : 
     171             : #endif /* nsDOMNavigationTiming_h___ */

Generated by: LCOV version 1.13