|
1 /* |
|
2 * Copyright (c) 2006-2009 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: Client/server interface for GOOM Monitor. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef R_GOOMMONITORSESSION_H |
|
20 #define R_GOOMMONITORSESSION_H |
|
21 |
|
22 #include <e32std.h> |
|
23 |
|
24 /** |
|
25 * The maximum amount of memory that can be allocated without permission. |
|
26 */ |
|
27 const TInt KGOomMaxAllocationWithoutPermission = 1048576; |
|
28 |
|
29 /** |
|
30 * The client interface for GOOM (Out Of Memory) monitor. |
|
31 * |
|
32 * @lib oommonitor.lib |
|
33 */ |
|
34 class RGOomMonitorSession : public RSessionBase |
|
35 { |
|
36 public: |
|
37 |
|
38 /** Defines the application priorities of GOOM monitor. */ |
|
39 enum TGOomPriority |
|
40 { |
|
41 /** |
|
42 * Application can be closed if needed. |
|
43 */ |
|
44 EGOomPriorityNormal = 0, |
|
45 |
|
46 /** |
|
47 * Application should not be closed if possible. |
|
48 */ |
|
49 EGOomPriorityHigh, |
|
50 |
|
51 /** |
|
52 * Application is busy and should not be closed. |
|
53 */ |
|
54 EGOomPriorityBusy |
|
55 }; |
|
56 |
|
57 public: |
|
58 /** |
|
59 * Connects a new session. |
|
60 * Sessions must be connected before any other APIs can be used. |
|
61 * When the client has finished using a session, Close() must be called. |
|
62 * @return KErrNone if successful, error code otherwise. |
|
63 */ |
|
64 IMPORT_C TInt Connect(); |
|
65 |
|
66 /** |
|
67 * Tells whether Goom FW is really present and connected |
|
68 * In some platforms, there's no need for GOOM to run |
|
69 * and all operations do just nothing |
|
70 */ |
|
71 IMPORT_C TBool IsConnected(); |
|
72 |
|
73 /** |
|
74 * Request that the GOOM monitor attempts to free some memory. |
|
75 * This function may take several seconds to execute, depending on |
|
76 * the memory state. It will not return until the attempt to recover |
|
77 * memory has completed. |
|
78 * @param aBytesRequested The number of bytes of free memory that the client requests. |
|
79 * @return KErrNone if the request memory is free. KErrNoMemory if that |
|
80 * amount of memory could not be recovered. |
|
81 */ |
|
82 IMPORT_C TInt RequestFreeMemory(TInt aBytesRequested); |
|
83 |
|
84 /** |
|
85 * Request that the GOOM monitor attempts to free some memory. |
|
86 * This is an asynchronous version of the request for free memory. |
|
87 * @param aBytesRequested The number of bytes of free memory that the client requests. |
|
88 * @param aStatus will be completed when the attempt to recover memory |
|
89 * has finished. This may take several seconds, depending on |
|
90 * the memory state. On completion, aStatus will be set to |
|
91 * KErrNone if the request memory is free. KErrNoMemory if that |
|
92 * amount of memory could not be recovered. |
|
93 */ |
|
94 IMPORT_C void RequestFreeMemory(TInt aBytesRequested, TRequestStatus& aStatus); |
|
95 |
|
96 /** |
|
97 * Request that the GOOM monitor attempts to free some memory for an optional allocation. |
|
98 * The passed in plugin ID is used to determine the priority for this allocation. |
|
99 * Lower priority OOM actions may be executed to free enough RAM for this allocation. |
|
100 * This function may take several seconds to execute, depending on |
|
101 * the memory state. It will not return until the attempt to recover |
|
102 * memory has completed. |
|
103 * @param aBytesRequested The number of bytes of free memory that the client requests. |
|
104 * @param aPluginId The ID of the plugin that may delete the allocation in event of low memory. |
|
105 * @return KErrNone if the request memory is free. KErrNoMemory if that |
|
106 * amount of memory could not be recovered. |
|
107 */ |
|
108 IMPORT_C TInt RequestOptionalRam(TInt aBytesRequested, TInt aMinimumBytesNeeded, TInt aPluginId, TInt& aBytesAvailable); |
|
109 |
|
110 /** |
|
111 * Request that the GOOM monitor attempts to free some memory for an optional allocation. |
|
112 * The passed in plugin ID is used to determine the priority for this allocation. |
|
113 * Lower priority OOM actions may be executed to free enough RAM for this allocation. |
|
114 * This function may take several seconds to execute, depending on |
|
115 * the memory state. It will not return until the attempt to recover |
|
116 * memory has completed. |
|
117 * @param aBytesRequested The number of bytes of free memory that the client requests. |
|
118 * @param aPluginId The ID of the plugin that may delete the allocation in event of low memory. |
|
119 * @param aStatus The TRequestStatus (completes with the number of bytes freed (aStatus >= 0) or an error (aStatus <= 0)) |
|
120 * @return None |
|
121 */ |
|
122 IMPORT_C void RequestOptionalRam(TInt aBytesRequested, TInt aMinimumBytesNeeded, TInt aPluginId, TRequestStatus& aStatus); |
|
123 |
|
124 /** |
|
125 * Cancels the asynchronous request for free memory. |
|
126 */ |
|
127 IMPORT_C void CancelRequestFreeMemory(); |
|
128 |
|
129 /** |
|
130 * Notify the GOOM monitor that this application is not responding |
|
131 * to the EEikCmdExit request to exit the application. |
|
132 * This function is used by the Avkon framework's app shutter. |
|
133 * @param aWgId the window group identifier of the app that is not exiting. |
|
134 */ |
|
135 IMPORT_C void ThisAppIsNotExiting(TInt aWgId); |
|
136 |
|
137 /** |
|
138 * Notify the GOOM monitor that this application has the specified priority |
|
139 * @param aPriority the priority of the application |
|
140 */ |
|
141 IMPORT_C void SetGOomPriority(TGOomPriority aPriority); |
|
142 |
|
143 /** |
|
144 * Notify the GOOM monitor that this application about to laucnh |
|
145 * effectively set the application specific threshold if found from |
|
146 * config file |
|
147 * @param aAppUid the identifier of the application |
|
148 */ |
|
149 IMPORT_C void ApplicationAboutToStart(const TUid& aAppUid); |
|
150 |
|
151 /** |
|
152 * Tell goom that number requested by application should be used as such |
|
153 * and not combined with currently active global threshold |
|
154 * @param aUseAbsoluteAmount whtether global thresholds are combined with targets |
|
155 */ |
|
156 IMPORT_C void UsesAbsoluteMemTargets(TBool aUseAbsoluteAmount = ETrue); |
|
157 |
|
158 /** |
|
159 * Asynchronous version of Connect. |
|
160 * @param aStatus request status, completed later only |
|
161 * if return value equals to KErrNone. |
|
162 * @return error code, KErrNone if connection started. |
|
163 */ |
|
164 IMPORT_C TInt Connect(TRequestStatus& aStatus); |
|
165 |
|
166 /** |
|
167 * Asynchronous version of AppAboutToStart. |
|
168 * @param aStatus request status. |
|
169 * @param aAppUid application UID being started. |
|
170 */ |
|
171 IMPORT_C void AppAboutToStart(TRequestStatus& aStatus, const TUid& aAppUid); |
|
172 |
|
173 private://data |
|
174 TInt iFlags; |
|
175 }; |
|
176 |
|
177 |
|
178 |
|
179 #endif // R_GOOMMONITORSESSION_H |