2016-08-22 15:52:45 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_idlerequest_h
|
|
|
|
#define mozilla_dom_idlerequest_h
|
|
|
|
|
|
|
|
#include "mozilla/LinkedList.h"
|
|
|
|
#include "mozilla/Maybe.h"
|
2017-11-28 22:23:46 +03:00
|
|
|
#include "mozilla/RefPtr.h"
|
2016-08-22 15:52:45 +03:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsDOMNavigationTiming.h"
|
2017-01-19 07:26:17 +03:00
|
|
|
#include "nsICancelableRunnable.h"
|
|
|
|
#include "nsIRunnable.h"
|
|
|
|
#include "nsString.h"
|
2016-08-22 15:52:45 +03:00
|
|
|
|
|
|
|
class nsPIDOMWindowInner;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class IdleRequestCallback;
|
|
|
|
|
2017-11-28 22:23:46 +03:00
|
|
|
class IdleRequest final : public LinkedListElement<RefPtr<IdleRequest>> {
|
2016-08-22 15:52:45 +03:00
|
|
|
public:
|
2016-11-08 15:54:40 +03:00
|
|
|
IdleRequest(IdleRequestCallback* aCallback, uint32_t aHandle);
|
2016-08-22 15:52:45 +03:00
|
|
|
|
2019-03-19 10:22:05 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
void IdleRun(nsPIDOMWindowInner* aWindow, DOMHighResTimeStamp aDeadline,
|
|
|
|
bool aDidTimeout);
|
2016-08-22 15:52:45 +03:00
|
|
|
|
2016-11-08 15:54:40 +03:00
|
|
|
void SetTimeoutHandle(int32_t aHandle);
|
|
|
|
bool HasTimeout() const { return mTimeoutHandle.isSome(); }
|
2017-01-31 18:25:49 +03:00
|
|
|
uint32_t GetTimeoutHandle() const;
|
2016-08-22 15:52:45 +03:00
|
|
|
|
|
|
|
uint32_t Handle() const { return mHandle; }
|
|
|
|
|
2017-11-28 22:23:46 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(IdleRequest)
|
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(IdleRequest)
|
2016-08-22 15:52:45 +03:00
|
|
|
private:
|
|
|
|
~IdleRequest();
|
|
|
|
|
|
|
|
RefPtr<IdleRequestCallback> mCallback;
|
2016-11-08 15:54:40 +03:00
|
|
|
const uint32_t mHandle;
|
2016-08-22 15:52:45 +03:00
|
|
|
mozilla::Maybe<int32_t> mTimeoutHandle;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_idlerequest_h
|