LCOV - code coverage report
Current view: top level - dom/base - Timeout.h (source / functions) Hit Total Coverage
Test: output.info Lines: 3 3 100.0 %
Date: 2017-07-14 16:53:18 Functions: 6 7 85.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim:set ts=2 sw=2 sts=2 et cindent: */
       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_dom_timeout_h
       8             : #define mozilla_dom_timeout_h
       9             : 
      10             : #include "mozilla/LinkedList.h"
      11             : #include "mozilla/TimeStamp.h"
      12             : #include "nsCOMPtr.h"
      13             : #include "nsCycleCollectionParticipant.h"
      14             : #include "nsGlobalWindow.h"
      15             : #include "nsITimeoutHandler.h"
      16             : 
      17             : class nsIEventTarget;
      18             : class nsIPrincipal;
      19             : class nsIEventTarget;
      20             : 
      21             : namespace mozilla {
      22             : namespace dom {
      23             : 
      24             : /*
      25             :  * Timeout struct that holds information about each script
      26             :  * timeout.  Holds a strong reference to an nsITimeoutHandler, which
      27             :  * abstracts the language specific cruft.
      28             :  */
      29             : class Timeout final
      30             :   : public LinkedListElement<RefPtr<Timeout>>
      31             : {
      32             : public:
      33             :   Timeout();
      34             : 
      35         289 :   NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(Timeout)
      36         265 :   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(Timeout)
      37             : 
      38             :   enum class Reason
      39             :   {
      40             :     eTimeoutOrInterval,
      41             :     eIdleCallbackTimeout,
      42             :   };
      43             : 
      44             :   void SetWhenOrTimeRemaining(const TimeStamp& aBaseTime,
      45             :                               const TimeDuration& aDelay);
      46             : 
      47             :   // Can only be called when not frozen.
      48             :   const TimeStamp& When() const;
      49             : 
      50             :   // Can only be called when frozen.
      51             :   const TimeDuration& TimeRemaining() const;
      52             : 
      53             :   // Window for which this timeout fires
      54             :   RefPtr<nsGlobalWindow> mWindow;
      55             : 
      56             :   // True if the timeout was cleared
      57             :   bool mCleared;
      58             : 
      59             :   // True if this is one of the timeouts that are currently running
      60             :   bool mRunning;
      61             : 
      62             :   // True if this is a repeating/interval timer
      63             :   bool mIsInterval;
      64             : 
      65             :   // True if this is a timeout coming from a tracking script
      66             :   bool mIsTracking;
      67             : 
      68             :   // Used to allow several reasons for setting a timeout, where each
      69             :   // 'Reason' value is using a possibly overlapping set of id:s.
      70             :   Reason mReason;
      71             : 
      72             :   // Returned as value of setTimeout()
      73             :   uint32_t mTimeoutId;
      74             : 
      75             :   // Interval
      76             :   TimeDuration mInterval;
      77             : 
      78             :   // Identifies which firing level this Timeout is being processed in
      79             :   // when sync loops trigger nested firing.
      80             :   uint32_t mFiringId;
      81             : 
      82             :   uint32_t mNestingLevel;
      83             : 
      84             :   // The popup state at timeout creation time if not created from
      85             :   // another timeout
      86             :   PopupControlState mPopupState;
      87             : 
      88             :   // The language-specific information about the callback.
      89             :   nsCOMPtr<nsITimeoutHandler> mScriptHandler;
      90             : 
      91             : private:
      92             :   // mWhen and mTimeRemaining can't be in a union, sadly, because they
      93             :   // have constructors.
      94             :   // Nominal time to run this timeout.  Use only when timeouts are not
      95             :   // frozen.
      96             :   TimeStamp mWhen;
      97             : 
      98             :   // Remaining time to wait.  Used only when timeouts are frozen.
      99             :   TimeDuration mTimeRemaining;
     100             : 
     101           6 :   ~Timeout() = default;
     102             : };
     103             : 
     104             : } // namespace dom
     105             : } // namespace mozilla
     106             : 
     107             : #endif // mozilla_dom_timeout_h

Generated by: LCOV version 1.13