64
|
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, TBool aUseSwRendering);
|
|
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 |
|
|
75 |
/** Ask nice */
|
|
76 |
void ConditionalClose();
|
|
77 |
|
|
78 |
/** When the gentle push is not enough (i.e. force is required) **/
|
|
79 |
void KillTask();
|
|
80 |
|
|
81 |
void KillTaskWaitDone();
|
|
82 |
|
|
83 |
private:
|
|
84 |
|
|
85 |
CGOomCloseApp(MGOomActionObserver& aStateChangeObserver, RWsSession& aWs);
|
|
86 |
|
|
87 |
void ConstructL();
|
|
88 |
|
|
89 |
TUint iWgId;
|
|
90 |
TInt iCloseTimeout;
|
|
91 |
TInt iWaitAfterClose;
|
|
92 |
|
|
93 |
TBool iAppCloserRunning;
|
|
94 |
TApaTask iCurrentTask;
|
|
95 |
|
|
96 |
/**
|
|
97 |
* A timeout for an app close action
|
|
98 |
* Own
|
|
99 |
*/
|
|
100 |
CGOomAppCloseTimer* iAppCloseTimer;
|
|
101 |
|
|
102 |
/**
|
|
103 |
* A watcher for the application closing
|
|
104 |
* Own
|
|
105 |
*/
|
|
106 |
CGOomAppCloseWatcher* iAppCloseWatcher;
|
|
107 |
|
|
108 |
TBool iAlreadyGaveUp;
|
|
109 |
};
|
|
110 |
|
|
111 |
#include "goomcloseapp.inl"
|
|
112 |
|
|
113 |
#endif /*GOOMCLOSEAPP_H_*/
|