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 file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef mozilla_a11y_xpcAccessibilityService_h_
6 #define mozilla_a11y_xpcAccessibilityService_h_
8 #include "nsIAccessibilityService.h"
11 class xpcAccessibilityService
: public nsIAccessibilityService
{
14 NS_DECL_NSIACCESSIBILITYSERVICE
17 * Return true if xpc accessibility service is in use.
19 static bool IsInUse() {
20 // When ref count goes down to 1 (held internally as a static reference),
21 // it means that there are no more external references and thus it is not in
23 return gXPCAccessibilityService
? gXPCAccessibilityService
->mRefCnt
> 1
28 virtual ~xpcAccessibilityService() {
30 mShutdownTimer
->Cancel();
31 mShutdownTimer
= nullptr;
33 gXPCAccessibilityService
= nullptr;
37 // xpcAccessibilityService creation is controlled by friend
38 // NS_GetAccessibilityService, keep constructor private.
39 xpcAccessibilityService() = default;
41 nsCOMPtr
<nsITimer
> mShutdownTimer
;
44 * Reference for xpc accessibility service instance.
46 static xpcAccessibilityService
* gXPCAccessibilityService
;
49 * Used to shutdown nsAccessibilityService if xpcom accessible service is not
52 static void ShutdownCallback(nsITimer
* aTimer
, void* aClosure
);
54 friend nsresult
NS_GetAccessibilityService(nsIAccessibilityService
** aResult
);
57 // for component registration
58 // {3b265b69-f813-48ff-880d-d88d101af404}
59 #define NS_ACCESSIBILITY_SERVICE_CID \
61 0x3b265b69, 0xf813, 0x48ff, { \
62 0x88, 0x0d, 0xd8, 0x8d, 0x10, 0x1a, 0xf4, 0x04 \
66 extern nsresult
NS_GetAccessibilityService(nsIAccessibilityService
** aResult
);