59 |
59 |
60 iFunction = aMessage.Function(); |
60 iFunction = aMessage.Function(); |
61 RThread t; |
61 RThread t; |
62 aMessage.Client(t); |
62 aMessage.Client(t); |
63 |
63 |
64 iClientId = t.SecureId(); |
64 TUint clientId = t.SecureId(); |
65 t.Close(); |
65 t.Close(); |
66 |
66 |
67 TRACES1("NEW REQUEST from client %x", iClientId); |
67 TRACES1("NEW REQUEST from client %x", clientId); |
68 switch (aMessage.Function()) |
68 switch (aMessage.Function()) |
69 { |
69 { |
70 case EGOomMonitorRequestFreeMemory: |
70 case EGOomMonitorRequestFreeMemory: |
71 |
71 |
72 //Do not take any more requests from the same client if previous request being served |
72 //Do not take any more requests from the same client if previous request being served |
73 if (!iRequestFreeRam.IsNull() && !Server().Monitor().IsSafeToProcessNewRequest(iClientId)) |
73 if (!iRequestFreeRam.IsNull() && !Server().Monitor().IsSafeToProcessNewRequest(clientId)) |
74 { |
74 { |
75 TRACES1("CANNOT PROCESS NEW REQUEST from %x", iClientId); |
75 TRACES1("CANNOT PROCESS NEW REQUEST from %x", clientId); |
76 aMessage.Complete(KErrInUse); |
76 aMessage.Complete(KErrInUse); |
77 return; |
77 return; |
78 } |
78 } |
79 |
79 |
80 Server().Monitor().SetActiveClient(iClientId); |
80 Server().Monitor().SetActiveClient(clientId); |
81 // message will be completed when CloseAppsFinished() is called. |
81 // message will be completed when CloseAppsFinished() is called. |
82 if (aMessage.Int1() == 0) |
82 if (aMessage.Int1() == 0) |
83 { |
83 { |
84 iRequestFreeRam = aMessage; |
84 iRequestFreeRam = aMessage; |
85 |
85 |
86 Server().Monitor().SessionInCriticalAllocation(1, iClientId); |
86 Server().Monitor().SessionInCriticalAllocation(1, clientId); |
87 |
87 |
88 TRAPD(err, Monitor().RequestFreeMemoryL(aMessage.Int0())); |
88 TRAPD(err, Monitor().RequestFreeMemoryL(aMessage.Int0())); |
89 if(err == KErrCompletion) |
89 if(err == KErrCompletion) |
90 { |
90 { |
91 TRACES("There is already enough memory - nothing to do"); |
91 TRACES("There is already enough memory - nothing to do"); |
92 Server().Monitor().SessionInCriticalAllocation(0, iClientId); |
92 Server().Monitor().SessionInCriticalAllocation(0, clientId); |
93 } |
93 } |
94 else if (err != KErrNone ) |
94 else if (err != KErrNone ) |
95 { |
95 { |
96 // completes the message if that was left to pending |
96 // completes the message if that was left to pending |
97 TRACES1("Error in RequestFreeMemory %d", err); |
97 TRACES1("Error in RequestFreeMemory %d", err); |
106 TRAP_IGNORE(Monitor().HandleFocusedWgChangeL(appUid)); |
106 TRAP_IGNORE(Monitor().HandleFocusedWgChangeL(appUid)); |
107 } |
107 } |
108 break; |
108 break; |
109 |
109 |
110 case EGOomMonitorMemoryAllocationsComplete: |
110 case EGOomMonitorMemoryAllocationsComplete: |
111 TRACES1("ServiceL : Memory Allocations complete from %x", iClientId); |
111 TRACES1("ServiceL : Memory Allocations complete from %x", clientId); |
112 Server().Monitor().SessionInCriticalAllocation(0, iClientId); |
112 Server().Monitor().SessionInCriticalAllocation(0, clientId); |
113 aMessage.Complete(KErrNone); |
113 aMessage.Complete(KErrNone); |
114 break; |
114 break; |
115 |
115 |
116 case EGOomMonitorCancelRequestFreeMemory: |
116 case EGOomMonitorCancelRequestFreeMemory: |
117 if (!iRequestFreeRam.IsNull()) |
117 if (!iRequestFreeRam.IsNull()) |
118 { |
118 { |
119 iRequestFreeRam.Complete(KErrCancel); |
119 iRequestFreeRam.Complete(KErrCancel); |
120 } |
120 } |
121 Server().Monitor().SessionInCriticalAllocation(0, iClientId); |
121 Server().Monitor().SessionInCriticalAllocation(0, clientId); |
122 aMessage.Complete(KErrNone); |
122 aMessage.Complete(KErrNone); |
123 break; |
123 break; |
124 |
124 |
125 case EGOomMonitorThisAppIsNotExiting: |
125 case EGOomMonitorThisAppIsNotExiting: |
126 Monitor().AppNotExiting(aMessage.Int0()); |
126 Monitor().AppNotExiting(aMessage.Int0()); |
127 aMessage.Complete(KErrNone); |
127 aMessage.Complete(KErrNone); |
128 break; |
128 break; |
129 |
129 |
130 case EGOomMonitorRequestOptionalRam: |
130 case EGOomMonitorRequestOptionalRam: |
131 if (!iRequestFreeRam.IsNull() && !Server().Monitor().IsSafeToProcessNewRequest(iClientId)) |
131 if (!iRequestFreeRam.IsNull() && !Server().Monitor().IsSafeToProcessNewRequest(clientId)) |
132 { |
132 { |
133 aMessage.Complete(KErrInUse); |
133 aMessage.Complete(KErrInUse); |
134 } |
134 } |
135 Server().Monitor().SetActiveClient(iClientId); |
135 Server().Monitor().SetActiveClient(clientId); |
136 // message will be completed when CloseAppsFinished() is called. |
136 // message will be completed when CloseAppsFinished() is called. |
137 iRequestFreeRam = aMessage; |
137 iRequestFreeRam = aMessage; |
138 iMinimumMemoryRequested = aMessage.Int1(); |
138 iMinimumMemoryRequested = aMessage.Int1(); |
139 Monitor().FreeOptionalRamL(aMessage.Int0(), aMessage.Int2()); |
139 Monitor().FreeOptionalRamL(aMessage.Int0(), aMessage.Int2()); |
140 break; |
140 break; |