33 } |
33 } |
34 |
34 |
35 CMemoryMonitorSession::~CMemoryMonitorSession() |
35 CMemoryMonitorSession::~CMemoryMonitorSession() |
36 { |
36 { |
37 FUNC_LOG; |
37 FUNC_LOG; |
|
38 /* TODO - need to add the right condition |
38 if (iUseAbsoluteTargets) |
39 if (iUseAbsoluteTargets) |
39 { // se3ssion terminated while on critical allocation, release lock |
40 { // se3ssion terminated while on critical allocation, release lock |
40 Server().Monitor().SessionInCriticalAllocation(0); |
41 Server().Monitor().SessionInCriticalAllocation(0); |
41 } |
42 } |
|
43 */ |
42 CloseAppsFinished(0, EFalse); |
44 CloseAppsFinished(0, EFalse); |
43 } |
45 } |
44 |
46 |
45 CMemoryMonitorServer& CMemoryMonitorSession::Server() |
47 CMemoryMonitorServer& CMemoryMonitorSession::Server() |
46 { |
48 { |
61 FUNC_LOG; |
63 FUNC_LOG; |
62 |
64 |
63 iFunction = aMessage.Function(); |
65 iFunction = aMessage.Function(); |
64 RThread t; |
66 RThread t; |
65 aMessage.Client(t); |
67 aMessage.Client(t); |
66 Server().Monitor().SetActiveClient(t.SecureId()); |
68 |
|
69 TUint clientId = t.SecureId(); |
67 t.Close(); |
70 t.Close(); |
68 |
71 |
|
72 TRACES1("NEW REQUEST from client %x", clientId); |
69 switch (aMessage.Function()) |
73 switch (aMessage.Function()) |
70 { |
74 { |
71 case EGOomMonitorRequestFreeMemory: |
75 case EGOomMonitorRequestFreeMemory: |
72 if (!iRequestFreeRam.IsNull()) |
76 |
73 { |
77 //Do not take any more requests from the same client if previous request being served |
|
78 if (!iRequestFreeRam.IsNull() && !Server().Monitor().IsSafeToProcessNewRequest(clientId)) |
|
79 { |
|
80 TRACES1("CANNOT PROCESS NEW REQUEST from %x", clientId); |
74 aMessage.Complete(KErrInUse); |
81 aMessage.Complete(KErrInUse); |
75 return; |
82 return; |
76 } |
83 } |
|
84 |
|
85 Server().Monitor().SetActiveClient(clientId); |
77 // message will be completed when CloseAppsFinished() is called. |
86 // message will be completed when CloseAppsFinished() is called. |
78 if (aMessage.Int1() == 0) |
87 if (aMessage.Int1() == 0) |
79 { |
88 { |
80 iRequestFreeRam = aMessage; |
89 iRequestFreeRam = aMessage; |
81 |
90 |
|
91 Server().Monitor().SessionInCriticalAllocation(1, clientId); |
|
92 |
82 TRAPD(err, Monitor().RequestFreeMemoryL(aMessage.Int0(), iUseAbsoluteTargets)); |
93 TRAPD(err, Monitor().RequestFreeMemoryL(aMessage.Int0(), iUseAbsoluteTargets)); |
83 if (err) |
94 if (err) |
84 { |
95 { |
85 // completes the message if that was left to pending |
96 // completes the message if that was left to pending |
86 CloseAppsFinished(0, EFalse); |
97 CloseAppsFinished(0, EFalse); |
92 // if no new memory was needed, the message is completed synchronously |
103 // if no new memory was needed, the message is completed synchronously |
93 iRequestFreeRam = aMessage; |
104 iRequestFreeRam = aMessage; |
94 TRAP_IGNORE(Monitor().HandleFocusedWgChangeL(appUid)); |
105 TRAP_IGNORE(Monitor().HandleFocusedWgChangeL(appUid)); |
95 } |
106 } |
96 break; |
107 break; |
|
108 |
|
109 case EGOomMonitorMemoryAllocationsComplete: |
|
110 TRACES1("ServiceL : Memory Allocations complete from %x", clientId); |
|
111 Server().Monitor().SessionInCriticalAllocation(0, clientId); |
|
112 aMessage.Complete(KErrNone); |
|
113 break; |
97 |
114 |
98 case EGOomMonitorCancelRequestFreeMemory: |
115 case EGOomMonitorCancelRequestFreeMemory: |
99 if (!iRequestFreeRam.IsNull()) |
116 if (!iRequestFreeRam.IsNull()) |
100 { |
117 { |
101 iRequestFreeRam.Complete(KErrCancel); |
118 iRequestFreeRam.Complete(KErrCancel); |
102 } |
119 } |
|
120 Server().Monitor().SessionInCriticalAllocation(0, clientId); |
103 aMessage.Complete(KErrNone); |
121 aMessage.Complete(KErrNone); |
104 break; |
122 break; |
105 |
123 |
106 case EGOomMonitorThisAppIsNotExiting: |
124 case EGOomMonitorThisAppIsNotExiting: |
107 Monitor().AppNotExiting(aMessage.Int0()); |
125 Monitor().AppNotExiting(aMessage.Int0()); |
108 aMessage.Complete(KErrNone); |
126 aMessage.Complete(KErrNone); |
109 break; |
127 break; |
110 |
128 |
111 case EGOomMonitorRequestOptionalRam: |
129 case EGOomMonitorRequestOptionalRam: |
112 if (!iRequestFreeRam.IsNull()) |
130 if (!iRequestFreeRam.IsNull() && !Server().Monitor().IsSafeToProcessNewRequest(clientId)) |
113 { |
131 { |
114 aMessage.Complete(KErrInUse); |
132 aMessage.Complete(KErrInUse); |
115 } |
133 } |
|
134 Server().Monitor().SetActiveClient(clientId); |
116 // message will be completed when CloseAppsFinished() is called. |
135 // message will be completed when CloseAppsFinished() is called. |
117 iRequestFreeRam = aMessage; |
136 iRequestFreeRam = aMessage; |
118 iMinimumMemoryRequested = aMessage.Int1(); |
137 iMinimumMemoryRequested = aMessage.Int1(); |
119 Monitor().FreeOptionalRamL(aMessage.Int0(), aMessage.Int2(), iUseAbsoluteTargets); |
138 Monitor().FreeOptionalRamL(aMessage.Int0(), aMessage.Int2(), iUseAbsoluteTargets); |
120 break; |
139 break; |
123 Monitor().SetPriorityBusy(aMessage.Int0()); |
142 Monitor().SetPriorityBusy(aMessage.Int0()); |
124 aMessage.Complete(KErrNone); |
143 aMessage.Complete(KErrNone); |
125 break; |
144 break; |
126 |
145 |
127 case EGOomMonitorSetPriorityNormal: |
146 case EGOomMonitorSetPriorityNormal: |
128 Monitor().SetPriorityNormal(aMessage.Int0()); |
147 Monitor().SetPriorityNormal(aMessage.Int0()); |
129 aMessage.Complete(KErrNone); |
148 aMessage.Complete(KErrNone); |
130 break; |
149 break; |
131 |
150 |
132 case EGOomMonitorSetPriorityHigh: |
151 case EGOomMonitorSetPriorityHigh: |
133 Monitor().SetPriorityHigh(aMessage.Int0()); |
152 Monitor().SetPriorityHigh(aMessage.Int0()); |
134 aMessage.Complete(KErrNone); |
153 aMessage.Complete(KErrNone); |
135 break; |
154 break; |
136 |
155 |
137 case EGoomMonitorAppAboutToStart: |
156 case EGoomMonitorAppAboutToStart: |
138 { |
157 { |
139 TInt appUid = aMessage.Int0(); |
158 TInt appUid = aMessage.Int0(); |
140 aMessage.Complete(KErrNone); |
159 aMessage.Complete(KErrNone); |
141 TRAP_IGNORE(Monitor().HandleFocusedWgChangeL(appUid)) |
160 TRAP_IGNORE(Monitor().HandleFocusedWgChangeL(appUid)) |
142 break; |
161 break; |
143 } |
162 } |
|
163 |
144 case EGoomMonitorAppUsesAbsoluteMemTargets: |
164 case EGoomMonitorAppUsesAbsoluteMemTargets: |
145 { |
165 { |
146 iUseAbsoluteTargets = aMessage.Int0(); |
166 iUseAbsoluteTargets = aMessage.Int0(); |
147 TRACES2("EGoomMonitorAppUsesAbsoluteMemTargets this: 0x%x, use abs targets %d", this, iUseAbsoluteTargets); |
167 /* TRACES2("EGoomMonitorAppUsesAbsoluteMemTargets this: 0x%x, use abs targets %d", this, iUseAbsoluteTargets); |
148 Server().Monitor().SessionInCriticalAllocation(iUseAbsoluteTargets); |
168 Server().Monitor().SessionInCriticalAllocation(iUseAbsoluteTargets); |
149 aMessage.Complete(KErrNone); |
169 */ aMessage.Complete(KErrNone); |
150 break; |
170 break; |
151 } |
171 } |
152 |
172 |
153 default: |
173 default: |
154 PanicClient(aMessage, EPanicIllegalFunction); |
174 PanicClient(aMessage, EPanicIllegalFunction); |