1 /* |
|
2 * Copyright (c) 2010 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: Fake class for testing |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef OOMMONITORSESSION_H |
|
19 #define OOMMONITORSESSION_H |
|
20 |
|
21 #include <e32base.h> |
|
22 |
|
23 const TInt KOomMaxAllocationWithoutPermission = 1048576; |
|
24 const TUid KOomMemoryMonitorStatusPropertyCategory = {0x10207218}; |
|
25 const TUint32 KOomMemoryMonitorStatusPropertyKey = 0; |
|
26 enum TMemoryMonitorStatusPropertyValues |
|
27 { |
|
28 // Above Treshhold: Free Ram is above good treshhold point and memory monitor isn't freeing any memory |
|
29 EAboveTreshHold, |
|
30 |
|
31 // Freeing Memory: Memory monitor is in the middle of freeing memory |
|
32 EFreeingMemory, |
|
33 |
|
34 // Below Treshhold: Memory monitor has tried to free some RAM but total memory is still below treshhold and memory monitor has given up freeing more memory. |
|
35 EBelowTreshHold |
|
36 }; |
|
37 class ROomMonitorSession |
|
38 { |
|
39 public: |
|
40 |
|
41 /** Defines the application priorities of OOM monitor. */ |
|
42 enum TOomPriority |
|
43 { |
|
44 /** |
|
45 * Application can be closed if needed. |
|
46 */ |
|
47 EOomPriorityNormal = 0, |
|
48 |
|
49 /** |
|
50 * Application should not be closed if possible. |
|
51 */ |
|
52 EOomPriorityHigh, |
|
53 |
|
54 /** |
|
55 * Application is busy and should not be closed. |
|
56 */ |
|
57 EOomPriorityBusy |
|
58 }; |
|
59 |
|
60 public: |
|
61 /** |
|
62 * Connects a new session. |
|
63 * Sessions must be connected before any other APIs can be used. |
|
64 * When the client has finished using a session, Close() must be called. |
|
65 * @return KErrNone if successful, error code otherwise. |
|
66 */ |
|
67 TInt Connect(); |
|
68 |
|
69 /** |
|
70 * Request that the OOM monitor attempts to free some paged memory. |
|
71 * This function may take several seconds to execute, depending on |
|
72 * the memory state. It will not return until the attempt to recover |
|
73 * memory has completed. |
|
74 * @param aBytesRequested The number of bytes of free memory that the client requests. |
|
75 * @return KErrNone if the request memory is free. KErrNoMemory if that |
|
76 * amount of memory could not be recovered. Other error codes may |
|
77 * also be returned. |
|
78 */ |
|
79 TInt RequestFreeMemory(TInt aBytesRequested); |
|
80 |
|
81 /** |
|
82 * Request that the OOM monitor attempts to free some paged memory. |
|
83 * This is an asynchronous version of the request for free paged memory. |
|
84 * @param aBytesRequested The number of bytes of free memory that the client requests. |
|
85 * @param aStatus will be completed when the attempt to recover memory |
|
86 * has finished. This may take several seconds, depending on |
|
87 * the memory state. On completion, aStatus will be set to |
|
88 * KErrNone if the request memory is free. KErrNoMemory if that |
|
89 * amount of memory could not be recovered. Other error codes may |
|
90 * also be set. |
|
91 */ |
|
92 void RequestFreeMemory(TInt aBytesRequested, TRequestStatus& aStatus); |
|
93 |
|
94 /** |
|
95 * Request that the OOM monitor attempts to free some memory for an optional allocation. |
|
96 * The passed in plugin ID is used to determine the priority for this allocation. |
|
97 * Lower priority OOM actions may be executed to free enough RAM for this allocation. |
|
98 * This function may take several seconds to execute, depending on |
|
99 * the memory state. It will not return until the attempt to recover |
|
100 * memory has completed. |
|
101 * @param aBytesRequested The number of bytes of free memory that the client requests. |
|
102 * @param aPluginId The ID of the plugin that may delete the allocation in event of low memory. |
|
103 * @return KErrNone if the request memory is free. KErrNoMemory if that |
|
104 * amount of memory could not be recovered. Other error codes may |
|
105 * also be returned. |
|
106 */ |
|
107 TInt RequestOptionalRam(TInt aBytesRequested, TInt aMinimumBytesNeeded, TInt aPluginId, TInt& aBytesAvailable); |
|
108 |
|
109 /** |
|
110 * Request that the OOM monitor attempts to free some memory for an optional allocation. |
|
111 * The passed in plugin ID is used to determine the priority for this allocation. |
|
112 * Lower priority OOM actions may be executed to free enough RAM for this allocation. |
|
113 * This function may take several seconds to execute, depending on |
|
114 * the memory state. It will not return until the attempt to recover |
|
115 * memory has completed. |
|
116 * @param aBytesRequested The number of bytes of free memory that the client requests. |
|
117 * @param aPluginId The ID of the plugin that may delete the allocation in event of low memory. |
|
118 * @param aStatus The TRequestStatus (completes with the number of bytes freed (aStatus >= 0) or an error (aStatus <= 0)) |
|
119 * @return None |
|
120 */ |
|
121 void RequestOptionalRam(TInt aBytesRequested, TInt aMinimumBytesNeeded, TInt aPluginId, TRequestStatus& aStatus); |
|
122 |
|
123 /** |
|
124 * Cancels the asynchronous request for free memory. |
|
125 */ |
|
126 void CancelRequestFreeMemory(); |
|
127 |
|
128 /** |
|
129 * Notify the OOM monitor that this application is not responding |
|
130 * to the EEikCmdExit request to exit the application. |
|
131 * This function is used by the Avkon framework's app shutter. |
|
132 * @param aWgId the window group identifier of the app that is not exiting. |
|
133 */ |
|
134 void ThisAppIsNotExiting(TInt aWgId); |
|
135 |
|
136 /** |
|
137 * Notify the OOM monitor that this application has the specified priority |
|
138 * @param aPriority the priority of the application |
|
139 */ |
|
140 void SetOomPriority(TOomPriority aPriority); |
|
141 |
|
142 void Close(); |
|
143 |
|
144 }; |
|
145 |
|
146 #endif // OOMMONITORSESSION_H |
|