no bug - Import translations from android-l10n r=release a=l10n CLOSED TREE
[gecko.git] / gfx / layers / ipc / ActiveResource.h
blob6e7db6054168f614f787a22167c41fbaad1a341a
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 {
14 /**
15 * See ActiveResourceTracker below.
17 class ActiveResource {
18 public:
19 virtual void NotifyInactive() = 0;
20 nsExpirationState* GetExpirationState() { return &mExpirationState; }
21 bool IsActivityTracked() { return mExpirationState.IsTracked(); }
23 private:
24 nsExpirationState mExpirationState;
27 /**
28 * A convenience class on top of nsExpirationTracker
30 class ActiveResourceTracker final
31 : public nsExpirationTracker<ActiveResource, 3> {
32 public:
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
45 #endif