uiacceltk/hitchcock/goommonitor/src/goommemorymonitorsession.cpp
branchRCL_3
changeset 15 cd0ae4656946
parent 7 88b23e2e82e1
child 17 c9d868f1e20c
equal deleted inserted replaced
13:3a60ebea00d0 15:cd0ae4656946
    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     Server().Monitor().SessionInCriticalAllocation(0,iClientId);
    39     if (iUseAbsoluteTargets)
       
    40         { // se3ssion terminated while on critical allocation, release lock
       
    41         Server().Monitor().SessionInCriticalAllocation(0);
       
    42         }
       
    43 	*/
       
    44     CloseAppsFinished(0, EFalse);
    39     CloseAppsFinished(0, EFalse);
    45     }
    40     }
    46 
    41 
    47 CMemoryMonitorServer& CMemoryMonitorSession::Server()
    42 CMemoryMonitorServer& CMemoryMonitorSession::Server()
    48     {
    43     {
    64     
    59     
    65     iFunction = aMessage.Function();
    60     iFunction = aMessage.Function();
    66     RThread t;
    61     RThread t;
    67     aMessage.Client(t);
    62     aMessage.Client(t);
    68     
    63     
    69     TUint clientId = t.SecureId();
    64     iClientId = t.SecureId();
    70     t.Close();
    65     t.Close();
    71     
    66     
    72     TRACES1("NEW REQUEST from client %x", clientId);
    67     TRACES1("NEW REQUEST from client %x", iClientId);
    73     switch (aMessage.Function())
    68     switch (aMessage.Function())
    74         {
    69         {
    75         case EGOomMonitorRequestFreeMemory:
    70         case EGOomMonitorRequestFreeMemory:
    76 
    71 
    77             //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
    78             if (!iRequestFreeRam.IsNull() && !Server().Monitor().IsSafeToProcessNewRequest(clientId))
    73             if (!iRequestFreeRam.IsNull() && !Server().Monitor().IsSafeToProcessNewRequest(iClientId))
    79                 {
    74                 {
    80                 TRACES1("CANNOT PROCESS NEW REQUEST from %x", clientId);
    75                 TRACES1("CANNOT PROCESS NEW REQUEST from %x", iClientId);
    81                 aMessage.Complete(KErrInUse);
    76                 aMessage.Complete(KErrInUse);
    82                 return;
    77                 return;
    83                 }
    78                 }
    84             
    79             
    85             Server().Monitor().SetActiveClient(clientId);
    80             Server().Monitor().SetActiveClient(iClientId);
    86             // message will be completed when CloseAppsFinished() is called.
    81             // message will be completed when CloseAppsFinished() is called.
    87             if (aMessage.Int1() == 0)
    82             if (aMessage.Int1() == 0)
    88                 {
    83                 {
    89                 iRequestFreeRam = aMessage;
    84                 iRequestFreeRam = aMessage;
    90 
    85 
    91                 Server().Monitor().SessionInCriticalAllocation(1, clientId);
    86                 Server().Monitor().SessionInCriticalAllocation(1, iClientId);
    92                 
    87                 
    93                 TRAPD(err, Monitor().RequestFreeMemoryL(aMessage.Int0()));
    88                 TRAPD(err, Monitor().RequestFreeMemoryL(aMessage.Int0()));
    94                 if (err)
    89                 if (err)
    95                     {
    90                     {
    96                     // completes the message if that was left to pending
    91                     // completes the message if that was left to pending
   106                 TRAP_IGNORE(Monitor().HandleFocusedWgChangeL(appUid));
   101                 TRAP_IGNORE(Monitor().HandleFocusedWgChangeL(appUid));
   107                 }
   102                 }
   108             break;
   103             break;
   109             
   104             
   110         case EGOomMonitorMemoryAllocationsComplete:
   105         case EGOomMonitorMemoryAllocationsComplete:
   111             TRACES1("ServiceL : Memory Allocations complete from %x", clientId);
   106             TRACES1("ServiceL : Memory Allocations complete from %x", iClientId);
   112             Server().Monitor().SessionInCriticalAllocation(0, clientId);
   107             Server().Monitor().SessionInCriticalAllocation(0, iClientId);
   113             aMessage.Complete(KErrNone);
   108             aMessage.Complete(KErrNone);
   114             break;
   109             break;
   115 
   110 
   116         case EGOomMonitorCancelRequestFreeMemory:
   111         case EGOomMonitorCancelRequestFreeMemory:
   117             if (!iRequestFreeRam.IsNull())
   112             if (!iRequestFreeRam.IsNull())
   118                 {
   113                 {
   119                 iRequestFreeRam.Complete(KErrCancel);
   114                 iRequestFreeRam.Complete(KErrCancel);
   120                 }
   115                 }
   121             Server().Monitor().SessionInCriticalAllocation(0, clientId);
   116             Server().Monitor().SessionInCriticalAllocation(0, iClientId);
   122             aMessage.Complete(KErrNone);
   117             aMessage.Complete(KErrNone);
   123             break;
   118             break;
   124 
   119 
   125         case EGOomMonitorThisAppIsNotExiting:
   120         case EGOomMonitorThisAppIsNotExiting:
   126             Monitor().AppNotExiting(aMessage.Int0());
   121             Monitor().AppNotExiting(aMessage.Int0());
   127             aMessage.Complete(KErrNone);
   122             aMessage.Complete(KErrNone);
   128             break;
   123             break;
   129 
   124 
   130         case EGOomMonitorRequestOptionalRam:
   125         case EGOomMonitorRequestOptionalRam:
   131             if (!iRequestFreeRam.IsNull() && !Server().Monitor().IsSafeToProcessNewRequest(clientId))
   126             if (!iRequestFreeRam.IsNull() && !Server().Monitor().IsSafeToProcessNewRequest(iClientId))
   132                 {
   127                 {
   133                 aMessage.Complete(KErrInUse);
   128                 aMessage.Complete(KErrInUse);
   134                 }
   129                 }
   135             Server().Monitor().SetActiveClient(clientId);
   130             Server().Monitor().SetActiveClient(iClientId);
   136             // message will be completed when CloseAppsFinished() is called.
   131             // message will be completed when CloseAppsFinished() is called.
   137             iRequestFreeRam = aMessage;
   132             iRequestFreeRam = aMessage;
   138             iMinimumMemoryRequested = aMessage.Int1();
   133             iMinimumMemoryRequested = aMessage.Int1();
   139             Monitor().FreeOptionalRamL(aMessage.Int0(), aMessage.Int2());
   134             Monitor().FreeOptionalRamL(aMessage.Int0(), aMessage.Int2());
   140             break;
   135             break;