LCOV - code coverage report
Current view: top level - dom/base - IdleDeadline.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 11 24 45.8 %
Date: 2017-07-14 16:53:18 Functions: 7 12 58.3 %
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             : #include <algorithm>
       8             : 
       9             : #include "mozilla/dom/IdleDeadline.h"
      10             : #include "mozilla/dom/IdleDeadlineBinding.h"
      11             : #include "mozilla/dom/Performance.h"
      12             : #include "nsCOMPtr.h"
      13             : #include "nsCycleCollectionParticipant.h"
      14             : #include "nsDOMNavigationTiming.h"
      15             : #include "nsPIDOMWindow.h"
      16             : 
      17             : namespace mozilla {
      18             : namespace dom {
      19             : 
      20           3 : NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(IdleDeadline, mWindow)
      21           2 : NS_IMPL_CYCLE_COLLECTING_ADDREF(IdleDeadline)
      22           1 : NS_IMPL_CYCLE_COLLECTING_RELEASE(IdleDeadline)
      23          10 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IdleDeadline)
      24           1 :   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
      25           0 :   NS_INTERFACE_MAP_ENTRY(nsISupports)
      26           0 : NS_INTERFACE_MAP_END
      27             : 
      28           1 : IdleDeadline::IdleDeadline(nsPIDOMWindowInner* aWindow, bool aDidTimeout,
      29           1 :                            DOMHighResTimeStamp aDeadline)
      30             :   : mWindow(aWindow)
      31             :   , mDidTimeout(aDidTimeout)
      32           1 :   , mDeadline(aDeadline)
      33             : {
      34           1 : }
      35             : 
      36           0 : IdleDeadline::~IdleDeadline()
      37             : {
      38           0 : }
      39             : 
      40             : JSObject*
      41           1 : IdleDeadline::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
      42             : {
      43           1 :   return IdleDeadlineBinding::Wrap(aCx, this, aGivenProto);
      44             : }
      45             : 
      46             : DOMHighResTimeStamp
      47           0 : IdleDeadline::TimeRemaining()
      48             : {
      49           0 :   if (mDidTimeout) {
      50           0 :     return 0.0;
      51             :   }
      52             : 
      53           0 :   RefPtr<Performance> performance = mWindow->GetPerformance();
      54           0 :   if (!performance) {
      55             :     // If there is no performance object the window is partially torn
      56             :     // down, so we can safely say that there is no time remaining.
      57           0 :     return 0.0;
      58             :   }
      59             : 
      60           0 :   return std::max(mDeadline - performance->Now(), 0.0);
      61             : }
      62             : 
      63             : bool
      64           0 : IdleDeadline::DidTimeout() const
      65             : {
      66           0 :   return mDidTimeout;
      67             : }
      68             : 
      69             : } // namespace dom
      70             : } // namespace mozilla

Generated by: LCOV version 1.13