LCOV - code coverage report
Current view: top level - dom/base - IdleRequest.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 22 26 84.6 %
Date: 2017-07-14 16:53:18 Functions: 7 11 63.6 %
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             : #include "IdleRequest.h"
       8             : 
       9             : #include "mozilla/TimeStamp.h"
      10             : #include "mozilla/dom/IdleDeadline.h"
      11             : #include "mozilla/dom/PerformanceTiming.h"
      12             : #include "mozilla/dom/TimeoutManager.h"
      13             : #include "mozilla/dom/WindowBinding.h"
      14             : #include "nsComponentManagerUtils.h"
      15             : #include "nsGlobalWindow.h"
      16             : #include "nsISupportsPrimitives.h"
      17             : #include "nsPIDOMWindow.h"
      18             : 
      19             : namespace mozilla {
      20             : namespace dom {
      21             : 
      22           3 : IdleRequest::IdleRequest(IdleRequestCallback* aCallback, uint32_t aHandle)
      23             :   : mCallback(aCallback)
      24             :   , mHandle(aHandle)
      25           3 :   , mTimeoutHandle(Nothing())
      26             : {
      27           3 :   MOZ_DIAGNOSTIC_ASSERT(mCallback);
      28           3 : }
      29             : 
      30           0 : IdleRequest::~IdleRequest()
      31             : {
      32           0 : }
      33             : 
      34           0 : NS_IMPL_CYCLE_COLLECTION(IdleRequest, mCallback)
      35             : 
      36           9 : NS_IMPL_CYCLE_COLLECTING_ADDREF(IdleRequest)
      37           5 : NS_IMPL_CYCLE_COLLECTING_RELEASE(IdleRequest)
      38             : 
      39           3 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IdleRequest)
      40           0 : NS_INTERFACE_MAP_END
      41             : 
      42             : void
      43           2 : IdleRequest::SetTimeoutHandle(int32_t aHandle)
      44             : {
      45           2 :   mTimeoutHandle = Some(aHandle);
      46           2 : }
      47             : 
      48             : uint32_t
      49           1 : IdleRequest::GetTimeoutHandle() const
      50             : {
      51           1 :   MOZ_DIAGNOSTIC_ASSERT(mTimeoutHandle.isSome());
      52           1 :   return mTimeoutHandle.value();
      53             : }
      54             : 
      55             : nsresult
      56           1 : IdleRequest::IdleRun(nsPIDOMWindowInner* aWindow,
      57             :                      DOMHighResTimeStamp aDeadline,
      58             :                      bool aDidTimeout)
      59             : {
      60           1 :   MOZ_ASSERT(NS_IsMainThread());
      61           1 :   MOZ_DIAGNOSTIC_ASSERT(mCallback);
      62             : 
      63           2 :   ErrorResult error;
      64             :   RefPtr<IdleDeadline> deadline =
      65           2 :     new IdleDeadline(aWindow, aDidTimeout, aDeadline);
      66           1 :   mCallback->Call(*deadline, error, "requestIdleCallback handler");
      67             : 
      68           1 :   mCallback = nullptr;
      69           1 :   error.SuppressException();
      70           2 :   return error.StealNSResult();
      71             : }
      72             : 
      73             : } // namespace dom
      74             : } // namespace mozilla

Generated by: LCOV version 1.13