uiacceltk/hitchcock/goommonitor/inc/goommemorymonitor.h
changeset 0 15bf7259bb7c
child 3 d8a3531bc6b8
child 13 8f67d927ea57
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 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:  Main classes for Graphics Out of Memory Monitor
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef GOOMMEMORYMONITOR_H
       
    20 #define GOOMMEMORYMONITOR_H
       
    21 
       
    22 #include <e32property.h>
       
    23 #include <f32file.h>
       
    24 #include <w32std.h>
       
    25 #include <EGL/egl.h>
       
    26 #include "goomglobalconfig.h"
       
    27 #include "goomwindowgrouplist.h"
       
    28 
       
    29 // ---------------------------------------------------------
       
    30 // CMemoryMonitor
       
    31 // ---------------------------------------------------------
       
    32 //
       
    33 class CGOomMonitorPlugin;
       
    34 class CMemoryMonitorServer;
       
    35 class CWservEventReceiver;
       
    36 class CGOomActionList;
       
    37 class CGOomLogger;
       
    38 class CGOomConfig;
       
    39 class CGoomThresholdCrossed;
       
    40 
       
    41 typedef EGLBoolean (*NOK_resource_profiling)(EGLDisplay, EGLint, EGLint*, EGLint, EGLint*);
       
    42 
       
    43 NONSHARABLE_CLASS(CMemoryMonitor) : public CBase
       
    44     {
       
    45 public:
       
    46     static CMemoryMonitor* NewL();
       
    47     ~CMemoryMonitor();
       
    48 
       
    49 public: // event handlers
       
    50     void FreeMemThresholdCrossedL(TInt aAction = 0, TInt aThreshold = 0);
       
    51     void AppNotExiting(TInt aWgId);
       
    52     void StartFreeSomeRamL(TInt aTargetFree);
       
    53     void FreeOptionalRamL(TInt aTargetFree, TInt aPluginId, TBool aUseAbsolute = EFalse); // The ID of the plugin that will clear up the allocation, used to determine the priority of the allocation
       
    54     void RequestFreeMemoryL(TInt aTargetFree, TBool aUseAbsolute = EFalse);
       
    55     void HandleFocusedWgChangeL(TInt aForegroundAppUid = KErrNotFound);
       
    56     static const CGOomGlobalConfig& GlobalConfig();
       
    57     void SetPriorityBusy(TInt aWgId);
       
    58     void SetPriorityNormal(TInt aWgId);
       
    59     void SetPriorityHigh(TInt aWgId);
       
    60     void ResetTargets(TInt aTarget = 0);
       
    61     TInt GetFreeMemory();
       
    62     void RunCloseAppActions(TInt aMaxPriority);
       
    63     CGOomWindowGroupList * GetWindowGroupList() const;
       
    64         
       
    65     
       
    66     void SetActiveClient(TInt aClientId)
       
    67         {
       
    68         iActiveClientId = aClientId;
       
    69         }  
       
    70     
       
    71     TInt ActiveClientId()
       
    72         {
       
    73         return iActiveClientId;
       
    74         }
       
    75 
       
    76     TInt ForegroundAppUid()
       
    77         {
       
    78         return iForegroundAppUid;
       
    79         } 
       
    80     void SessionInCriticalAllocation(TBool aPostponeMemGood)
       
    81         {
       
    82         if (aPostponeMemGood)
       
    83             {
       
    84             iPostponeMemGood++;
       
    85             }
       
    86         else
       
    87             {
       
    88             iPostponeMemGood--;
       
    89             if(iPostponeMemGood<0)
       
    90                 {
       
    91                 iPostponeMemGood = 0;
       
    92                 }
       
    93             }
       
    94                         
       
    95         if (iPostponeMemGood == 0)
       
    96             {
       
    97             DoPostponedMemoryGood();
       
    98             }
       
    99         
       
   100         } 
       
   101     
       
   102     void DoPostponedMemoryGood();
       
   103     
       
   104     TBool NeedToPostponeMemGood()
       
   105         {
       
   106         return (iPostponeMemGood != 0);
       
   107         } 
       
   108     
       
   109 private:
       
   110     CMemoryMonitor();
       
   111     void ConstructL();
       
   112     TBool FreeGraphicsMemoryAboveThresholdL(TInt& aCurrentFreeMemory);
       
   113     void CloseNextApp();
       
   114     void RefreshThresholds(TInt aForegroundAppUid = KErrNotFound);
       
   115     void StartFreeSomeRamL(TInt aTargetFree, TInt aMaxPriority);
       
   116     void AppClosePriorityChanged(TInt aWgId, TInt aPriority);
       
   117     
       
   118 public:
       
   119     // All members are owned
       
   120     // generally useful sessions
       
   121     RFs iFs;
       
   122     RWsSession iWs;
       
   123 
       
   124 private: //data
       
   125 
       
   126     // parameters for GOOM watcher.
       
   127     TInt iLowThreshold;
       
   128     TInt iGoodThreshold;
       
   129     TInt iCurrentTarget;
       
   130         
       
   131     // event receivers
       
   132     CWservEventReceiver* iWservEventReceiver;
       
   133 
       
   134     /**
       
   135      * The Memory Monitor Server
       
   136      * Own.       
       
   137      */
       
   138     CMemoryMonitorServer* iServer;
       
   139     
       
   140 #ifdef _DEBUG    
       
   141     /**
       
   142      * GOom logging tool - samples free memory for profiling
       
   143      * Own.       
       
   144      */
       
   145     CGOomLogger* iLogger;
       
   146 #endif
       
   147     
       
   148     /**
       
   149      * A list of window group Ids, with child window groups removed such that there is one Id per application
       
   150      * Own.       
       
   151      */    
       
   152     CGOomWindowGroupList* iGOomWindowGroupList;
       
   153     
       
   154     /**
       
   155      * The object responsible for identifying the best actions to run, and running them 
       
   156      * Own.       
       
   157      */
       
   158     CGOomActionList* iGOomActionList;
       
   159     
       
   160     /**
       
   161      * The entire GOom Monitor configuration
       
   162      * Own.       
       
   163      */
       
   164     CGOomConfig* iConfig;
       
   165     
       
   166     // resource profiling extension function ptr
       
   167     NOK_resource_profiling eglQueryProfilingData;
       
   168     
       
   169     TInt iActiveClientId;
       
   170     
       
   171     // could use pointer array
       
   172     CGoomThresholdCrossed* iMemAllocationsGrowing;
       
   173     CGoomThresholdCrossed* iMemAllocationsGoingDown;
       
   174     
       
   175     TInt iForegroundAppUid;
       
   176     TInt iPostponeMemGood;
       
   177     };
       
   178 
       
   179 #endif /*GOOMMEMORYMONITOR_H*/