/src/mozilla-central/accessible/xpcom/xpcAccessibilityService.h
Line | Count | Source (jump to first uncovered line) |
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/. */ |
4 | | |
5 | | #ifndef mozilla_a11y_xpcAccessibilityService_h_ |
6 | | #define mozilla_a11y_xpcAccessibilityService_h_ |
7 | | |
8 | | #include "nsIAccessibilityService.h" |
9 | | |
10 | | class xpcAccessibilityService : public nsIAccessibilityService |
11 | | { |
12 | | |
13 | | public: |
14 | | NS_DECL_ISUPPORTS |
15 | | NS_DECL_NSIACCESSIBILITYSERVICE |
16 | | |
17 | | /** |
18 | | * Return true if xpc accessibility service is in use. |
19 | | */ |
20 | 0 | static bool IsInUse() { |
21 | 0 | // When ref count goes down to 1 (held internally as a static reference), |
22 | 0 | // it means that there are no more external references and thus it is not in |
23 | 0 | // use. |
24 | 0 | return gXPCAccessibilityService ? gXPCAccessibilityService->mRefCnt > 1 : false; |
25 | 0 | } |
26 | | |
27 | | protected: |
28 | 0 | virtual ~xpcAccessibilityService() { |
29 | 0 | if (mShutdownTimer) { |
30 | 0 | mShutdownTimer->Cancel(); |
31 | 0 | mShutdownTimer = nullptr; |
32 | 0 | } |
33 | 0 | gXPCAccessibilityService = nullptr; |
34 | 0 | } |
35 | | |
36 | | private: |
37 | | // xpcAccessibilityService creation is controlled by friend |
38 | | // NS_GetAccessibilityService, keep constructor private. |
39 | 0 | xpcAccessibilityService() { }; |
40 | | |
41 | | nsCOMPtr<nsITimer> mShutdownTimer; |
42 | | |
43 | | /** |
44 | | * Reference for xpc accessibility service instance. |
45 | | */ |
46 | | static xpcAccessibilityService* gXPCAccessibilityService; |
47 | | |
48 | | /** |
49 | | * Used to shutdown nsAccessibilityService if xpcom accessible service is not |
50 | | * in use any more. |
51 | | */ |
52 | | static void ShutdownCallback(nsITimer* aTimer, void* aClosure); |
53 | | |
54 | | friend nsresult NS_GetAccessibilityService(nsIAccessibilityService** aResult); |
55 | | }; |
56 | | |
57 | | // for component registration |
58 | | // {3b265b69-f813-48ff-880d-d88d101af404} |
59 | | #define NS_ACCESSIBILITY_SERVICE_CID \ |
60 | | { 0x3b265b69, 0xf813, 0x48ff, { 0x88, 0x0d, 0xd8, 0x8d, 0x10, 0x1a, 0xf4, 0x04 } } |
61 | | |
62 | | extern nsresult |
63 | | NS_GetAccessibilityService(nsIAccessibilityService** aResult); |
64 | | |
65 | | #endif |