|
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_dom_IccListener_h |
|
6 #define mozilla_dom_IccListener_h |
|
7 |
|
8 #include "nsAutoPtr.h" |
|
9 #include "nsIIccProvider.h" |
|
10 |
|
11 namespace mozilla { |
|
12 namespace dom { |
|
13 |
|
14 class IccManager; |
|
15 class Icc; |
|
16 |
|
17 class IccListener : public nsIIccListener |
|
18 { |
|
19 public: |
|
20 NS_DECL_ISUPPORTS |
|
21 NS_DECL_NSIICCLISTENER |
|
22 |
|
23 IccListener(IccManager* aIccManager, uint32_t aClientId); |
|
24 ~IccListener(); |
|
25 |
|
26 void |
|
27 Shutdown(); |
|
28 |
|
29 already_AddRefed<Icc> |
|
30 GetIcc() |
|
31 { |
|
32 nsRefPtr<Icc> icc = mIcc; |
|
33 return icc.forget(); |
|
34 } |
|
35 |
|
36 private: |
|
37 uint32_t mClientId; |
|
38 // We did not setup 'mIcc' and 'mIccManager' being a participant of cycle |
|
39 // collection is because in Navigator->Invalidate() it will call |
|
40 // mIccManager->Shutdown(), then IccManager will call Shutdown() of each |
|
41 // IccListener, this will release the reference and break the cycle. |
|
42 nsRefPtr<Icc> mIcc; |
|
43 nsRefPtr<IccManager> mIccManager; |
|
44 // mProvider is a xpcom service and will be released at shutdown, so it |
|
45 // doesn't need to be cycle collected. |
|
46 nsCOMPtr<nsIIccProvider> mProvider; |
|
47 }; |
|
48 |
|
49 } // namespace dom |
|
50 } // namespace mozilla |
|
51 |
|
52 #endif // mozilla_dom_IccListener_h |