Bug 1673311 [wpt PR 26282] - Fieldset NG: Percentage heights for content elements...
[gecko.git] / widget / gtk / WakeLockListener.h
blob4f163434dfdf74956c244fabecd34037c1b637bc
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:expandtab:shiftwidth=2:tabstop=2:
3 */
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #ifndef __WakeLockListener_h__
9 #define __WakeLockListener_h__
11 #include <unistd.h>
13 #include "mozilla/StaticPtr.h"
14 #include "nsHashKeys.h"
15 #include "nsClassHashtable.h"
17 #include "nsIDOMWakeLockListener.h"
19 #ifdef MOZ_ENABLE_DBUS
20 # include "mozilla/DBusHelpers.h"
21 #endif
23 class WakeLockTopic;
25 /**
26 * Receives WakeLock events and simply passes it on to the right WakeLockTopic
27 * to inhibit the screensaver.
29 class WakeLockListener final : public nsIDOMMozWakeLockListener {
30 public:
31 NS_DECL_ISUPPORTS;
33 static WakeLockListener* GetSingleton(bool aCreate = true);
34 static void Shutdown();
36 virtual nsresult Callback(const nsAString& topic,
37 const nsAString& state) override;
39 private:
40 WakeLockListener();
41 ~WakeLockListener() = default;
43 bool EnsureDBusConnection();
45 static mozilla::StaticRefPtr<WakeLockListener> sSingleton;
47 #ifdef MOZ_ENABLE_DBUS
48 RefPtr<DBusConnection> mConnection;
49 #endif
50 // Map of topic names to |WakeLockTopic|s.
51 // We assume a small, finite-sized set of topics.
52 nsClassHashtable<nsStringHashKey, WakeLockTopic> mTopics;
55 #endif // __WakeLockListener_h__