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/. */
7 #ifndef MOZILLA_LAYERS_ACTIVERESOURCE
8 #define MOZILLA_LAYERS_ACTIVERESOURCE
10 #include "nsExpirationTracker.h"
12 namespace mozilla::layers
{
15 * See ActiveResourceTracker below.
17 class ActiveResource
{
19 virtual void NotifyInactive() = 0;
20 nsExpirationState
* GetExpirationState() { return &mExpirationState
; }
21 bool IsActivityTracked() { return mExpirationState
.IsTracked(); }
24 nsExpirationState mExpirationState
;
28 * A convenience class on top of nsExpirationTracker
30 class ActiveResourceTracker final
31 : public nsExpirationTracker
<ActiveResource
, 3> {
33 ActiveResourceTracker(uint32_t aExpirationCycle
, const char* aName
,
34 nsIEventTarget
* aEventTarget
)
35 : nsExpirationTracker(aExpirationCycle
, aName
, aEventTarget
) {}
37 void NotifyExpired(ActiveResource
* aResource
) override
{
38 RemoveObject(aResource
);
39 aResource
->NotifyInactive();
43 } // namespace mozilla::layers