|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Classes for executing GOOM actions (e.g. closing applications and running plugins). |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef GOOMCLOSEAPP_H_ |
|
20 #define GOOMCLOSEAPP_H_ |
|
21 |
|
22 |
|
23 #include <apgtask.h> |
|
24 |
|
25 #include "goomaction.h" |
|
26 |
|
27 class CGOomAppCloseTimer; |
|
28 class CGOomAppCloseWatcher; |
|
29 class TApaTask; |
|
30 class TActionRef; |
|
31 |
|
32 /* |
|
33 * The OOM action of closing an application in order to free up memory. |
|
34 * |
|
35 * @lib oommonitor.lib |
|
36 * @since S60 v5.0 |
|
37 */ |
|
38 NONSHARABLE_CLASS(CGOomCloseApp) : public CGOomAction |
|
39 { |
|
40 public: |
|
41 /** |
|
42 * Two-phased constructor. |
|
43 * @param aStateChangeObserver an observer to the state of the application |
|
44 * @param aWs a connected handle to a window server session |
|
45 */ |
|
46 static CGOomCloseApp* NewL(MGOomActionObserver& aStateChangeObserver, RWsSession& aWs); |
|
47 |
|
48 //from CGOomAction |
|
49 |
|
50 /** |
|
51 * Close the application in order to free memory |
|
52 * Call the CGOomAction::MemoryFreed when it is done |
|
53 * @param aBytesRequested not used for clsoe app actions |
|
54 */ |
|
55 virtual void FreeMemory(TInt aBytesRequested); |
|
56 |
|
57 ~CGOomCloseApp(); |
|
58 |
|
59 /** |
|
60 * Callback from CGOomAppCloseWatcher and CGOomAppCloseTimer |
|
61 */ |
|
62 void CloseAppEvent(); |
|
63 |
|
64 inline TBool IsRunning(); |
|
65 |
|
66 /** |
|
67 * Configure, or reconfigure the CGOomCloseApp object |
|
68 * Action objects are reused to minimize any memory allocation when memory is low |
|
69 */ |
|
70 void Reconfigure(const TActionRef& aRef); |
|
71 |
|
72 inline TUint WgId() const; |
|
73 |
|
74 /** When the gentle push is not enough (i.e. force is required) **/ |
|
75 void KillTask(); |
|
76 |
|
77 void KillTaskWaitDone(); |
|
78 |
|
79 private: |
|
80 |
|
81 CGOomCloseApp(MGOomActionObserver& aStateChangeObserver, RWsSession& aWs); |
|
82 |
|
83 void ConstructL(); |
|
84 |
|
85 TUint iWgId; |
|
86 |
|
87 TBool iAppCloserRunning; |
|
88 TApaTask iCurrentTask; |
|
89 |
|
90 /** |
|
91 * A timeout for an app close action |
|
92 * Own |
|
93 */ |
|
94 CGOomAppCloseTimer* iAppCloseTimer; |
|
95 |
|
96 /** |
|
97 * A watcher for the application closing |
|
98 * Own |
|
99 */ |
|
100 CGOomAppCloseWatcher* iAppCloseWatcher; |
|
101 }; |
|
102 |
|
103 #include "goomcloseapp.inl" |
|
104 |
|
105 #endif /*GOOMCLOSEAPP_H_*/ |