Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / widget / cocoa / nsUserIdleServiceX.h
blobff559293e95df481a1c689cc51b66b04dcb6cce6
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef nsUserIdleServiceX_h_
6 #define nsUserIdleServiceX_h_
8 #include "nsUserIdleService.h"
9 #include "mozilla/AppShutdown.h"
11 class nsUserIdleServiceX : public nsUserIdleService {
12 public:
13 NS_INLINE_DECL_REFCOUNTING_INHERITED(nsUserIdleServiceX, nsUserIdleService)
15 bool PollIdleTime(uint32_t* aIdleTime) override;
17 static already_AddRefed<nsUserIdleServiceX> GetInstance() {
18 RefPtr<nsUserIdleService> idleService = nsUserIdleService::GetInstance();
19 if (!idleService) {
20 // Avoid late instantiation or resurrection during shutdown.
21 if (mozilla::AppShutdown::IsInOrBeyond(
22 mozilla::ShutdownPhase::AppShutdownConfirmed)) {
23 return nullptr;
25 idleService = new nsUserIdleServiceX();
28 return idleService.forget().downcast<nsUserIdleServiceX>();
31 protected:
32 nsUserIdleServiceX() {}
33 virtual ~nsUserIdleServiceX() {}
36 #endif // nsUserIdleServiceX_h_